Skip to content

Commit 1bcca84

Browse files
authored
fix(node-otel): Suppress tracing for generated sentry spans (#9142)
This should ensure that #9127 is fully fixed, and no otel instrumentation picks anything up (hopefully) for closed spans.
1 parent f112204 commit 1bcca84

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/opentelemetry-node/src/spanprocessor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Context } from '@opentelemetry/api';
2-
import { SpanKind, trace } from '@opentelemetry/api';
2+
import { context, SpanKind, trace } from '@opentelemetry/api';
3+
import { suppressTracing } from '@opentelemetry/core';
34
import type { Span as OtelSpan, SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base';
45
import { addGlobalEventProcessor, addTracingExtensions, getCurrentHub, Transaction } from '@sentry/core';
56
import type { DynamicSamplingContext, Span as SentrySpan, TraceparentData, TransactionContext } from '@sentry/types';
@@ -121,7 +122,10 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
121122
updateSpanWithOtelData(sentrySpan, otelSpan);
122123
}
123124

124-
sentrySpan.finish(convertOtelTimeToSeconds(otelSpan.endTime));
125+
// Ensure we do not capture any OTEL spans for finishing (and sending) this
126+
context.with(suppressTracing(context.active()), () => {
127+
sentrySpan.finish(convertOtelTimeToSeconds(otelSpan.endTime));
128+
});
125129

126130
clearSpan(otelSpanId);
127131
}

0 commit comments

Comments
 (0)