Skip to content

Commit

Permalink
Update to use seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon authored and Gordon committed Jun 11, 2024
1 parent 6b85598 commit e969e88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion telemetry/prometheus/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Config struct {
Subsystem string // optional
HistogramBucketCount int // Number of buckets for histogram, default to 1000
// Number of buckets for time buckets, default to 1000.
// The bucket size is 10ms, so the maximum covered time range is 10ms * TimeBucketCount.
// The bucket size is 0.01s(10ms), so the maximum covered time range is 10ms * TimeBucketCount.
TimeBucketCount int
}

Expand Down
6 changes: 3 additions & 3 deletions telemetry/prometheus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ func (p *metrics) Time(name string, value time.Duration, tags []string) {
Namespace: p.cfg.Namespace,
Subsystem: p.cfg.Subsystem,
Help: name + " timing histogram",
// Given bucket=10ms, the maximum covered time range is 10ms * TimeBucketCount
Buckets: prometheus.LinearBuckets(0, 10, p.cfg.TimeBucketCount),
// Given bucket=0.01s(10ms), the maximum covered time range is 10ms * TimeBucketCount
Buckets: prometheus.LinearBuckets(0, 0.01, p.cfg.TimeBucketCount),
}, labels)
prometheus.MustRegister(histogramVec)
p.histogramVecs[name] = histogramVec
}

// Convert time.Duration to seconds since Prometheus prefers base units
histogramVec.WithLabelValues(labelValues...).Observe(float64(value.Milliseconds()))
histogramVec.WithLabelValues(labelValues...).Observe(float64(value.Seconds()))

Check failure on line 209 in telemetry/prometheus/metrics.go

View workflow job for this annotation

GitHub Actions / ci (lint, ubuntu-latest, 1.21.0)

unnecessary conversion (unconvert)
}

// Latency is a helper function to measure the latency of a routine.
Expand Down

0 comments on commit e969e88

Please sign in to comment.