Search in sources :

Example 6 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy in project jaeger-client-java by jaegertracing.

the class PerOperationSamplerTest method testUpdateIgnoreGreaterThanMax.

@Test
public void testUpdateIgnoreGreaterThanMax() {
    GuaranteedThroughputSampler guaranteedThroughputSampler = mock(GuaranteedThroughputSampler.class);
    operationToSamplers.put(OPERATION, guaranteedThroughputSampler);
    PerOperationSampler undertest = new PerOperationSampler(1, operationToSamplers, defaultProbabilisticSampler, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND);
    PerOperationSamplingParameters perOperationSamplingParameters1 = new PerOperationSamplingParameters(OPERATION, new ProbabilisticSamplingStrategy(SAMPLING_RATE));
    PerOperationSamplingParameters perOperationSamplingParameters2 = new PerOperationSamplingParameters("second OPERATION", new ProbabilisticSamplingStrategy(SAMPLING_RATE));
    List<PerOperationSamplingParameters> parametersList = new ArrayList<>();
    parametersList.add(perOperationSamplingParameters1);
    parametersList.add(perOperationSamplingParameters2);
    undertest.update(new OperationSamplingParameters(DEFAULT_SAMPLING_PROBABILITY, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND, parametersList));
    assertEquals(1, undertest.getOperationNameToSampler().size());
    assertNotNull(undertest.getOperationNameToSampler().get(OPERATION));
}
Also used : PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) ArrayList(java.util.ArrayList) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 7 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy in project jaeger-client-java by jaegertracing.

the class PerOperationSamplerTest method testUpdateAddOperation.

@Test
public void testUpdateAddOperation() {
    PerOperationSamplingParameters perOperationSamplingParameters1 = new PerOperationSamplingParameters(OPERATION, new ProbabilisticSamplingStrategy(SAMPLING_RATE));
    List<PerOperationSamplingParameters> parametersList = new ArrayList<>();
    parametersList.add(perOperationSamplingParameters1);
    undertest.update(new OperationSamplingParameters(DEFAULT_SAMPLING_PROBABILITY, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND, parametersList));
    assertEquals(1, undertest.getOperationNameToSampler().size());
    assertEquals(new GuaranteedThroughputSampler(SAMPLING_RATE, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND), undertest.getOperationNameToSampler().get(OPERATION));
}
Also used : PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) ArrayList(java.util.ArrayList) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 8 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy in project jaeger-client-java by jaegertracing.

the class PerOperationSamplerTest method testUpdate.

@Test
public void testUpdate() {
    GuaranteedThroughputSampler guaranteedThroughputSampler = mock(GuaranteedThroughputSampler.class);
    operationToSamplers.put(OPERATION, guaranteedThroughputSampler);
    PerOperationSamplingParameters perOperationSamplingParameters = new PerOperationSamplingParameters(OPERATION, new ProbabilisticSamplingStrategy(SAMPLING_RATE));
    List<PerOperationSamplingParameters> parametersList = new ArrayList<>();
    parametersList.add(perOperationSamplingParameters);
    OperationSamplingParameters parameters = new OperationSamplingParameters(DEFAULT_SAMPLING_PROBABILITY, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND, parametersList);
    assertTrue(undertest.update(parameters));
    verify(guaranteedThroughputSampler).update(SAMPLING_RATE, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND);
    verifyNoMoreInteractions(guaranteedThroughputSampler);
}
Also used : PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) ArrayList(java.util.ArrayList) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 9 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy in project jaeger-client-java by jaegertracing.

the class PerOperationSamplerTest method testNoopUpdate.

@Test
public void testNoopUpdate() {
    ProbabilisticSampler defaultProbabilisticSampler = new ProbabilisticSampler(DEFAULT_SAMPLING_PROBABILITY);
    double operationSamplingRate = 0.23;
    operationToSamplers.put(OPERATION, new GuaranteedThroughputSampler(operationSamplingRate, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND));
    undertest = new PerOperationSampler(MAX_OPERATIONS, operationToSamplers, defaultProbabilisticSampler, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND);
    List<PerOperationSamplingParameters> parametersList = new ArrayList<>();
    parametersList.add(new PerOperationSamplingParameters(OPERATION, new ProbabilisticSamplingStrategy(operationSamplingRate)));
    OperationSamplingParameters parameters = new OperationSamplingParameters(DEFAULT_SAMPLING_PROBABILITY, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND, parametersList);
    assertFalse(undertest.update(parameters));
    assertEquals(operationToSamplers, undertest.getOperationNameToSampler());
    assertEquals(DEFAULT_LOWER_BOUND_TRACES_PER_SECOND, undertest.getLowerBound(), DELTA);
    assertEquals(DEFAULT_SAMPLING_PROBABILITY, undertest.getDefaultSampler().getSamplingRate(), DELTA);
}
Also used : PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) ArrayList(java.util.ArrayList) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 10 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy 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)

Aggregations

ProbabilisticSamplingStrategy (io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy)10 Test (org.junit.Test)9 OperationSamplingParameters (io.jaegertracing.internal.samplers.http.OperationSamplingParameters)7 PerOperationSamplingParameters (io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters)7 ArrayList (java.util.ArrayList)6 SamplingStrategyResponse (io.jaegertracing.internal.samplers.http.SamplingStrategyResponse)4 Sampler (io.jaegertracing.spi.Sampler)2 JerseyTest (org.glassfish.jersey.test.JerseyTest)2 RateLimitingSamplingStrategy (io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy)1