@@ -52,13 +52,6 @@ export class SentrySampler implements Sampler {
52
52
return { decision : SamplingDecision . NOT_RECORD , traceState } ;
53
53
}
54
54
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
-
62
55
// If we have a http.client span that has no local parent, we never want to sample it
63
56
// but we want to leave downstream sampling decisions up to the server
64
57
if (
@@ -71,6 +64,14 @@ export class SentrySampler implements Sampler {
71
64
72
65
const parentSampled = parentSpan ? getParentSampled ( parentSpan , traceId , spanName ) : undefined ;
73
66
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
+
74
75
const [ sampled , sampleRate ] = sampleSpan ( options , {
75
76
name : spanName ,
76
77
attributes : spanAttributes ,
0 commit comments