Skip to content

Report never-set gauges in mostrecent multiprocess mode - #1193

Open
sean-kim05 wants to merge 1 commit into
prometheus:masterfrom
sean-kim05:fix/multiprocess-mostrecent-zero-ts
Open

Report never-set gauges in mostrecent multiprocess mode#1193
sean-kim05 wants to merge 1 commit into
prometheus:masterfrom
sean-kim05:fix/multiprocess-mostrecent-zero-ts

Conversation

@sean-kim05

Copy link
Copy Markdown
Contributor

In the mostrecent/livemostrecent accumulation branch, sample_timestamps
is a defaultdict(float), so the stored timestamp of a series defaults to
0.0. A gauge child that was created but never set() also has a stored
timestamp of 0, so the strict 'current_timestamp < timestamp' check was
never satisfied and the series was dropped from collection entirely.

Every other gauge mode (sum, min, max, all) reports such a child as 0,
so mostrecent silently omitting it was inconsistent. Register the sample
when it is first seen, regardless of timestamp, and still let a strictly
newer timestamp win afterwards.

Add test_gauge_mostrecent_never_set, asserting a mostrecent gauge that is
created but never set is reported as 0 rather than missing.

@csmarchbanks

In the mostrecent/livemostrecent accumulation branch, sample_timestamps
is a defaultdict(float), so the stored timestamp of a series defaults to
0.0. A gauge child that was created but never set() also has a stored
timestamp of 0, so the strict 'current_timestamp < timestamp' check was
never satisfied and the series was dropped from collection entirely.

Every other gauge mode (sum, min, max, all) reports such a child as 0,
so mostrecent silently omitting it was inconsistent. Register the sample
when it is first seen, regardless of timestamp, and still let a strictly
newer timestamp win afterwards.

Add test_gauge_mostrecent_never_set, asserting a mostrecent gauge that is
created but never set is reported as 0 rather than missing.

Signed-off-by: Sean Kim <skim8705@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant