@@ -74,12 +74,14 @@ func (pm *PrometheusMapping) MapRate(ms *metricsStorage, sample metrics.Sample,
7474func (pm * PrometheusMapping ) MapTrend (ms * metricsStorage , sample metrics.Sample , labels []prompb.Label ) []prompb.TimeSeries {
7575 metric := ms .update (sample , trendAdd )
7676
77- // Prometheus metric system does not support Trend so this mapping will store gauges
78- // to keep track of key values.
77+ // Prometheus metric system does not support Trend so this mapping will
78+ // store a counter for the number of reported values and gauges to keep
79+ // track of aggregated values.
7980 // TODO: when Prometheus implements support for sparse histograms, re-visit this implementation
8081
8182 s := metric .Sink .(* metrics.TrendSink )
8283 aggr := map [string ]float64 {
84+ "count" : float64 (s .Count ),
8385 "min" : s .Min ,
8486 "max" : s .Max ,
8587 "avg" : s .Avg ,
@@ -89,6 +91,18 @@ func (pm *PrometheusMapping) MapTrend(ms *metricsStorage, sample metrics.Sample,
8991 }
9092
9193 return []prompb.TimeSeries {
94+ {
95+ Labels : append (labels , prompb.Label {
96+ Name : "__name__" ,
97+ Value : fmt .Sprintf ("%s%s_count" , defaultMetricPrefix , sample .Metric .Name ),
98+ }),
99+ Samples : []prompb.Sample {
100+ {
101+ Value : aggr ["count" ],
102+ Timestamp : timestamp .FromTime (sample .Time ),
103+ },
104+ },
105+ },
92106 {
93107 Labels : append (labels , prompb.Label {
94108 Name : "__name__" ,
0 commit comments