-
-
Notifications
You must be signed in to change notification settings - Fork 764
Improve testing of {Scheduler|Worker}MetricCollector
#6945
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
Merged
fjetter
merged 14 commits into
dask:main
from
hendrikmakait:improve-worker-metric-collector-testing
Aug 31, 2022
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fbcdb57
Check for all expected metrics
hendrikmakait d2a437f
Check for all expected metrics in scheduler prometheus collector
hendrikmakait 84d7656
Fix test name
hendrikmakait 0834fc8
Test prometheus worker task states
hendrikmakait 981aad0
Refactor to event-based test
hendrikmakait b4a3aa1
Improve singleton pattern
hendrikmakait ac6876d
Fix test
hendrikmakait f79e003
Update distributed/http/worker/tests/test_worker_http.py
hendrikmakait a6dd39a
Update distributed/http/worker/tests/test_worker_http.py
hendrikmakait c034689
Update distributed/http/worker/tests/test_worker_http.py
hendrikmakait c20f075
Update distributed/http/worker/prometheus/core.py
hendrikmakait 35a9700
Fix typos
hendrikmakait 157d25b
Extract fetch_metrics
hendrikmakait 51f9781
Fix lint
hendrikmakait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
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.
If there are multiple concurrent
Workerinstances in the same process (very common with async workers in allgen_clustertests), this meansPrometheusHandler._collectorwill only be set to theWorkerMetricCollectorof the last worker to start. Is that okay? Does theprometheus_client.REGISTRY.register(PrometheusHandler._collector)mean that all the collectors will be registered somewhere anywhere?I don't know what either
_collectororprometheus_client.REGISTRYare for, I'm just seeing some global variables getting overwritten in a place where I know there might not just be multiple workers sequentially, but also multiple workers in parallel.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.
The way this had been implemented before was that we'd simply set up a
PrometheusHandlerfor the first worker spinning up in the process, set_initializedtoTrueand call it a day. This led totest_prometheus_collect_task_statesbecause thatPrometheusHandlerdid not belong to the newly spun-up worker when running multiple tests. This new pattern surely isn't perfect as we only ever have a single instance of aPrometheusHandlerper process talking to the last worker we spun up. However, IMO this is better than what we had before and it would require some more serious thinking to understand the Prometheus client to handle parallel workers gracefully. I'm happy to file a follow-up issue for that.Regarding the singleton implementation: I've stolen that from https://github.com/hendrikmakait/distributed/blob/13e315c11c7277ba0cadd9f5c2a16364cdeaf14b/distributed/http/scheduler/prometheus/core.py#L79
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 was pretty painful when we started testing this stuff. I'm OK with either solution and don't think we need anything more sophisticated for now.
As was already pointed out, this is merely an artifact for testing and no real world application would ever run multiple workers in the same process AND use prometheus. At the very least, this is something we then choose to not properly support
TLDR As long as the testing works out, I'm happy