Skip to content

Commit

Permalink
Prometheus starting outputting floats? (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon committed Jan 8, 2019
1 parent aed3207 commit a7c6dde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions metrics/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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)))
}
}
}
Expand Down

0 comments on commit a7c6dde

Please sign in to comment.