[PR #1] Interface should not use the impl instead of the interface

This commit is contained in:
Guillaume Polaert 2017-05-03 10:01:33 +02:00
parent 7031ff1976
commit 4cc2b46295
3 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
package com.datadoghq.trace; package com.datadoghq.trace;
import com.datadoghq.trace.impl.DDSpan; import io.opentracing.Span;
/** /**
* Main interface to sample a collection of traces. * Main interface to sample a collection of traces.
@ -14,6 +14,6 @@ public interface Sampler {
* @param span the parent span with its context * @param span the parent span with its context
* @return true when the trace/spans has to be reported/written * @return true when the trace/spans has to be reported/written
*/ */
boolean sample(DDSpan span); boolean sample(Span span);
} }

View File

@ -1,6 +1,7 @@
package com.datadoghq.trace.impl; package com.datadoghq.trace.impl;
import com.datadoghq.trace.Sampler; import com.datadoghq.trace.Sampler;
import io.opentracing.Span;
/** /**
* Sampler that always says yes... * Sampler that always says yes...
@ -8,7 +9,7 @@ import com.datadoghq.trace.Sampler;
public class AllSampler implements Sampler { public class AllSampler implements Sampler {
@Override @Override
public boolean sample(DDSpan span) { public boolean sample(Span span) {
return true; return true;
} }

View File

@ -2,6 +2,7 @@ package com.datadoghq.trace.impl;
import com.datadoghq.trace.Sampler; import com.datadoghq.trace.Sampler;
import io.opentracing.Span;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -41,7 +42,7 @@ public class RateSampler implements Sampler {
} }
@Override @Override
public boolean sample(DDSpan span) { public boolean sample(Span span) {
boolean sample = Math.random() <= this.sampleRate; boolean sample = Math.random() <= this.sampleRate;
logger.debug("{} - Span is sampled: {}", span, sample); logger.debug("{} - Span is sampled: {}", span, sample);
return sample; return sample;