Skip to content

Commit ff34d04

Browse files
committed
Add an example to the description and update docs
1 parent 2d714d3 commit ff34d04

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Diff for: README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ fn main() {
2727
let service = ServiceBuilder::new()
2828
// Make a trace layer where the chunks are bytes::Bytes
2929
.layer(make_layer(|b: &bytes::Bytes| b.len() as u64));
30-
// ... Use this service in a Tower Middleware stack.
30+
// ... Use this service in a Tower middleware stack.
3131
}
32-
```
32+
```
33+
34+
## Recorded Metrics
35+
36+
* http_request_counter The total count of all requests
37+
* http_request_failure_counter The total count of all request failures
38+
* http_request_size_bytes_hist A histogram of request size in bytes
39+
* http_request_request_time_micros_hist A histogram of request time in microseconds
40+
41+
Each metric is faceted by `path`, `method`, and `host` for the request.

Diff for: src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ where
5858
pub labels: Arc<Mutex<Vec<Label>>>,
5959
/// The accumulator for the number of bytes on this request.
6060
pub size: Arc<AtomicU64>,
61-
/// The mapper function to extract the size from a chunk in [OnBodyChunk<B>],
61+
/// The mapper function to extract the size in bytes from a chunk in [OnBodyChunk<B>],
6262
pub chunk_len: Arc<F>,
6363
_phantom: PhantomData<B>,
6464
}
@@ -82,7 +82,7 @@ where
8282
F: Fn(&B) -> u64,
8383
{
8484
/// Construct a new [MetricsRecorder] using the installed [metrics::Recorder].
85-
/// The function passed in is used to extract the size from the chunks in a
85+
/// The function passed in is used to extract the size in bytes from the chunks in a
8686
/// response for all [OnBodyChunk] calls.
8787
pub fn new(f: F) -> Self {
8888
Self {
@@ -169,7 +169,7 @@ where
169169
}
170170

171171
/// Construct a [TraceLayer] that will use an installed [metrics::Recorder] to record metrics per request.
172-
/// The provided [Fn] is used to extract the size from the chunks in a
172+
/// The provided [Fn] is used to extract the size in bytes from the chunks in a
173173
/// response for all [OnBodyChunk] calls.
174174
pub fn make_layer<B, F>(f: F) -> MetricsTraceLayer<B, F>
175175
where

0 commit comments

Comments
 (0)