-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
- I have looked for existing issues (including closed) about this
Bug Report
I am looking at the example code for setting up prometheus metrics in https://github.com/tokio-rs/axum/blob/main/examples/prometheus-metrics/src/main.rs. It creates a handle like so:
axum/examples/prometheus-metrics/src/main.rs
Lines 84 to 92 in 2977bd4
PrometheusBuilder::new() | |
.set_buckets_for_metric( | |
Matcher::Full("http_requests_duration_seconds".to_string()), | |
EXPONENTIAL_SECONDS, | |
) | |
.unwrap() | |
.install_recorder() | |
.unwrap() | |
} |
Reading the docs for https://docs.rs/metrics-exporter-prometheus/latest/metrics_exporter_prometheus/#upkeep-and-maintenance it states
However, when using lower-level builder methods PrometheusBuilder::build_recorder or PrometheusBuilder::install_recorder, this upkeep task is not spawned automatically. Users are responsible for keeping a handle to the recorder (PrometheusHandle) and calling the run_upkeep method at a regular interval.
I see no calls to run_upkeep()
in the example code, is this something that should be added? From looking at upstream code it seems this is done like so:
https://docs.rs/metrics-exporter-prometheus/latest/src/metrics_exporter_prometheus/exporter/builder.rs.html#472-478:
let recorder_handle = handle.clone();
tokio::spawn(async move {
loop {
tokio::time::sleep(upkeep_timeout).await;
recorder_handle.run_upkeep();
}
});
Version
main