Skip to content

Commit 1a3167a

Browse files
committed
Add test for histogram count accumulation
1 parent 2027424 commit 1a3167a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/histogram_test.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ TEST_F(HistogramTest, bucket_bounds) {
7676
EXPECT_EQ(h.bucket(1).upper_bound(), 2);
7777
EXPECT_EQ(h.bucket(2).upper_bound(), std::numeric_limits<double>::infinity());
7878
}
79+
80+
TEST_F(HistogramTest, cumulative_bucket_counts_not_reset_by_collection) {
81+
Histogram histogram{{1, 2}};
82+
histogram.Observe(1.5);
83+
histogram.Collect();
84+
histogram.Observe(1.5);
85+
auto metric = histogram.Collect();
86+
ASSERT_TRUE(metric.has_histogram());
87+
auto h = metric.histogram();
88+
ASSERT_EQ(h.bucket_size(), 3);
89+
EXPECT_EQ(h.bucket(1).cumulative_count(), 2);
90+
}

0 commit comments

Comments
 (0)