Exemplo n.º 1
0
    def __init__(self):
        cfg = Config(config)
        init_sampler = cfg.sampler
        channel = self.local_agent_sender

        reporter = Reporter(channel=channel,
                            flush_interval=cfg.reporter_flush_interval)

        remote_sampler = RemoteControlledSampler(
            channel=channel,
            service_name=cfg.service_name,
            sampling_refresh_interval=cfg.sampling_refresh_interval,
            init_sampler=init_sampler)

        remote_tracer = Tracer(service_name=cfg.service_name,
                               reporter=reporter,
                               sampler=remote_sampler)

        const_tracer = Tracer(service_name=cfg.service_name,
                              reporter=reporter,
                              sampler=ConstSampler(decision=True))

        self._tracers = {
            SAMPLER_TYPE_CONST: const_tracer,
            SAMPLER_TYPE_REMOTE: remote_tracer
        }
Exemplo n.º 2
0
def test_100pct_sampling_250mcs(benchmark):
    tracer = Tracer.default_tracer(channel=None,
                                   service_name='benchmark',
                                   reporter=NullReporter(),
                                   sampler=ConstSampler(True))
    # 250 micros for request execution
    benchmark(_generate_spans, tracer, sleep=0.00025)
Exemplo n.º 3
0
    def __init__(self):
        cfg = Config(config)
        init_sampler = cfg.sampler
        channel = self.local_agent_sender

        sender = UDPSender(
            io_loop=channel.io_loop,
            host=os.getenv('AGENT_HOST', 'jaeger-agent'),
            port=cfg.local_agent_reporting_port,
        )
        reporter = Reporter(sender=sender,
                            flush_interval=cfg.reporter_flush_interval)

        remote_sampler = RemoteControlledSampler(
            channel=channel,
            service_name=cfg.service_name,
            sampling_refresh_interval=cfg.sampling_refresh_interval,
            init_sampler=init_sampler)

        remote_tracer = Tracer(service_name=cfg.service_name,
                               reporter=reporter,
                               sampler=remote_sampler)

        const_tracer = Tracer(service_name=cfg.service_name,
                              reporter=reporter,
                              sampler=ConstSampler(decision=True))

        self._tracers = {
            SAMPLER_TYPE_CONST: const_tracer,
            SAMPLER_TYPE_REMOTE: remote_tracer
        }
Exemplo n.º 4
0
def test_all_not_batched(benchmark):
    from tchannel.sync import TChannel
    ch = TChannel(name='foo')
    f = ch.advertise(routers=["127.0.0.1:21300", "127.0.0.1:21301"])
    f.result()
    tracer = Tracer.default_tracer(ch, service_name='benchmark', sampler=ConstSampler(True))
    tracer.reporter.batch_size = 1
    # 250 micros for request execution
    benchmark(_generate_spans, tracer, sleep=0.00025)
def test_const_sampler():
    sampler = ConstSampler(True)
    assert sampler.is_sampled(1)
    assert sampler.is_sampled(MAX_INT)
    sampler = ConstSampler(False)
    sampled, tags = sampler.is_sampled(1)
    assert not sampled
    sampled, tags = sampler.is_sampled(MAX_INT)
    assert not sampled
    assert tags == get_tags('const', False)
    assert '%s' % sampler == 'ConstSampler(False)'
Exemplo n.º 6
0
def test_sampler_equality():
    const1 = ConstSampler(True)
    const2 = ConstSampler(True)
    const3 = ConstSampler(False)
    assert const1 == const2
    assert const1 != const3

    prob1 = ProbabilisticSampler(rate=0.01)
    prob2 = ProbabilisticSampler(rate=0.01)
    prob3 = ProbabilisticSampler(rate=0.02)
    assert prob1 == prob2
    assert prob1 != prob3
    assert const1 != prob1

    rate1 = RateLimitingSampler(max_traces_per_second=0.01)
    rate2 = RateLimitingSampler(max_traces_per_second=0.01)
    rate3 = RateLimitingSampler(max_traces_per_second=0.02)
    assert rate1 == rate2
    assert rate1 != rate3
    assert rate1 != const1
    assert rate1 != prob1
Exemplo n.º 7
0
def test_const_sampler():
    sampler = ConstSampler(True)
    sampled, _ = sampler.is_sampled(1)
    assert sampled
    sampled, _ = sampler.is_sampled(MAX_INT)
    assert sampled
    sampler = ConstSampler(False)
    sampled, tags = sampler.is_sampled(1)
    assert not sampled
    sampled, tags = sampler.is_sampled(MAX_INT)
    assert not sampled
    assert tags == get_tags('const', False)
    assert '%s' % sampler == 'ConstSampler(False)'
Exemplo n.º 8
0
def test_100pct_sampling(benchmark):
    tracer = Tracer.default_tracer(channel=None,
                                   service_name='benchmark',
                                   reporter=NullReporter(),
                                   sampler=ConstSampler(True))
    benchmark(_generate_spans, tracer)