Skip to content

Commit

Permalink
fix: update tracer service name
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Nov 26, 2024
1 parent a349c2c commit b2275c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ impl Default for TracingConfig {

pub fn init_tracer(config: TracingConfig) -> anyhow::Result<()> {
let tracing_endpoint = format!("http://{}:{}", config.host, config.port);
let service_name = config.service_name;
println!("Sending traces to {tracing_endpoint}");

let exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_endpoint(tracing_endpoint)
.build()?;

let config = Config::default()
let provider_config = Config::default()
.with_sampler(Sampler::AlwaysOn)
.with_resource(Resource::new(vec![KeyValue::new(
"service.name",
config.service_name,
service_name.clone(),
)]));

let provider = TracerProvider::builder()
.with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
.with_config(config)
.with_config(provider_config)
.build();
let tracer = provider.tracer("readme_example");
let tracer = provider.tracer(service_name);

let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);

Expand Down

0 comments on commit b2275c4

Please sign in to comment.