Skip to content

Commit

Permalink
Merge pull request #667 from jan--f/id-native-hist-by-span
Browse files Browse the repository at this point in the history
api: identify native histograms by presence if at least one span
  • Loading branch information
beorn7 authored Jul 11, 2024
2 parents 42c4075 + 8e2feac commit 0a7ebfb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,10 @@ func makeEncodableMetrics(metrics []*dto.Metric, metricsType dto.MetricType) []e
metric["count"] = fmt.Sprint(m.GetSummary().GetSampleCount())
metric["sum"] = fmt.Sprint(m.GetSummary().GetSampleSum())
case dto.MetricType_HISTOGRAM:
metric["sum"] = fmt.Sprint(m.GetHistogram().GetSampleSum())
if b := makeBuckets(m); len(b) > 0 {
metric["buckets"] = b
metric["count"] = fmt.Sprint(m.GetHistogram().GetSampleCount())
} else {
h, fh := histogram.NewModelHistogram(m.GetHistogram())
dtoH := m.GetHistogram()
metric["sum"] = fmt.Sprint(dtoH.GetSampleSum())
if len(dtoH.GetNegativeSpan())+len(dtoH.GetPositiveSpan()) > 0 {
h, fh := histogram.NewModelHistogram(dtoH)
if h == nil {
// float histogram
metric["count"] = fmt.Sprint(fh.Count)
Expand All @@ -245,6 +243,9 @@ func makeEncodableMetrics(metrics []*dto.Metric, metricsType dto.MetricType) []e
metric["count"] = fmt.Sprint(h.Count)
metric["buckets"] = histogram.BucketsAsJson[uint64](histogram.GetAPIBuckets(h))
}
} else {
metric["buckets"] = makeBuckets(m)
metric["count"] = fmt.Sprint(dtoH.GetSampleCount())
}
default:
metric["value"] = fmt.Sprint(getValue(m))
Expand Down

0 comments on commit 0a7ebfb

Please sign in to comment.