-
Notifications
You must be signed in to change notification settings - Fork 840
Support MultiProcessCollector in RestrictedRegistry. #1150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@csmarchbanks do you know if you will be able to review this? If you agree with the idea but would prefer a different implementation, I’m happy to rewrite that differently. |
|
Hello! I am out of town for another week but will review this after I return. In the meantime it looks like the DCO check is failing. |
This change makes it so that the RestrictedRegistry will always attempt to collect metrics from a collector for which it couldn’t find any metrics name. Although this can be used generally, this is meant to be used with MultiProcessCollector. This changes the current behavior of the code but should be somehow safe as it enables filtering in case where it was not working previously. If this is an issue, an alternative approach with an explicit flag could be used (set either in the MultiProcessCollector or in the registry). The intent here is to allow collecting a subset of metrics from production fastapi servers (running in multiprocess mode). So not having to change the library usage in these servers is advantageous to have filtering work out-of-the-box with this change. Signed-off-by: Mathias Kende <mathias.kende@mistral.ai>
ba49b92 to
792e478
Compare
csmarchbanks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving this some more thought I think it would be good to have an opt in for this feature. If any existing users have registries without names that suddenly started having .collect() called on them that could introduce significant performance issues. Just an optional argument about supporting collectors without names to __init__ would be good enough I think.
a94acbe to
b401ade
Compare
This adds a parameters to the constructor of CollectorRegistry to allow that new behavior rather than make it be the default. Signed-off-by: Mathias Kende <mathias.kende@mistral.ai>
b401ade to
d284cbe
Compare
|
Thanks, I added the explicit flag. Please take another look. |
| To handle this the client library can be put in multiprocess mode. | ||
| This comes with a number of limitations: | ||
|
|
||
| - Registries can not be used as normal, all instantiated metrics are exported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably worth keeping in as all instantiated metrics are still exported, not just those added to a specific registry. We could change exported to collected I guess since they could then be filtered before exporting now?
| - Registries can not be used as normal | ||
| - Registering metrics to a registry later used by a `MultiProcessCollector` | ||
| may cause duplicate metrics to be exported | ||
| - Filtering on metrics works but might be inefficient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be worth calling out that it works iff support_collectors_without_names=True.
This change makes it so that the RestrictedRegistry will always attempt to collect metrics from a collector for which it couldn’t find any metrics name. This is meant to be used with MultiProcessCollector (but there is no strong reason to limit it to that one).
This changes the current behavior of the code but should be somehow safe as it enables filtering in case where it was not working previously. If this is an issue, an alternative approach with an explicit flag could be used (set either in the MultiProcessCollector or in the registry itself).
The intent here is to allow collecting a subset of metrics from production fastapi servers (running in multiprocess mode). So not having to change the library usage in these servers is advantageous to have filtering work out-of-the-box with this change.
@csmarchbanks let me know what you think.
Thanks