use of io.jaegertracing.internal.samplers.http.OperationSamplingParameters 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);
}
use of io.jaegertracing.internal.samplers.http.OperationSamplingParameters 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);
}
use of io.jaegertracing.internal.samplers.http.OperationSamplingParameters in project jaeger-client-java by jaegertracing.
the class RemoteControlledSamplerTest method testUpdatePerOperationSamplerUpdatesExistingPerOperationSampler.
@Test
public void testUpdatePerOperationSamplerUpdatesExistingPerOperationSampler() throws Exception {
undertest.close();
PerOperationSampler perOperationSampler = mock(PerOperationSampler.class);
OperationSamplingParameters parameters = mock(OperationSamplingParameters.class);
when(samplingManager.getSamplingStrategy(SERVICE_NAME)).thenReturn(new SamplingStrategyResponse(null, null, parameters));
undertest = new RemoteControlledSampler.Builder(SERVICE_NAME).withSamplingManager(samplingManager).withInitialSampler(perOperationSampler).withMetrics(metrics).build();
undertest.updateSampler();
Thread.sleep(20);
// updateSampler is hit once automatically because of the pollTimer
verify(perOperationSampler, times(2)).update(parameters);
}
Aggregations