Skip to content

Refactor MultiProcessCollector.collect() to allow for arbitrary merging. - #302

Merged
brian-brazil merged 7 commits into
prometheus:masterfrom
canonical-ols:refactor-multiprocess-collect
Sep 7, 2018
Merged

Refactor MultiProcessCollector.collect() to allow for arbitrary merging.#302
brian-brazil merged 7 commits into
prometheus:masterfrom
canonical-ols:refactor-multiprocess-collect

Conversation

@bloodearnest

@bloodearnest bloodearnest commented Sep 5, 2018

Copy link
Copy Markdown
Contributor

Factors out a merge() method from the previous collect() method, which
is parameterized, and thus can be used for arbitrary merging of samples.
For motivation, see discussion in issue #275 around merging dead worker's
data into a single mmaped file.

This basically allows us to parameterize the files to be merged, and
also whether to accumulate histograms or not. Accumulation is on by
default, as that is what the prometheus format expects. But it can now
be disabled, which allows merged values to be correctly written back to
an mmaped file. For the same reason, the order of labels is preserved
via OrderedDict.

@brian-brazil

Copy link
Copy Markdown
Contributor

You've test failures, and need to add a DCO.

@bloodearnest
bloodearnest force-pushed the refactor-multiprocess-collect branch from f4cde59 to 34c366d Compare September 5, 2018 13:15
Comment thread prometheus_client/multiprocess.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should still work on 2.6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code works, but the order is not preserved on 2.6, so it's different behaviour

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than changing this, how about changing the format of the multiprocess key to be a dict for the labels and using sort_keys=True?

@bloodearnest
bloodearnest force-pushed the refactor-multiprocess-collect branch from 2f12be2 to afaf04d Compare September 7, 2018 13:07
Comment thread prometheus_client/multiprocess.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ordering here deterministic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, good catch.

Comment thread prometheus_client/core.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was todo with trying to fix that fact that repr of float in 2.6 is different. Ended up just skipping those tests on 2.6.

@brian-brazil

Copy link
Copy Markdown
Contributor

Can you resolve the conflict? I just merged a large reworking of the library to support openmetrics.

Simon Davy added 7 commits September 7, 2018 18:00
Factors out a merge() method from the previous collect() method, which
is parameterized, and thus can be used for arbitrary merging of samples.
For motivation, see discussion in issue prometheus#275 around merging dead workers
data into a single mmaped file.

This basically allows us to parameterize the files to be merged, and
also whether to accumulate histograms or not. Accumulation is on by
default, as that is what the prometheus format expects. But it can now
be disabled, which allows merged values to be correctly written back to
an mmaped file. For the same reason, the order of labels is preserved
via OrderedDict.

Signed-off-by: Simon Davy <simon.davy@canonical.com>
Signed-off-by: Simon Davy <simon.davy@canonical.com>
Signed-off-by: Simon Davy <simon.davy@canonical.com>
Signed-off-by: Simon Davy <simon.davy@canonical.com>
…ion differences make it too difficult

Signed-off-by: Simon Davy <simon.davy@canonical.com>
Signed-off-by: Simon Davy <simon.davy@canonical.com>
Signed-off-by: Simon Davy <simon.davy@canonical.com>
@bloodearnest
bloodearnest force-pushed the refactor-multiprocess-collect branch from c955f42 to a4370a5 Compare September 7, 2018 17:09
@bloodearnest

Copy link
Copy Markdown
Contributor Author

Rebased on latest master

@brian-brazil
brian-brazil merged commit 18017c6 into prometheus:master Sep 7, 2018
@brian-brazil

Copy link
Copy Markdown
Contributor

Thanks!

@bloodearnest

Copy link
Copy Markdown
Contributor Author

Awesome, thanks :)

@bloodearnest
bloodearnest deleted the refactor-multiprocess-collect branch September 7, 2018 18:17
@xavfernandez

Copy link
Copy Markdown
Contributor

Thanks @bloodearnest for this feature.

@brian-brazil : any idea when you might release the next version including this ?

@brian-brazil

Copy link
Copy Markdown
Contributor

I'm waiting to get all the openmetrics stuff in, and then release.

brian-brazil pushed a commit that referenced this pull request Oct 2, 2018
…ng. (#302)

* Refactor MultiprocessCollector.collect to allow for arbitrary merging.

Factors out a merge() method from the previous collect() method, which
is parameterized, and thus can be used for arbitrary merging of samples.
For motivation, see discussion in issue #275 around merging dead workers
data into a single mmaped file.

This basically allows us to parameterize the files to be merged, and
also whether to accumulate histograms or not. Accumulation is on by
default, as that is what the prometheus format expects. But it can now
be disabled, which allows merged values to be correctly written back to
an mmaped file.

Signed-off-by: Simon Davy <simon.davy@canonical.com>
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.

3 participants