@@ -52,13 +52,6 @@ export class SentrySampler implements Sampler {
5252 return { decision : SamplingDecision . NOT_RECORD , traceState } ;
5353 }
5454
55- // If we encounter a span emitted by Next.js, we do not want to sample it
56- // The reason for this is that the data quality of the spans varies, it is different per version of Next,
57- // and we need to keep our manual instrumentation around for the edge runtime anyhow.
58- if ( spanAttributes [ 'next.span_type' ] ) {
59- return { decision : SamplingDecision . NOT_RECORD , traceState : traceState } ;
60- }
61-
6255 // If we have a http.client span that has no local parent, we never want to sample it
6356 // but we want to leave downstream sampling decisions up to the server
6457 if (
@@ -71,6 +64,14 @@ export class SentrySampler implements Sampler {
7164
7265 const parentSampled = parentSpan ? getParentSampled ( parentSpan , traceId , spanName ) : undefined ;
7366
67+ // If we encounter a span emitted by Next.js, we do not want to sample it
68+ // The reason for this is that the data quality of the spans varies, it is different per version of Next,
69+ // 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' ) {
72+ return { decision : SamplingDecision . NOT_RECORD , traceState : traceState } ;
73+ }
74+
7475 const [ sampled , sampleRate ] = sampleSpan ( options , {
7576 name : spanName ,
7677 attributes : spanAttributes ,
0 commit comments