Skip to content

Commit

Permalink
take the first counter value into account
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-dd committed Nov 13, 2024
1 parent 54960ed commit 828a0a8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/sinks/util/buffer/metrics/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,25 @@ impl MetricSet {
// introducing a small amount of lag before a metric is emitted by having to wait to see it
// again, but this is a behavior we have to observe for sinks that can only handle
// incremental updates.
Some(metric.into_incremental())
match self.0.get_mut(metric.series()) {
Some(reference) => {
let new_value = metric.value().clone();
// From the stored reference value, emit an increment
if metric.subtract(&reference.0) {
reference.0.value = new_value;
Some(metric.into_incremental())
} else {
// Metric changed type, store this and emit nothing
self.insert(metric);
None
}
}
None => {
// No reference so store this and emit nothing
self.insert(metric.clone());
Some(metric.into_incremental())
}
}
}

fn insert(&mut self, metric: Metric) {
Expand Down

0 comments on commit 828a0a8

Please sign in to comment.