Fix rollover bug in mountstats collector (#1364)

* Update procfs vendor to pull in github.com/prometheus/procfs/pull/165
* Update mountstats collector to use new types.
* Rollover counter automatically to avoid float64 accuracy issues.
* Update e2e test.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2019-05-31 18:30:37 +02:00 committed by GitHub
commit 8146998945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 771 additions and 76 deletions

View file

@ -21,6 +21,11 @@ import (
"github.com/prometheus/procfs"
)
var (
// 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
float64Mantissa uint64 = 9007199254740992
)
type mountStatsCollector struct {
// General statistics
NFSAgeSecondsTotal *prometheus.Desc
@ -618,7 +623,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSTransportIdleTimeSeconds,
prometheus.GaugeValue,
s.Transport.IdleTime.Seconds(),
float64(s.Transport.IdleTimeSeconds%float64Mantissa),
export,
protocol,
)
@ -728,7 +733,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsQueueTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeQueueTime.Seconds(),
float64(op.CumulativeQueueMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,
@ -737,7 +742,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsResponseTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeTotalResponseTime.Seconds(),
float64(op.CumulativeTotalResponseMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,
@ -746,7 +751,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsRequestTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeTotalRequestTime.Seconds(),
float64(op.CumulativeTotalRequestMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,