How to use the basictracer.recorder.Sampler function in basictracer

To help you get started, we’ve selected a few basictracer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opentracing / basictracer-python / basictracer / recorder.py View on Github external
with self.mux:
            return self.spans[:]


class Sampler(six.with_metaclass(ABCMeta, object)):
    """Sampler determines the sampling status of a span given its trace_id.

    Sampler.sampled() is expected to return a boolean.
    """

    @abstractmethod
    def sampled(self, trace_id):
        pass


class DefaultSampler(Sampler):
    """DefaultSampler determines the sampling status via ID % rate == 0.
    """
    def __init__(self, rate):
        self.rate = rate

    def sampled(self, trace_id):
        return trace_id % self.rate == 0