def _new_reporter(self, batch_size, flush=None, queue_cap=100):
     reporter = Reporter('ch',
                         batch_size=batch_size,
                         flush_interval=flush,
                         metrics=FakeMetrics(),
                         error_reporter=HardErrorReporter(),
                         queue_capacity=queue_cap)
     sender = ManualSender()
     reporter._send = sender
     return reporter, sender
 def _new_reporter(self, batch_size, flush=None, queue_cap=100):
     reporter = Reporter(channel=mock.MagicMock(),
                         io_loop=IOLoop.current(),
                         batch_size=batch_size,
                         flush_interval=flush,
                         metrics_factory=FakeMetricsFactory(),
                         error_reporter=HardErrorReporter(),
                         queue_capacity=queue_cap)
     sender = FakeSender()
     reporter._send = sender
     return reporter, sender
 def _new_reporter(batch_size, flush=None, queue_cap=100):
     reporter = Reporter(channel=mock.MagicMock(),
                         io_loop=IOLoop.current(),
                         batch_size=batch_size,
                         flush_interval=flush,
                         metrics_factory=FakeMetricsFactory(),
                         error_reporter=HardErrorReporter(),
                         queue_capacity=queue_cap)
     reporter.set_process('service', {}, max_length=0)
     sender = FakeSender()
     reporter._send = sender
     return reporter, sender
 def _new_reporter(batch_size, flush=None, queue_cap=100):
     reporter = Reporter(sender=mock.MagicMock(),
                         io_loop=IOLoop.current(),
                         batch_size=batch_size,
                         flush_interval=flush,
                         metrics_factory=FakeMetricsFactory(),
                         error_reporter=HardErrorReporter(),
                         queue_capacity=queue_cap)
     reporter.set_process('service', {}, max_length=0)
     sender = FakeSender()
     reporter._send = sender
     return reporter, sender
Beispiel #5
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
        }
    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
        }
    def test_reporter_calls_sender_correctly(self):
        reporter = Reporter(sender=mock.MagicMock(),
                            io_loop=IOLoop.current(),
                            batch_size=10,
                            flush_interval=None,
                            metrics_factory=FakeMetricsFactory(),
                            error_reporter=HardErrorReporter(),
                            queue_capacity=100)
        test_data = {'foo': 'bar'}

        reporter._send(test_data)
        reporter.sender.send.assert_called_once_with(test_data)
    def new_tracer(self, logger_reporter, io_loop=None):
        """
        Create a new Jaeger Tracer based on the passed `jaeger_client.Config`.
        """
        channel = self._create_local_agent_channel(io_loop=io_loop)
        sampler = self.sampler
        if not sampler:
            sampler = RemoteControlledSampler(
                channel=channel,
                service_name=self.service_name,
                logger=default_logger,
                metrics_factory=self._metrics_factory,
                error_reporter=self.error_reporter,
                sampling_refresh_interval=self.sampling_refresh_interval,
                max_operations=self.max_operations)
        default_logger.info('Using sampler %s', sampler)

        reporter = Reporter(
            channel=channel,
            queue_capacity=self.reporter_queue_size,
            batch_size=self.reporter_batch_size,
            flush_interval=self.reporter_flush_interval,
            logger=default_logger,
            metrics_factory=self._metrics_factory,
            error_reporter=self.error_reporter)

        if self.logging:
            reporter = CompositeReporter(
                reporter, logger_reporter)

        if not self.throttler_group() is None:
            throttler = RemoteThrottler(
                channel,
                self.service_name,
                refresh_interval=self.throttler_refresh_interval,
                logger=default_logger,
                metrics_factory=self._metrics_factory,
                error_reporter=self.error_reporter)
        else:
            throttler = None

        return self.create_tracer(
            reporter=reporter,
            sampler=sampler,
            throttler=throttler,
        )