Skip to content

Commit b4c5637

Browse files
authored
fix(profiling): Defaul in_app decision to None (#1855)
Currently, the SDK marks all frames as in_app when it can't find any in_app frames. As we try to move some of this detection server side, we still want to allow the end user to overwrite the decision client side. So we'll leave in_app as `None` to indicate the server should decide of the frame is in_app.
1 parent 1eadbd2 commit b4c5637

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

sentry_sdk/profiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,10 @@ def to_json(self, event_opt, options):
449449
profile = self.process()
450450

451451
handle_in_app_impl(
452-
profile["frames"], options["in_app_exclude"], options["in_app_include"]
452+
profile["frames"],
453+
options["in_app_exclude"],
454+
options["in_app_include"],
455+
default_in_app=False, # Do not default a frame to `in_app: True`
453456
)
454457

455458
return {

sentry_sdk/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,8 @@ def handle_in_app(event, in_app_exclude=None, in_app_include=None):
773773
return event
774774

775775

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

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

798-
if not any_in_app:
798+
if default_in_app and not any_in_app:
799799
for frame in frames:
800800
if frame.get("in_app") is None:
801801
frame["in_app"] = True

tests/utils/test_general.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ def test_in_app(empty):
154154
) == [{"module": "foo", "in_app": False}, {"module": "bar", "in_app": True}]
155155

156156

157+
def test_default_in_app():
158+
assert handle_in_app_impl(
159+
[{"module": "foo"}, {"module": "bar"}], in_app_include=None, in_app_exclude=None
160+
) == [
161+
{"module": "foo", "in_app": True},
162+
{"module": "bar", "in_app": True},
163+
]
164+
165+
assert handle_in_app_impl(
166+
[{"module": "foo"}, {"module": "bar"}],
167+
in_app_include=None,
168+
in_app_exclude=None,
169+
default_in_app=False,
170+
) == [{"module": "foo"}, {"module": "bar"}]
171+
172+
157173
def test_iter_stacktraces():
158174
assert set(
159175
iter_event_stacktraces(

0 commit comments

Comments
 (0)