getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.86k stars 1.55k forks source link

Sentry messes up NextJS Opentelemtry #13127

Open Meemaw opened 1 month ago

Meemaw commented 1 month ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.20.0

Framework Version

14.2.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

In instrumentation.ts

import { registerOTel } from "@vercel/otel"
import * as Sentry from "@sentry/nextjs"

export function register() {
  Sentry.init({})
  registerOTel("my-service")
}

Steps to Reproduce

  1. Add Sentry.init({}) to the next instrumentation hook
  2. Otel integration stops working

Expected Result

Sentry shouldn't mess with otel instrumentation from nextjs.

Actual Result

Traces are not produced/send to collector

chargome commented 1 month ago

Hey @Meemaw thanks for reaching out!

For a custom otel setup some additional steps are required: https://docs.sentry.io/platforms/javascript/guides/nextjs/tracing/instrumentation/opentelemetry/#using-a-custom-opentelemetry-setup. We're currently updating this part of the docs, so you'll likely find a new version in the upcoming days.

In short, you'll need to add skipOpenTelemetrySetup: true to your init call and make sure some required components like SentryContextManager and SentryPropagator are instantiated.

Would you mind sharing how you want to use Sentry with this setup?