1 个不稳定版本
| 0.1.0 | 2023年2月4日 |
|---|
#12 in #tower-http
9KB
140 行代码(不包括注释)
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.
}
记录的度量
- http_request_counter 所有请求的总数
- http_request_failure_counter 所有请求失败的总数
- http_request_size_bytes_hist 请求大小的字节直方图
- http_request_request_time_micros_hist 请求时间的微秒直方图
每个度量都按请求的 path、method 和 host 分面。
依赖关系
~5MB
~103K SLoC