@Test public void testFallbackToDefaultProbabilisticSampler() { undertest = new PerOperationSampler(0, operationToSamplers, defaultProbabilisticSampler, DEFAULT_LOWER_BOUND_TRACES_PER_SECOND); SamplingStatus samplingStatus = undertest.sample(OPERATION, TRACE_ID); assertTrue(samplingStatus.isSampled()); verify(defaultProbabilisticSampler).sample(OPERATION, TRACE_ID); }
@Override public synchronized SamplingStatus sample(String operation, long id) { GuaranteedThroughputSampler sampler = operationNameToSampler.get(operation); if (sampler != null) { return sampler.sample(operation, id); } if (operationNameToSampler.size() < maxOperations) { sampler = new GuaranteedThroughputSampler(defaultSampler.getSamplingRate(), lowerBound); operationNameToSampler.put(operation, sampler); return sampler.sample(operation, id); } return defaultSampler.sample(operation, id); }
PerOperationSampler implements Sampler { @Override public synchronized SamplingStatus sample(String operation, long id) { GuaranteedThroughputSampler sampler = operationNameToSampler.get(operation); if (sampler != null) { return sampler.sample(operation, id); } if (operationNameToSampler.size() < maxOperations) { sampler = new GuaranteedThroughputSampler(defaultSampler.getSamplingRate(), lowerBound); operationNameToSampler.put(operation, sampler); return sampler.sample(operation, id); } return defaultSampler.sample(operation, id); } }
PerOperationSampler implements Sampler { @Override public synchronized SamplingStatus sample(String operation, long id) { GuaranteedThroughputSampler sampler = operationNameToSampler.get(operation); if (sampler != null) { return sampler.sample(operation, id); } if (operationNameToSampler.size() < maxOperations) { sampler = new GuaranteedThroughputSampler(defaultSampler.getSamplingRate(), lowerBound); operationNameToSampler.put(operation, sampler); return sampler.sample(operation, id); } return defaultSampler.sample(operation, id); } PerOperationSampler(int maxOperations, OperationSamplingParameters strategies); }
PerOperationSampler implements Sampler { @Override public synchronized SamplingStatus sample(String operation, long id) { GuaranteedThroughputSampler sampler = operationNameToSampler.get(operation); if (sampler != null) { return sampler.sample(operation, id); } if (operationNameToSampler.size() < maxOperations) { sampler = new GuaranteedThroughputSampler(defaultSampler.getSamplingRate(), lowerBound); operationNameToSampler.put(operation, sampler); return sampler.sample(operation, id); } return defaultSampler.sample(operation, id); } PerOperationSampler(int maxOperations, OperationSamplingParameters strategies); synchronized boolean update(final OperationSamplingParameters strategies); @Override synchronized SamplingStatus sample(String operation, long id); @Override synchronized void close(); }
PerOperationSampler implements Sampler { @Override public synchronized SamplingStatus sample(String operation, long id) { GuaranteedThroughputSampler sampler = operationNameToSampler.get(operation); if (sampler != null) { return sampler.sample(operation, id); } if (operationNameToSampler.size() < maxOperations) { sampler = new GuaranteedThroughputSampler(defaultSampler.getSamplingRate(), lowerBound); operationNameToSampler.put(operation, sampler); return sampler.sample(operation, id); } return defaultSampler.sample(operation, id); } PerOperationSampler(int maxOperations, OperationSamplingParameters strategies); synchronized boolean update(final OperationSamplingParameters strategies); @Override synchronized SamplingStatus sample(String operation, long id); @Override synchronized void close();  }