Skip to content

Commit 3c06588

Browse files
committed
more changes
1 parent 81c70f9 commit 3c06588

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

packages/opentelemetry-node/src/spanprocessor.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { Context, trace } from '@opentelemetry/api';
22
import { Span as OtelSpan, SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base';
33
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
44
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';
612
import { logger } from '@sentry/utils';
713

814
import { 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

Comments
 (0)