Repository navigation
fix(prometheus): avoid replaying stream bandwidth after baseline loss - #14279
Open
Zi-Yi-Ming wants to merge 1 commit into
Open
Zi-Yi-Ming wants to merge 1 commit into
Zi-Yi-Ming wants to merge 1 commit into
Conversation
Recover a lost publication baseline from the current zone total when the matching counter survives. Count new slots from zero and keep baseline writes from evicting metrics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A missing publication baseline can mean a new stream metrics slot or a slot whose Prometheus counter survived eviction of its baseline. Starting from zero in the latter case adds bytes that the counter has already recorded.
When the baseline is missing, check whether the counter still exists. A surviving counter resumes from the next recorded zone total. A new slot, or an emptied metric dictionary, starts from zero. The exporter uses non-evicting writes for the publication lock and baselines, and flushes buffered increments before releasing the lock so the next publisher can see the counters.
The regression deletes a baseline twice while retaining the counter. It checks that both scrapes keep the same count and that the next session adds five bytes. The stream metrics suite also covers the first bytes of a new slot and a full dictionary reset.
Which issue(s) this PR fixes:
Fixes #14103.
Validation
Used a dedicated test etcd and the CI-pinned Test::Nginx checkout.
FLUSH_ETCD=1 TEST_NGINX_BINARY="$(command -v openresty)" \ prove --timer -v -I/opt/test-nginx/lib -I. \ t/stream-plugin/prometheus-metrics-service.t t/stream-plugin/prometheus-metrics.t LC_ALL=C.UTF-8 make lint git diff --checkChecklist