Skip to content

fix(profiling): Fix accidentally correct Android profile chunk parsing - #6183

Merged
0xadam-brown merged 3 commits into
masterfrom
fix/v2-android-trace-version
Jul 27, 2026
Merged

fix(profiling): Fix accidentally correct Android profile chunk parsing#6183
0xadam-brown merged 3 commits into
masterfrom
fix/v2-android-trace-version

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Jul 6, 2026

Copy link
Copy Markdown
Member

Overview

Fixes logic for handling Android profile chunks that pass through AndroidOrV2ProfileChunk::parse (viz., Android trace profiles and Android ANR profiles). Prior to this PR, the ::parse implementation worked only because it had been tailored to the quirks of existing Android trace + ANR profiles. But that special-casing will break once the updates to ANR billing under JAVA-548 are complete.

This PR anticipates JAVA-548 by:

  1. routing Android trace profile chunks by their payload shape, and allowing all ANR profiles to (rightly) be parsed as V2ProfileChunk's; and

  2. parsing + serializing Android trace chunks with a new 2.android-trace version so downstream consumers can distinguish them from sample v2 chunks.

Note: we now reject v1 and version-less Android trace profile chunks. Sentry's Android SDK implementation suggests they were always unwanted, but this PR makes that explicit. (But see the comment here.)

JAVA-634

⚠️ Callouts

[1] See my comment here.

[2] I don't plan to update our profiling docs.

Those docs don't mention the already special-cased Android trace payloads currently sent under version: 2. I'm assuming that means we're deliberately not advertising them. (This PR now lets those profiles be marked as version: 2.android-trace, but the payloads otherwise remain the same.)

Let me know if I'm wrong about that^^, and I can update the docs to discuss Android trace payloads + 2.android-trace.

Discussed with @Dav1dde offline, and we decided to update the docs on the assumption that they were simply overlooked when Android special-casing was introduced. I'll post a follow-on PR in the sentry-docs repo.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Comment thread relay-profiling/src/profile_chunk.rs Outdated
// Destination type: V2ProfileChunk

// First handle Android trace profiles...
(_, true) => AndroidProfileChunk::parse(data)

This comment was marked as duplicate.

@0xadam-brown
0xadam-brown requested a review from markushi July 6, 2026 20:22
@0xadam-brown 0xadam-brown changed the title fix(profiling): Fix accidentally correct Android profile_chunk parsing fix(profiling): Fix accidentally correct Android profile chunk parsing Jul 6, 2026
Fixes logic for parsing Android profile chunks that pass through AndroidOrV2ProfileChunk::parse (viz., Android trace profiles and Android ANR profiles). Prior to this commit, the ::parse implementation worked only because it had been tailored to the quirks of existing Android trace + ANR profiles. But that special-casing will break once the updates to ANR billing under [JAVA-548](https://linear.app/getsentry/issue/JAVA-548/bill-anr-profiles-as-ui-profile-hours-instead-of-continuous-profile0) are complete.

Commit anticipates JAVA-548 by:

 1. routing Android trace profile chunks by their payload shape, and allowing all ANR profiles to (rightly) be parsed as V2ProfileChunk's; and

 2. parsing + serializing Android trace chunks with a new 2.android-trace version so downstream consumers can distinguish them from sample-format v2 chunks.

Note: we now reject v1 and versionless Android trace profile chunks. They were always unwanted (and never existed in our reference Android SDK implementation); this commit makes that explicit.

Co-Authored-By: Codex <noreply@openai.com>
@0xadam-brown
0xadam-brown force-pushed the fix/v2-android-trace-version branch from c60d4b0 to 17415a2 Compare July 24, 2026 14:25
Comment thread relay-profiling/src/profile_chunk.rs Outdated
sample::Version::V2 => V2ProfileChunk::parse(data).map(Box::new).map(Self::V2),
sample::Version::V2AndroidTrace
| sample::Version::V1
| sample::Version::Unknown => Err(ProfileError::PlatformNotSupported),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

⚠️ Note that we previously mapped any chunks with the "android" platform to AndroidProfileChunk. Now we do so only if is_android_trace_profile is true.

My research here indicates the new (and narrower) approach works well with Sentry's own SDK implementations:

Relay profile types - boxed

But what about non-Sentry implementations? Do we want to support anyone who might be relying on Relay's existing approach of parsing anything with an "android" platform as AndroidProfileChunk? We could easily do so by including a if (platform == android) => AndroidProfileChunk::parse(data) fallback after the (sample::Version::V2, _) check.

I've omitted the fallback because it requires extra explanation to understand what's going on + it'd leave a live code path "just in case", and I assumed we probably don't want to support speculative use cases. (I've added a callout in the CHANGELOG instead.)

Chime in if you think otherwise and I can easily include that fallback....


Note: all values that currently pass through AndroidOrV2ProfileChunk::parse are covered by the red box in the table above. (The "cocoa" platform is representative of all non-Android platforms.) W/r/t any previous Sentry SDK implementations, my LLM confirmed that this PR can handle all historical profile types that i) would currently be routed through AndroidOrV2ProfileChunk::parse and ii) should be mapped to AndroidProfileChunk.

@0xadam-brown
0xadam-brown marked this pull request as ready for review July 24, 2026 15:03
@0xadam-brown
0xadam-brown requested a review from a team as a code owner July 24, 2026 15:03
0xadam-brown added a commit to getsentry/sentry-java that referenced this pull request Jul 24, 2026
Commit updates the platform used with ANR profiles from Java to Android so that we can properly bill ANR profiling under UI Profile Hours rather than Continuous Profile Hours.

Depends on the updates made in [Relay #6183](getsentry/relay#6183), [getsentry #118849](getsentry/sentry#118849), [vroomrs #93](getsentry/vroomrs#93), and [vroom #672](getsentry/vroom#672).
Comment thread relay-profiling/src/profile_chunk.rs
Comment thread relay-profiling/src/profile_chunk.rs
Comment thread relay-profiling/src/profile_chunk.rs Outdated
Comment thread relay-profiling/src/profile_chunk.rs Outdated
Comment thread relay-profiling/src/profile_chunk.rs Outdated
Comment thread relay-profiling/src/profile_chunk.rs Outdated
Comment thread relay-profiling/src/android/chunk.rs
@0xadam-brown
0xadam-brown added this pull request to the merge queue Jul 27, 2026
Merged via the queue into master with commit 9474426 Jul 27, 2026
37 checks passed
@0xadam-brown
0xadam-brown deleted the fix/v2-android-trace-version branch July 27, 2026 12:16
0xadam-brown added a commit to getsentry/sentry-java that referenced this pull request Jul 28, 2026
Commit updates the platform used with ANR profiles from Java to Android so that we can properly bill ANR profiling under UI Profile Hours rather than Continuous Profile Hours.

Depends on the updates made in [Relay #6183](getsentry/relay#6183), [getsentry #118849](getsentry/sentry#118849), [vroomrs #93](getsentry/vroomrs#93), and [vroom #672](getsentry/vroom#672).

# Conflicts:
#	CHANGELOG.md
0xadam-brown added a commit to getsentry/sentry-java that referenced this pull request Jul 28, 2026
Commit updates the platform used with ANR profiles from Java to Android so that we can properly bill ANR profiling under UI Profile Hours rather than Continuous Profile Hours.

Depends on the updates made in [Relay #6183](getsentry/relay#6183), [getsentry #118849](getsentry/sentry#118849), [vroomrs #93](getsentry/vroomrs#93), and [vroom #672](getsentry/vroom#672).

# Conflicts:
#	CHANGELOG.md
0xadam-brown added a commit to getsentry/sentry-java that referenced this pull request Jul 29, 2026
#5836)

Commit updates the platform used with ANR profiles from Java to Android so that we can properly bill ANR profiling under UI Profile Hours rather than Continuous Profile Hours.

Depends on the updates made in [Relay #6183](getsentry/relay#6183), [getsentry #118849](getsentry/sentry#118849), [vroomrs #93](getsentry/vroomrs#93), and [vroom #672](getsentry/vroom#672).

Co-authored-by: Markus Hintersteiner <markus.hintersteiner@sentry.io>
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.

2 participants