Skip to content

Commit c7e137c

Browse files
[metricbeat] Add divide by zero check to docker/diskio (#15649)
* add NaN check to docker/diskio * return 0
1 parent 935e58f commit c7e137c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

metricbeat/module/docker/diskio/helper.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,11 @@ func calculatePerSecond(duration time.Duration, old uint64, new uint64) float64
174174
if value < 0 {
175175
value = 0
176176
}
177-
return value / duration.Seconds()
177+
178+
timeSec := duration.Seconds()
179+
if timeSec == 0 {
180+
return 0
181+
}
182+
183+
return value / timeSec
178184
}

0 commit comments

Comments
 (0)