def test_adjust_span(monkeypatch): span = MagicMock() span.set_tag.side_effect = [Exception, None, None] adjust_span(span, 'op_name', 'component', {'tag1': '1', 'tag2': '2'}) span.set_tag.assert_called_with(opentracing_tags.COMPONENT, 'component') span.set_operation_name.assert_called_with('op_name')
def wrapper(*args, **kwargs): # Get a new current span wrapping this traced function. # ``get_new_span`` should retrieve parent_span if any! span_arg_name, current_span = get_new_span( f, args, kwargs, inspect_stack=inspect_stack, ignore_parent_span=ignore_parent_span, span_extractor=span_extractor, use_follows_from=use_follows_from) if pass_span and span_arg_name: kwargs[span_arg_name] = current_span else: if span_extractor: kwarg_span, _ = get_span_from_kwargs(**kwargs) kwargs.pop(kwarg_span, None) kwargs.pop(span_arg_name, None) current_span = adjust_span(current_span, operation_name, component, tags) with current_span: return f(*args, **kwargs)