diff --git a/src/utils/metrics.rs b/src/utils/metrics.rs index 7d10cf1..8754220 100644 --- a/src/utils/metrics.rs +++ b/src/utils/metrics.rs @@ -1,4 +1,5 @@ use crate::utils::from_env::{FromEnv, FromEnvErr, FromEnvVar}; +use core::net::SocketAddr; use metrics_exporter_prometheus::PrometheusBuilder; use super::from_env::EnvItemInfo; @@ -72,8 +73,14 @@ impl FromEnv for MetricsConfig { pub fn init_metrics() { let cfg = MetricsConfig::from_env().unwrap(); + let address = SocketAddr::from(([0, 0, 0, 0], cfg.port)); + PrometheusBuilder::new() - .with_http_listener(([0, 0, 0, 0], cfg.port)) + .with_http_listener(address) .install() - .expect("failed to install prometheus exporter"); + .unwrap_or_else(|error| { + panic!( + "failed to install prometheus exporter on {address} (configure with {METRICS_PORT} env var): {error}", + ) + }); } diff --git a/src/utils/otlp.rs b/src/utils/otlp.rs index fe48af3..51a3135 100644 --- a/src/utils/otlp.rs +++ b/src/utils/otlp.rs @@ -65,8 +65,6 @@ impl Drop for OtelGuard { /// will return [`None`]. /// - OTEL_LEVEL - optional. Specifies the minimum [`tracing::Level`] to /// export in the [`EnvFilter`] format. Defaults to [`tracing::Level::DEBUG`]. -/// - OTEL_TIMEOUT - optional. Specifies the timeout for the exporter in -/// **milliseconds**. Defaults to 1000ms, which is equivalent to 1 second. /// - OTEL_ENVIRONMENT_NAME - optional. Value for the `deployment.environment. /// name` resource key according to the OTEL conventions. #[derive(Debug, Clone)] @@ -79,7 +77,7 @@ pub struct OtelConfig { /// Defaults to DEBUG. pub level: EnvFilter, - /// OTEL convenition `deployment.environment.name` + /// OTEL convention `deployment.environment.name` pub environment: String, } @@ -139,8 +137,6 @@ impl OtelConfig { /// OTLP exporting will be disabled. /// - `OTEL_LEVEL` - optional. Specifies the minimum [`tracing::Level`] to /// export. Defaults to [`tracing::Level::DEBUG`]. - /// - `OTEL_TIMEOUT` - optional. Specifies the timeout for the exporter in - /// **milliseconds**. Defaults to 1000ms, which is equivalent to 1 second. /// - `OTEL_ENVIRONMENT_NAME` - optional. Value for the /// `deployment.environment.name` resource key according to the OTEL /// conventions. Defaults to `"unknown"`.