|
1 | 1 | import type { DurableObjectStorage } from '@cloudflare/workers-types'; |
2 | 2 | import { TraceFlags } from '@opentelemetry/api'; |
3 | 3 | import type { SpanLink } from '@sentry/core'; |
4 | | -import { debug, getActiveSpan } from '@sentry/core'; |
| 4 | +import { debug, getActiveSpan, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE, spanIsSampled } from '@sentry/core'; |
5 | 5 | import { DEBUG_BUILD } from '../debug-build'; |
6 | 6 |
|
7 | 7 | /** Storage key prefix for the span context that links consecutive method invocations */ |
@@ -34,7 +34,7 @@ export async function storeSpanContext(originalStorage: DurableObjectStorage, me |
34 | 34 | const storedContext: StoredSpanContext = { |
35 | 35 | traceId: spanContext.traceId, |
36 | 36 | spanId: spanContext.spanId, |
37 | | - sampled: spanContext.traceFlags === TraceFlags.SAMPLED, |
| 37 | + sampled: spanIsSampled(activeSpan), |
38 | 38 | }; |
39 | 39 | await originalStorage.put(getTraceLinkKey(methodName), storedContext); |
40 | 40 | } |
@@ -70,7 +70,7 @@ export function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] { |
70 | 70 | traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE, |
71 | 71 | }, |
72 | 72 | attributes: { |
73 | | - 'sentry.link.type': 'previous_trace', |
| 73 | + [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace', |
74 | 74 | }, |
75 | 75 | }, |
76 | 76 | ]; |
|
0 commit comments