MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / storeSpanContext

Function storeSpanContext

packages/cloudflare/src/utils/traceLinks.ts:29–46  ·  view source on GitHub ↗
(originalStorage: DurableObjectStorage, methodName: string)

Source from the content-addressed store, hash-verified

27 * Errors are silently ignored to prevent internal storage failures from propagating to user code.
28 */
29export function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): void {
30 try {
31 const activeSpan = getActiveSpan();
32 if (activeSpan) {
33 const spanContext = activeSpan.spanContext();
34 const storedContext: StoredSpanContext = {
35 traceId: spanContext.traceId,
36 spanId: spanContext.spanId,
37 sampled: spanIsSampled(activeSpan),
38 };
39
40 originalStorage.kv.put(getTraceLinkKey(methodName), storedContext);
41 }
42 } catch (error) {
43 // Silently ignore storage errors to prevent internal failures from affecting user code
44 DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);
45 }
46}
47
48/**
49 * Retrieves a stored span context from Durable Object storage.

Callers 3

traceLinks.test.tsFile · 0.90
teardownFunction · 0.90
teardownFunction · 0.90

Calls 6

getActiveSpanFunction · 0.90
spanIsSampledFunction · 0.90
getTraceLinkKeyFunction · 0.85
putMethod · 0.80
spanContextMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected