Do not set the sampler rate for RateByServiceSampler

This commit is contained in:
Andrew Kent 2018-12-13 08:17:19 -08:00
parent bd57b05537
commit 2dfc3ed465
3 changed files with 2 additions and 6 deletions

View File

@ -2,7 +2,6 @@ package datadog.trace.common.sampling;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import datadog.opentracing.DDSpan; import datadog.opentracing.DDSpan;
import datadog.opentracing.DDSpanContext;
import datadog.trace.api.sampling.PrioritySampling; import datadog.trace.api.sampling.PrioritySampling;
import datadog.trace.common.writer.DDApi.ResponseListener; import datadog.trace.common.writer.DDApi.ResponseListener;
import java.util.HashMap; import java.util.HashMap;
@ -58,7 +57,6 @@ public class RateByServiceSampler implements Sampler, ResponseListener {
} else { } else {
span.setSamplingPriority(PrioritySampling.SAMPLER_DROP); span.setSamplingPriority(PrioritySampling.SAMPLER_DROP);
} }
span.context().setMetric(DDSpanContext.SAMPLE_RATE_KEY, sampler.getSampleRate());
} }
private static String getSpanEnv(DDSpan span) { private static String getSpanEnv(DDSpan span) {

View File

@ -177,13 +177,10 @@ class DDSpanTest extends Specification {
expect: expect:
parent.context().samplingPriority == PrioritySampling.SAMPLER_KEEP parent.context().samplingPriority == PrioritySampling.SAMPLER_KEEP
parent.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == 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.getSamplingPriority() == parent.getSamplingPriority()
child1.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null child1.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null
child1.getMetrics().get(DDSpanContext.SAMPLE_RATE_KEY) == null
child2.getSamplingPriority() == parent.getSamplingPriority() child2.getSamplingPriority() == parent.getSamplingPriority()
child2.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null child2.getMetrics().get(DDSpanContext.PRIORITY_SAMPLING_KEY) == null
child2.getMetrics().get(DDSpanContext.SAMPLE_RATE_KEY) == null
} }
def "getRootSpan returns the root span"() { def "getRootSpan returns the root span"() {

View File

@ -65,6 +65,7 @@ class RateByServiceSamplerTest extends Specification {
expect: expect:
// sets correctly on root span // sets correctly on root span
span.getSamplingPriority() == PrioritySampling.SAMPLER_KEEP 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
} }
} }