Refactor PrometheusController into global singleton with self-registration#2659
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the Prometheus observability stack by introducing a global singleton pattern for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring of the PrometheusController. Moving to a global singleton with a self-registration pattern decouples the observability logic from the core storage managers, which is a great improvement for modularity and maintainability. The lifecycle management (init, start, stop) is now cleanly handled at the server layer, and the configuration has been centralized. The updated tests, including the new fixtures for test isolation, are thorough and well-written. I have one suggestion to improve thread safety during shutdown, but overall this is an excellent change.
| for pl in self.all_loggers: | ||
| pl.unregister() |
There was a problem hiding this comment.
There's a potential race condition here. The self.all_loggers list is being iterated over without holding the lock, while another thread could be calling register_logger() which modifies the list. This could lead to unexpected behavior during shutdown. To ensure thread safety, it's better to create a snapshot of the list under the lock before iterating.
| for pl in self.all_loggers: | |
| pl.unregister() | |
| with self._lock: | |
| # Create a snapshot for thread-safe iteration. | |
| loggers_to_unregister = list(self.all_loggers) | |
| for pl in loggers_to_unregister: | |
| pl.unregister() |
Signed-off-by: ApostaC <yihua98@uchicago.edu>
277e103 to
1101896
Compare
Signed-off-by: ApostaC <yihua98@uchicago.edu>
…age manager Signed-off-by: ApostaC <yihua98@uchicago.edu>
…/LMCache into local-dev/observability-refactor
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: Ofer Kiselov Nahman <ofer.kiselovnahman@weka.io>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: shaoxiawjc <wjc2800@163.com>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
…ation (LMCache#2659) * refactor the controller to become the singleton Signed-off-by: ApostaC <yihua98@uchicago.edu> * fix precommit issues Signed-off-by: ApostaC <yihua98@uchicago.edu> * rollback the storage controller interface and remove the need of storage manager Signed-off-by: ApostaC <yihua98@uchicago.edu> --------- Signed-off-by: ApostaC <yihua98@uchicago.edu>
Summary
Resolves #2650
PrometheusControllerfromStorageControllerInterface: it is now a standalone class with no knowledge of specific managersinit_prometheus_controller(config)creates the singleton at server startup;get_prometheus_controller()provides access from anywhereL1Manager,StorageManager) creates and registers its own stats logger viaget_prometheus_controller().register_logger()run_cache_server()in bothserver.pyandblend_server.pynow ownsinit → start → stopPrometheusConfigdecoupled fromStorageManagerConfig: config parsing uses its ownadd_prometheus_args()/parse_args_to_prometheus_config()helpersStorageControllerInterface: removestorage_managerparameter sincePrometheusControllerwas the only consumer;EvictionControlleronly needsl1_managerTest plan
pytest -xvs tests/v1/mp_observability/— 47 passedpytest -xvs tests/v1/distributed/— 146 passed