Skip to content

Commit

Permalink
Adds path to metric labels for http blackhole (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottopell authored Dec 16, 2024
1 parent b99b8c4 commit 7df73bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Added
- Parse nearly the complete field list of smaps/smaps_rollup in the Linux observer.
- Metrics storage is now generational, expiring unwritten metrics by configuration parameter `expiration`.
- Requests sent to the 'http' blackhole will now record the `path` of the HTTP
request as a tag of the `bytes_received` and `requests_received` metrics.
## Removed
- Removed the unused target-rss-byte-limit from the command line, internal stub of.
## Changed
Expand Down
9 changes: 6 additions & 3 deletions lading/src/blackhole/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,18 @@ struct KinesisPutRecordBatchResponse {
#[allow(clippy::borrow_interior_mutable_const)]
async fn srv(
status: StatusCode,
metric_labels: Vec<(String, String)>,
mut metric_labels: Vec<(String, String)>,
body_bytes: Vec<u8>,
req: Request<Body>,
headers: HeaderMap,
response_delay: Duration,
) -> Result<Response<Body>, hyper::Error> {
counter!("requests_received", &metric_labels).increment(1);

let (parts, body) = req.into_parts();
if let Some(path_and_query) = parts.uri.path_and_query() {
metric_labels.push(("path".to_string(), path_and_query.path().to_string()));
}

counter!("requests_received", &metric_labels).increment(1);

let bytes = body.collect().await?.to_bytes();

Expand Down

0 comments on commit 7df73bc

Please sign in to comment.