From a10d055c32ec3ef50b9d1b921975f71b948515bb Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Sun, 21 Jul 2013 17:14:29 +0200 Subject: [PATCH] Include sample count and sum in Proto output. --- prometheus/histogram.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/prometheus/histogram.go b/prometheus/histogram.go index 85389a2..5a806bb 100644 --- a/prometheus/histogram.go +++ b/prometheus/histogram.go @@ -87,6 +87,8 @@ type histogram struct { type histogramVector struct { buckets []Bucket labels map[string]string + sum float64 + count uint64 } func (h *histogram) Add(labels map[string]string, value float64) { @@ -124,6 +126,9 @@ func (h *histogram) Add(labels map[string]string, value float64) { } histogram.buckets[lastIndex].Add(value) + + histogram.sum += value + histogram.count++ } func (h *histogram) String() string { @@ -313,7 +318,10 @@ func (metric *histogram) dumpChildren(f *dto.MetricFamily) { f.Type = dto.MetricType_SUMMARY.Enum() for signature, child := range metric.values { - c := &dto.Summary{} + c := &dto.Summary{ + SampleSum: proto.Float64(child.sum), + SampleCount: proto.Uint64(child.count), + } m := &dto.Metric{ Summary: c,