@@ -2,7 +2,13 @@ import { Context, trace } from '@opentelemetry/api';
22import { Span as OtelSpan , SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base' ;
33import { addGlobalEventProcessor , getCurrentHub } from '@sentry/core' ;
44import { Transaction } from '@sentry/tracing' ;
5- import { DynamicSamplingContext , Span as SentrySpan , TraceparentData , TransactionContext } from '@sentry/types' ;
5+ import {
6+ Contexts ,
7+ DynamicSamplingContext ,
8+ Span as SentrySpan ,
9+ TraceparentData ,
10+ TransactionContext ,
11+ } from '@sentry/types' ;
612import { logger } from '@sentry/utils' ;
713
814import { SENTRY_DYNAMIC_SAMPLING_CONTEXT_KEY , SENTRY_TRACE_PARENT_CONTEXT_KEY } from './constants' ;
@@ -27,20 +33,13 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
2733 return event ;
2834 }
2935
30- const otelSpanId = otelSpan . spanContext ( ) . spanId ;
31- const sentrySpan = SENTRY_SPAN_PROCESSOR_MAP . get ( otelSpanId ) ;
32-
33- if ( ! sentrySpan ) {
34- return event ;
35- }
36-
3736 // If event has already set `trace` context, use that one.
3837 // This happens in the case of transaction events.
39- event . contexts = { trace : sentrySpan . getTraceContext ( ) , ... event . contexts } ;
40- const transactionName = sentrySpan . transaction && sentrySpan . transaction . name ;
41- if ( transactionName ) {
42- event . tags = { transaction : transactionName , ... event . tags } ;
43- }
38+ const traceContext : Contexts [ ' trace' ] = {
39+ trace_id : otelSpan . spanContext ( ) . traceId ,
40+ span_id : otelSpan . spanContext ( ) . spanId ,
41+ } ;
42+ event . contexts = { trace : traceContext , ... event . contexts } ;
4443
4544 return event ;
4645 } ) ;
0 commit comments