Skip to content

Float divide-by-zero silently writes +Inf/NaN to a metric (int errors): intended? #1005

Description

@Lougarou

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<denom>-?\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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions