Skip to main content

Module observability

Module observability 

Source
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§

OtelConfig
Configuration for the OTel tracing subscriber.
OtelGuard
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 traceparent header value extracted from the current tracing span, formatted as 00-<trace_id>-<span_id>-<flags>.
http_get_with_traceparent
Perform an HTTP GET against url with the current span’s traceparent header injected (FU-3).
init_otel_subscriber
Initialize a tracing-subscriber::Registry with an OTel layer pointing at the OTLP endpoint described by cfg.