Пример #1
0
def test_log_span_calls_transport_handler_with_correct_params(
        thrift_obj, create_sp):
    transport_handler = mock.Mock()
    logging_helper.log_span(
        span_id='0000000000000002',
        parent_span_id='0000000000000001',
        trace_id='00000000000000015',
        span_name='span',
        annotations='ann',
        binary_annotations='binary_ann',
        transport_handler=transport_handler,
    )
    transport_handler.assert_called_once_with(thrift_obj.return_value)
Пример #2
0
def test_log_span_defensive_about_transport_handler(thrift_obj, create_sp):
    transport_handler = None
    logging_helper.log_span(
        span_id='0000000000000002',
        parent_span_id='0000000000000001',
        trace_id='00000000000000015',
        span_name='span',
        annotations='ann',
        binary_annotations='binary_ann',
        transport_handler=transport_handler,
    )
    assert thrift_obj.call_count == 0
    assert create_sp.call_count == 0
Пример #3
0
def test_log_span(thrift_obj):
    # Not much logic here, so this is basically a smoke test

    logging_helper.log_span(
        span_id='0000000000000002',
        parent_span_id='0000000000000001',
        trace_id='000000000000000f',
        span_name='span',
        annotations='ann',
        binary_annotations='binary_ann',
        timestamp_s=None,
        duration_s=None,
        transport_handler=mock_transport_handler,
    )
    assert thrift_obj.call_count == 1
Пример #4
0
def test_log_span_defensive_about_transport_handler(thrift_obj, create_sp):
    """Make sure log_span doesn't try to call the transport handler if it's
    None."""
    logging_helper.log_span(
        span_id='0000000000000002',
        parent_span_id='0000000000000001',
        trace_id='00000000000000015',
        span_name='span',
        annotations='ann',
        binary_annotations='binary_ann',
        timestamp_s=None,
        duration_s=None,
        transport_handler=None,
    )
    assert thrift_obj.call_count == 0
    assert create_sp.call_count == 0
Пример #5
0
def test_log_span(thrift_obj):
    # Not much logic here, so this is basically a smoke test

    def fake_transport_handler(x):
        return x

    logging_helper.log_span(
        span_id='0000000000000002',
        parent_span_id='0000000000000001',
        trace_id='000000000000000f',
        span_name='span',
        annotations='ann',
        binary_annotations='binary_ann',
        transport_handler=fake_transport_handler,
    )
    assert thrift_obj.call_count == 1