-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issuesI have reviewed the documentation https://docs.sentry.io/I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releasesTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
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
- Clone the repo at the
sentry-and-custom-otel
branch. - Run
npm install
- Run
npm run dev
- Set up a Sentry DSN using
export SENTRY_DSN="some DSN"
- 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
.
- Now, go to
instrumentation.ts
and remove or comment out the Sentry relevant part. Just leave theregisterOtel()
function. - Restart the app with
npm run dev
- 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.
Metadata
Metadata
Assignees
Labels
Projects
Status
Activity
mydea commentedon 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!
lforst commentedon Jul 23, 2024
Hi, sorry for the wait. The reproduction repo is private so I cannot look at it, but I am still gonna try to be useful here.
As a first step I would recommend upgrading to the latest SDK version. We changed a few things around how we do tracing in the Next.js SDK recently. I don't think it is gonna solve the sampling decision stuff entirely, but it may help.
Additionally, I'd like to better understand the specific issues you are facing. You mentioned that Sentry takes over sampling decisions, would you mind elaborating with specifics or share some examples?
Basically, I want to get an understanding of the status quo and where we want to get to.
getsantry commentedon Aug 23, 2024
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label
Waiting for: Community
, I will leave it alone ... forever!"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
anyulled commentedon Jan 13, 2025
I'm having this issue with my Next.js v.15 application, any updates on this?
You can check the code here:
https://github.com/anyulled/my-portfolio-website/blob/main/src/instrumentation.ts
lforst commentedon Jan 13, 2025
@anyulled Please check our guide on how to combine Sentry with your own opentelemetry setup: https://docs.sentry.io/platforms/javascript/guides/node/opentelemetry/custom-setup/ Seems like you didn't do that from looking at your setup.