Open
Description
Link to the code that reproduces this issue
https://github.com/estigma88/opentelemetry-nextjs-issue
To Reproduce
- Clone the following project https://github.com/vercel/opentelemetry-collector-dev-setup/tree/main
- Run the
docker-compose up
to start up Prometheus and the otel-collector - Clone https://github.com/estigma88/opentelemetry-nextjs-issue
- Run the nextjs app with
npm run dev
- Go to http://localhost:3000/ several times
- Wait for a while for the metrics to be collected
- Go to Prometheus in http://0.0.0.0:9090/query
- Explore the metrics, you will see
http_client_request_duration_bucket
but nothttp_server_request_duration_bucket
Current vs. Expected behavior
Http client metrics are collected but not Http server metrics.
The following is the Opentelemetry configuration:
const sdk = new opentelemetry.NodeSDK({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: 'next-app',
}),
traceExporter: new OTLPTraceExporter(),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
}),
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
Same configuration using Express works fine.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #63-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 19:04:15 UTC 2025
Available memory (MB): 31731
Available CPU cores: 12
Binaries:
Node: 20.16.0
npm: 10.8.1
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.4.0-canary.29 // There is a newer canary version (15.4.0-canary.69) available, please upgrade!
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 4.7.4
Next.js Config:
output: N/A
⚠ There is a newer canary version (15.4.0-canary.69) available, please upgrade!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Which area(s) are affected? (Select all that apply)
Instrumentation
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This is how metrics look in Prometheus:
Interestingly enough, traces are collected fine for endpoints: