Skip to content

Commit 88f6fc2

Browse files
committed
feat(cloudflare): Add debug line | use SpanLink type from core
1 parent 445c94d commit 88f6fc2

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

packages/cloudflare/src/utils/traceLinks.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { DurableObjectStorage } from '@cloudflare/workers-types';
22
import { TraceFlags } from '@opentelemetry/api';
3-
import { getActiveSpan } from '@sentry/core';
3+
import type { SpanLink } from '@sentry/core';
4+
import { debug, getActiveSpan } from '@sentry/core';
5+
import { DEBUG_BUILD } from '../debug-build';
46

57
/** Storage key prefix for the span context that links consecutive method invocations */
68
const SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';
@@ -12,16 +14,6 @@ export interface StoredSpanContext {
1214
sampled: boolean;
1315
}
1416

15-
/** Span link structure for connecting traces */
16-
export interface SpanLink {
17-
context: {
18-
traceId: string;
19-
spanId: string;
20-
traceFlags: number;
21-
};
22-
attributes?: Record<string, string>;
23-
}
24-
2517
/**
2618
* Gets the storage key for a specific method's trace link.
2719
*/
@@ -46,8 +38,9 @@ export async function storeSpanContext(originalStorage: DurableObjectStorage, me
4638
};
4739
await originalStorage.put(getTraceLinkKey(methodName), storedContext);
4840
}
49-
} catch {
41+
} catch (error) {
5042
// Silently ignore storage errors to prevent internal failures from affecting user code
43+
DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);
5144
}
5245
}
5346

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ export type {
485485
} from './types-hoist/span';
486486
export type { SpanStatus } from './types-hoist/spanStatus';
487487
export type { Log, LogSeverityLevel } from './types-hoist/log';
488+
export type { SpanLink } from './types-hoist/link';
488489
export type {
489490
Metric,
490491
MetricType,

0 commit comments

Comments
 (0)