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
5 changes: 4 additions & 1 deletion sentry_sdk/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ def to_json(self, event_opt, options):
profile = self.process()

handle_in_app_impl(
profile["frames"], options["in_app_exclude"], options["in_app_include"]
profile["frames"],
options["in_app_exclude"],
options["in_app_include"],
default_in_app=False, # Do not default a frame to `in_app: True`
)

return {
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ def handle_in_app(event, in_app_exclude=None, in_app_include=None):
return event


def handle_in_app_impl(frames, in_app_exclude, in_app_include):
# type: (Any, Optional[List[str]], Optional[List[str]]) -> Optional[Any]
def handle_in_app_impl(frames, in_app_exclude, in_app_include, default_in_app=True):
# type: (Any, Optional[List[str]], Optional[List[str]], bool) -> Optional[Any]
if not frames:
return None

Expand All @@ -795,7 +795,7 @@ def handle_in_app_impl(frames, in_app_exclude, in_app_include):
elif _module_in_set(module, in_app_exclude):
frame["in_app"] = False

if not any_in_app:
if default_in_app and not any_in_app:
for frame in frames:
if frame.get("in_app") is None:
frame["in_app"] = True
Expand Down
16 changes: 16 additions & 0 deletions tests/utils/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ def test_in_app(empty):
) == [{"module": "foo", "in_app": False}, {"module": "bar", "in_app": True}]


def test_default_in_app():
assert handle_in_app_impl(
[{"module": "foo"}, {"module": "bar"}], in_app_include=None, in_app_exclude=None
) == [
{"module": "foo", "in_app": True},
{"module": "bar", "in_app": True},
]

assert handle_in_app_impl(
[{"module": "foo"}, {"module": "bar"}],
in_app_include=None,
in_app_exclude=None,
default_in_app=False,
) == [{"module": "foo"}, {"module": "bar"}]


def test_iter_stacktraces():
assert set(
iter_event_stacktraces(
Expand Down