tower-trace-metrics

Crates.iotower-trace-metrics
lib.rstower-trace-metrics
version0.1.0
sourcesrc
created_at2023-02-04 15:51:03.413376
updated_at2023-02-04 15:51:03.413376
descriptionA tower-http TraceLayer that records metrics per request
homepage
repository
max_upload_size
id776414
size20,018
Jeremy Wall (zaphar)

documentation

README

tower-trace-metrics

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.
}

Recorded Metrics

  • http_request_counter The total count of all requests
  • http_request_failure_counter The total count of all request failures
  • http_request_size_bytes_hist A histogram of request size in bytes
  • http_request_request_time_micros_hist A histogram of request time in microseconds

Each metric is faceted by path, method, and host for the request.

Commit count: 0

cargo fmt