@@ -2,15 +2,15 @@ import type { Span, SpanJSON, SpanTimeInput, TraceContext } from '@sentry/types'
22import { dropUndefinedKeys , generateSentryTraceHeader , timestampInSeconds } from '@sentry/utils' ;
33import type { Span as SpanClass } from '../tracing/span' ;
44
5- export const TraceFlagNone = 0x0 ;
6- // eslint-disable-next-line no-bitwise
7- export const TraceFlagSampled = 0x1 << 0 ;
5+ // These are aligned with OpenTelemetry trace flags
6+ export const TRACE_FLAG_NONE = 0x0 ;
7+ export const TRACE_FLAG_SAMPLED = 0x1 ;
88
99/**
1010 * Convert a span to a trace context, which can be sent as the `trace` context in an event.
1111 */
1212export function spanToTraceContext ( span : Span ) : TraceContext {
13- const { spanId : span_id , traceId : trace_id } = span ;
13+ const { spanId : span_id , traceId : trace_id } = span . spanContext ( ) ;
1414 const { data, description, op, parent_span_id, status, tags, origin } = spanToJSON ( span ) ;
1515
1616 return dropUndefinedKeys ( {
@@ -102,7 +102,9 @@ function spanIsSpanClass(span: Span): span is SpanClass {
102102 * So in the case where this distinction is important, use this method.
103103 */
104104export function spanIsSampled ( span : Span ) : boolean {
105+ // We align our trace flags with the ones OpenTelemetry use
106+ // So we also check for sampled the same way they do.
105107 const { traceFlags } = span . spanContext ( ) ;
106108 // eslint-disable-next-line no-bitwise
107- return Boolean ( traceFlags & TraceFlagSampled ) ;
109+ return Boolean ( traceFlags & TRACE_FLAG_SAMPLED ) ;
108110}
0 commit comments