Skip to content

Commit bc843f1

Browse files
committed
feat: Reuse existing tools from core
1 parent 56a53f8 commit bc843f1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/cloudflare/src/utils/traceLinks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DurableObjectStorage } from '@cloudflare/workers-types';
22
import { TraceFlags } from '@opentelemetry/api';
33
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';
55
import { DEBUG_BUILD } from '../debug-build';
66

77
/** Storage key prefix for the span context that links consecutive method invocations */
@@ -34,7 +34,7 @@ export async function storeSpanContext(originalStorage: DurableObjectStorage, me
3434
const storedContext: StoredSpanContext = {
3535
traceId: spanContext.traceId,
3636
spanId: spanContext.spanId,
37-
sampled: spanContext.traceFlags === TraceFlags.SAMPLED,
37+
sampled: spanIsSampled(activeSpan),
3838
};
3939
await originalStorage.put(getTraceLinkKey(methodName), storedContext);
4040
}
@@ -70,7 +70,7 @@ export function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] {
7070
traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,
7171
},
7272
attributes: {
73-
'sentry.link.type': 'previous_trace',
73+
[SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',
7474
},
7575
},
7676
];

0 commit comments

Comments
 (0)