Expand description
Observability for klauthed services: structured logging/tracing, Prometheus
metrics, and OpenTelemetry trace export — from one TelemetryConfig.
init installs the global tracing subscriber (and, per feature + config,
the metrics recorder and the OTLP trace pipeline) and returns a Telemetry
handle. Keep it alive for the program’s lifetime; dropping it flushes
OpenTelemetry spans.
use klauthed_observability::{init, TelemetryConfig};
use klauthed_core::config::Profile;
let config = TelemetryConfig::for_profile(&Profile::detect(), "billing-api");
let _telemetry = init(&config).expect("telemetry init");
tracing::info!("service starting");Features:
metrics— Prometheus recorder + a/metricsrender handle.otel— OTLP trace export wired into the tracing subscriber.
Modules§
- metrics
- Prometheus metrics (feature
metrics). - prelude
- Common imports for telemetry setup:
use klauthed_observability::prelude::*;. - propagation
- W3C trace-context propagation across service boundaries (
otelfeature).
Structs§
- LogConfig
- Logging / tracing-subscriber settings.
- Metrics
Config - Prometheus metrics settings.
- Otel
Config - OpenTelemetry (OTLP) trace export settings.
- Telemetry
- A live telemetry installation. Hold it for the program’s lifetime.
- Telemetry
Config - Top-level telemetry settings for a service.
Enums§
- LogFormat
- Log output format.
- Observability
Error - Errors raised while initializing telemetry.
Traits§
- Record
Context - Attach
ctx’s identifying fields to an existing span.
Functions§
- init
- Initialize telemetry from
config, installing the global subscriber and, per features and config, the metrics recorder and OTLP trace pipeline. - request_
span - Create the root
requestspan forctx.