Search in sources :

Example 11 with Sampler

use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.

the class RemoteControlledSamplerTest method testUpdateToPerOperationSamplerReplacesProbabilisticSampler.

@Test
public void testUpdateToPerOperationSamplerReplacesProbabilisticSampler() throws Exception {
    List<PerOperationSamplingParameters> operationToSampler = new ArrayList<>();
    operationToSampler.add(new PerOperationSamplingParameters("operation", new ProbabilisticSamplingStrategy(0.1)));
    OperationSamplingParameters parameters = new OperationSamplingParameters(0.11, 0.22, operationToSampler);
    SamplingStrategyResponse response = new SamplingStrategyResponse(null, null, parameters);
    when(samplingManager.getSamplingStrategy(SERVICE_NAME)).thenReturn(response);
    undertest.updateSampler();
    PerOperationSampler perOperationSampler = new PerOperationSampler(2000, parameters);
    Sampler actualSampler = undertest.getSampler();
    assertEquals(perOperationSampler, actualSampler);
}
Also used : SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) Sampler(io.jaegertracing.spi.Sampler) ArrayList(java.util.ArrayList) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 12 with Sampler

use of io.jaegertracing.spi.Sampler in project jaeger-client-java by jaegertracing.

the class ProbabilisticSamplerTest method testSamplingBoundariesPositive.

@Test
public void testSamplingBoundariesPositive() {
    double samplingRate = 0.5;
    long halfwayBoundary = 0x3fffffffffffffffL;
    Sampler sampler = new ProbabilisticSampler(samplingRate);
    assertTrue(sampler.sample("", halfwayBoundary).isSampled());
    assertFalse(sampler.sample("", halfwayBoundary + 2).isSampled());
}
Also used : Sampler(io.jaegertracing.spi.Sampler) Test(org.junit.Test)

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