From 8a4c1b1036c5fc52a76067509190a9779c86587a Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Fri, 6 Oct 2023 02:26:52 -0400 Subject: [PATCH] Prefix metrics --- Cargo.lock | 2 +- pypx-DICOMweb/Cargo.toml | 2 +- pypx-DICOMweb/src/main.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 482307f..4210c71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1393,7 +1393,7 @@ dependencies = [ [[package]] name = "pypx_dicomweb" -version = "0.1.0" +version = "0.2.0" dependencies = [ "axum", "axum-prometheus", diff --git a/pypx-DICOMweb/Cargo.toml b/pypx-DICOMweb/Cargo.toml index 041a815..401c1aa 100644 --- a/pypx-DICOMweb/Cargo.toml +++ b/pypx-DICOMweb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pypx_dicomweb" -version = "0.1.0" +version = "0.2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/pypx-DICOMweb/src/main.rs b/pypx-DICOMweb/src/main.rs index eb03280..f325ad1 100644 --- a/pypx-DICOMweb/src/main.rs +++ b/pypx-DICOMweb/src/main.rs @@ -11,7 +11,7 @@ use crate::router::get_router; use axum::{http::Method, routing::get, Router}; use std::path::PathBuf; use tower_http::cors::{Any, CorsLayer}; -use axum_prometheus::PrometheusMetricLayer; +use axum_prometheus::PrometheusMetricLayerBuilder; #[tokio::main] async fn main() { @@ -29,7 +29,11 @@ async fn main() { .allow_methods([Method::GET]) .allow_origin(Any); - let (prometheus_layer, metric_handle) = PrometheusMetricLayer::pair(); + let (prometheus_layer, metric_handle) = PrometheusMetricLayerBuilder::new() + .with_prefix("pypx_dicomweb_axum") + .with_ignore_pattern("/metrics") + .with_default_metrics() + .build_pair(); let pypx_dicomweb_router = get_router(pypx) .layer(prometheus_layer);