Expand description
Distributed-tracing span context and propagation codecs.
Shared by the tracing plugins (opentelemetry, zipkin, skywalking),
which are each a start/end node pair around upstream: the start node
extracts or creates a SpanContext, stores it in context.message
(per-request state), and injects the downstream propagation header so the
upstream service continues the trace; the end node loads the span, computes
its duration, and exports it to the collector (fire-and-forget).
Provides trace/span id generation and codecs for the three wire formats:
W3C traceparent (OpenTelemetry), B3 (Zipkin), and SkyWalking sw8.
Structs§
- Span
Context - A span in flight: the trace it belongs to, this hop’s span, its parent, the sampling decision, and when it started (unix millis).
Constants§
- SPAN_
KEY - The reserved
context.messagekey under which the active span is stored.
Functions§
- build_
b3_ headers - Builds the B3 multi-headers for a span as
(name, value)pairs to set on the outgoing request. - build_
traceparent - Builds a W3C
traceparentheader value for a span. - hex 🔒
- load_
span - Loads the span previously stored by the start node.
- new_
span_ id - A random 16-hex-char (64-bit) span id.
- new_
trace_ id - A random 32-hex-char (128-bit) trace id.
- now_ms
- Current unix time in milliseconds.
- parse_
b3 - Parses B3 propagation from either the single
b3header (trace-span-sampled-parent) or the multi-header form, given a lookup of the relevant request headers, into(trace_id, parent_span_id, sampled). - parse_
sw8 - Parses a SkyWalking
sw8header (hyphen-separated, base64 fields) into(trace_id, parent_segment_span_id, sampled). Field 0 is the sample flag, field 1 the base64 trace id, field 3 the parent span id. - parse_
traceparent - Parses a W3C
traceparentheader (00-<trace>-<parent>-<flags>) into(trace_id, parent_span_id, sampled). - store_
span - Stores the span in
context.message. - sw8_
encode - Base64-encodes a field for an sw8 header.