Crates.io | tower-trace-metrics |
lib.rs | tower-trace-metrics |
version | 0.1.0 |
source | src |
created_at | 2023-02-04 15:51:03.413376 |
updated_at | 2023-02-04 15:51:03.413376 |
description | A tower-http TraceLayer that records metrics per request |
homepage | |
repository | |
max_upload_size | |
id | 776414 |
size | 20,018 |
A tower-http TraceLayer
that records metrics using the metrics facade.
use tower_trace_metrics::make_layer;
use tower::ServiceBuilder;
use bytes;
fn main() {
let service = ServiceBuilder::new()
// Make a trace layer where the chunks are bytes::Bytes
.layer(make_layer(|b: &bytes::Bytes| b.len() as u64));
// ... Use this service in a Tower middleware stack.
}
Each metric is faceted by path
, method
, and host
for the request.