Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: identify native histograms by presence if at least one span #667

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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