opentelemetry, how to disable some of the default spans? #58614
Replies: 2 comments 1 reply
-
I haven't found a way to disable producing the spans but I've been experimenting with using a custom class CustomSampler implements Sampler {
shouldSample(
context: Context,
traceId: string,
spanName: string,
spanKind: SpanKind,
attributes: Attributes,
): SamplingResult {
if (attributes['next.span_type']) {
return {
decision: SamplingDecision.NOT_RECORD,
}
}
return {
decision: SamplingDecision.RECORD_AND_SAMPLED,
}
}
} I think you could adopt this for your usecase by looking into the Although it'd be defintely appreciated to have a way to control span generation baked into Next.js itself. |
Beta Was this translation helpful? Give feedback.
-
Another workaround is to filter at the level of the exporter. For example, you can override
Above is a very coarse criteria for dropping everything that comes from the next.js framework itself, but you can tweak the filter criteria to whatever you need. As of next.js 15.0.1 default spans are documented at Default Spans https://nextjs.org/docs/pages/building-your-application/optimizing/open-telemetry#default-spans-in-nextjs and the resulting
|
Beta Was this translation helpful? Give feedback.
-
Summary
Specifically I would like to disable a couple of apis from having spans created for them. namely the /liveness and /readiness endpoints that kubernetes uses to see if the app is ready and alive. these endpoints get hit alot from the kubernetes api server.
I followed this doc
https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions