Skip to content

Commit ccb3ee4

Browse files
committed
fix(otel): Remove sampling decision in propagator
1 parent eb04258 commit ccb3ee4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/opentelemetry-node/src/propagator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export class SentryPropagator implements TextMapPropagator {
6262
const traceparentData = extractTraceparentData(header);
6363
newContext = newContext.setValue(SENTRY_TRACE_PARENT_CONTEXT_KEY, traceparentData);
6464
if (traceparentData) {
65-
const traceFlags = traceparentData.parentSampled ? TraceFlags.SAMPLED : TraceFlags.NONE;
6665
const spanContext = {
6766
traceId: traceparentData.traceId || '',
6867
spanId: traceparentData.parentSpanId || '',
6968
isRemote: true,
70-
traceFlags,
69+
// Always sample if traceparent exists, we use SentrySpanProcessor to make sampling decisions with `startTransaction`.
70+
traceFlags: TraceFlags.SAMPLED,
7171
};
7272
newContext = trace.setSpanContext(newContext, spanContext);
7373
}

packages/opentelemetry-node/src/spanprocessor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function getTraceData(otelSpan: OtelSpan, parentContext: Context): Partial<Trans
133133
spanId,
134134
traceId,
135135
parentSpanId,
136+
...traceparentData,
136137
metadata: {
137138
// only set dynamic sampling context if sentry-trace header was set
138139
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,

0 commit comments

Comments
 (0)