Skip to content

feat(protocol): Add new frame fields for metric kit flamegraphs#5539

Merged
noahsmartin merged 2 commits intomasterfrom
newFieldsHangFlamegraph
Feb 4, 2026
Merged

feat(protocol): Add new frame fields for metric kit flamegraphs#5539
noahsmartin merged 2 commits intomasterfrom
newFieldsHangFlamegraph

Conversation

@noahsmartin
Copy link
Contributor

@noahsmartin noahsmartin commented Jan 15, 2026

MetricKit provides app hang data on iOS which the cocoa SDK reports as an event. However, the stacktrace metric kit provides is really a "call stack tree" each node has a sample count and a parent. The best way to visualize it is a flamegraph, so this PR adds the relevant fields to relay allowing us to show the flamegraph on the issue detail page.

It doesn't look that useful yet because the frames are not symbolicated when I run it locally, but once this is merged I'll be able to run it on prod data with the frontend updates to see a symbolicated flamegraph:
Screenshot 2026-02-03 at 8 58 09 AM

Another way of doing this that I considered when chatting with @jan-auer was to include this in the frame data but I tried that and it didn't seem like the fields in data were preserved. This seems to work well though, and IMO is a bit cleaner than just throwing it in data.

WIP Frontend PR: getsentry/sentry#106412
WIP SDK PR: getsentry/sentry-cocoa#7185

@noahsmartin noahsmartin force-pushed the newFieldsHangFlamegraph branch from d55d573 to 3a1981c Compare January 16, 2026 01:09
@noahsmartin noahsmartin marked this pull request as ready for review February 3, 2026 17:02
@noahsmartin noahsmartin requested a review from a team as a code owner February 3, 2026 17:02
@Dav1dde Dav1dde changed the title Add new frame fields for metric kit flamegraphs feat(protocol): Add new frame fields for metric kit flamegraphs Feb 4, 2026
Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good if you can also add a small changelog message.

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should this go into FrameData: "Auxiliary information about the frame that is platform specific."

/// Auxiliary information about the frame that is platform specific.
#[metastructure(omit_from_schema)]
#[metastructure(skip_serialization = "empty")]
pub data: Annotated<FrameData>,

@jjbayer
Copy link
Member

jjbayer commented Feb 4, 2026

My previous comment might be wrong, the doc on FrameData itself mention that it should not be set by SDKs:

/// Additional frame data information.
///
/// This value is set by the server and should not be set by the SDK.

@noahsmartin noahsmartin force-pushed the newFieldsHangFlamegraph branch from 3a1981c to eb9b029 Compare February 4, 2026 16:50
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


/// The number of times this frame was sampled, used for flamegraphs provided by iOS.
#[metastructure(skip_serialization = "null")]
pub sample_count: Annotated<u64>,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frame indices break after stacktrace trimming

Medium Severity

parent_index encodes positional relationships within stacktrace.frames, but existing normalization/trimming logic can remove frames from the middle of the list. After trimming, parent_index can point at the wrong frame or a removed one, breaking MetricKit flamegraph reconstruction and potentially causing downstream consumers to error.

Fix in Cursor Fix in Web

@noahsmartin noahsmartin added this pull request to the merge queue Feb 4, 2026
Merged via the queue into master with commit 7f391c7 Feb 4, 2026
28 checks passed
@noahsmartin noahsmartin deleted the newFieldsHangFlamegraph branch February 4, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants