Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update to using `NaN`

Table of Contents

Status

Current state"Under Discussion"

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

A complex system like Kafka is non-trivial to operate. Metrics help users gauge how the system is behaving in real time. Kafka exposes metrics via JMX. Most users typically integrate these metrics with third-party systems which ease monitoring, detection of abnormal behavior and alerting.
When starting up a broker, most metrics will naturally not be populated since not much activity has happened. In this case, said metrics will output their default value.


In particular, Kafka has two I want to shine the light on three classes which help the tracking of Max, Avg and Min statistics. Both These classes respectively keep track of the maximum, average and minimum value they have recorded just fine.
The problem is that these metrics give out inconsistent with (in regards to each other) default values. Max gives out `-Inf`, whereas Avg gives out `0.0` and Min gives out `1.7976931348623157e+308` (Double.MAX_VALUE).

This is confusing at best to say the least and can cause third-party tool failures at worst. Most likely, users have explicit checks in their metrics monitoring software for default values like `metricValue != Double.NEGATIVE_INFINITY` and etc.
It is more intuitive to have these values be consistent.


Public Interfaces

The following All `-min`, `-avg` and `-max` metrics will now output `+InfNaN` default values rather than the previous `1.7976931348623157e+308` value.

...

.

...

Proposed Changes

Change the Min stat, Avg and Max stats' s default value to be be `NaN` and therefore consistent with the Max stat's default value. Namely, change Min's default value to `+Inf`each other.

Compatibility, Deprecation, and Migration Plan

The default value for the three metrics outlined above in "Public Interfaces" all `-min`, `-avg` and `-max` metrics will change.
If users' tools cannot handle `+Inf` `NaN` as a default value, they will need to use some sort of workaroundwork around it (probably via an explicit check).

Rejected Alternatives

  • Change Max's default value to `4.9e-324` (Double.MIN_VALUE) (to be consistent with Min)
    • The Max stat is used in far more metrics than Min so it is better to change the one that is least used
    • -Inf and +Inf are more intuitive default values for Max and Min stats respectively
  • Change Min's default value to be `+Inf` (to be consistent with Min)
    • This would cause the least backwards compatibility problems since there are only 3 metrics that use `-min`.
    • As discussed in the thread, `NaN` is more correct semantically and more intuitively shows that nothing has been recorded