fix(profiling): Fix accidentally correct Android profile chunk parsing - #6183
Conversation
| // Destination type: V2ProfileChunk | ||
|
|
||
| // First handle Android trace profiles... | ||
| (_, true) => AndroidProfileChunk::parse(data) |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
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>
c60d4b0 to
17415a2
Compare
| sample::Version::V2 => V2ProfileChunk::parse(data).map(Box::new).map(Self::V2), | ||
| sample::Version::V2AndroidTrace | ||
| | sample::Version::V1 | ||
| | sample::Version::Unknown => Err(ProfileError::PlatformNotSupported), |
There was a problem hiding this comment.
is_android_trace_profile is true.
My research here indicates the new (and narrower) approach works well with Sentry's own SDK implementations:
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.
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).
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
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
#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>
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:
routing Android trace profile chunks by their payload shape, and allowing all ANR profiles to (rightly) be parsed as V2ProfileChunk's; and
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
[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 underversion: 2. I'm assuming that means we're deliberately not advertising them. (This PR now lets those profiles be marked asversion: 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.