Comments (2)
@vbuhaiov Thanks for opening the issue.
Our hope is to support tracing of recent Next.js versions via OpenTelemetry support that Next.js has added to its core.
However, this isn't a well trodden path yet, so there may likely be limitations/bugs.
The current Next.js instrumentation in the Elastic Node.js APM agent (experimental, and limited to next <13.3.0
) has proven to be brittle. Changes in the minor version of Next.js releases tended to break the instrumentation. We feel the addition of @opentelemetry/api
usage in the next
core package is a better architectural path.
We haven't yet had a chance to try to work through it, but this is how I see it working:
- Enable the
elastic-apm-node
's OpenTelemetry tracing bridge viaELASTIC_APM_OPENTELEMETRY_BRIDGE_ENABLED=true
. This tells the Elastic Node.js APM agent to register an OpenTelemetry "TracerProvider" so that usage of the@opentelemetry/api
in the Node.js app will be picked up by the APM agent and translated to Elastic APM tracing data.
Really that should be the only required step.
Unfortunately we don't have a current timeline for looking into this.
Some notes/thoughts on troubleshooting this:
- I don't know if bundling, that may be common in Next.js apps, might cause surprises.
- As long as Next is using
@opentelemetry/api@^1.0.0
it should be fine. However, OTel is generally setup to be silent if not registered, so if there is a hiccup, it can be a little hard to diagnose.
from apm-agent-nodejs.
Do you have any estimations regarding support of nextjs 14 ?
Is your feature request related to a problem? Please describe. Not able to use APM with the latest next js versions ^14. No package was found during node ./server.js
Describe the solution you'd like Increase a supported version to the ^14
Describe alternatives you've considered No alternatives, it is not supported and the build does not work
Additional context ./package.json "dependencies": { "elastic-apm-node": "^4.4.0", "next": "14.1.0" },
Dockerfile FROM node:18-alpine AS base
I'm using almost the same version and it's working (I also see the unsupported version but it seems it's not affecting)
{
"name": "xxx",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": " NODE_OPTIONS=--require=elastic-apm-node/start-next.js dotenv -e ./../.env.local -- next dev",
"dev:build": "dotenv -e ./../.env.local -- next build",
"build": "next build",
"start": "NODE_OPTIONS=--require=elastic-apm-node/start-next.js next start -H 0.0.0.0",
"lint": "NODE_OPTIONS=--require=elastic-apm-node/start-next.js next lint",
"migrate:dev": "dotenv -e ./../.env.local -- npx prisma migrate dev",
"migrate:deploy": "dotenv -e -- npx prisma migrate deploy",
"migrate:format": "dotenv -e ./../.env.local -- npx prisma format",
"migrate:generate": "dotenv -e ./../.env.local -- npx prisma generate",
"migrate:reset": "dotenv -e ./../.env.local -- npx prisma migrate reset",
"db:seed": "dotenv -e ./../.env.local -- npx prisma db seed"
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"dependencies": {
"@prisma/client": "^5.9.1",
"console-log-level": "^1.4.1",
"dotenv-cli": "^7.3.0",
"elastic-apm-node": "^4.4.1",
"next": "14.1.0",
"openai": "^4.28.0",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20.11.17",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/parser": "^7.0.2",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"prettier-eslint": "^16.3.0",
"prisma": "^5.9.1",
"tailwindcss": "^3.3.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
this is my elastic-apm-node.js file
module.exports = {
serverUrl: process.env.ELASTIC_APM_SERVER_URL,
secretToken: process.env.ELASTIC_APM_SECRET_TOKEN,
active: true,
logLevel: "error",
logger: false,
verifyServerCert: false,
usePathAsTransactionName: true,
opentelemetryBridgeEnabled: false,
};
and this is my apm-server definition
cat > apm_server.yaml <<EOF
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
name: pergamino-apm-server
namespace: $NAMESPACE
spec:
version: 8.12.1
count: 1
elasticsearchRef:
name: $PREFIX_NAME
kibanaRef:
name: $PREFIX_NAME
http:
tls:
selfSignedCertificate:
disabled: true
subjectAltNames:
- dns: pergamino-apm-server-apm-http.default.svc.cluster.local
EOF
I hope this configuration helps someone.
from apm-agent-nodejs.
Related Issues (20)
- support `node --enable-source-maps` usage with our custom `Error.prepareStackTrace` usage
- fix <database>.$cmd.getMore span on mongodb
- Memory usage reported incorrectly in k8s pod HOT 3
- `_signalLambdaEnd` request to Lambda extension should set `Content-Type`
- Questions re ESM support for MikroOrm / knex, Node v20, & OIDC HOT 3
- Unhandled ERR_INVALID_URL causing node.js service to exit HOT 1
- question: applying user.id when using opentelemetry api with Elastic HOT 2
- remove opentracing doc
- issue labeler workflow failing HOT 7
- Support mtls connection
- test issue to see if labeler action works on an issue HOT 1
- edge "test-nightly" failing after kafka/zookeeper addition
- TAV failing for `[email protected]` HOT 4
- Agent doesn't capture uncaught exceptions or unhandled rejections HOT 11
- Request body is logged even with `captureBody: off` HOT 17
- undici instrumentation can add duplicate trace-context headers, which can break Elasticsearch HOT 2
- release fails in make-distribution.sh step
- KafkaJS instrumentation throw exception on "tombstone message" HOT 2
- Agent not working with Yarn Pnp + NextJS HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apm-agent-nodejs.