Skip to content

Opentelemetry - Spans for static resources and API pages not part of page load trace #65989

Open
@bradleyberwick

Description

@bradleyberwick

Link to the code that reproduces this issue

https://github.com/bradleyberwick/reproduction-otel

To Reproduce

  1. Yarn build
  2. Yarn start
  3. View traces in local Grafana

Current vs. Expected behavior

Current behaviour:
When I do a full page load in my app (I've added my OTEL config in the repo app), spans are created for the page (e.g. GET /), for static resources (e.g. _next/static/chunks/...js , _next/static/{id}/_buildManifest.js, etc) and API pages (e.g. /api/geoip, etc). Currently these spans are separate and part of different trace ID's.

Expected behaviour:
Ideally, I want these spans to be part of the same trace as they're loaded as part of the same page load. I don't think this is possible because the other resources (i.e. static resources and API pages) are pre-built on the server-side and they don't know the trace ID at this point. The calls to these other resources are then made from the client and not via the initial page load request and therefore the context is not propagated.

Can I have some further clarification on this please?

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
Binaries:
  Node: 20.11.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
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 start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    InstrumentationRelated to Next.js Instrumentation.bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions