Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create clean custom OpenTelemetry setup combined with Sentry #12678

Open
3 tasks done
tnolet opened this issue Jun 27, 2024 · 1 comment
Open
3 tasks done

Unable to create clean custom OpenTelemetry setup combined with Sentry #12678

tnolet opened this issue Jun 27, 2024 · 1 comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Package-Meta: OpenTelemetry Type: Bug

Comments

@tnolet
Copy link

tnolet commented Jun 27, 2024

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.12.0

Framework Version

Next 14.0.4

Link to Sentry event

No response

SDK Setup/Reproduction Example

No response

Steps to Reproduce

I want to run a custom OpenTelemetry installation next to using Sentry, but Sentry's tracing / performance features interfere with my own setup. I still want to use Sentry tracing, in addition to my own setup.
I followed the instructions as per https://docs.sentry.io/platforms/javascript/guides/nextjs/tracing/instrumentation/opentelemetry/. Additionally, I set up a repo demonstrating my setup. See sentry-and-custom-otel branch here https://github.com/tnolet/tims-otel-app/tree/sentry-and-custom-otel

  1. Clone the repo at the sentry-and-custom-otel branch.
  2. Run npm install
  3. Run npm run dev
  4. Set up a Sentry DSN using export SENTRY_DSN="some DSN"
  5. Go to localhost:3000

You will now see some debug logging from Sentry showing a trace was recorded and flushed, e.g.

Sentry Logger [info]: Starting a new trace with id 82ff1d8fc6824d7797373e078adabc0f
Sentry Logger [info]: Starting a new trace with id f3d68a78734449b3a17d71d83f7a1050
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: Done flushing events
Sentry Logger [log]: Done flushing events

Note that you will NOT see the console.log statements that are added to the custom OTel setup as per instrumentation.ts.

  1. Now, go to instrumentation.ts and remove or comment out the Sentry relevant part. Just leave the registerOtel() function.
  2. Restart the app with npm run dev
  3. Execute a curl command to trigger the custom OTel setup with the customer sampler.
curl http://localhost:3000/ --header "tracestate: checkly=true" --header "traceparent: 00-6d2eac29c9283ece795b4fbaa2d57225-bad4e819c34d2cdb-01"

The logs should now show something like:

Sampling decision for Checkly span: 2
 ○ Compiling / ...
 ✓ Compiled / in 941ms (1573 modules)
Sampling decision for Checkly span: 2

Expected Result

I can run a separate, custom OTel setup with distinct sampling rules and exporters next to a Sentry installation.

Actual Result

See the reproduction steps. The result is I can run either Sentry or my own custom OTel setup, not both.

@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Jun 27, 2024
@mydea
Copy link
Member

mydea commented Jun 28, 2024

Thank you for opening this, and for the repro app! We will look into this to figure out what's going on.
We started creating E2E test apps testing custom otel setups (e.g. #12690), but haven't looked in detail into next.js specific setups there. We'll keep you posted in this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Package-Meta: OpenTelemetry Type: Bug
Projects
Status: No status
Development

No branches or pull requests

2 participants