Expand description
Request correlation and structured terminal access logging for Axum.
ObservabilityLayer validates or generates request IDs, accepts strict
W3C trace context, installs a RequestContext extension, and emits one
terminal access event after the response body completes or is abandoned.
JsonLayer formats those records and application tracing events without
installing a global subscriber.
use axum::{Router, routing::get};
use axum_observability::{ObservabilityConfig, ObservabilityLayer};
use tracing_subscriber::prelude::*;
let config = ObservabilityConfig::default();
let subscriber = tracing_subscriber::registry()
.with(config.json_layer(std::io::sink));
let app: Router = Router::new()
.route("/health", get(|| async { "ok" }))
.layer(ObservabilityLayer::new(config));
Structs§
- Json
Layer - A composable newline-delimited JSON
tracinglayer. - Missing
Request Context - Rejection returned when
RequestContextis extracted without the observability middleware installed. - Observability
Config - Configuration for
ObservabilityLayer. - Observability
Layer - Cloneable Tower layer that installs correlation and terminal access logs.
- Observability
Service - Service produced by
ObservabilityLayer. - Operation
Id - Stable application operation name attached to request or response extensions.
- Request
Context - Correlation metadata installed in every observed request’s extensions.
- Request
Id - A request identifier selected by the configured request-ID policy.
- Trace
Context - Validated inbound W3C trace context.
Enums§
- Field
Convention - Structured logging field convention.
- Invalid
Request Id - Reason a request identifier failed baseline validation.
- Trace
Context Level - W3C Trace Context level used for inbound validation and projection.