Search in sources :

Example 1 with ProbabilisticSamplingStrategy

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

the class HttpSamplingManagerTest method testParsePerOperationSampling.

@Test
public void testParsePerOperationSampling() throws Exception {
    SamplingStrategyResponse response = undertest.parseJson(readFixture("per_operation_sampling.json"));
    OperationSamplingParameters actual = response.getOperationSampling();
    assertEquals(0.001, actual.getDefaultSamplingProbability(), 0.0001);
    assertEquals(0.001666, actual.getDefaultLowerBoundTracesPerSecond(), 0.0001);
    List<PerOperationSamplingParameters> actualPerOperationStrategies = actual.getPerOperationStrategies();
    assertEquals(2, actualPerOperationStrategies.size());
    assertEquals(new PerOperationSamplingParameters("GET:/search", new ProbabilisticSamplingStrategy(1.0)), actualPerOperationStrategies.get(0));
    assertEquals(new PerOperationSamplingParameters("PUT:/pacifique", new ProbabilisticSamplingStrategy(0.8258308134813166)), actualPerOperationStrategies.get(1));
}
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) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 2 with ProbabilisticSamplingStrategy

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

the class HttpSamplingManagerTest method testParseProbabilisticSampling.

@Test
public void testParseProbabilisticSampling() throws Exception {
    SamplingStrategyResponse response = undertest.parseJson(readFixture("probabilistic_sampling.json"));
    assertEquals(new ProbabilisticSamplingStrategy(0.01), response.getProbabilisticSampling());
    assertNull(response.getRateLimitingSampling());
}
Also used : SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with ProbabilisticSamplingStrategy

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

the class PerOperationSamplerTest method testAbsentOperationIsRemoved.

@Test
public void testAbsentOperationIsRemoved() {
    String absentOp = "ShouldBeRemoved";
    operationToSamplers.put(absentOp, mock(GuaranteedThroughputSampler.class));
    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));
    assertFalse(undertest.getOperationNameToSampler().containsKey(absentOp));
}
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 4 with ProbabilisticSamplingStrategy

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

the class RemoteControlledSamplerTest method testUpdateToProbabilisticSampler.

@Test
public void testUpdateToProbabilisticSampler() throws Exception {
    final double samplingRate = 0.55;
    SamplingStrategyResponse probabilisticResponse = new SamplingStrategyResponse(new ProbabilisticSamplingStrategy(samplingRate), null, null);
    when(samplingManager.getSamplingStrategy(SERVICE_NAME)).thenReturn(probabilisticResponse);
    undertest.updateSampler();
    assertEquals(new ProbabilisticSampler(samplingRate), undertest.getSampler());
}
Also used : SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) Test(org.junit.Test)

Example 5 with ProbabilisticSamplingStrategy

use of io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy 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);
    }
}
Also used : Sampler(io.jaegertracing.spi.Sampler) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) RateLimitingSamplingStrategy(io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy)

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