Skip to content

Commit c64e9ff

Browse files
committed
log sampler env var, and better event naming for bsp
1 parent d04c091 commit c64e9ff

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

opentelemetry-sdk/src/trace/config.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ impl Default for Config {
125125
"always_on" => Box::new(Sampler::AlwaysOn),
126126
"always_off" => Box::new(Sampler::AlwaysOff),
127127
"traceidratio" => {
128-
let ratio = sampler_arg.and_then(|r| r.parse::<f64>().ok());
128+
let ratio = sampler_arg.as_ref().and_then(|r| r.parse::<f64>().ok());
129129
if let Some(r) = ratio {
130130
Box::new(Sampler::TraceIdRatioBased(r))
131131
} else {
132132
otel_warn!(
133133
name: "TracerProvider.Config.Sampler.InvalidArgument",
134-
message = "OTEL_TRACES_SAMPLER is set to 'traceidratio' but OTEL_TRACES_SAMPLER_ARG environment variable is missing or invalid. OTEL_TRACES_SAMPLER_ARG must be a valid float between 0.0 and 1.0 representing the desired sampling probability (0.0 = no traces sampled, 1.0 = all traces sampled, 0.5 = 50% of traces sampled). Falling back to default ratio: 1.0 (100% sampling)"
134+
message = "OTEL_TRACES_SAMPLER is set to 'traceidratio' but OTEL_TRACES_SAMPLER_ARG environment variable is missing or invalid. OTEL_TRACES_SAMPLER_ARG must be a valid float between 0.0 and 1.0 representing the desired sampling probability (0.0 = no traces sampled, 1.0 = all traces sampled, 0.5 = 50% of traces sampled). Falling back to default ratio: 1.0 (100% sampling)",
135+
otel_traces_sampler_arg = format!("{:?}", sampler_arg)
135136
);
136137
Box::new(Sampler::TraceIdRatioBased(1.0))
137138
}
@@ -143,15 +144,16 @@ impl Default for Config {
143144
Box::new(Sampler::ParentBased(Box::new(Sampler::AlwaysOff)))
144145
}
145146
"parentbased_traceidratio" => {
146-
let ratio = sampler_arg.and_then(|r| r.parse::<f64>().ok());
147+
let ratio = sampler_arg.as_ref().and_then(|r| r.parse::<f64>().ok());
147148
if let Some(r) = ratio {
148149
Box::new(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(
149150
r,
150151
))))
151152
} else {
152153
otel_warn!(
153154
name: "TracerProvider.Config.Sampler.InvalidArgument",
154-
message = "OTEL_TRACES_SAMPLER is set to 'parentbased_traceidratio' but OTEL_TRACES_SAMPLER_ARG environment variable is missing or invalid. OTEL_TRACES_SAMPLER_ARG must be a valid float between 0.0 and 1.0 representing the desired sampling probability (0.0 = no traces sampled, 1.0 = all traces sampled, 0.5 = 50% of traces sampled). Falling back to default ratio: 1.0 (100% sampling)"
155+
message = "OTEL_TRACES_SAMPLER is set to 'parentbased_traceidratio' but OTEL_TRACES_SAMPLER_ARG environment variable is missing or invalid. OTEL_TRACES_SAMPLER_ARG must be a valid float between 0.0 and 1.0 representing the desired sampling probability (0.0 = no traces sampled, 1.0 = all traces sampled, 0.5 = 50% of traces sampled). Falling back to default ratio: 1.0 (100% sampling)",
156+
otel_traces_sampler_arg = format!("{:?}", sampler_arg)
155157
);
156158
Box::new(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(
157159
1.0,

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<R: RuntimeChannel> SpanProcessor for BatchSpanProcessor<R> {
251251

252252
if let Err(err) = result {
253253
otel_debug!(
254-
name: "BatchSpanProcessor.OnEnd.SendResultError",
254+
name: "BatchSpanProcessor.Export.SendResultError",
255255
reason = format!("{:?}", TraceError::Other(err.into()))
256256
);
257257
}
@@ -370,7 +370,7 @@ impl<R: RuntimeChannel> BatchSpanProcessorInternal<R> {
370370
let task = async move {
371371
if let Err(err) = export_task.await {
372372
otel_error!(
373-
name: "BatchSpanProcessor.OnEnd.Error",
373+
name: "BatchSpanProcessor.Export.Error",
374374
reason = format!("{}", err)
375375
);
376376
}

0 commit comments

Comments
 (0)