def test_log_span_calls_transport_handler_with_correct_params(thrift_obj, create_sp): transport_handler = mock.Mock() registry = {'zipkin.transport_handler': transport_handler, 'zipkin.stream_name': 'foo'} logging_helper.log_span('attr', 'X', registry, 'ann', 'bann', 'is_client') transport_handler.assert_called_once_with('foo', thrift_obj.return_value)
def test_log_span_uses_default_stream_name_if_not_provided( thrift_obj, create_sp): transport_handler = mock.Mock() registry = {'zipkin.transport_handler': transport_handler} logging_helper.log_span('attr', 'X', registry, 'ann', 'bann', 'is_client') transport_handler.assert_called_once_with('zipkin', thrift_obj.return_value)
def test_log_span_raises_error_if_handler_not_defined(thrift_obj, create_sp): with pytest.raises(ZipkinError) as excinfo: logging_helper.log_span( '0000000000000002', '0000000000000001', '00000000000000015', 'span', 'ann', 'binary_ann', {} ) assert ("`zipkin.transport_handler` is a required config property" in str( excinfo.value))
def test_log_span_uses_default_stream_name_if_not_provided(thrift_obj, create_sp): transport_handler = mock.Mock() registry = {'zipkin.transport_handler': transport_handler} logging_helper.log_span( '0000000000000002', '0000000000000001', '00000000000000015', 'span', 'ann', 'binary_ann', registry ) transport_handler.assert_called_once_with('zipkin', thrift_obj.return_value)
def test_log_span_calls_transport_handler_with_correct_params(thrift_obj, create_sp): transport_handler = mock.Mock() registry = {'zipkin.transport_handler': transport_handler, 'zipkin.stream_name': 'foo'} logging_helper.log_span( '0000000000000002', '0000000000000001', '00000000000000015', 'span', 'ann', 'binary_ann', registry ) transport_handler.assert_called_once_with('foo', thrift_obj.return_value)
def test_log_span(thrift_obj): # Not much logic here, so this is basically a smoke test thrift_obj.return_value = 'obj' registry = {'zipkin.transport_handler': (lambda x, y: (x, y))} stream, span_bytes = logging_helper.log_span( span_id='0000000000000002', parent_span_id='0000000000000001', trace_id='000000000000000f', span_name='span', annotations='ann', binary_annotations='binary_ann', registry_settings=registry, ) assert thrift_obj.call_count == 1 assert stream == 'zipkin' assert span_bytes == 'obj'
def test_log_span_creates_service_annotations_and_logs_span( thrift_obj, create_sp): registry = {'zipkin.transport_handler': (lambda x, y: None)} logging_helper.log_span('attr', 'X', registry, 'ann', 'bann', 'is_client') create_sp.assert_called_once_with('attr', 'X', 'ann', 'bann', 'is_client') thrift_obj.assert_called_once_with(create_sp.return_value)
def test_log_span_raises_error_if_handler_not_defined(thrift_obj, create_sp): registry = {'zipkin.stream_name': 'foo'} with pytest.raises(ZipkinError) as excinfo: logging_helper.log_span('attr', 'X', registry, 'ann', 'bann', '_') assert ("`zipkin.transport_handler` is a required config property" in str( excinfo.value))
def test_log_span_uses_default_stream_name_if_not_provided(thrift_obj, create_sp): transport_handler = mock.Mock() registry = {'zipkin.transport_handler': transport_handler} logging_helper.log_span('attr', 'X', registry, 'ann', 'bann', 'is_client') transport_handler.assert_called_once_with('zipkin', thrift_obj.return_value)