Expand description
OpenTelemetry tracing-subscriber layer for uni-db.
Per proposal §12.1.1, plugin spans should propagate alongside the
host’s tracing events so a query trace shows up as one continuous
span tree in Jaeger / Tempo / Datadog. This module exposes a single
initialization helper that constructs a tracing_subscriber::Registry
with the tracing-opentelemetry
layer wrapping the standard fmt layer.
§Why a helper, not auto-install?
Embedders frequently bring their own tracing subscriber (server
frameworks like axum/tower-http, test harnesses, Python bindings).
Auto-installing a global subscriber from Uni::open would conflict
with those setups and produce the runtime panic
“a global default trace dispatcher has already been set”. The
conservative shape: ship the helper, let embedders opt in.
Inside the host, the uni_plugin::observability::record_invocation
function emits tracing::debug! events tagged with kind / qname /
plugin id. With the OTel layer installed those events become OTLP
spans automatically.
§Usage
use uni_plugin_host::observability::OtelConfig;
let cfg = OtelConfig {
service_name: "my-app".into(),
otlp_endpoint: "http://localhost:4317".into(),
};
let _guard = uni_plugin_host::observability::init_otel_subscriber(cfg)
.expect("OTel subscriber must initialize once");
// ... use Uni normally; events become OTLP spans.Structs§
- Otel
Config - Configuration for the OTel tracing subscriber.
- Otel
Guard - RAII guard that flushes and shuts down the OTel tracer provider on drop. Keep the returned value alive for the lifetime of the process; dropping it tears down the OTel pipeline.
Functions§
- current_
traceparent - W3C
traceparentheader value extracted from the currenttracingspan, formatted as00-<trace_id>-<span_id>-<flags>. - http_
get_ with_ traceparent - Perform an HTTP GET against
urlwith the current span’straceparentheader injected (FU-3). - init_
otel_ subscriber - Initialize a
tracing-subscriber::Registrywith an OTel layer pointing at the OTLP endpoint described bycfg.