nextjs - 💡(How to fix) Fix Opentelemetry instrumentation for pino doesn't work [11 comments, 5 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#84291Fetched 2026-04-08 02:20:04
View on GitHub
Comments
11
Participants
5
Timeline
37
Reactions
4
Author
Timeline (top)
commented ×11subscribed ×11mentioned ×8labeled ×2

Code Example

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Mon, 22 Sep 2025 22:08:35 +0000
  Available memory (MB): 23250
  Available CPU cores: 16
Binaries:
  Node: 22.19.0
  npm: 11.6.0
  Yarn: 1.22.22
  pnpm: 10.17.1
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: 15.5.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/abnud11/nextjs-opentelemetry-pino-reproduction-issue

To Reproduce

  1. Run docker-compose up --build
  2. Open http://localhost:3000
  3. Click "Test Logging"
  4. See that otel-collector doesn't show any exported log records

Current vs. Expected behavior

Current: When I call logger.info using supposedly instrumented pino, it doesn't show any exported log records in otel collector Expected: I should see log records exported when I have @opentelemetry/instrumentation-pino installed and using auto-instrumentations-node

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Mon, 22 Sep 2025 22:08:35 +0000
  Available memory (MB): 23250
  Available CPU cores: 16
Binaries:
  Node: 22.19.0
  npm: 11.6.0
  Yarn: 1.22.22
  pnpm: 10.17.1
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: 15.5.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Instrumentation

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

When I log using @opentelemetry/api-logs, that is using opentelemetry logger directly, I can see the log records exported in opentelemetry collector messages, it's pino logger that doesn't work

The message is logged in next.js console but not exported to opentelemetry collector.

I tried using webpack instead of turbopack, it still showed the same issue.

The code shows that I'm importing pino logger in a lazy fashion, but I also tried importing it and exporting the logger instance without getLogger function also without success.

I added a check to instrumentation code to verify that pinoInstrumentation is loaded, according to console messages it is loaded and enabled too.

extent analysis

TL;DR

The issue is likely due to incorrect configuration or instrumentation of OpenTelemetry with Pino, and a workaround could be to manually configure the Pino logger to export logs to the OpenTelemetry collector.

Guidance

  • Verify that the @opentelemetry/instrumentation-pino package is correctly installed and imported in the project.
  • Check the instrumentation configuration to ensure that Pino is properly instrumented to export logs to the OpenTelemetry collector.
  • Try logging using the @opentelemetry/api-logs package directly to see if the issue is specific to Pino or a more general OpenTelemetry configuration problem.
  • Review the code to ensure that the Pino logger is being used correctly and that the logs are being exported to the OpenTelemetry collector.

Example

No code example is provided as the issue is likely related to configuration or instrumentation, and the provided code repository should be reviewed for specific implementation details.

Notes

The issue may be specific to the combination of Next.js, OpenTelemetry, and Pino, and further investigation is needed to determine the root cause. The fact that logging using @opentelemetry/api-logs works suggests that the OpenTelemetry configuration is partially correct.

Recommendation

Apply workaround: manually configure the Pino logger to export logs to the OpenTelemetry collector, as the automatic instrumentation may not be working as expected. This will help to isolate the issue and determine if it's a configuration problem or a bug in the instrumentation package.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING