Search in sources :

Example 1 with SamplingStrategyResponse

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

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

the class HttpSamplingManagerTest method testGetSamplingStrategy.

@Test
public void testGetSamplingStrategy() throws Exception {
    URI uri = target().getUri();
    undertest = new HttpSamplingManager(uri.getHost() + ":" + uri.getPort());
    SamplingStrategyResponse response = undertest.getSamplingStrategy("clairvoyant");
    assertNotNull(response.getProbabilisticSampling());
}
Also used : SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) URI(java.net.URI) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with SamplingStrategyResponse

use of io.jaegertracing.internal.samplers.http.SamplingStrategyResponse 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 4 with SamplingStrategyResponse

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

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

Aggregations

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