Expand description
Distributed tracing via OpenTelemetry (opentelemetry).
The featherbit port of Apache APISIX’s opentelemetry plugin. Unlike the
single-phase APISIX plugin, this is 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 the W3Ctraceparentheader. If present, this hop continues the incoming trace (sametrace_id, the caller’s span becomes our parent, and the incoming sampled flag is honored). If absent, a new trace is started (new_trace_id(), no parent, sampled per thesamplerconfig). Either way this hop gets a freshspan_idand start time, the span is stored viastore_span, and the outgoingtraceparentheader is injected so the upstream service continues the trace. - end node (
phase: end, placed afterupstream, right beforeclient): loads the span, computes its duration, and — when sampled — builds an OTLP/HTTP JSON payload and fire-and-forgets a POST to the collector’s/v1/tracesendpoint on 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 (start node absent or misordered) it passes through untouched.
§Deviations from APISIX
- Spans are exported one-per-request (fire-and-forget) rather than through a
batch span processor;
batch_span_processorconfig is not supported. - Sampler strategies are
always_on,always_off, andtrace_id_ratio(parent_baseis not supported). The new-trace sampling draw is a pseudo-random, per-trace-consistent hash of the trace id (norandcrate), so a given trace id always samples the same way in a process. - OTLP/JSON id fields (
traceId,spanId,parentSpanId) are emitted as lowercase hex strings, which is the canonical OTLP/JSON encoding accepted by modern collectors.
Structs§
- Open
Telemetry Plugin - One node of the OpenTelemetry tracing pair.
Enums§
- Phase 🔒
- Which node of the tracing pair this instance is.
- Sampler 🔒
- New-trace sampling strategy (used only when no incoming
traceparent).
Functions§
- build_
otlp 🔒 - Builds the OTLP/HTTP JSON payload for a finished span (pure; no I/O).
- int_
attr 🔒 - parse_
sampler 🔒 - Parses the
samplerconfig object into aSampler, failing fast on an unknown strategy name or a malformedfraction. - 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 ratio sampling without arandcrate. - str_
attr 🔒