diff --git a/src/builder.rs b/src/builder.rs index d001915..a6a860d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -261,10 +261,6 @@ impl StatsdBuilder { /// /// Refer to the documentation for [`MetricKindMask`](metrics_util::MetricKindMask) for more /// information on defining a metric kind mask. - /// - /// When a metric is rendered its value is replaced with a "zero-value" for that `MetricKind` - /// however any metric with a state "zero-value" will not be rendered and will be cleaned up - /// when its corresponding idle timeout expires. #[must_use] pub fn idle_timeout(mut self, mask: MetricKindMask, timeout: Option) -> Self { self.idle_timeout = timeout; @@ -614,7 +610,12 @@ mod tests { gauge1.set(-3.44); let rendered = handle.render(); // each render call will reset the value of the counter - let expected_gauge = "basic.gauge:-3.44|g|#wutang:forever\n\n"; + let expected_gauge = concat!( + "basic.counter:0|c\n", + "\n", + "basic.gauge:-3.44|g|#wutang:forever\n", + "\n", + ); assert_eq!(rendered, expected_gauge); let key = Key::from_name("basic.histogram"); @@ -623,6 +624,8 @@ mod tests { let rendered = handle.render(); let histogram_data = concat!( + "basic.counter:0|c\n\n", + "basic.gauge:-3.44|g|#wutang:forever\n\n", "basic.histogram.min:12|g\n", "basic.histogram.max:12|g\n", "basic.histogram.avg:12|g\n", diff --git a/src/recorder.rs b/src/recorder.rs index f26fdce..bee6205 100644 --- a/src/recorder.rs +++ b/src/recorder.rs @@ -51,7 +51,7 @@ impl Inner { } let (name, labels) = key_to_parts(&key, Some(&self.global_tags)); - let value = f64::from_bits(gauge.get_inner().swap(0, Ordering::Acquire)); + let value = f64::from_bits(gauge.get_inner().load(Ordering::Acquire)); let entry = gauges .entry(name) .or_insert_with(HashMap::new) @@ -103,9 +103,6 @@ impl Inner { for (name, mut by_labels) in counters.drain() { let mut wrote = false; for (labels, value) in by_labels.drain() { - if value == 0 { - continue; - } wrote = true; write_metric_line::<&str, u64>( &mut output, @@ -128,9 +125,6 @@ impl Inner { for (name, mut by_labels) in gauges.drain() { let mut wrote = false; for (labels, value) in by_labels.drain() { - if value == 0.0 { - continue; - } wrote = true; write_metric_line::<&str, f64>( &mut output, @@ -156,9 +150,6 @@ impl Inner { let (sum, count) = match distribution { Distribution::Summary(summary, quantiles, sum) => { let count = summary.count(); - if count == 0 { - continue; - } wrote = true; let snapshot = summary.snapshot(Instant::now()); for quantile in quantiles.iter() { @@ -192,9 +183,6 @@ impl Inner { } Distribution::Histogram(histogram) => { let count = histogram.count(); - if count == 0 { - continue; - } wrote = true; for (le, count) in histogram.buckets() { write_metric_line(