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
15 changes: 14 additions & 1 deletion sentry_sdk/integrations/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,24 @@ def processor(event):
with _internal_exceptions():
_set_user_info(request, event)

# TODO: user info
with _internal_exceptions():
_process_frames(event)

return processor


def _process_frames(event):
for frame in event.iter_frames():
if "in_app" in frame:
continue

module = frame.get("module")
if not module:
continue
if module == "django" or module.startswith("django."):
frame["in_app"] = False


def _got_request_exception(request=None, **kwargs):
capture_exception()

Expand Down
22 changes: 21 additions & 1 deletion sentry_sdk/integrations/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
except ImportError:
current_user = None

from flask import request
from flask import current_app, request
from flask.signals import (
appcontext_pushed,
appcontext_tearing_down,
Expand Down Expand Up @@ -56,6 +56,26 @@ def _event_processor(event):
with _internal_exceptions():
_set_user_info(event)

with _internal_exceptions():
_process_frames(event)


def _process_frames(event):
for frame in event.iter_frames():
if "in_app" in frame:
continue
module = frame.get("module")
if not module:
continue

if module == "flask" or module.startswith("flask."):
frame["in_app"] = False
elif current_app and (
module.startswith("%s." % current_app.import_name)
or module == current_app.import_name
):
frame["in_app"] = True


class FlaskRequestExtractor(RequestExtractor):
@property
Expand Down
14 changes: 13 additions & 1 deletion sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def frame_from_traceback(tb, with_locals=True):
abs_path = None
function = None
try:
module = frame.f_globals["__module__"]
module = frame.f_globals["__name__"]
except Exception:
module = None

Expand Down Expand Up @@ -354,6 +354,18 @@ def __iter__(self):
def __len__(self):
return len(self._data)

def iter_frames(self):
stacktraces = []
if "stacktrace" in self:
stacktraces.append(self["stacktrace"])
if "exception" in self:
for exception in self["exception"].get("values") or ():
if "stacktrace" in exception:
stacktraces.append(exception["stacktrace"])
for stacktrace in stacktraces:
for frame in stacktrace.get("frames") or ():
yield frame


class SkipEvent(Exception):
"""Risen from an event processor to indicate that the event should be
Expand Down