Skip to content

Support exemplars in multiprocess mode - #1265

Open
vignesh2027 wants to merge 1 commit into
prometheus:masterfrom
vignesh2027:multiproc-exemplars
Open

vignesh2027 wants to merge 1 commit into
prometheus:masterfrom
vignesh2027:multiproc-exemplars

Conversation

@vignesh2027

Copy link
Copy Markdown

Fixes #826

Exemplars passed to Counter.inc and Histogram.observe were silently dropped in multiprocess mode, because MmapedValue.set_exemplar and get_exemplar were stubs. The docs listed exemplars as unsupported there.

This follows the second option csmarchbanks described in the issue, a separate set of exemplar files so the existing .db files stay as they are. Each process writes counter_<pid>.exemplars and histogram_<pid>.exemplars lazily, on the first exemplar. A series gets one fixed size slot that is replaced in place, so the files do not grow with the number of exemplars. The labels are stored as JSON in the slot, sized for the 128 character limit. A sequence number lets the collector skip a slot that is being rewritten while it reads.

MultiProcessCollector globs the *.exemplars files next to the .db files and, for every series, exposes the exemplar with the newest timestamp across processes. For histograms that is per bucket, as in single process mode. The different extension means older collectors never treat the new files as metric files during a rolling upgrade, and merge() accepts them in the same file list.

Tests cover counters and histograms across processes, newest wins, no growth on repeated writes, non-ASCII and maximum size labels, fork handling, a missing file during merge, and the slot format itself, including a half written slot. The new tests fail on master and pass here. flake8 and the full suite are clean.

Signed off under the DCO. The change is above the trivial size, so I am happy to take the design to the mailing list first if that is preferred.

Counter.inc and Histogram.observe accepted an exemplar in multiprocess
mode but dropped it, so nothing was ever exposed for it. This was left
as a TODO in MmapedValue.

Each process now keeps its exemplars in a counter_<pid>.exemplars or
histogram_<pid>.exemplars file next to its .db files. Every series gets
one fixed size slot, written once and then replaced in place, so the file
does not grow with the number of exemplars. A sequence number lets the
collector skip a slot that is being rewritten while it reads it.

MultiProcessCollector picks up the *.exemplars files and, for every
series, exposes the exemplar with the newest timestamp across processes.
The extension keeps older collectors from mistaking the new files for
metric files during a rolling upgrade.

Signed-off-by: vigneshwar <applemacbook6sep2004@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why is there no examplar support on multiprocss mode?

1 participant