Add an example to the description

This commit is contained in:
Jeremy Wall 2023-01-30 19:09:39 -05:00
parent db1ac94815
commit 2d714d3c45

View File

@ -15,4 +15,18 @@
-->
# tower-trace-metrics
A [tower-http](https://crates.io/crates/tower-http) `TraceLayer` that records metrics using the [metrics](https://crates.io/crates/metrics) facade.
A [tower-http](https://crates.io/crates/tower-http) `TraceLayer` that records metrics using the [metrics](https://crates.io/crates/metrics) facade.
```rust
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.
}
```