(span: Span)
| 7 | * Print a log message for a started span. |
| 8 | */ |
| 9 | export 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. |
no test coverage detected