Skip to content

Commit b05bfd9

Browse files
authored
fix(nextjs): Do not sample next spans if they have remote parent (#11680)
This hopefully fixes this, not sure how to write a test for this (?) but we can add one later as well...
1 parent e9d846b commit b05bfd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/opentelemetry/src/sampler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export class SentrySampler implements Sampler {
6767
// If we encounter a span emitted by Next.js, we do not want to sample it
6868
// The reason for this is that the data quality of the spans varies, it is different per version of Next,
6969
// and we need to keep our manual instrumentation around for the edge runtime anyhow.
70-
// BUT we only do this if we don't have a parent span with a sampling decision yet
71-
if (spanAttributes['next.span_type'] && typeof parentSampled !== 'boolean') {
70+
// BUT we only do this if we don't have a parent span with a sampling decision yet (or if the parent is remote)
71+
if (spanAttributes['next.span_type'] && (typeof parentSampled !== 'boolean' || parentContext?.isRemote)) {
7272
return { decision: SamplingDecision.NOT_RECORD, traceState: traceState };
7373
}
7474

0 commit comments

Comments
 (0)