Skip to main content

Module zipkin

Module zipkin 

Source
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 after listener, before upstream): extracts B3 propagation from either the single b3 header or the x-b3-* multi-header form. If present, this hop continues the incoming trace (same trace_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 per sample_ratio). This hop gets a fresh span_id and start time, the span is stored via store_span, and the outgoing x-b3-* headers are injected so the upstream continues the trace.
  • end node (phase: end, placed after upstream, right before client): loads the span, computes its duration, and — when sampled — builds a Zipkin v2 JSON span array and fire-and-forgets a POST to the collector endpoint on a detached tokio::spawn task (the same best-effort pattern as proxy-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 SERVER span per hop (no apisix.rewrite/proxy children).
  • The new-trace sampling draw is a pseudo-random, per-trace-consistent hash of the trace id (no rand crate), so a given trace id always samples the same way in a process.

Structs§

ZipkinPlugin
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 for sample_ratio without a rand crate.