Skip to content
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

Cannot use PrometheusMetricsBuilder with default prometheus registry and lazy static #3

Open
artefom opened this issue Jan 9, 2023 · 0 comments

Comments

@artefom
Copy link

artefom commented Jan 9, 2023

PrometheusMetricsBuilder consumes Registry not allowing to pass default prometheus registry.
This prevents usage of very convinient lazy static metrics from prometheus package

// This will register to prometheus::default_registry()
lazy_static! {
    static ref HIGH_FIVE_COUNTER: IntCounter =
        register_int_counter!("highfives", "Number of high fives received").unwrap();
}

...

let prometheus = PrometheusMetricsBuilder::new("api")
    .endpoint("/metrics")
    .registry(prometheus::default_registry()) // <<<<<<<<<<<<<<<<<<<<<< ERROR
    .build()
    .map_err(|e| RunServiceError::Prometheus(e.to_string()))?;

Though, from the first glance it should be perfectly possible to accept registry by reference instead

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

No branches or pull requests

1 participant