You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref(opentelemetry): Avoid sampling work for non-root spans (#15820)
Related to
#15725 (comment)
When a span is not a root span, we do not need to do sampling work for
it. By reordering stuff in the `shouldSample` function, we should be
able to save a bunch of operations for the vast majority of (non-root)
spans.
I _think_ this should be just fine!
DEBUG_BUILD&&logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
129
-
130
-
return{
131
-
...wrapSamplingDecision({
132
-
decision: SamplingDecision.NOT_RECORD,
133
-
context,
134
-
spanAttributes,
135
-
sampleRand,
136
-
downstreamTraceSampleRate: 0,// we don't want to sample anything in the downstream trace either
137
-
}),
138
-
};
139
-
}
140
-
141
-
if(
142
-
!sampled&&
143
-
// We check for `parentSampled === undefined` because we only want to record client reports for spans that are trace roots (ie. when there was incoming trace)
144
-
parentSampled===undefined
145
-
){
146
-
DEBUG_BUILD&&logger.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
downstreamTraceSampleRate: 0,// we don't want to sample anything in the downstream trace either
142
+
});
143
+
}
144
+
145
+
if(
146
+
!sampled&&
147
+
// We check for `parentSampled === undefined` because we only want to record client reports for spans that are trace roots (ie. when there was incoming trace)
148
+
parentSampled===undefined
149
+
){
150
+
DEBUG_BUILD&&logger.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
0 commit comments