Пример #1
0
def test_composite_reporter():
    reporter = jaeger_client.reporter.CompositeReporter(
        jaeger_client.reporter.NullReporter(),
        jaeger_client.reporter.LoggingReporter())
    with mock.patch('jaeger_client.reporter.NullReporter.set_process') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.set_process') \
                as log_mock:
            reporter.set_process('x', {}, 123)
            null_mock.assert_called_with('x', {}, 123)
            log_mock.assert_called_with('x', {}, 123)
    with mock.patch('jaeger_client.reporter.NullReporter.report_span') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.report_span') \
                as log_mock:
            reporter.report_span({})
            null_mock.assert_called_with({})
            log_mock.assert_called_with({})
    with mock.patch('jaeger_client.reporter.NullReporter.close') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.close') \
                as log_mock:

            f1 = Future()
            f2 = Future()
            null_mock.return_value = f1
            log_mock.return_value = f2
            f = reporter.close()
            null_mock.assert_called_once()
            log_mock.assert_called_once()
            assert not f.done()
            f1.set_result(True)
            f2.set_result(True)
            assert f.done()
Пример #2
0
def test_composite_reporter():
    reporter = jaeger_client.reporter.CompositeReporter(
        jaeger_client.reporter.NullReporter(),
        jaeger_client.reporter.LoggingReporter())
    with mock.patch('jaeger_client.reporter.NullReporter.set_process') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.set_process') \
                as log_mock:
            reporter.set_process('x', {}, 123)
            null_mock.assert_called_with('x', {}, 123)
            log_mock.assert_called_with('x', {}, 123)
    with mock.patch('jaeger_client.reporter.NullReporter.report_span') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.report_span') \
                as log_mock:
            reporter.report_span({})
            null_mock.assert_called_with({})
            log_mock.assert_called_with({})
    with mock.patch('jaeger_client.reporter.NullReporter.close') \
            as null_mock:
        with mock.patch('jaeger_client.reporter.LoggingReporter.close') \
                as log_mock:

            f1 = Future()
            f2 = Future()
            null_mock.return_value = f1
            log_mock.return_value = f2
            f = reporter.close()
            null_mock.assert_called_once()
            log_mock.assert_called_once()
            assert not f.done()
            f1.set_result(True)
            f2.set_result(True)
            assert f.done()
Пример #3
0
 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
Пример #4
0
 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