File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -231,12 +231,10 @@ func makeEncodableMetrics(metrics []*dto.Metric, metricsType dto.MetricType) []e
231
231
metric ["count" ] = fmt .Sprint (m .GetSummary ().GetSampleCount ())
232
232
metric ["sum" ] = fmt .Sprint (m .GetSummary ().GetSampleSum ())
233
233
case dto .MetricType_HISTOGRAM :
234
- metric ["sum" ] = fmt .Sprint (m .GetHistogram ().GetSampleSum ())
235
- if b := makeBuckets (m ); len (b ) > 0 {
236
- metric ["buckets" ] = b
237
- metric ["count" ] = fmt .Sprint (m .GetHistogram ().GetSampleCount ())
238
- } else {
239
- h , fh := histogram .NewModelHistogram (m .GetHistogram ())
234
+ dtoH := m .GetHistogram ()
235
+ metric ["sum" ] = fmt .Sprint (dtoH .GetSampleSum ())
236
+ if len (dtoH .GetNegativeSpan ())+ len (dtoH .GetPositiveSpan ()) > 0 {
237
+ h , fh := histogram .NewModelHistogram (dtoH )
240
238
if h == nil {
241
239
// float histogram
242
240
metric ["count" ] = fmt .Sprint (fh .Count )
@@ -245,6 +243,9 @@ func makeEncodableMetrics(metrics []*dto.Metric, metricsType dto.MetricType) []e
245
243
metric ["count" ] = fmt .Sprint (h .Count )
246
244
metric ["buckets" ] = histogram.BucketsAsJson [uint64 ](histogram .GetAPIBuckets (h ))
247
245
}
246
+ } else {
247
+ metric ["buckets" ] = makeBuckets (m )
248
+ metric ["count" ] = fmt .Sprint (dtoH .GetSampleCount ())
248
249
}
249
250
default :
250
251
metric ["value" ] = fmt .Sprint (getValue (m ))
You can’t perform that action at this time.
0 commit comments