Skip to content

Commit

Permalink
decorator only trace very top level function (#6530)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuyogSoti authored Jul 29, 2019
1 parent f49422f commit afa6ba3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/tracing/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def wrapper_use_tracer(self, *args, **kwargs):
original_span_instance = wrapper_class.get_current_span()
parent_span = common.get_parent_span(passed_in_parent)
ans = None
if parent_span is not None:
if parent_span is not None and orig_wrapped_span is None:
common.set_span_contexts(parent_span)
name = name_of_span or self.__class__.__name__ + "." + func.__name__
child = parent_span.span(name=name)
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/azure/core/tracing/decorator_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def wrapper_use_tracer(self, *args, **kwargs):
original_span_instance = wrapper_class.get_current_span()
parent_span = common.get_parent_span(passed_in_parent)
ans = None
if parent_span is not None:
if parent_span is not None and orig_wrapped_span is None:
common.set_span_contexts(parent_span)
name = name_of_span or self.__class__.__name__ + "." + func.__name__
child = parent_span.span(name=name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,10 @@ async def test_span_with_opencensus_complicated(value):
parent = exporter.root
assert len(parent.children) == 4
assert parent.children[0].span_data.name == "MockClient.__init__"
assert not parent.children[0].children
assert parent.children[1].span_data.name == "MockClient.make_request"
assert parent.children[1].children[0].span_data.name == "MockClient.get_foo"
assert parent.children[1].children[1].span_data.name == "MockClient.make_request"
assert not parent.children[1].children
assert parent.children[2].span_data.name == "child"
assert parent.children[2].children[0].span_data.name == "MockClient.make_request"
assert parent.children[3].span_data.name == "MockClient.make_request"
assert parent.children[3].children[0].span_data.name == "MockClient.get_foo"
assert parent.children[3].children[1].span_data.name == "MockClient.make_request"
children = parent.children[1].children
assert len(children) == 2
assert not parent.children[3].children
9 changes: 3 additions & 6 deletions sdk/core/azure-core/tests/test_tracing_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,10 @@ def test_span_with_opencensus_complicated(self, value):
parent = exporter.root
assert len(parent.children) == 4
assert parent.children[0].span_data.name == "MockClient.__init__"
assert not parent.children[0].children
assert parent.children[1].span_data.name == "MockClient.make_request"
assert parent.children[1].children[0].span_data.name == "MockClient.get_foo"
assert parent.children[1].children[1].span_data.name == "MockClient.make_request"
assert not parent.children[1].children
assert parent.children[2].span_data.name == "child"
assert parent.children[2].children[0].span_data.name == "MockClient.make_request"
assert parent.children[3].span_data.name == "MockClient.make_request"
assert parent.children[3].children[0].span_data.name == "MockClient.get_foo"
assert parent.children[3].children[1].span_data.name == "MockClient.make_request"
children = parent.children[1].children
assert len(children) == 2
assert not parent.children[3].children

0 comments on commit afa6ba3

Please sign in to comment.