Skip to content

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

@artefom

Description

@artefom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions