Skip to main content

Crate klauthed_observability

Crate klauthed_observability 

Source
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 /metrics render 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 (otel feature).

Structs§

LogConfig
Logging / tracing-subscriber settings.
MetricsConfig
Prometheus metrics settings.
OtelConfig
OpenTelemetry (OTLP) trace export settings.
Telemetry
A live telemetry installation. Hold it for the program’s lifetime.
TelemetryConfig
Top-level telemetry settings for a service.

Enums§

LogFormat
Log output format.
ObservabilityError
Errors raised while initializing telemetry.

Traits§

RecordContext
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 request span for ctx.