From e7a487a7f5c89e39077e2a80c197f750f858dc1d Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Tue, 8 Jan 2019 17:48:26 +0100 Subject: [PATCH] Prometheus starting outputting floats? --- metrics/prometheus/prometheus_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index 2a921bd64..6bfc8a224 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -163,13 +163,14 @@ func TestHistogram(t *testing.T) { // Then, we use ExpectedObservationsLessThan to validate. for _, line := range strings.Split(scrape(), "\n") { + t.Logf("### %s", line) match := re.FindStringSubmatch(line) if match == nil { continue } bucket, _ := strconv.ParseInt(match[1], 10, 64) - have, _ := strconv.ParseInt(match[2], 10, 64) + have, _ := strconv.ParseFloat(match[2], 64) want := teststat.ExpectedObservationsLessThan(bucket) if match[1] == "+Inf" { @@ -182,7 +183,7 @@ func TestHistogram(t *testing.T) { // with my Expected calculation, or in Prometheus. tolerance := 0.25 if delta := math.Abs(float64(want) - float64(have)); (delta / float64(want)) > tolerance { - t.Errorf("Bucket %d: want %d, have %d (%.1f%%)", bucket, want, have, (100.0 * delta / float64(want))) + t.Errorf("Bucket %d: want %d, have %d (%.1f%%)", bucket, want, int(have), (100.0 * delta / float64(want))) } } }