Skip to content

fix(profiling): keep frame-level platform information when available in mixed stack traces #68694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 11, 2024
22 changes: 21 additions & 1 deletion src/sentry/profiles/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def process_profile_task(
if not _normalize_profile(profile, organization, project):
return

# set platform information at frame-level
# only for those platforms that didn't go through symbolication
_set_frames_platform(profile)

if "version" in profile:
set_measurement("profile.samples.processed", len(profile["profile"]["samples"]))
set_measurement("profile.stacks.processed", len(profile["profile"]["stacks"]))
Expand Down Expand Up @@ -637,7 +641,9 @@ def truncate_stack_needed(
# This works since symbolicated_frames are in the same order
# as raw_frames (except some frames are not sent).
for frame_idx in symbolicated_frames_dict[symbolicated_frame_idx]:
new_frames.append(symbolicated_frames[frame_idx])
f = symbolicated_frames[frame_idx]
f["platform"] = platform
new_frames.append(f)

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

def _calculate_duration_for_android_format(profile: Profile) -> int:
return int(profile["duration_ns"] * 1e-6)


def _set_frames_platform(profile: Profile):
if "version" in profile:
platform = profile["platform"]
if platform in ["javascript", "node", "cocoa"]:
# bail early because it was already set
return
for i, _ in enumerate(profile["profile"]["frames"]):
profile["profile"]["frames"]["platform"] = platform
return
elif profile["platform"] == "android":
for i, _ in enumerate(profile["profile"]["methods"]):
profile["profile"]["methods"][i] = "android"
Loading