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());
}
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);
}
}
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());
}
Aggregations