Skip to content

Commit 6d5befa

Browse files
committed
NOMERGE - add gauge metrics & temporarily remove histogram ones
1 parent 06c3be0 commit 6d5befa

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lading/src/blackhole/http.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
//! ## Metrics
44
//!
55
//! `bytes_received`: Total bytes received
6-
//! `bytes_received_distr`: Distribution of compressed bytes per request (with `path` label)
6+
//! `bytes_received_gauge`: Compressed body sizes, in bytes (with `path` label)
77
//! `decoded_bytes_received`: Total decoded bytes received
8-
//! `decoded_bytes_received_distr`: Distribution of decompressed bytes per request (with `path` label)
8+
//! `decoded_bytes_received_gauge`: Decompressed request body sizes, in bytes (with `path` label)
99
//! `requests_received`: Total requests received
10+
//! `bytes_sent_gauge`: Response packets body sizes, in bytes (with `path` label)
1011
//!
1112
1213
use bytes::Bytes;
1314
use http::{HeaderMap, header::InvalidHeaderValue, status::InvalidStatusCode};
1415
use http_body_util::{BodyExt, combinators::BoxBody};
1516
use hyper::{Request, Response, StatusCode, header};
16-
use metrics::{counter, histogram};
17+
use metrics::{counter, gauge}; // NOMERGE: temporarily remove histogram! calls as they're not yet supported in the metrics processing backends
1718
use serde::{Deserialize, Serialize};
1819
use std::{net::SocketAddr, time::Duration};
1920
use tracing::error;
@@ -164,16 +165,18 @@ async fn srv(
164165

165166
let mut labels_with_path = metric_labels.clone();
166167
labels_with_path.push(("path".to_string(), path));
167-
histogram!("bytes_received_distr", &labels_with_path).record(body.len() as f64);
168+
gauge!("bytes_received_gauge", &labels_with_path).set(body.len() as f64);
168169

169170
match crate::codec::decode(parts.headers.get(hyper::header::CONTENT_ENCODING), body) {
170171
Err(response) => Ok(*response),
171172
Ok(body) => {
172173
counter!("decoded_bytes_received", &metric_labels).increment(body.len() as u64);
173-
histogram!("decoded_bytes_received_distr", &labels_with_path).record(body.len() as f64);
174+
gauge!("decoded_bytes_received_gauge", &labels_with_path).set(body.len() as f64);
174175

175176
tokio::time::sleep(response_delay).await;
176177

178+
gauge!("bytes_sent_gauge", &labels_with_path).set(body_bytes.len() as f64);
179+
177180
let mut okay = Response::default();
178181
*okay.status_mut() = status;
179182
*okay.headers_mut() = headers;

0 commit comments

Comments
 (0)