Details

Type: Incident report

Status: Open

Priority: Major

Resolution: Unresolved

Affects Version/s: 2.4.0

Fix Version/s: None

Component/s: Frontend (F)

Labels:
Description
We'll need to reimplement our roundoff algorithm used in latest data, overview and some other places. The current implementation seemed to have deviated from the original idea at some point. Here's a summary of how it works now, omitting some details:
If units are empty or unit is either %, ms, rpm or RPM then: If the modulus of the value is >= 0.01 (ZBX_UNITS_ROUNDOFF_THRESHOLD) then: round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT) numbers after the decimal point else: round it off to 6 (ZBX_UNITS_ROUNDOFF_LOWER_LIMIT) numbers else If the modulus of the value is >= 1 (hardcoded) then: convert it to some power and add the prefix (K, M, G etc) round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT) else: round if off to 4 (ZBX_UNITS_ROUNDOFF_MIDDLE_LIMIT)
I'm not sure about the reasoning behind this algorithm, but I don't think we need two different ways of rounding values depending on their units.
I believe, the algorithm should be simple and look something like this:
If the modulus of the value is >= 0.01 (ZBX_UNITS_ROUNDOFF_THRESHOLD) then: round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT) numbers after the decimal point else: round it off to 6 (ZBX_UNITS_ROUNDOFF_LOWER_LIMIT) numbers
We should also consider making these constants configurable from the frontend.