Skip to main content

Module trace

Module trace 

Source
Available on crate feature tracing only.
Expand description

Logs every request with tracing (feature tracing).

TraceLayer opens a http.request span per request, with the method and the URL without its query (a query can hold an API key), and records the status and duration when the response arrives:

  • a response below 500: an event at DEBUG;
  • a 5xx response or a failure to send: an event at WARN.

Events have the target timvw_rust_runtime::trace, so RUST_LOG=timvw_rust_runtime=debug shows every request. With the retry feature, RetryPolicy logs each retry at DEBUG too.

use timvw_rust_runtime::{trace::TraceLayer, Client};

let client = Client::default().layer(TraceLayer::new());

Headers and bodies are not logged. For more (headers, custom spans, OpenTelemetry), use tower-http’s TraceLayer; it works with Client::layer too.

Structs§

TraceLayer
A tower layer that logs each request and its outcome. See the module documentation.
TraceService
The service of a TraceLayer.