Skip to content
Snippets Groups Projects
Commit 81d50cd3 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

backwards compatibility, 2.17.1

parent f4abdfaf
No related branches found
No related tags found
No related merge requests found
# v2.17.1
* add backwards compatibility for tags_factory
__version__ = '2.17.1a1'
__version__ = '2.17.1'
......@@ -52,7 +52,14 @@ def trace_function(tracer, name: str, tags: tp.Optional[dict] = None,
tags = {}
my_tags = copy.copy(tags)
for key, value in tags_factory:
my_tags[key] = value(*args, **kwargs)
try:
v = value(*args, **kwargs)
except TypeError:
warnings.warn('You are using the deprecated single-parameter version '
'of tags_factory. Please upgrade to the newer one.',
DeprecationWarning)
v = value(args)
my_tags[key] = v
with tracer.start_active_span(name, tags=my_tags):
return fun(*args, **kwargs)
......
......@@ -14,7 +14,7 @@ class TestOpentracing(unittest.TestCase):
self.start_active_span_called = True
def start_active_span(self, *args, tags=None, **kwargs):
slf.assertEqual(tags, {'a': 'b', 'c': 'd'})
slf.assertEqual(tags, {'a': 'b', 'c': 'd', 'e': 'f'})
class MockScope(mock.Mock):
def __enter__(self):
......@@ -28,7 +28,9 @@ class TestOpentracing(unittest.TestCase):
tracer = MockTracer()
@trace_function(tracer, 'trace_me',
tags_factory= {('a', lambda: 'b'), ('c', lambda: 'd')})
tags_factory= {'a': lambda: 'b',
'c': lambda: 'd',
'e': (lambda args: 'f')})
def trace_me():
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment