Skip to content

Commit 3d10c89

Browse files
author
Alex Wong
committed
Ignore first collected disk stats to prevent metric distortion
1 parent 219b408 commit 3d10c89

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/systemstatsmonitor/disk_collector.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,16 @@ func (dc *diskCollector) collect() {
109109

110110
for deviceName, ioCountersStat := range ioCountersStats {
111111
// Calculate average IO queue length since last measurement.
112-
lastIOTime := dc.historyIOTime[deviceName]
112+
lastIOTime, historyExist := dc.historyIOTime[deviceName]
113113
lastWeightedIO := dc.historyWeightedIO[deviceName]
114114

115115
dc.historyIOTime[deviceName] = ioCountersStat.IoTime
116116
dc.historyWeightedIO[deviceName] = ioCountersStat.WeightedIO
117117

118+
if !historyExist {
119+
// Ignore first collected stats.
120+
return
121+
}
118122
avgQueueLen := float64(0.0)
119123
if lastIOTime != ioCountersStat.IoTime {
120124
avgQueueLen = float64(ioCountersStat.WeightedIO-lastWeightedIO) / float64(ioCountersStat.IoTime-lastIOTime)

0 commit comments

Comments
 (0)