Expand description
Distributed tracing via Zipkin / B3 propagation (zipkin).
The featherbit port of Apache APISIX’s zipkin plugin. Where APISIX runs it
across nginx phases, featherbit models it as a start/end node pair wired
around the upstream node, using the shared
trace helper to carry a SpanContext
through context.message:
- start node (
phase: start, placed right afterlistener, beforeupstream): extracts B3 propagation from either the singleb3header or thex-b3-*multi-header form. If present, this hop continues the incoming trace (sametrace_id, the caller’s span becomes our parent, the incoming sampled flag is honored). If absent, a new trace is started (new_trace_id(), no parent, sampled persample_ratio). This hop gets a freshspan_idand start time, the span is stored viastore_span, and the outgoingx-b3-*headers are injected so the upstream continues the trace. - end node (
phase: end, placed afterupstream, right beforeclient): loads the span, computes its duration, and — when sampled — builds a Zipkin v2 JSON span array and fire-and-forgets a POST to the collectorendpointon a detachedtokio::spawntask (the same best-effort pattern asproxy-mirror). The export result is ignored and never blocks or fails the request.
Both nodes always return Ok: tracing is observability, so it never
short-circuits the request through an error port. If the end node finds no
stored span it passes through untouched.
§Deviations from APISIX
- Spans are exported one-per-request (fire-and-forget) rather than through a
batched reporter; only span_version 2 (the APISIX default) is modeled, and
only a single
SERVERspan per hop (noapisix.rewrite/proxychildren). - The new-trace sampling draw is a pseudo-random, per-trace-consistent
hash of the trace id (no
randcrate), so a given trace id always samples the same way in a process.
Structs§
- Zipkin
Plugin - One node of the Zipkin tracing pair.
Enums§
- Phase 🔒
- Which node of the tracing pair this instance is.
Functions§
- build_
zipkin 🔒 - Builds the Zipkin v2 JSON span array for a finished span (pure; no I/O).
- ratio_
draw 🔒 - A pseudo-random draw in
[0.0, 1.0)derived deterministically from a trace id, so the same trace id always samples the same way within a process. Not cryptographic; good enough forsample_ratiowithout arandcrate.