Skip to content

Commit d7a32bb

Browse files
authored
fix(profiling): keep frame-level platform information when available in mixed stack traces (#68694)
Way back we added [frame-level](https://github.com/getsentry/vroom/blob/main/internal/frame/frame.go#L42) platform information in `vroom`, but we're not passing this information down from `sentry`. This will help us to distinguish between `js` and `cocoa` frames in mixed stack traces scenarios (such as for react-native).
1 parent 96c3939 commit d7a32bb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/sentry/profiles/task.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ def process_profile_task(
148148
if not _normalize_profile(profile, organization, project):
149149
return
150150

151+
# set platform information at frame-level
152+
# only for those platforms that didn't go through symbolication
153+
_set_frames_platform(profile)
154+
151155
if "version" in profile:
152156
set_measurement("profile.samples.processed", len(profile["profile"]["samples"]))
153157
set_measurement("profile.stacks.processed", len(profile["profile"]["stacks"]))
@@ -637,7 +641,9 @@ def truncate_stack_needed(
637641
# This works since symbolicated_frames are in the same order
638642
# as raw_frames (except some frames are not sent).
639643
for frame_idx in symbolicated_frames_dict[symbolicated_frame_idx]:
640-
new_frames.append(symbolicated_frames[frame_idx])
644+
f = symbolicated_frames[frame_idx]
645+
f["platform"] = platform
646+
new_frames.append(f)
641647

642648
# go to the next symbolicated frame result
643649
symbolicated_frame_idx += 1
@@ -1115,3 +1121,17 @@ def _calculate_duration_for_sample_format_v2(profile: Profile) -> int:
11151121

11161122
def _calculate_duration_for_android_format(profile: Profile) -> int:
11171123
return int(profile["duration_ns"] * 1e-6)
1124+
1125+
1126+
def _set_frames_platform(profile: Profile):
1127+
if "version" in profile:
1128+
platform = profile["platform"]
1129+
if platform in ["javascript", "node", "cocoa"]:
1130+
# bail early because it was already set
1131+
return
1132+
for i, _ in enumerate(profile["profile"]["frames"]):
1133+
profile["profile"]["frames"]["platform"] = platform
1134+
return
1135+
elif profile["platform"] == "android":
1136+
for i, _ in enumerate(profile["profile"]["methods"]):
1137+
profile["profile"]["methods"][i] = "android"

0 commit comments

Comments
 (0)