Search in sources :

Example 1 with RateLimitingSamplingStrategy

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

the class RemoteControlledSamplerTest method testUpdateToRateLimitingSampler.

@Test
public void testUpdateToRateLimitingSampler() throws Exception {
    final int tracesPerSecond = 22;
    SamplingStrategyResponse rateLimitingResponse = new SamplingStrategyResponse(null, new RateLimitingSamplingStrategy(tracesPerSecond), null);
    when(samplingManager.getSamplingStrategy(SERVICE_NAME)).thenReturn(rateLimitingResponse);
    undertest.updateSampler();
    assertEquals(new RateLimitingSampler(tracesPerSecond), undertest.getSampler());
}
Also used : SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) RateLimitingSamplingStrategy(io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy) Test(org.junit.Test)

Example 2 with RateLimitingSamplingStrategy

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

Example 3 with RateLimitingSamplingStrategy

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

the class HttpSamplingManagerTest method testParseRateLimitingSampling.

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

Aggregations

RateLimitingSamplingStrategy (io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy)3 SamplingStrategyResponse (io.jaegertracing.internal.samplers.http.SamplingStrategyResponse)2 Test (org.junit.Test)2 ProbabilisticSamplingStrategy (io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy)1 Sampler (io.jaegertracing.spi.Sampler)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1