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 for Azure OpenAI
- nightly test with Node.js v23 failing in `elasticsearch` module
- add support for synchronous gauge to OTel Bridge metrics support
- Is there any plan to add a way to customize trace.id ? HOT 2
- Nested labels are indexed as `[object Object]` HOT 1
- "active" config not being respected when the agent is started with -r or top level import HOT 3
- TypeError: Cannot read properties of null (reading 'propagateTraceContextHeaders') HOT 1
- integrate with Nuxtjs but cannot see any transaction in APM HOT 11
- mssql tests are failing in CI because a recent `mcr.microsoft.com/mssql/server` docker image release breaks our healthcheck HOT 10
- Dependency Dashboard
- do a new minor release for `process.getBuiltinModule` RITM hooking HOT 1
- Support aws EventBridge instrumentation HOT 2
- [META 882] Check classic and OTel agents against serverless HOT 2
- Version v4.7.1 Lambda Layer Misconfigured: All Regions Pointing to us-east-1 HOT 3
- use IITM wrap-only-hooked support for ESM
- Add support for `koa@13`
- [META 888] Update AWS ECS Fargate container ID regex.
- Add support for tedious@19
- Add support for express@5
- Use `traceparent` from SQS MessageAttribute so that the transaction in Lambda to be a child of SQS Message Sender
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.