| 1 |
use axum::{extract::State, response::IntoResponse}; |
| 2 |
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle}; |
| 3 |
|
| 4 |
pub fn init() -> PrometheusHandle { |
| 5 |
PrometheusBuilder::new().install_recorder().expect("install prometheus recorder") |
| 6 |
} |
| 7 |
|
| 8 |
pub async fn render(State(handle): State<PrometheusHandle>) -> impl IntoResponse { |
| 9 |
handle.render() |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#[cfg(test)] |
| 17 |
pub fn test_handle() -> PrometheusHandle { |
| 18 |
PrometheusBuilder::new().build_recorder().handle() |
| 19 |
} |
| 20 |
|