aws_xray_sdk.core.sampling.reservoir

Module Contents

class Reservoir

Bases:object

Centralized thread-safe reservoir which holds fixed sampling quota, borrowed count and TTL.

quota
TTL
borrow_or_take(self, now, can_borrow)

Decide whether to borrow or take one quota from the reservoir. Return False if it can neither borrow nor take. This method is thread-safe.

load_quota(self, quota, TTL, interval)

Load new quota with a TTL. If the input is None, the reservoir will continue using old quota until it expires or has a non-None quota/TTL in a future load.

_time_to_report(self)
_borrow_or_take(self, now, can_borrow)
_adjust_this_sec(self, now)
class ReservoirDecision

Bases:enum.Enum

An Enum of decisions the reservoir could make based on assigned quota with TTL and the current timestamp/usage.

TAKE = take
BORROW = borrow
NO = no