@@ -2,7 +2,13 @@ import { Context, trace } from '@opentelemetry/api';
2
2
import { Span as OtelSpan , SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base' ;
3
3
import { addGlobalEventProcessor , getCurrentHub } from '@sentry/core' ;
4
4
import { 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' ;
6
12
import { logger } from '@sentry/utils' ;
7
13
8
14
import { SENTRY_DYNAMIC_SAMPLING_CONTEXT_KEY , SENTRY_TRACE_PARENT_CONTEXT_KEY } from './constants' ;
@@ -27,20 +33,13 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
27
33
return event ;
28
34
}
29
35
30
- const otelSpanId = otelSpan . spanContext ( ) . spanId ;
31
- const sentrySpan = SENTRY_SPAN_PROCESSOR_MAP . get ( otelSpanId ) ;
32
-
33
- if ( ! sentrySpan ) {
34
- return event ;
35
- }
36
-
37
36
// If event has already set `trace` context, use that one.
38
37
// 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 } ;
44
43
45
44
return event ;
46
45
} ) ;
0 commit comments