From 49677d929f483dcb00569f0d23f4cbd51f826e26 Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Wed, 24 Dec 2025 23:34:42 +0530 Subject: [PATCH 1/7] Emit warning when TraceIdRatioBasedSampler is used as child sampler --- .../trace/samplers/ParentBasedSampler.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java index 0b54cf2180f..b94380ea3d6 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java @@ -12,13 +12,17 @@ import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.data.LinkData; import java.util.List; +import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; /** - * A Sampler that uses the sampled flag of the parent Span, if present. If the span has no parent, - * this Sampler will use the "root" sampler that it is built with. See documentation on the {@link - * ParentBasedSamplerBuilder} methods for the details on the various configurable options. + * A Sampler that uses the sampled flag of the parent Span, if present. If the + * span has no parent, + * this Sampler will use the "root" sampler that it is built with. See + * documentation on the {@link + * ParentBasedSamplerBuilder} methods for the details on the various + * configurable options. */ @Immutable final class ParentBasedSampler implements Sampler { @@ -28,6 +32,7 @@ final class ParentBasedSampler implements Sampler { private final Sampler remoteParentNotSampled; private final Sampler localParentSampled; private final Sampler localParentNotSampled; + private static final Logger logger = Logger.getLogger(ParentBasedSampler.class.getName()); ParentBasedSampler( Sampler root, @@ -36,17 +41,28 @@ final class ParentBasedSampler implements Sampler { @Nullable Sampler localParentSampled, @Nullable Sampler localParentNotSampled) { this.root = root; - this.remoteParentSampled = - remoteParentSampled == null ? Sampler.alwaysOn() : remoteParentSampled; - this.remoteParentNotSampled = - remoteParentNotSampled == null ? Sampler.alwaysOff() : remoteParentNotSampled; + this.remoteParentSampled = remoteParentSampled == null ? Sampler.alwaysOn() : remoteParentSampled; + this.remoteParentNotSampled = remoteParentNotSampled == null ? Sampler.alwaysOff() : remoteParentNotSampled; this.localParentSampled = localParentSampled == null ? Sampler.alwaysOn() : localParentSampled; - this.localParentNotSampled = - localParentNotSampled == null ? Sampler.alwaysOff() : localParentNotSampled; + this.localParentNotSampled = localParentNotSampled == null ? Sampler.alwaysOff() : localParentNotSampled; + warnIfTraceIdRatioBased(this.remoteParentSampled, "remoteParentSampled"); + warnIfTraceIdRatioBased(this.remoteParentNotSampled, "remoteParentNotSampled"); + warnIfTraceIdRatioBased(this.localParentSampled, "localParentSampled"); + warnIfTraceIdRatioBased(this.localParentNotSampled, "localParentNotSampled"); + } + + private static void warnIfTraceIdRatioBased(Sampler sampler, String role) { + if (sampler instanceof TraceIdRatioBasedSampler) { + logger.warning( + "TraceIdRatioBasedSampler is being used as a child sampler (" + role + "). " + + "This configuration is discouraged per the OpenTelemetry specification " + + "and may lead to unexpected sampling behavior."); + } } // If a parent is set, always follows the same sampling decision as the parent. - // Otherwise, uses the delegateSampler provided at initialization to make a decision. + // Otherwise, uses the delegateSampler provided at initialization to make a + // decision. @Override public SamplingResult shouldSample( Context parentContext, From 4af9078ac9e68bc9f5902996303a176667d31044 Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 00:17:36 +0530 Subject: [PATCH 2/7] Format ParentBasedSamplerBuilder with Spotless --- .../samplers/ParentBasedSamplerBuilder.java | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java index 24cb7ea4860..f85f6a2f4f2 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java @@ -5,16 +5,23 @@ package io.opentelemetry.sdk.trace.samplers; +import java.util.logging.Logger; import javax.annotation.Nullable; /** A builder for creating ParentBased sampler instances. */ public final class ParentBasedSamplerBuilder { + private static final Logger logger = Logger.getLogger(ParentBasedSamplerBuilder.class.getName()); + private final Sampler root; @Nullable private Sampler remoteParentSampled; @Nullable private Sampler remoteParentNotSampled; @Nullable private Sampler localParentSampled; @Nullable private Sampler localParentNotSampled; + private boolean warnedRemoteParentSampled; + private boolean warnedRemoteParentNotSampled; + private boolean warnedLocalParentSampled; + private boolean warnedLocalParentNotSampled; ParentBasedSamplerBuilder(Sampler root) { this.root = root; @@ -27,6 +34,13 @@ public final class ParentBasedSamplerBuilder { * @return this Builder */ public ParentBasedSamplerBuilder setRemoteParentSampled(Sampler remoteParentSampled) { + if (!warnedRemoteParentSampled && remoteParentSampled instanceof TraceIdRatioBasedSampler) { + warnedRemoteParentSampled = true; + logger.warning( + "TraceIdRatioBasedSampler is being used as a child sampler (remoteParentSampled). " + + "This configuration is discouraged per the OpenTelemetry specification " + + "and may lead to unexpected sampling behavior."); + } this.remoteParentSampled = remoteParentSampled; return this; } @@ -38,6 +52,14 @@ public ParentBasedSamplerBuilder setRemoteParentSampled(Sampler remoteParentSamp * @return this Builder */ public ParentBasedSamplerBuilder setRemoteParentNotSampled(Sampler remoteParentNotSampled) { + if (!warnedRemoteParentNotSampled + && remoteParentNotSampled instanceof TraceIdRatioBasedSampler) { + warnedRemoteParentNotSampled = true; + logger.warning( + "TraceIdRatioBasedSampler is being used as a child sampler (remoteParentNotSampled). " + + "This configuration is discouraged per the OpenTelemetry specification " + + "and may lead to unexpected sampling behavior."); + } this.remoteParentNotSampled = remoteParentNotSampled; return this; } @@ -49,6 +71,13 @@ public ParentBasedSamplerBuilder setRemoteParentNotSampled(Sampler remoteParentN * @return this Builder */ public ParentBasedSamplerBuilder setLocalParentSampled(Sampler localParentSampled) { + if (!warnedLocalParentSampled && localParentSampled instanceof TraceIdRatioBasedSampler) { + warnedLocalParentSampled = true; + logger.warning( + "TraceIdRatioBasedSampler is being used as a child sampler (localParentSampled). " + + "This configuration is discouraged per the OpenTelemetry specification " + + "and may lead to unexpected sampling behavior."); + } this.localParentSampled = localParentSampled; return this; } @@ -60,15 +89,18 @@ public ParentBasedSamplerBuilder setLocalParentSampled(Sampler localParentSample * @return this Builder */ public ParentBasedSamplerBuilder setLocalParentNotSampled(Sampler localParentNotSampled) { + if (!warnedLocalParentNotSampled && localParentNotSampled instanceof TraceIdRatioBasedSampler) { + warnedLocalParentNotSampled = true; + logger.warning( + "TraceIdRatioBasedSampler is being used as a child sampler (localParentNotSampled). " + + "This configuration is discouraged per the OpenTelemetry specification " + + "and may lead to unexpected sampling behavior."); + } this.localParentNotSampled = localParentNotSampled; return this; } - /** - * Builds the {@link ParentBasedSampler}. - * - * @return the ParentBased sampler. - */ + /** Builds the {@link ParentBasedSampler}. */ public Sampler build() { return new ParentBasedSampler( this.root, From ef831315ee17cce79145e4f514fd186956472eb9 Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 00:27:38 +0530 Subject: [PATCH 3/7] Remove child-sampler warnings from ParentBasedSampler --- .../trace/samplers/ParentBasedSampler.java | 36 ++++++------------- .../samplers/ParentBasedSamplerBuilder.java | 6 +++- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java index b94380ea3d6..0b54cf2180f 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSampler.java @@ -12,17 +12,13 @@ import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.data.LinkData; import java.util.List; -import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; /** - * A Sampler that uses the sampled flag of the parent Span, if present. If the - * span has no parent, - * this Sampler will use the "root" sampler that it is built with. See - * documentation on the {@link - * ParentBasedSamplerBuilder} methods for the details on the various - * configurable options. + * A Sampler that uses the sampled flag of the parent Span, if present. If the span has no parent, + * this Sampler will use the "root" sampler that it is built with. See documentation on the {@link + * ParentBasedSamplerBuilder} methods for the details on the various configurable options. */ @Immutable final class ParentBasedSampler implements Sampler { @@ -32,7 +28,6 @@ final class ParentBasedSampler implements Sampler { private final Sampler remoteParentNotSampled; private final Sampler localParentSampled; private final Sampler localParentNotSampled; - private static final Logger logger = Logger.getLogger(ParentBasedSampler.class.getName()); ParentBasedSampler( Sampler root, @@ -41,28 +36,17 @@ final class ParentBasedSampler implements Sampler { @Nullable Sampler localParentSampled, @Nullable Sampler localParentNotSampled) { this.root = root; - this.remoteParentSampled = remoteParentSampled == null ? Sampler.alwaysOn() : remoteParentSampled; - this.remoteParentNotSampled = remoteParentNotSampled == null ? Sampler.alwaysOff() : remoteParentNotSampled; + this.remoteParentSampled = + remoteParentSampled == null ? Sampler.alwaysOn() : remoteParentSampled; + this.remoteParentNotSampled = + remoteParentNotSampled == null ? Sampler.alwaysOff() : remoteParentNotSampled; this.localParentSampled = localParentSampled == null ? Sampler.alwaysOn() : localParentSampled; - this.localParentNotSampled = localParentNotSampled == null ? Sampler.alwaysOff() : localParentNotSampled; - warnIfTraceIdRatioBased(this.remoteParentSampled, "remoteParentSampled"); - warnIfTraceIdRatioBased(this.remoteParentNotSampled, "remoteParentNotSampled"); - warnIfTraceIdRatioBased(this.localParentSampled, "localParentSampled"); - warnIfTraceIdRatioBased(this.localParentNotSampled, "localParentNotSampled"); - } - - private static void warnIfTraceIdRatioBased(Sampler sampler, String role) { - if (sampler instanceof TraceIdRatioBasedSampler) { - logger.warning( - "TraceIdRatioBasedSampler is being used as a child sampler (" + role + "). " - + "This configuration is discouraged per the OpenTelemetry specification " - + "and may lead to unexpected sampling behavior."); - } + this.localParentNotSampled = + localParentNotSampled == null ? Sampler.alwaysOff() : localParentNotSampled; } // If a parent is set, always follows the same sampling decision as the parent. - // Otherwise, uses the delegateSampler provided at initialization to make a - // decision. + // Otherwise, uses the delegateSampler provided at initialization to make a decision. @Override public SamplingResult shouldSample( Context parentContext, diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java index f85f6a2f4f2..10b9dc5102f 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java @@ -100,7 +100,11 @@ public ParentBasedSamplerBuilder setLocalParentNotSampled(Sampler localParentNot return this; } - /** Builds the {@link ParentBasedSampler}. */ + /** + * Builds the {@link ParentBasedSampler}. + * + * @return the ParentBased sampler. + */ public Sampler build() { return new ParentBasedSampler( this.root, From db30494b070143d6434ae60fee508619b843ab2d Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 01:01:40 +0530 Subject: [PATCH 4/7] Add test for child TraceIdRatioBasedSampler warning --- .../ParentBasedSamplerBuilderTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java new file mode 100644 index 00000000000..24637c244d3 --- /dev/null +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java @@ -0,0 +1,57 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.trace.samplers; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import org.junit.jupiter.api.Test; + +class ParentBasedSamplerBuilderTest { + + @Test + void emitsWarningWhenTraceIdRatioBasedUsedAsChildSampler() { + Logger logger = Logger.getLogger(ParentBasedSamplerBuilder.class.getName()); + TestLogHandler handler = new TestLogHandler(); + logger.addHandler(handler); + + try { + Sampler ratioSampler = Sampler.traceIdRatioBased(0.5); + + Sampler.parentBasedBuilder(Sampler.alwaysOn()).setRemoteParentSampled(ratioSampler).build(); + + assertTrue( + handler.warnings.stream() + .anyMatch( + msg -> + msg.contains("TraceIdRatioBasedSampler is being used as a child sampler"))); + } finally { + logger.removeHandler(handler); + } + } + + static class TestLogHandler extends Handler { + final List warnings = new ArrayList<>(); + + @Override + public void publish(LogRecord record) { + if (record.getLevel().equals(Level.WARNING)) { + warnings.add(record.getMessage()); + } + } + + @Override + public void flush() {} + + @Override + public void close() {} + } +} From 64e09bc32689ea8943400263fe4d1422655c1f9a Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 01:35:40 +0530 Subject: [PATCH 5/7] Increase test coverage for ParentBasedSamplerBuilder warnings --- .../ParentBasedSamplerBuilderTest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java index 24637c244d3..f50781d3029 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java @@ -38,12 +38,36 @@ void emitsWarningWhenTraceIdRatioBasedUsedAsChildSampler() { } } + @Test + void emitsWarningForAllChildSamplerSetters() { + Logger logger = Logger.getLogger(ParentBasedSamplerBuilder.class.getName()); + TestLogHandler handler = new TestLogHandler(); + logger.addHandler(handler); + + try { + Sampler ratioSampler = Sampler.traceIdRatioBased(0.5); + + Sampler.parentBasedBuilder(Sampler.alwaysOn()) + .setRemoteParentNotSampled(ratioSampler) + .setLocalParentSampled(ratioSampler) + .setLocalParentNotSampled(ratioSampler) + .build(); + + assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("remoteParentNotSampled"))); + assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("localParentSampled"))); + assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("localParentNotSampled"))); + } finally { + logger.removeHandler(handler); + } + } + static class TestLogHandler extends Handler { + final List warnings = new ArrayList<>(); @Override public void publish(LogRecord record) { - if (record.getLevel().equals(Level.WARNING)) { + if (Level.WARNING.equals(record.getLevel())) { warnings.add(record.getMessage()); } } From e94446343091cfa282d21c84c6645c500a5c94bb Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 02:18:58 +0530 Subject: [PATCH 6/7] test: cover all ParentBasedSamplerBuilder warning branches --- .../ParentBasedSamplerBuilderTest.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java index f50781d3029..97972ebd24d 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilderTest.java @@ -25,14 +25,13 @@ void emitsWarningWhenTraceIdRatioBasedUsedAsChildSampler() { try { Sampler ratioSampler = Sampler.traceIdRatioBased(0.5); + ParentBasedSamplerBuilder builder = Sampler.parentBasedBuilder(Sampler.alwaysOn()); - Sampler.parentBasedBuilder(Sampler.alwaysOn()).setRemoteParentSampled(ratioSampler).build(); + builder.setRemoteParentSampled(ratioSampler); + builder.setRemoteParentSampled(ratioSampler); + builder.build(); - assertTrue( - handler.warnings.stream() - .anyMatch( - msg -> - msg.contains("TraceIdRatioBasedSampler is being used as a child sampler"))); + assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("remoteParentSampled"))); } finally { logger.removeHandler(handler); } @@ -46,12 +45,18 @@ void emitsWarningForAllChildSamplerSetters() { try { Sampler ratioSampler = Sampler.traceIdRatioBased(0.5); + ParentBasedSamplerBuilder builder = Sampler.parentBasedBuilder(Sampler.alwaysOn()); - Sampler.parentBasedBuilder(Sampler.alwaysOn()) - .setRemoteParentNotSampled(ratioSampler) - .setLocalParentSampled(ratioSampler) - .setLocalParentNotSampled(ratioSampler) - .build(); + builder.setRemoteParentNotSampled(ratioSampler); + builder.setRemoteParentNotSampled(ratioSampler); + + builder.setLocalParentSampled(ratioSampler); + builder.setLocalParentSampled(ratioSampler); + + builder.setLocalParentNotSampled(ratioSampler); + builder.setLocalParentNotSampled(ratioSampler); + + builder.build(); assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("remoteParentNotSampled"))); assertTrue(handler.warnings.stream().anyMatch(msg -> msg.contains("localParentSampled"))); @@ -61,7 +66,7 @@ void emitsWarningForAllChildSamplerSetters() { } } - static class TestLogHandler extends Handler { + static final class TestLogHandler extends Handler { final List warnings = new ArrayList<>(); From efdcb79751aceb2396852c2ebf33062d07e14128 Mon Sep 17 00:00:00 2001 From: Sumit Chauhan Date: Thu, 25 Dec 2025 10:38:36 +0530 Subject: [PATCH 7/7] Simplify child sampler warning logic --- .../samplers/ParentBasedSamplerBuilder.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java index 10b9dc5102f..1738646a0be 100644 --- a/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java +++ b/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/samplers/ParentBasedSamplerBuilder.java @@ -18,10 +18,6 @@ public final class ParentBasedSamplerBuilder { @Nullable private Sampler remoteParentNotSampled; @Nullable private Sampler localParentSampled; @Nullable private Sampler localParentNotSampled; - private boolean warnedRemoteParentSampled; - private boolean warnedRemoteParentNotSampled; - private boolean warnedLocalParentSampled; - private boolean warnedLocalParentNotSampled; ParentBasedSamplerBuilder(Sampler root) { this.root = root; @@ -34,8 +30,7 @@ public final class ParentBasedSamplerBuilder { * @return this Builder */ public ParentBasedSamplerBuilder setRemoteParentSampled(Sampler remoteParentSampled) { - if (!warnedRemoteParentSampled && remoteParentSampled instanceof TraceIdRatioBasedSampler) { - warnedRemoteParentSampled = true; + if (remoteParentSampled instanceof TraceIdRatioBasedSampler) { logger.warning( "TraceIdRatioBasedSampler is being used as a child sampler (remoteParentSampled). " + "This configuration is discouraged per the OpenTelemetry specification " @@ -52,9 +47,7 @@ public ParentBasedSamplerBuilder setRemoteParentSampled(Sampler remoteParentSamp * @return this Builder */ public ParentBasedSamplerBuilder setRemoteParentNotSampled(Sampler remoteParentNotSampled) { - if (!warnedRemoteParentNotSampled - && remoteParentNotSampled instanceof TraceIdRatioBasedSampler) { - warnedRemoteParentNotSampled = true; + if (remoteParentNotSampled instanceof TraceIdRatioBasedSampler) { logger.warning( "TraceIdRatioBasedSampler is being used as a child sampler (remoteParentNotSampled). " + "This configuration is discouraged per the OpenTelemetry specification " @@ -71,8 +64,7 @@ public ParentBasedSamplerBuilder setRemoteParentNotSampled(Sampler remoteParentN * @return this Builder */ public ParentBasedSamplerBuilder setLocalParentSampled(Sampler localParentSampled) { - if (!warnedLocalParentSampled && localParentSampled instanceof TraceIdRatioBasedSampler) { - warnedLocalParentSampled = true; + if (localParentSampled instanceof TraceIdRatioBasedSampler) { logger.warning( "TraceIdRatioBasedSampler is being used as a child sampler (localParentSampled). " + "This configuration is discouraged per the OpenTelemetry specification " @@ -89,8 +81,7 @@ public ParentBasedSamplerBuilder setLocalParentSampled(Sampler localParentSample * @return this Builder */ public ParentBasedSamplerBuilder setLocalParentNotSampled(Sampler localParentNotSampled) { - if (!warnedLocalParentNotSampled && localParentNotSampled instanceof TraceIdRatioBasedSampler) { - warnedLocalParentNotSampled = true; + if (localParentNotSampled instanceof TraceIdRatioBasedSampler) { logger.warning( "TraceIdRatioBasedSampler is being used as a child sampler (localParentNotSampled). " + "This configuration is discouraged per the OpenTelemetry specification "