Skip to content

Commit 5d3649d

Browse files
authored
Better naming (#1962)
1 parent b339d83 commit 5d3649d

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

sentry_sdk/tracing_utils_py2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ def start_child_span_decorator(func):
2626
def func_with_tracing(*args, **kwargs):
2727
# type: (*Any, **Any) -> Any
2828

29-
span_or_trx = get_current_span(sentry_sdk.Hub.current)
29+
span = get_current_span(sentry_sdk.Hub.current)
3030

31-
if span_or_trx is None:
31+
if span is None:
3232
logger.warning(
33-
"No transaction found. Not creating a child span for %s. "
33+
"Can not create a child span for %s. "
3434
"Please start a Sentry transaction before calling this function.",
3535
qualname_from_function(func),
3636
)
3737
return func(*args, **kwargs)
3838

39-
with span_or_trx.start_child(
39+
with span.start_child(
4040
op=OP.FUNCTION,
4141
description=qualname_from_function(func),
4242
):

sentry_sdk/tracing_utils_py3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ def start_child_span_decorator(func):
3030
async def func_with_tracing(*args, **kwargs):
3131
# type: (*Any, **Any) -> Any
3232

33-
span_or_trx = get_current_span(sentry_sdk.Hub.current)
33+
span = get_current_span(sentry_sdk.Hub.current)
3434

35-
if span_or_trx is None:
35+
if span is None:
3636
logger.warning(
37-
"No transaction found. Not creating a child span for %s. "
37+
"Can not create a child span for %s. "
3838
"Please start a Sentry transaction before calling this function.",
3939
qualname_from_function(func),
4040
)
4141
return await func(*args, **kwargs)
4242

43-
with span_or_trx.start_child(
43+
with span.start_child(
4444
op=OP.FUNCTION,
4545
description=qualname_from_function(func),
4646
):
@@ -53,17 +53,17 @@ async def func_with_tracing(*args, **kwargs):
5353
def func_with_tracing(*args, **kwargs):
5454
# type: (*Any, **Any) -> Any
5555

56-
span_or_trx = get_current_span(sentry_sdk.Hub.current)
56+
span = get_current_span(sentry_sdk.Hub.current)
5757

58-
if span_or_trx is None:
58+
if span is None:
5959
logger.warning(
60-
"No transaction found. Not creating a child span for %s. "
60+
"Can not create a child span for %s. "
6161
"Please start a Sentry transaction before calling this function.",
6262
qualname_from_function(func),
6363
)
6464
return func(*args, **kwargs)
6565

66-
with span_or_trx.start_child(
66+
with span.start_child(
6767
op=OP.FUNCTION,
6868
description=qualname_from_function(func),
6969
):

tests/tracing/test_decorator_py2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def test_trace_decorator_py2_no_trx():
4444

4545
result2 = start_child_span_decorator_py2(my_example_function)()
4646
fake_warning.assert_called_once_with(
47-
"No transaction found. Not creating a child span for %s. Please start a Sentry transaction before calling this function.",
47+
"Can not create a child span for %s. "
48+
"Please start a Sentry transaction before calling this function.",
4849
"test_decorator_py2.my_example_function",
4950
)
5051
assert result2 == "return_of_sync_function"

tests/tracing/test_decorator_py3.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def test_trace_decorator_sync_py3_no_trx():
5353

5454
result2 = start_child_span_decorator_py3(my_example_function)()
5555
fake_warning.assert_called_once_with(
56-
"No transaction found. Not creating a child span for %s. Please start a Sentry transaction before calling this function.",
56+
"Can not create a child span for %s. "
57+
"Please start a Sentry transaction before calling this function.",
5758
"test_decorator_py3.my_example_function",
5859
)
5960
assert result2 == "return_of_sync_function"
@@ -95,7 +96,8 @@ async def test_trace_decorator_async_py3_no_trx():
9596

9697
result2 = await start_child_span_decorator_py3(my_async_example_function)()
9798
fake_warning.assert_called_once_with(
98-
"No transaction found. Not creating a child span for %s. Please start a Sentry transaction before calling this function.",
99+
"Can not create a child span for %s. "
100+
"Please start a Sentry transaction before calling this function.",
99101
"test_decorator_py3.my_async_example_function",
100102
)
101103
assert result2 == "return_of_async_function"

0 commit comments

Comments
 (0)