Float divide-by-zero silently writes +Inf/NaN to a metric (int errors): intended?
- Dominant language
- Go
- Stars
- 4k
- Forks
- 392
- PR merge metrics
- No merged PRs in 30d
Description
Hi! Quick one, is this intended or just an oversight?
Integer divide-by-zero raises a runtime error (drops the line, bumps `prog_runtime_errors_total`), but float divide-by-zero doesn't. It just writes `+Inf`/`NaN` straight into the metric, no error. Same with `%` (`Fmod` gives `NaN`).
```
gauge ratio
/(?P-?\d+)/ {
ratio = 1000.0 / $denom
}
```
Feed it the line `0` and `ratio` comes out `+Inf`, silently. The int version (`1000 / $denom`) errors with `Divide by zero` instead, which is what made me notice.
(`float($x)` also happily takes `"Inf"`/`"NaN"`, so you can get a non-finite metric with no division at all.)
Intended? Happy to send a small PR if not. Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.