Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Opentelemetry is not collecting http_server_request_duration_bucket metrics for Nextjs endpoints | GoodFirstPicks

Opentelemetry is not collecting http_server_request_duration_bucket metrics for Nextjs endpoints

vercel/next.js 7 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

HTTP server metrics are not being collected due to initialization timing issues with Next.js.

AI Summary

The issue involves OpenTelemetry not collecting HTTP server metrics for Next.js endpoints, likely due to initialization timing where Next.js starts before OpenTelemetry can patch the HTTP module. The solution requires ensuring proper initialization order or patching, but there's uncertainty about the exact approach due to version-specific behavior and maintainer comments indicating complexity.

Issue Description

Link to the code that reproduces this issue

https://github.com/estigma88/opentelemetry-nextjs-issue

To Reproduce

  1. Clone the following project https://github.com/vercel/opentelemetry-collector-dev-setup/tree/main
  2. Run the docker-compose up to start up Prometheus and the otel-collector
  3. Clone https://github.com/estigma88/opentelemetry-nextjs-issue
  4. Run the nextjs app with npm run dev
  5. Go to http://localhost:3000/ several times
  6. Wait for a while for the metrics to be collected
  7. Go to Prometheus in http://0.0.0.0:9090/query
  8. Explore the metrics, you will see http_client_request_duration_bucket but not http_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/open

GitHub Labels

Instrumentation

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • timing-sensitive initialization
  • Next.js version dependency
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno