diff --git a/server/src/metrics/actix_web_metrics.rs b/server/src/metrics/actix_web_metrics.rs index 2a2b1965..c66fa815 100644 --- a/server/src/metrics/actix_web_metrics.rs +++ b/server/src/metrics/actix_web_metrics.rs @@ -273,7 +273,7 @@ impl RequestMetricsBuilder { /// construct meters for this crate fn get_versioned_meter(meter_provider: impl MeterProvider) -> Meter { meter_provider.versioned_meter( - "actix_web_opentelemetry", + "unleash_edge", Some(env!("CARGO_PKG_VERSION")), Some(opentelemetry_semantic_conventions::SCHEMA_URL), None, @@ -384,7 +384,6 @@ where timer.elapsed().map(|t| t.as_secs_f64()).unwrap_or_default(), &attributes, ); - Ok(res) } else { res diff --git a/server/src/prom_metrics.rs b/server/src/prom_metrics.rs index bb70b728..07efd1f8 100644 --- a/server/src/prom_metrics.rs +++ b/server/src/prom_metrics.rs @@ -1,5 +1,7 @@ use crate::cli::LogFormat; +use opentelemetry::global; use opentelemetry_sdk::metrics::MeterProvider; +use opentelemetry_semantic_conventions::resource::SERVICE_NAME; #[cfg(target_os = "linux")] use prometheus::process_collector::ProcessCollector; use tracing_subscriber::layer::SubscriberExt; @@ -47,11 +49,19 @@ fn instantiate_prometheus_metrics_handler( registry: prometheus::Registry, ) -> (PrometheusMetricsHandler, RequestMetrics) { let resource = opentelemetry_sdk::Resource::new(vec![ - opentelemetry::KeyValue::new("service.name", "unleash-edge"), - opentelemetry::KeyValue::new("edge.version", crate::types::build::PKG_VERSION), - opentelemetry::KeyValue::new("edge.githash", crate::types::build::SHORT_COMMIT), + opentelemetry::KeyValue::new(SERVICE_NAME, "unleash-edge"), + opentelemetry::KeyValue::new("edge_version", crate::types::build::PKG_VERSION), + opentelemetry::KeyValue::new("edge_githash", crate::types::build::SHORT_COMMIT), ]); - let provider = MeterProvider::builder().with_resource(resource).build(); + let exporter = opentelemetry_prometheus::exporter() + .with_registry(registry.clone()) + .build() + .expect("Failed to setup prometheus"); + let provider = MeterProvider::builder() + .with_resource(resource) + .with_reader(exporter) + .build(); + global::set_meter_provider(provider.clone()); ( PrometheusMetricsHandler::new(registry), RequestMetricsBuilder::new()