aws_xray_sdk.core.sampling.local package

Submodules

aws_xray_sdk.core.sampling.local.reservoir module

class aws_xray_sdk.core.sampling.local.reservoir.Reservoir(traces_per_sec=0)

Bases: object

Keeps track of the number of sampled segments within a single second. This class is implemented to be thread-safe to achieve accurate sampling.

take()

Returns True if there are segments left within the current second, otherwise return False.

aws_xray_sdk.core.sampling.local.sampler module

class aws_xray_sdk.core.sampling.local.sampler.LocalSampler(rules={'default': {'fixed_target': 1, 'rate': 0.05}, 'rules': [], 'version': 2})

Bases: object

The local sampler that holds either custom sampling rules or default sampling rules defined locally. The X-Ray recorder use it to calculate if this segment should be sampled or not when local rules are neccessary.

load_local_rules(rules)
should_trace(sampling_req=None)

Return True if the sampler decide to sample based on input information and sampling rules. It will first check if any custom rule should be applied, if not it falls back to the default sampling rule.

All optional arugments are extracted from incoming requests by X-Ray middleware to perform path based sampling.

aws_xray_sdk.core.sampling.local.sampling_rule module

class aws_xray_sdk.core.sampling.local.sampling_rule.SamplingRule(rule_dict, version=2, default=False)

Bases: object

One SamolingRule represents one rule defined from local rule json file or from a dictionary. It can be either a custom rule or default rule.

FIXED_TARGET = 'fixed_target'
HOST = 'host'
METHOD = 'http_method'
PATH = 'url_path'
RATE = 'rate'
SERVICE_NAME = 'service_name'
applies(host, method, path)

Determines whether or not this sampling rule applies to the incoming request based on some of the request’s parameters. Any None parameters provided will be considered an implicit match.

property fixed_target

Defines fixed number of sampled segments per second. This doesn’t count for sampling rate.

property host

The host name of the reqest to sample.

property method

HTTP method of the request to sample.

property path

The url path of the request to sample.

property rate

A float number less than 1.0 defines the sampling rate.

property reservoir

Keeps track of used sampled targets within the second.

property version

Keeps track of used sampled targets within the second.

Module contents