Skip to content

OpenTelemetry spans have different trace id with same request spans #78926

@adam187

Description

@adam187

Link to the code that reproduces this issue

https://github.com/adam187/next-js-otel-test

To Reproduce

  1. build application with npm run build
  2. start server with npm run start
  3. send a request curl -I http://localhost:3000/static -H "Baggage: foo=bar"

Current vs. Expected behavior

Current:
Currently spans produced within single request have different trace id, (baggage context is propagated properly)

f461e766556b795e6c69359a1617a25e 4900d9f30e1f5b0c HEAD /static BaseServer.handleRequest Baggage items in the instrumentation:
  foo: bar
82a90567468fac031b25952f7ae664c7 bdffcfe2c42b7147 middleware HEAD /static Middleware.execute Baggage items in the instrumentation:
  foo: bar
82a90567468fac031b25952f7ae664c7 bdffcfe2c42b7147 baggage in middleware:
  foo: bar
39af849f6622aeaf156a8e958e6f93fa 7e7ea8080876c4c0 HEAD /static BaseServer.handleRequest Baggage items in the instrumentation:
  foo: bar
39af849f6622aeaf156a8e958e6f93fa 98261006e5287fe6 resolve page components NextNodeServer.findPageComponents Baggage items in the instrumentation:
  foo: bar
39af849f6622aeaf156a8e958e6f93fa 18933ecbfa02d55f getStaticProps /static Render.getStaticProps Baggage items in the instrumentation:
  foo: bar
39af849f6622aeaf156a8e958e6f93fa a377af8aab9029e5 render route (pages) /static Render.renderDocument Baggage items in the instrumentation:
  foo: bar

Expected behavior
To have all spans with same trace id

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.18.3
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.8.0
Relevant Packages:
  next: 15.3.2 // Latest available version is detected (15.3.2).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

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

Not sure

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

next start (local), next build (local), next dev (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions