Add histogram sum/count publishing to reduce metrics cardinality#296
Conversation
This change allows histograms to publish only sum and count metrics instead of full bucket distributions, significantly reducing Prometheus cardinality from 30+ time series per metric down to just 2. Changes: - Add publish_as_sum_count enum value to _publish_as - Add ReportSumCount interface and PrometheusReportSumCount implementation - Update HistogramDynamicInfo to support sum/count reporting mode via variant - Add is_sum_count_reporter() helper and update unregister() logic - Add remove_sum_count() to Reporter interface and PrometheusReporter - Add test case demonstrating sum/count histogram usage When a histogram is registered with publish_as_sum_count: - Reports only metric_sum and metric_count to Prometheus (2 time series) - Still collects full bucket data in memory for local JSON API access - Maintains backward compatibility with existing histogram behavior Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
3299d21 to
34549a0
Compare
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #296 +/- ##
===========================================
- Coverage 64.29% 50.49% -13.81%
===========================================
Files 72 63 -9
Lines 4406 4135 -271
Branches 555 1803 +1248
===========================================
- Hits 2833 2088 -745
+ Misses 1327 867 -460
- Partials 246 1180 +934
🚀 New features to boost your workflow:
|
Besroy
left a comment
There was a problem hiding this comment.
LGTM. Just curious if this sum/count is guaranteed to be non-decreasing - if so, do you want add a check in set_value (assert or log) when diff < 0
I am not sure we put some negative value into the histogram as there is no bucket defined with negative, but technically you are right. we can change it to gauge in next commit. |
This change allows histograms to publish only sum and count metrics instead of full bucket distributions, significantly reducing Prometheus cardinality from 30+ time series per metric down to just 2.
Changes:
When a histogram is registered with publish_as_sum_count: