Skip to content

Commit

Permalink
Correctly treat +Inf and quantiles encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Pérez-Aradros Herce committed Jan 9, 2019
1 parent 86bc56a commit 411cc77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions metricbeat/module/prometheus/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) {
"http_request_duration_microseconds": float64(10),
},
labels: common.MapStr{
"quantile": float64(0.99),
"quantile": "0.99",
},
},
},
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) {
data: common.MapStr{
"http_request_duration_microseconds": uint64(10),
},
labels: common.MapStr{"le": float64(0.99)},
labels: common.MapStr{"le": "0.99"},
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions metricbeat/module/prometheus/collector/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package collector

import (
"math"
"strconv"

"github.com/elastic/beats/libbeat/common"

Expand Down Expand Up @@ -88,7 +89,7 @@ func getPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent {
}

quantileLabels := labels.Clone()
quantileLabels["quantile"] = quantile.GetQuantile()
quantileLabels["quantile"] = strconv.FormatFloat(quantile.GetQuantile(), 'f', -1, 64)
events = append(events, PromEvent{
data: common.MapStr{
name: quantile.GetValue(),
Expand All @@ -110,8 +111,7 @@ func getPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent {

for _, bucket := range histogram.GetBucket() {
bucketLabels := labels.Clone()
// XXX 0 == +Inf?
bucketLabels["le"] = bucket.GetUpperBound()
bucketLabels["le"] = strconv.FormatFloat(bucket.GetUpperBound(), 'f', -1, 64)

events = append(events, PromEvent{
data: common.MapStr{
Expand Down

0 comments on commit 411cc77

Please sign in to comment.