From afe700caafc3b38c62527fc05d92bb3bd826da01 Mon Sep 17 00:00:00 2001 From: Dev Agarwal Date: Wed, 7 Feb 2024 04:10:21 +0530 Subject: [PATCH] Updated transport action sampler Signed-off-by: Dev Agarwal --- .../sampler/ProbabilisticTransportActionSampler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticTransportActionSampler.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticTransportActionSampler.java index 996f8ec0396f5..93a8edaaaa760 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticTransportActionSampler.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/sampler/ProbabilisticTransportActionSampler.java @@ -21,6 +21,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.samplers.Sampler; +import io.opentelemetry.sdk.trace.samplers.SamplingDecision; import io.opentelemetry.sdk.trace.samplers.SamplingResult; import static org.opensearch.telemetry.tracing.AttributeNames.TRANSPORT_ACTION; @@ -71,7 +72,11 @@ public SamplingResult shouldSample( ) { final String action = attributes.get(AttributeKey.stringKey(TRANSPORT_ACTION)); if (action != null) { - return actionSampler.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks); + final SamplingResult result = actionSampler.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks); + if (result.getDecision() != SamplingDecision.DROP && fallbackSampler != null) { + return fallbackSampler.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks); + } + return result; } if (fallbackSampler != null) return fallbackSampler.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);