Expand description
Tower middleware that emits structured rlg records for every HTTP request that passes through it.
Compatible with any service that satisfies
tower::Service<http::Request<B>> — axum, tonic, hyper services,
lambda_runtime, custom stacks.
§Example (axum)
ⓘ
use axum::{Router, routing::get};
use rlg::log_format::LogFormat;
use rlg::log_level::LogLevel;
use rlg_tower::RlgLayer;
let app: Router = Router::new()
.route("/", get(|| async { "hello" }))
.layer(
RlgLayer::new()
.level(LogLevel::INFO)
.format(LogFormat::JSON)
.header("x-request-id"),
);One record is emitted per response, with the following fields:
| Attribute | Source |
|---|---|
component | "rlg-tower" (override with .component(...)) |
description | "<METHOD> <path> -> <status>" |
http.method | request method |
http.path | request URI path |
http.status | response status code |
http.latency_ms | wall-clock milliseconds from poll-ready to ready response |
trace_id, span_id | extracted from configured request headers (W3C / b3) if present |
Structs§
- RlgFuture
- Future returned by
RlgService::call. - RlgLayer
- Tower [
Layer] that wraps a service with rlg request logging. - RlgService
- Service wrapper produced by
RlgLayer.