Skip to content
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/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _emit(self, record):
client_options=client_options,
mechanism={"type": "logging", "handled": True},
)
elif record.exc_info and record.exc_info[0] is None:
elif (record.exc_info and record.exc_info[0] is None) or record.stack_info:
event = {}
hint = {}
with capture_internal_exceptions():
Expand Down
11 changes: 9 additions & 2 deletions tests/integrations/logging/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ def test_logging_extra_data_integer_keys(sentry_init, capture_events):
assert event["extra"] == {"1": 1}


def test_logging_stack(sentry_init, capture_events):
@pytest.mark.parametrize(
"enable_stack_trace_kwarg",
(
pytest.param({"exc_info": True}, id="exc_info"),
pytest.param({"stack_info": True}, id="stack_info"),
),
)
def test_logging_stack_trace(sentry_init, capture_events, enable_stack_trace_kwarg):
sentry_init(integrations=[LoggingIntegration()], default_integrations=False)
events = capture_events()

logger.error("first", exc_info=True)
logger.error("first", **enable_stack_trace_kwarg)
logger.error("second")

(
Expand Down
Loading