Skip to content

Commit 3b72741

Browse files
Disable warning message when using traceIdSampler as root (#8065)
1 parent 9a089b6 commit 3b72741

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public final class ParentBasedSamplerBuilder {
2020
@Nullable private Sampler localParentNotSampled;
2121

2222
ParentBasedSamplerBuilder(Sampler root) {
23-
maybeLogTraceIdSamplerWarning(root, "root");
23+
// This is the only valid traceIdSampler location according to Spec
24+
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#compatibility-warnings-for-traceidratiobased-sampler
2425
this.root = root;
2526
}
2627

sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@ void emitsWarningForAllChildSamplerSetters() {
2828
.setLocalParentNotSampled(ratioSampler)
2929
.build();
3030

31-
assertThat(logs.getEvents()).hasSize(5);
31+
assertThat(logs.getEvents()).hasSize(4);
3232
assertThat(logs.getEvents().get(0).getMessage())
33-
.contains("TraceIdRatioBasedSampler is being used as a child sampler (root)");
34-
assertThat(logs.getEvents().get(1).getMessage())
3533
.contains(
3634
"TraceIdRatioBasedSampler is being used as a child sampler (remoteParentNotSampled)");
37-
assertThat(logs.getEvents().get(2).getMessage())
35+
assertThat(logs.getEvents().get(1).getMessage())
3836
.contains(
3937
"TraceIdRatioBasedSampler is being used as a child sampler (remoteParentSampled)");
40-
assertThat(logs.getEvents().get(3).getMessage())
38+
assertThat(logs.getEvents().get(2).getMessage())
4139
.contains("TraceIdRatioBasedSampler is being used as a child sampler (localParentSampled)");
42-
assertThat(logs.getEvents().get(4).getMessage())
40+
assertThat(logs.getEvents().get(3).getMessage())
4341
.contains(
4442
"TraceIdRatioBasedSampler is being used as a child sampler (localParentNotSampled)");
4543
}

0 commit comments

Comments
 (0)