Skip to content

ref(logging): Lower logger level for some messages #3305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def _possibly_started(self):
def __enter__(self):
# type: () -> Transaction
if not self._possibly_started():
logger.warning(
logger.debug(
"Transaction was entered without being started with sentry_sdk.start_transaction."
"The transaction will not be sent to Sentry. To fix, start the transaction by"
"passing it to sentry_sdk.start_transaction."
Expand Down
8 changes: 4 additions & 4 deletions sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ async def func_with_tracing(*args, **kwargs):
span = get_current_span()

if span is None:
logger.warning(
"Can not create a child span for %s. "
logger.debug(
"Cannot create a child span for %s. "
"Please start a Sentry transaction before calling this function.",
qualname_from_function(func),
)
Expand All @@ -665,8 +665,8 @@ def func_with_tracing(*args, **kwargs):
span = get_current_span()

if span is None:
logger.warning(
"Can not create a child span for %s. "
logger.debug(
"Cannot create a child span for %s. "
"Please start a Sentry transaction before calling this function.",
qualname_from_function(func),
)
Expand Down
16 changes: 8 additions & 8 deletions tests/tracing/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def test_trace_decorator():

def test_trace_decorator_no_trx():
with patch_start_tracing_child(fake_transaction_is_none=True):
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
with mock.patch.object(logger, "debug", mock.Mock()) as fake_debug:
result = my_example_function()
fake_warning.assert_not_called()
fake_debug.assert_not_called()
assert result == "return_of_sync_function"

result2 = start_child_span_decorator(my_example_function)()
fake_warning.assert_called_once_with(
"Can not create a child span for %s. "
fake_debug.assert_called_once_with(
"Cannot create a child span for %s. "
"Please start a Sentry transaction before calling this function.",
"test_decorator.my_example_function",
)
Expand All @@ -66,14 +66,14 @@ async def test_trace_decorator_async():
@pytest.mark.asyncio
async def test_trace_decorator_async_no_trx():
with patch_start_tracing_child(fake_transaction_is_none=True):
with mock.patch.object(logger, "warning", mock.Mock()) as fake_warning:
with mock.patch.object(logger, "debug", mock.Mock()) as fake_debug:
result = await my_async_example_function()
fake_warning.assert_not_called()
fake_debug.assert_not_called()
assert result == "return_of_async_function"

result2 = await start_child_span_decorator(my_async_example_function)()
fake_warning.assert_called_once_with(
"Can not create a child span for %s. "
fake_debug.assert_called_once_with(
"Cannot create a child span for %s. "
"Please start a Sentry transaction before calling this function.",
"test_decorator.my_async_example_function",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/tracing/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def test_transaction_not_started_warning(sentry_init):
with tx:
pass

mock_logger.warning.assert_any_call(
mock_logger.debug.assert_any_call(
"Transaction was entered without being started with sentry_sdk.start_transaction."
"The transaction will not be sent to Sentry. To fix, start the transaction by"
"passing it to sentry_sdk.start_transaction."
Expand Down
Loading