Skip to content

When running sentry.init with opentelemetry in next.js instrumentation, next.route span attributes is lost #15634

Open
@rlawnsxo131

Description

@rlawnsxo131

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nextjs

SDK Version

8.42.0, 9.5.0

It is reproduced in both versions.

Framework Version

next@15.1.7

Link to Sentry event

No response

Reproduction Example/SDK Setup

github repository link

DSN is internal information so it is not published, but it does not have any effect on reproducing the issue.

Sentry.init({
  dsn: "john-dsn",
  release: "john-release",
});

Steps to Reproduce

  1. project clone
  2. Run without commenting out the line(reproduce the problem) - pnpm dev
  3. Comment out the line and run it (desired behavior) - pnpm dev

Running pnpm dev and build after that gives the same result.

Expected Result

next.route must remain in BaseServer.handleRequest span_type regardless of whether sentry.init is included in the code or not

Actual Result

Additional Details

  1. I am using next.js and opentelemetry and prometheus together.
  2. At this time, we are trying to add metrics to prometheus by utilizing next.route, an opentelemetry span element provided by next.js.
  3. However, when running sentry.init in the instrumentation file like the sentry guide says, the next.route span element is lost in the BaseServer.handleRequest event logged in onEnd.
  4. When sentry.init is excluded from the code, the next.route span element remains normally.

Why does the next.route span element disappear depending on whether sentry.init is present or not?
Not shown in the image, but other span elements also change depending on sentry.init being run.

You can easily reproduce this by cloning the above repository and running the project.

Actual Result

  • When sentry.init is excluded from the line
Image Image
  • When sentry.init is included in the line
Image Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions