use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testConstSampler.
@Test
public void testConstSampler() {
SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(ConstSampler.TYPE);
Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new InMemoryMetricsFactory()));
assertTrue(sampler instanceof ConstSampler);
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class Configuration method getTracerBuilder.
public JaegerTracer.Builder getTracerBuilder() {
if (reporterConfig == null) {
reporterConfig = new ReporterConfiguration();
}
if (samplerConfig == null) {
samplerConfig = new SamplerConfiguration();
}
if (codecConfig == null) {
codecConfig = new CodecConfiguration();
}
if (metricsFactory == null) {
metricsFactory = loadMetricsFactory();
}
Metrics metrics = new Metrics(metricsFactory);
Reporter reporter = reporterConfig.getReporter(metrics);
Sampler sampler = samplerConfig.createSampler(serviceName, metrics);
JaegerTracer.Builder builder = createTracerBuilder(serviceName).withSampler(sampler).withReporter(reporter).withMetrics(metrics).withTags(tracerTags);
if (useTraceId128Bit) {
builder = builder.withTraceId128Bit();
}
codecConfig.apply(builder);
return builder;
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class RemoteControlledSampler method updatePerOperationSampler.
private void updatePerOperationSampler(OperationSamplingParameters samplingParameters) {
Sampler currentSampler = sampler;
if (currentSampler instanceof PerOperationSampler) {
if (((PerOperationSampler) currentSampler).update(samplingParameters)) {
metrics.samplerUpdated.inc(1);
}
} else {
sampler = new PerOperationSampler(maxOperations, samplingParameters);
metrics.samplerUpdated.inc(1);
}
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class ProbabilisticSamplerTest method testSamplingBoundariesNegative.
@Test
public void testSamplingBoundariesNegative() {
double samplingRate = 0.5;
long halfwayBoundary = -0x4000000000000000L;
Sampler sampler = new ProbabilisticSampler(samplingRate);
assertTrue(sampler.sample("", halfwayBoundary).isSampled());
assertFalse(sampler.sample("", halfwayBoundary - 1).isSampled());
}
use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.
the class EndToEndBehavior method getRemoteTracer.
private Tracer getRemoteTracer(Metrics metrics, Reporter reporter, String serviceName, String samplingHostPort) {
Sampler initialSampler = new ProbabilisticSampler(1.0);
HttpSamplingManager manager = new HttpSamplingManager(samplingHostPort);
RemoteControlledSampler remoteSampler = new RemoteControlledSampler.Builder(serviceName).withSamplingManager(manager).withInitialSampler(initialSampler).withMetrics(metrics).withPollingInterval(5000).build();
return new JaegerTracer.Builder(serviceName).withReporter(reporter).withSampler(remoteSampler).build();
}
Aggregations