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

Function logSpanStart

packages/core/src/tracing/logSpans.ts:9–40  ·  view source on GitHub ↗
(span: Span)

Source from the content-addressed store, hash-verified

7 * Print a log message for a started span.
8 */
9export function logSpanStart(span: Span): void {
10 if (!DEBUG_BUILD) return;
11
12 const { description = '< unknown name >', op = '< unknown op >', parent_span_id: parentSpanId } = spanToJSON(span);
13 const { spanId } = span.spanContext();
14
15 const sampled = spanIsSampled(span);
16 const rootSpan = getRootSpan(span);
17 const isRootSpan = rootSpan === span;
18
19 const header = `[Tracing] Starting ${sampled ? 'sampled' : 'unsampled'} ${isRootSpan ? 'root ' : ''}span`;
20
21 const infoParts: string[] = [`op: ${op}`, `name: ${description}`, `ID: ${spanId}`];
22
23 if (parentSpanId) {
24 infoParts.push(`parent ID: ${parentSpanId}`);
25 }
26
27 if (!isRootSpan) {
28 const { op, description } = spanToJSON(rootSpan);
29 infoParts.push(`root ID: ${rootSpan.spanContext().spanId}`);
30 if (op) {
31 infoParts.push(`root op: ${op}`);
32 }
33 if (description) {
34 infoParts.push(`root description: ${description}`);
35 }
36 }
37
38 debug.log(`${header}
39 ${infoParts.join('\n ')}`);
40}
41
42/**
43 * Print a log message for an ended span.

Callers 2

createChildOrRootSpanFunction · 0.90
onStartMethod · 0.90

Calls 6

spanToJSONFunction · 0.90
spanIsSampledFunction · 0.90
getRootSpanFunction · 0.85
pushMethod · 0.80
spanContextMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected