From 2dfc3ed4650285d3a848baffd1a571d9080097bc Mon Sep 17 00:00:00 2001 From: Andrew Kent Date: Thu, 13 Dec 2018 08:17:19 -0800 Subject: [PATCH] Do not set the sampler rate for RateByServiceSampler --- .../datadog/trace/common/sampling/RateByServiceSampler.java | 2 -- .../src/test/groovy/datadog/opentracing/DDSpanTest.groovy | 3 --- .../datadog/trace/api/sampling/RateByServiceSamplerTest.groovy | 3 ++- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dd-trace-ot/src/main/java/datadog/trace/common/sampling/RateByServiceSampler.java b/dd-trace-ot/src/main/java/datadog/trace/common/sampling/RateByServiceSampler.java index bad0b6f2f3..61e716efaa 100644 --- a/dd-trace-ot/src/main/java/datadog/trace/common/sampling/RateByServiceSampler.java +++ b/dd-trace-ot/src/main/java/datadog/trace/common/sampling/RateByServiceSampler.java @@ -2,7 +2,6 @@ package datadog.trace.common.sampling; import com.fasterxml.jackson.databind.JsonNode; import datadog.opentracing.DDSpan; -import datadog.opentracing.DDSpanContext; import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.common.writer.DDApi.ResponseListener; import java.util.HashMap; @@ -58,7 +57,6 @@ public class RateByServiceSampler implements Sampler, ResponseListener { } else { span.setSamplingPriority(PrioritySampling.SAMPLER_DROP); } - span.context().setMetric(DDSpanContext.SAMPLE_RATE_KEY, sampler.getSampleRate()); } private static String getSpanEnv(DDSpan span) { diff --git a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy index 3d2de7671b..548d4a0d5a 100644 --- a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy @@ -177,13 +177,10 @@ class DDSpanTest extends Specification { expect: parent.context().samplingPriority == PrioritySampling.SAMPLER_KEEP parent.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == PrioritySampling.SAMPLER_KEEP - parent.getMetrics().get(DDSpanContext.SAMPLE_RATE_KEY) == 1.0 child1.getSamplingPriority() == parent.getSamplingPriority() child1.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null - child1.getMetrics().get(DDSpanContext.SAMPLE_RATE_KEY) == null child2.getSamplingPriority() == parent.getSamplingPriority() child2.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null - child2.getMetrics().get(DDSpanContext.SAMPLE_RATE_KEY) == null } def "getRootSpan returns the root span"() { diff --git a/dd-trace-ot/src/test/groovy/datadog/trace/api/sampling/RateByServiceSamplerTest.groovy b/dd-trace-ot/src/test/groovy/datadog/trace/api/sampling/RateByServiceSamplerTest.groovy index 0b343b2997..dfa9faee30 100644 --- a/dd-trace-ot/src/test/groovy/datadog/trace/api/sampling/RateByServiceSamplerTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/trace/api/sampling/RateByServiceSamplerTest.groovy @@ -65,6 +65,7 @@ class RateByServiceSamplerTest extends Specification { expect: // sets correctly on root span span.getSamplingPriority() == PrioritySampling.SAMPLER_KEEP - span.getMetrics().get("_sample_rate") == 1.0 + // RateByServiceSamler must not set the sample rate + span.getMetrics().get("_sample_rate") == null } }