Skip to content

Commit 5a4ac81

Browse files
author
Alex Wong
committed
Only disk_avg_queue_len is distorted on first collection
1 parent 3d10c89 commit 5a4ac81

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

pkg/systemstatsmonitor/disk_collector.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,6 @@ func (dc *diskCollector) collect() {
115115
dc.historyIOTime[deviceName] = ioCountersStat.IoTime
116116
dc.historyWeightedIO[deviceName] = ioCountersStat.WeightedIO
117117

118-
if !historyExist {
119-
// Ignore first collected stats.
120-
return
121-
}
122-
avgQueueLen := float64(0.0)
123-
if lastIOTime != ioCountersStat.IoTime {
124-
avgQueueLen = float64(ioCountersStat.WeightedIO-lastWeightedIO) / float64(ioCountersStat.IoTime-lastIOTime)
125-
}
126-
127118
// Attach label {"device_name": deviceName} to the metrics.
128119
tags := map[string]string{deviceNameLabel: deviceName}
129120
if dc.mIOTime != nil {
@@ -132,8 +123,14 @@ func (dc *diskCollector) collect() {
132123
if dc.mWeightedIO != nil {
133124
dc.mWeightedIO.Record(tags, int64(ioCountersStat.WeightedIO-lastWeightedIO))
134125
}
135-
if dc.mAvgQueueLen != nil {
136-
dc.mAvgQueueLen.Record(tags, avgQueueLen)
126+
if historyExist {
127+
avgQueueLen := float64(0.0)
128+
if lastIOTime != ioCountersStat.IoTime {
129+
avgQueueLen = float64(ioCountersStat.WeightedIO-lastWeightedIO) / float64(ioCountersStat.IoTime-lastIOTime)
130+
}
131+
if dc.mAvgQueueLen != nil {
132+
dc.mAvgQueueLen.Record(tags, avgQueueLen)
133+
}
137134
}
138135
}
139136
}

0 commit comments

Comments
 (0)