use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class MicrometerTest method validateMetricCounts.
@Test
public void validateMetricCounts() throws InterruptedException {
Sampler constantSampler = new ConstSampler(true);
Configuration configuration = new Configuration("validateMetricCounts");
JaegerTracer tracer = configuration.getTracerBuilder().withSampler(constantSampler).withMetrics(metrics).build();
createSomeSpans(tracer);
tracer.close();
double finishedSpans = registry.get("jaeger_tracer_finished_spans").counter().count();
double startedSpans = registry.get("jaeger_tracer_started_spans").tag("sampled", "y").counter().count();
double traces = registry.get("jaeger_tracer_traces").tag("sampled", "y").tag("state", "started").counter().count();
assertEquals("Wrong number of finishedSpans", 4.0, finishedSpans, assertDelta);
assertEquals("Wrong number of startedSpans", 10.0, startedSpans, assertDelta);
assertEquals("Wrong number of traces", 10.0, traces, assertDelta);
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class RemoteControlledSampler method updateRateLimitingOrProbabilisticSampler.
/**
* Replace {@link #sampler} with a new instance when parameters are updated.
* @param response which contains either a {@link ProbabilisticSampler} or {@link RateLimitingSampler}
*/
private void updateRateLimitingOrProbabilisticSampler(SamplingStrategyResponse response) {
Sampler sampler;
if (response.getProbabilisticSampling() != null) {
ProbabilisticSamplingStrategy strategy = response.getProbabilisticSampling();
sampler = new ProbabilisticSampler(strategy.getSamplingRate());
} else if (response.getRateLimitingSampling() != null) {
RateLimitingSamplingStrategy strategy = response.getRateLimitingSampling();
sampler = new RateLimitingSampler(strategy.getMaxTracesPerSecond());
} else {
metrics.samplerParsingFailure.inc(1);
log.error("No strategy present in response. Not updating sampler.");
return;
}
if (!this.sampler.equals(sampler)) {
this.sampler = sampler;
metrics.samplerUpdated.inc(1);
}
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testProbabilisticSampler.
@Test
public void testProbabilisticSampler() {
SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(ProbabilisticSampler.TYPE);
Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new InMemoryMetricsFactory()));
assertTrue(sampler instanceof ProbabilisticSampler);
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testRateLimitingSampler.
@Test
public void testRateLimitingSampler() {
SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(RateLimitingSampler.TYPE);
Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new InMemoryMetricsFactory()));
assertTrue(sampler instanceof RateLimitingSampler);
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class JaegerTracerTest method testClose.
@Test
public void testClose() {
Reporter reporter = mock(Reporter.class);
Sampler sampler = mock(Sampler.class);
tracer = new JaegerTracer.Builder("bonda").withReporter(reporter).withSampler(sampler).build();
tracer.close();
verify(reporter).close();
verify(sampler).close();
}
Aggregations