Skip to content

Commit

Permalink
Report scraped counters without aggregation (#712)
Browse files Browse the repository at this point in the history
* Report scraped counters without aggregation

Openmetrics counters are absolute values; report them as such. The
`counter` macro expects delta values and was causing a
double-aggregation.

Co-authored-by: Scott Opell <scott.opell@datadoghq.com>

* changelog

---------

Co-authored-by: Scott Opell <scott.opell@datadoghq.com>
  • Loading branch information
GeorgeHahn and scottopell authored Oct 17, 2023
1 parent c4ced6e commit 9e144c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Report scraped Prometheus counters correctly

### Fixed
- Correct metrics emitted by http blackhole
Expand Down
8 changes: 6 additions & 2 deletions lading/src/target_metrics/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::{str::FromStr, time::Duration};

use metrics::{counter, gauge};
use metrics::{absolute_counter, gauge};
use rustc_hash::FxHashMap;
use serde::Deserialize;
use tracing::{error, info, trace, warn};
Expand Down Expand Up @@ -197,7 +197,11 @@ impl Prometheus {
};

trace!("counter: {name} = {value}");
counter!(format!("target/{name}"), value, &labels.unwrap_or_default());
absolute_counter!(
format!("target/{name}"),
value,
&labels.unwrap_or_default()
);
}
Some(_) | None => {
trace!("unsupported metric type: {name} = {value}");
Expand Down

0 comments on commit 9e144c9

Please sign in to comment.