Comments (10)
Looks like it could be related to #11625
from sentry-javascript.
Hi, I am trying to better understand your desired outcome. What do traces look for you, and what would you like them to look like?
from sentry-javascript.
Hi, I am trying to better understand your desired outcome. What do traces look for you, and what would you like them to look like?
Sorry for late reply.
The desired outcome would be to have all spans from single request assigned to same trace id.
Now Sentry creates own context so all spans created by sentry and within sentry context are not assigned to original trace.
For us it's problematic since we can't see full trace by original trace id.
from sentry-javascript.
Hi @adam187, I talked with @lforst and there are a few things to unpack:
- In order to use Sentry with a custom OTEL instrumentation you need to follow some additional steps: https://docs.sentry.io/platforms/javascript/guides/nextjs/tracing/instrumentation/opentelemetry/#using-a-custom-opentelemetry-setup Make sure to add all of the components like the span processor, the propagator, the context manager and so on!
- We do not pick up OTEL instrumentation from Next.js pages router, because we found that it has a lot of incorrect data (see vercel/next.js#64723). For app router, the data emitted by Next.js is accurate.
- Our current recommendation for you, if you are only intending to use Sentry for tracing is to ditch the
@vercel/otel
package. You will not get much more (if any) good data from it.
from sentry-javascript.
Hey @chargome, sorry for late replay.
The main issue here is not missing spans, I could live with that since I filter some of them myself. The main issue here is that it looks like that sentry create it's own isolated context and ignores tracing from the origin.
So if I make a request with some traceparent header (for example from load balancer)
curl 'http://localhost:3000' -H 'traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01'
Then trace id from origin (0af7651916cd43dd8448eb211c80319c
) is used for next spans but not for the sentry spans.
span.spanContext().traceId 0af7651916cd43dd8448eb211c80319c 65073143ff8e8137 next.js
span.spanContext().traceId 0af7651916cd43dd8448eb211c80319c fd2126cfa6b28748 next.js
span.spanContext().traceId 343e1e0631bfb3841a90e43e1852ce66 f0ee3f56c7b50523 @sentry/node
span.spanContext().traceId 343e1e0631bfb3841a90e43e1852ce66 1e93ba38b4669365 @sentry/node
span.spanContext().traceId 0af7651916cd43dd8448eb211c80319c 7d54d9af00b36793 next.js
I wanted to check if it's working the same as in example from docs but for some reason I But I'm getting error:
▲ Next.js 14.2.5
- Local: http://localhost:3000
- Experiments (use with caution):
· instrumentationHook
✓ Starting...
○ Compiling /instrumentation ...
⨯ node:child_process
Module build failed: UnhandledSchemeError: Reading from "node:child_process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:child_process
./node_modules/@sentry/node/build/esm/integrations/context.js
./node_modules/@sentry/node/build/esm/index.js
✓ Ready in 2s
https://github.com/adam187/nextjs-sentry-otel-example/tree/sentry-example-otel
When I tried to use @sentry/nextjs
insted of @sentry/node
I got it compiled with some errors but still I don't see trace id to be propagated properly from request header.
https://github.com/adam187/nextjs-sentry-otel-example/tree/sentry-example-otel-2
Even if I explicitly add W3C propagators like
const propagator = new CompositePropagator({
propagators: [
new SentryPropagator(),
new W3CTraceContextPropagator(),
new W3CBaggagePropagator(),
],
});
I see the same effect, traceparent is reflected on next.js spans but sentry use own context and trace id.
https://github.com/adam187/nextjs-sentry-otel-example/tree/sentry-example-otel-3
For now I reverted back to v7
from sentry-javascript.
Hi, the Sentry SDK doesn't speak the traceparent
header, which is why the SDK might send disconnected traces from the rest of your OTEL setup. As a bare minimum, the SDK uses a proprietary sentry-trace
header with an optional but strongly recommended baggage
header. This is mostly due to historical (implementation pre-dating the wider adoption of OTEL within the ecosystem), but also technical reasons (more involved serverside sampling rules). If you have other components in your system that you want to have traced with Sentry, you need to install the Sentry SDK there too. Does this make sense?
from sentry-javascript.
I don't want to use Sentry to trace our whole system. We already using OTEL and W3C Tracing across our system. We're only using Sentry for error reporting from frontend part of the stack.
from sentry-javascript.
That's fair. You don't have to. But then you need to set up trace propagation yourself. We have documented the primitives here: https://docs.sentry.io/platforms/javascript/tracing/trace-propagation/custom-instrumentation/
from sentry-javascript.
That's fair. You don't have to. But then you need to set up trace propagation yourself. We have documented the primitives here: https://docs.sentry.io/platforms/javascript/tracing/trace-propagation/custom-instrumentation/
Still it doesn't look like my case, this look like propagating trace from server side to client side and I have issue with pure SSR requests and it's not the issue with propagating traces to other services with outgoing request but the fact that Sentry creates separate trace scope that is isolated from initial tracing 🤔
from sentry-javascript.
If you do not care about connecting errors to traces, you should be able to skip using the SentryPropagator.
We have new and improved docs on using Sentry with a custom otel setup here: https://docs.sentry.io/platforms/javascript/guides/nextjs/opentelemetry/custom-setup/
This explains what you need to set up and why. Your setup cannot work because you did not set up the SentryContextManager - without this, the Sentry SDK will not work as expected, because Sentry scope & OTEL context will not be linked correctly.
You need to use SentrySampler (or use wrapSamplingDecision
in your own sampler) and SentryProagator if you want to be able to connect errors in your frontend to your backend.
from sentry-javascript.
Related Issues (20)
- 🧑💻👩💻👨💻 Hackweek is ongoing! HOT 1
- Inaccurate Replay HOT 2
- TrpcMiddleware types are not compatible with trpc v11 HOT 3
- withScope not creating a new scope, changes affect global scope HOT 4
- Add Vitest eslint plugin
- Switch to vitest in `@sentry/core` HOT 1
- Fix SDK source in CDN bundles
- `sentry.client.config.ts` could not access system environment variables that are defined in Azure? HOT 4
- Add timestamps to replays based on local time HOT 2
- nextjs-app-dir (latest) Test Failed HOT 1
- Better document how to gracefully shutdown on SIGTERM HOT 2
- User feedback says submissions was successful but nothing shows up in the dashboard HOT 2
- Session Replay on Mobile Javascript Appears Longer Than the User's Screen HOT 1
- @sentry/node async contexts play poorly with http response events HOT 2
- Replay tunnel fails due to empty envelope HOT 4
- Module '"@sentry/nestjs"' has no exported member 'WithSentry'. HOT 1
- SolidJS sample error not captured HOT 3
- All exceptions are logged into the console
- Sentry-related spans are appearing in dns/net opentelemetry traces HOT 1
- User feedback not showing after fully render in next.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-javascript.