From a5eb7684ffa1f4b069dd5c465e3347270f226846 Mon Sep 17 00:00:00 2001 From: Anshal Shukla Date: Thu, 27 Jul 2023 13:07:57 +0530 Subject: [PATCH] add getters to histogram and summary metrics --- histogram.go | 8 ++++++++ summary.go | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/histogram.go b/histogram.go index 47af50c..02535e3 100644 --- a/histogram.go +++ b/histogram.go @@ -77,6 +77,14 @@ func (h *Histogram) Reset() { h.mu.Unlock() } +func (h *Histogram) GetSum() float64 { + return h.sum +} + +func (h *Histogram) GetDecimalBuckets() [decimalBucketsCount]*[bucketsPerDecimal]uint64 { + return h.decimalBuckets +} + // Update updates h with v. // // Negative values and NaNs are ignored. diff --git a/summary.go b/summary.go index 52183d2..1eb0889 100644 --- a/summary.go +++ b/summary.go @@ -31,6 +31,26 @@ type Summary struct { window time.Duration } +func (s *Summary) GetSum() float64 { + return s.sum +} + +func (s *Summary) GetCount() uint64 { + return s.count +} + +func (s *Summary) GetTime() time.Duration { + return s.window +} + +func (s *Summary) GetQuantiles() []float64 { + return s.quantiles +} + +func (s *Summary) GetQuantileValues() []float64 { + return s.quantileValues +} + // NewSummary creates and returns new summary with the given name. // // name must be valid Prometheus-compatible metric with possible labels.