Refactor: Centralize Prometheus logic into utils module#4
Merged
Conversation
I've moved Prometheus-related functionality from `producer.rs` and `worker.rs` into the `src/utils` module to improve code sharing and reduce duplication. Specific changes: - The `setup_prometheus_metrics` function, responsible for initializing the Axum server for the /metrics endpoint, has been moved to `src/utils/utils.rs`. Both producer and I now call this shared function. - The associated `metrics_handler` function for Axum has also been moved to `src/utils/utils.rs` and is used by the shared `setup_prometheus_metrics`. - All static Prometheus metric declarations (Counters, Gauges, Histograms) from both producer and my own operations have been consolidated into a new file: `src/utils/prometheus_metrics.rs`. - Producer and I now import these metrics from `TextBlaster::utils::prometheus_metrics::*`. - I've updated `src/utils/mod.rs` to include and export the new `prometheus_metrics` module. This refactoring centralizes Prometheus setup and metric definitions, making them easier to manage and maintain.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've moved Prometheus-related functionality from
producer.rsandworker.rsinto thesrc/utilsmodule to improve code sharing and reduce duplication.Specific changes:
setup_prometheus_metricsfunction, responsible for initializing the Axum server for the /metrics endpoint, has been moved tosrc/utils/utils.rs. Both producer and I now call this shared function.metrics_handlerfunction for Axum has also been moved tosrc/utils/utils.rsand is used by the sharedsetup_prometheus_metrics.src/utils/prometheus_metrics.rs.TextBlaster::utils::prometheus_metrics::*.src/utils/mod.rsto include and export the newprometheus_metricsmodule.This refactoring centralizes Prometheus setup and metric definitions, making them easier to manage and maintain.