Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
capture: make otel service name configurable, will use deploy name
Browse files Browse the repository at this point in the history
  • Loading branch information
xvello committed Apr 22, 2024
1 parent 56d4615 commit da88320
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions capture-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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())
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions capture/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit da88320

Please sign in to comment.