Search in sources :

Example 1 with Sampler

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);
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Sampler(io.jaegertracing.spi.Sampler) RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Test(org.junit.Test)

Example 2 with Sampler

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;
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) Reporter(io.jaegertracing.spi.Reporter) CompositeReporter(io.jaegertracing.internal.reporters.CompositeReporter) RemoteReporter(io.jaegertracing.internal.reporters.RemoteReporter) LoggingReporter(io.jaegertracing.internal.reporters.LoggingReporter) Sampler(io.jaegertracing.spi.Sampler) RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) RemoteControlledSampler(io.jaegertracing.internal.samplers.RemoteControlledSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer)

Example 3 with Sampler

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);
    }
}
Also used : Sampler(io.jaegertracing.spi.Sampler)

Example 4 with Sampler

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());
}
Also used : Sampler(io.jaegertracing.spi.Sampler) Test(org.junit.Test)

Example 5 with Sampler

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();
}
Also used : HttpSamplingManager(io.jaegertracing.internal.samplers.HttpSamplingManager) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) RemoteControlledSampler(io.jaegertracing.internal.samplers.RemoteControlledSampler) Sampler(io.jaegertracing.spi.Sampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) RemoteControlledSampler(io.jaegertracing.internal.samplers.RemoteControlledSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer)

Aggregations

Sampler (io.jaegertracing.spi.Sampler)12 Test (org.junit.Test)8 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)7 ProbabilisticSampler (io.jaegertracing.internal.samplers.ProbabilisticSampler)5 Metrics (io.jaegertracing.internal.metrics.Metrics)4 RateLimitingSampler (io.jaegertracing.internal.samplers.RateLimitingSampler)4 SamplerConfiguration (io.jaegertracing.Configuration.SamplerConfiguration)3 JaegerTracer (io.jaegertracing.internal.JaegerTracer)3 InMemoryMetricsFactory (io.jaegertracing.internal.metrics.InMemoryMetricsFactory)3 RemoteReporter (io.jaegertracing.internal.reporters.RemoteReporter)2 RemoteControlledSampler (io.jaegertracing.internal.samplers.RemoteControlledSampler)2 ProbabilisticSamplingStrategy (io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy)2 Reporter (io.jaegertracing.spi.Reporter)2 Configuration (io.jaegertracing.Configuration)1 Builder (io.jaegertracing.internal.JaegerTracer.Builder)1 CompositeReporter (io.jaegertracing.internal.reporters.CompositeReporter)1 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)1 LoggingReporter (io.jaegertracing.internal.reporters.LoggingReporter)1 HttpSamplingManager (io.jaegertracing.internal.samplers.HttpSamplingManager)1 OperationSamplingParameters (io.jaegertracing.internal.samplers.http.OperationSamplingParameters)1