diff --git a/capture-server/src/main.rs b/capture-server/src/main.rs index 97967ed..22c82aa 100644 --- a/capture-server/src/main.rs +++ b/capture-server/src/main.rs @@ -31,7 +31,7 @@ async fn shutdown() { tracing::info!("Shutting down gracefully..."); } -fn init_tracer(sink_url: &str, sampling_rate: f64) -> Tracer { +fn init_tracer(sink_url: &str, sampling_rate: f64, service_name: String) -> Tracer { opentelemetry_otlp::new_pipeline() .tracing() .with_trace_config( @@ -42,7 +42,7 @@ fn init_tracer(sink_url: &str, sampling_rate: f64) -> Tracer { .with_id_generator(RandomIdGenerator::default()) .with_resource(Resource::new(vec![KeyValue::new( "service.name", - "capture", + &service_name, )])), ) .with_batch_config(BatchConfig::default()) @@ -67,7 +67,7 @@ async fn main() { let otel_layer = config .otel_url .clone() - .map(|url| OpenTelemetryLayer::new(init_tracer(&url, config.otel_sampling_rate))) + .map(|url| OpenTelemetryLayer::new(init_tracer(&url, config.otel_sampling_rate, config.otel_service_name))) .with_filter(LevelFilter::from_level(Level::INFO)); tracing_subscriber::registry() .with(log_layer) diff --git a/capture-server/tests/common.rs b/capture-server/tests/common.rs index e33ef4c..5ee2caa 100644 --- a/capture-server/tests/common.rs +++ b/capture-server/tests/common.rs @@ -43,6 +43,7 @@ pub static DEFAULT_CONFIG: Lazy = Lazy::new(|| Config { }, otel_url: None, otel_sampling_rate: 0.0, + otel_service_name: "capture-testing".to_string(), export_prometheus: false, }); diff --git a/capture/src/config.rs b/capture/src/config.rs index 0c6ab1c..a4bd8f2 100644 --- a/capture/src/config.rs +++ b/capture/src/config.rs @@ -27,6 +27,9 @@ pub struct Config { #[envconfig(default = "1.0")] pub otel_sampling_rate: f64, + #[envconfig(default = "capture")] + pub otel_service_name: String, + #[envconfig(default = "true")] pub export_prometheus: bool, }