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
8 changes: 7 additions & 1 deletion sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
DEFAULT_LEVEL = logging.INFO
DEFAULT_EVENT_LEVEL = logging.ERROR

_IGNORED_LOGGERS = set(["sentry_sdk.errors"])
# Capturing events from those loggers causes recursion errors. We cannot allow
# the user to unconditionally create events from those loggers under any
# circumstances.
#
# Note: Ignoring by logger name here is better than mucking with thread-locals.
# We do not necessarily know whether thread-locals work 100% correctly in the user's environment.
_IGNORED_LOGGERS = set(["sentry_sdk.errors", "urllib3.connectionpool"])


def ignore_logger(
Expand Down
18 changes: 18 additions & 0 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from sentry_sdk import Hub, Client, add_breadcrumb, capture_message
from sentry_sdk.transport import _parse_rate_limits
from sentry_sdk.integrations.logging import LoggingIntegration


@pytest.fixture(params=[True, False])
Expand Down Expand Up @@ -57,6 +58,23 @@ def test_transport_works(
assert any("Sending event" in record.msg for record in caplog.records) == debug


def test_transport_infinite_loop(httpserver, request):
httpserver.serve_content("ok", 200)

client = Client(
"http://foobar@{}/123".format(httpserver.url[len("http://") :]),
debug=True,
# Make sure we cannot create events from our own logging
integrations=[LoggingIntegration(event_level=logging.DEBUG)],
)

with Hub(client):
capture_message("hi")
client.flush()

assert len(httpserver.requests) == 1


NOW = datetime(2014, 6, 2)


Expand Down