Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jan 10, 2023
1 parent 0efadc0 commit bcc75fd
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/opentelemetry-node/src/spanprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { Context, trace } from '@opentelemetry/api';
import { Span as OtelSpan, SpanProcessor as OtelSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { Transaction } from '@sentry/tracing';
import { DynamicSamplingContext, Span as SentrySpan, TraceparentData, TransactionContext } from '@sentry/types';
import {
Contexts,
DynamicSamplingContext,
Span as SentrySpan,
TraceparentData,
TransactionContext,
} from '@sentry/types';
import { logger } from '@sentry/utils';

import { SENTRY_DYNAMIC_SAMPLING_CONTEXT_KEY, SENTRY_TRACE_PARENT_CONTEXT_KEY } from './constants';
Expand All @@ -27,20 +33,13 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
return event;
}

const otelSpanId = otelSpan.spanContext().spanId;
const sentrySpan = SENTRY_SPAN_PROCESSOR_MAP.get(otelSpanId);

if (!sentrySpan) {
return event;
}

// If event has already set `trace` context, use that one.
// This happens in the case of transaction events.
event.contexts = { trace: sentrySpan.getTraceContext(), ...event.contexts };
const transactionName = sentrySpan.transaction && sentrySpan.transaction.name;
if (transactionName) {
event.tags = { transaction: transactionName, ...event.tags };
}
const traceContext: Contexts['trace'] = {
trace_id: otelSpan.spanContext().traceId,
span_id: otelSpan.spanContext().spanId,
};
event.contexts = { trace: traceContext, ...event.contexts };

return event;
});
Expand Down

0 comments on commit bcc75fd

Please sign in to comment.