Skip to content

Histogram should ignore NaN observations #1275

Closed
@fstab

Description

@fstab

When a NaN value is observed, the current implementation of histogram increases count and sets sum to NaN.

https://github.com/prometheus/client_golang/blob/main/prometheus/histogram_test.go#L541-L544

This violates two parts of the OpenMetrics spec:

  • Sum MUST NOT be NaN.
  • Count must be equal to the +Inf bucket.

This means NaN values must be ignored according to OpenMetrics.

I think ignoring NaN observations is a good idea, because then the count can be calculated from the bucket values. I'm doing this in client_java's new data model, and I like it because the derived count can never become inconsistent.

Anyway, it would be good if all Prometheus client libraries behaved the same, so what do you think of ignoring NaN observations?

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