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
1 change: 1 addition & 0 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def inner():

with Hub(Hub.current) as hub:
with hub.configure_scope() as scope:
scope.clear_breadcrumbs()
scope.add_event_processor(_make_request_processor(weak_request))

try:
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def sentry_handler(event, context, *args, **kwargs):

with hub.push_scope() as scope:
with capture_internal_exceptions():
scope.clear_breadcrumbs()
scope.transaction = context.function_name
scope.add_event_processor(_make_request_event_processor(event, context))

Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def _inner(*args, **kwargs):

with hub.push_scope() as scope:
scope._name = "celery"
scope.clear_breadcrumbs()
scope.add_event_processor(_make_event_processor(task, *args, **kwargs))

return f(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):
return old_perform_job(self, job, *args, **kwargs)

with hub.push_scope() as scope:
scope.clear_breadcrumbs()
scope.add_event_processor(_make_event_processor(weakref.ref(job)))
rv = old_perform_job(self, job, *args, **kwargs)

Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def sentry_handle_request(self, request, *args, **kwargs):

with Hub(hub) as hub:
with hub.configure_scope() as scope:
scope.clear_breadcrumbs()
scope.add_event_processor(_make_request_processor(weak_request))

response = old_handle_request(self, request, *args, **kwargs)
Expand Down
7 changes: 5 additions & 2 deletions sentry_sdk/integrations/serverless.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
import sys

from sentry_sdk import Hub
from sentry_sdk.hub import Hub
from sentry_sdk.utils import event_from_exception
from sentry_sdk._compat import reraise

Expand All @@ -10,7 +10,10 @@ def serverless_function(f=None, flush=True):
def wrapper(f):
@functools.wraps(f)
def inner(*args, **kwargs):
with Hub(Hub.current):
with Hub(Hub.current) as hub:
with hub.configure_scope() as scope:
scope.clear_breadcrumbs()

try:
return f(*args, **kwargs)
except Exception:
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async def sentry_execute_request_handler(self, *args, **kwargs):

with Hub(hub) as hub:
with hub.configure_scope() as scope:
scope.clear_breadcrumbs()
scope.add_event_processor(_make_event_processor(weak_handler))
return await old_execute(self, *args, **kwargs)

Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __call__(self, environ, start_response):
with hub:
with capture_internal_exceptions():
with hub.configure_scope() as scope:
scope.clear_breadcrumbs()
scope._name = "wsgi"
scope.add_event_processor(_make_wsgi_event_processor(environ))

Expand Down
8 changes: 6 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ def clear(self):
self._contexts = {} # type: Dict[str, Dict]
self._extras = {} # type: Dict[str, Any]

self._breadcrumbs = deque() # type: Deque[Dict]

self.clear_breadcrumbs()
self._should_capture = True

def clear_breadcrumbs(self):
# type: () -> None
"""Clears breadcrumb buffer."""
self._breadcrumbs = deque() # type: Deque[Dict]

def add_event_processor(self, func):
# type: (Callable) -> None
""""Register a scope local event processor on the scope.
Expand Down
7 changes: 6 additions & 1 deletion tests/integrations/pyramid/test_pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from werkzeug.test import Client

from sentry_sdk import capture_message
from sentry_sdk import capture_message, add_breadcrumb
from sentry_sdk.integrations.pyramid import PyramidIntegration


Expand Down Expand Up @@ -61,8 +61,11 @@ def test_view_exceptions(
events = capture_events()
exceptions = capture_exceptions()

add_breadcrumb({"message": "hi"})

@route("/errors")
def errors(request):
add_breadcrumb({"message": "hi2"})
1 / 0

client = get_client()
Expand All @@ -73,6 +76,8 @@ def errors(request):
assert isinstance(error, ZeroDivisionError)

event, = events
breadcrumb, = event["breadcrumbs"]
assert breadcrumb["message"] == "hi2"
assert event["exception"]["values"][0]["mechanism"]["type"] == "pyramid"


Expand Down