in aws_xray_sdk/core/sampling/sampler.py [0:0]
def _process_matched_rule(self, rule, now):
# As long as a rule is matched we increment request counter.
rule.increment_request_count()
reservoir = rule.reservoir
sample = True
# We check if we can borrow or take from reservoir first.
decision = reservoir.borrow_or_take(now, rule.can_borrow)
if(decision == ReservoirDecision.BORROW):
rule.increment_borrow_count()
elif (decision == ReservoirDecision.TAKE):
rule.increment_sampled_count()
# Otherwise we compute based on fixed rate of this sampling rule.
elif (self._random.random() <= rule.rate):
rule.increment_sampled_count()
else:
sample = False
if sample:
return rule.name
else:
return False