Skip to content

Commit

Permalink
Remove synchronized on GuaranteedThroughputSampler.sample
Browse files Browse the repository at this point in the history
- Add volatile keyword to underlying samplers so updated references can
be made available to other threads.

See jaegertracing#609 for
similar work.

Fixes jaegertracing#807

Signed-off-by: Will Tran <will@autonomic.ai>
  • Loading branch information
Will Tran committed Oct 14, 2021
1 parent 6003c01 commit f9a9592
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
public final class GuaranteedThroughputSampler implements Sampler {
public static final String TYPE = "lowerbound";

private ProbabilisticSampler probabilisticSampler;
private RateLimitingSampler lowerBoundSampler;
private volatile ProbabilisticSampler probabilisticSampler;
private volatile RateLimitingSampler lowerBoundSampler;
private Map<String, Object> tags;

public GuaranteedThroughputSampler(double samplingRate, double lowerBound) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public synchronized boolean update(double samplingRate, double lowerBound) {
* @param id The traceId on the span
*/
@Override
public synchronized SamplingStatus sample(String operation, long id) {
public SamplingStatus sample(String operation, long id) {
SamplingStatus probabilisticSamplingStatus = probabilisticSampler.sample(operation, id);
SamplingStatus lowerBoundSamplingStatus = lowerBoundSampler.sample(operation, id);

Expand Down

0 comments on commit f9a9592

Please sign in to comment.