Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions relay-profiling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,23 +405,21 @@ impl Getter for ExpandedPerfettoChunk {

/// Expands a binary Perfetto trace into a Sample v2 profile chunk.
///
/// Decodes the protobuf trace, converts it into the internal Sample v2 format,
/// merges the provided JSON `metadata_json` (containing platform, environment, etc.),
/// and returns an [`ExpandedPerfettoChunk`] with the serialized JSON payload plus
/// Returns an [`ExpandedPerfettoChunk`] with the serialized JSON payload plus
/// the profile metadata needed for downstream processing (platform, profile type,
/// inbound filtering) — avoiding a second JSON deserialization pass in callers.
pub fn expand_perfetto(
perfetto_bytes: &[u8],
metadata_json: &[u8],
perfetto_payload: &[u8],
json_payload: &[u8],
) -> Result<ExpandedPerfettoChunk, ProfileError> {
let d = &mut Deserializer::from_slice(metadata_json);
let d = &mut Deserializer::from_slice(json_payload);
let mut chunk: sample::v2::ProfileChunk =
serde_path_to_error::deserialize(d).map_err(ProfileError::InvalidJson)?;

let platform = chunk.metadata.platform.clone();
let release = chunk.metadata.release.clone();

let (profile_data, debug_images) = perfetto::convert(perfetto_bytes)?;
let (profile_data, debug_images) = perfetto::convert(perfetto_payload)?;
chunk.profile = profile_data;
chunk.metadata.debug_meta.images.extend(debug_images);
chunk.normalize()?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"event_id":"c3b09c0608844f558eaf6e65df6b9cdf","sdk":{"name":"sentry.java.android","version":"8.38.0","packages":[{"name":"maven:io.sentry:sentry","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-core","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-fragment","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-timber","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-replay","version":"8.38.0"},{"name":"maven:io.sentry:sentry-spotlight","version":"8.38.0"},{"name":"maven:io.sentry:sentry-compose","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-ndk","version":"8.38.0"}],"integrations":["Screenshot","ViewHierarchy","UncaughtExceptionHandler","ShutdownHook","Spotlight","SendCachedEnvelope","Ndk","Tombstone","AppLifecycle","AnrV2","AnrProfiling","ActivityLifecycle","ActivityBreadcrumbs","UserInteraction","FeedbackShake","FragmentLifecycle","Timber","AppComponentsBreadcrumbs","NetworkBreadcrumbs","AutoInit","EnvelopeFileObserver","SystemEventsBreadcrumbs"]}}
{"content_type":"application/octet-stream","filename":"profile_sentry-profiling_2026-04-28-08-33-40.perfetto-stack-sample","type":"profile_chunk","platform":"android","meta_length":7739,"length":104991}
{"content_type":"application/x-perfetto-trace","filename":"profile_sentry-profiling_2026-04-28-08-33-40.perfetto-stack-sample","type":"profile_chunk","platform":"android","meta_length":7739,"length":104991}
{"profiler_id":"814b081c638b4ad982ae351547bfe499","chunk_id":"c3b09c0608844f558eaf6e65df6b9cdf","client_sdk":{"name":"sentry.java.android","version":"8.38.0","packages":[{"name":"maven:io.sentry:sentry","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-core","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-fragment","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-timber","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-replay","version":"8.38.0"},{"name":"maven:io.sentry:sentry-spotlight","version":"8.38.0"},{"name":"maven:io.sentry:sentry-compose","version":"8.38.0"},{"name":"maven:io.sentry:sentry-android-ndk","version":"8.38.0"}],"integrations":["Screenshot","ViewHierarchy","UncaughtExceptionHandler","ShutdownHook","Spotlight","SendCachedEnvelope","Ndk","Tombstone","AppLifecycle","AnrV2","AnrProfiling","ActivityLifecycle","ActivityBreadcrumbs","UserInteraction","FeedbackShake","FragmentLifecycle","Timber","AppComponentsBreadcrumbs","NetworkBreadcrumbs","AutoInit","EnvelopeFileObserver","SystemEventsBreadcrumbs"]},"measurements":{"memory_native_footprint":{"unit":"byte","values":[{"value":3.6631152E7,"elapsed_since_start_ns":"1777358020895000000","timestamp":1777358020.895000},{"value":3.6636E7,"elapsed_since_start_ns":"1777358020994000000","timestamp":1777358020.994000},{"value":3.6598336E7,"elapsed_since_start_ns":"1777358021094000000","timestamp":1777358021.094000},{"value":3.6600496E7,"elapsed_since_start_ns":"1777358021194000000","timestamp":1777358021.193999},{"value":3.6601984E7,"elapsed_since_start_ns":"1777358021294000000","timestamp":1777358021.294000},{"value":3.6604128E7,"elapsed_since_start_ns":"1777358021394000000","timestamp":1777358021.393999},{"value":3.6606272E7,"elapsed_since_start_ns":"1777358021494000000","timestamp":1777358021.494000},{"value":3.6608416E7,"elapsed_since_start_ns":"1777358021594000000","timestamp":1777358021.593999},{"value":3.6614672E7,"elapsed_since_start_ns":"1777358021695000000","timestamp":1777358021.695000},{"value":3.6616816E7,"elapsed_since_start_ns":"1777358021794000000","timestamp":1777358021.794000},{"value":3.661896E7,"elapsed_since_start_ns":"1777358021894000000","timestamp":1777358021.894000},{"value":3.6621104E7,"elapsed_since_start_ns":"1777358021995000000","timestamp":1777358021.995000},{"value":3.6623248E7,"elapsed_since_start_ns":"1777358022094000000","timestamp":1777358022.094000},{"value":3.6625392E7,"elapsed_since_start_ns":"1777358022194000000","timestamp":1777358022.193999},{"value":3.6627536E7,"elapsed_since_start_ns":"1777358022294000000","timestamp":1777358022.294000},{"value":3.662968E7,"elapsed_since_start_ns":"1777358022394000000","timestamp":1777358022.393999},{"value":3.6631824E7,"elapsed_since_start_ns":"1777358022495000000","timestamp":1777358022.495000},{"value":3.6672752E7,"elapsed_since_start_ns":"1777358022594000000","timestamp":1777358022.593999},{"value":3.6748144E7,"elapsed_since_start_ns":"1777358022694000000","timestamp":1777358022.694000},{"value":3.6754304E7,"elapsed_since_start_ns":"1777358022794000000","timestamp":1777358022.794000}]},"frozen_frame_renders":{"unit":"nanosecond","values":[{"value":7.49833322E8,"elapsed_since_start_ns":"71057630775779","timestamp":1777358020.888000}]},"cpu_usage":{"unit":"percent","values":[{"value":56.20094079375762,"elapsed_since_start_ns":"1777358020895000000","timestamp":1777358020.895000},{"value":47.72786092177692,"elapsed_since_start_ns":"1777358020994000000","timestamp":1777358020.994000},{"value":52.289708049827254,"elapsed_since_start_ns":"1777358021094000000","timestamp":1777358021.094000},{"value":50.050196342916244,"elapsed_since_start_ns":"1777358021194000000","timestamp":1777358021.193999},{"value":52.620478795841386,"elapsed_since_start_ns":"1777358021294000000","timestamp":1777358021.294000},{"value":49.83694994597027,"elapsed_since_start_ns":"1777358021394000000","timestamp":1777358021.393999},{"value":52.61821576681683,"elapsed_since_start_ns":"1777358021494000000","timestamp":1777358021.494000},{"value":50.00733407561553,"elapsed_since_start_ns":"1777358021594000000","timestamp":1777358021.593999},{"value":52.31104830862539,"elapsed_since_start_ns":"1777358021695000000","timestamp":1777358021.695000},{"value":50.08750688152257,"elapsed_since_start_ns":"1777358021794000000","timestamp":1777358021.794000},{"value":52.61428295786996,"elapsed_since_start_ns":"1777358021894000000","timestamp":1777358021.894000},{"value":49.84011689221911,"elapsed_since_start_ns":"1777358021995000000","timestamp":1777358021.995000},{"value":50.07609463188072,"elapsed_since_start_ns":"1777358022094000000","timestamp":1777358022.094000},{"value":52.764437950744615,"elapsed_since_start_ns":"1777358022194000000","timestamp":1777358022.193999},{"value":49.7033742388127,"elapsed_since_start_ns":"1777358022294000000","timestamp":1777358022.294000},{"value":52.63426105211958,"elapsed_since_start_ns":"1777358022394000000","timestamp":1777358022.393999},{"value":49.806191656715804,"elapsed_since_start_ns":"1777358022495000000","timestamp":1777358022.495000},{"value":52.611141035437356,"elapsed_since_start_ns":"1777358022594000000","timestamp":1777358022.593999},{"value":32.55163503106803,"elapsed_since_start_ns":"1777358022694000000","timestamp":1777358022.694000},{"value":2.50511253386361,"elapsed_since_start_ns":"1777358022794000000","timestamp":1777358022.794000}]},"memory_footprint":{"unit":"byte","values":[{"value":1.18884E7,"elapsed_since_start_ns":"1777358020895000000","timestamp":1777358020.895000},{"value":1.2003504E7,"elapsed_since_start_ns":"1777358020994000000","timestamp":1777358020.994000},{"value":1.2056752E7,"elapsed_since_start_ns":"1777358021094000000","timestamp":1777358021.094000},{"value":1.211E7,"elapsed_since_start_ns":"1777358021194000000","timestamp":1777358021.193999},{"value":1.213048E7,"elapsed_since_start_ns":"1777358021294000000","timestamp":1777358021.294000},{"value":1.215096E7,"elapsed_since_start_ns":"1777358021394000000","timestamp":1777358021.393999},{"value":1.22124E7,"elapsed_since_start_ns":"1777358021494000000","timestamp":1777358021.494000},{"value":1.223288E7,"elapsed_since_start_ns":"1777358021594000000","timestamp":1777358021.593999},{"value":1.2286128E7,"elapsed_since_start_ns":"1777358021695000000","timestamp":1777358021.695000},{"value":1.2339376E7,"elapsed_since_start_ns":"1777358021794000000","timestamp":1777358021.794000},{"value":1.2359856E7,"elapsed_since_start_ns":"1777358021894000000","timestamp":1777358021.894000},{"value":1.2421296E7,"elapsed_since_start_ns":"1777358021995000000","timestamp":1777358021.995000},{"value":1.2441776E7,"elapsed_since_start_ns":"1777358022094000000","timestamp":1777358022.094000},{"value":1.2495024E7,"elapsed_since_start_ns":"1777358022194000000","timestamp":1777358022.193999},{"value":1.2515504E7,"elapsed_since_start_ns":"1777358022294000000","timestamp":1777358022.294000},{"value":1.2535984E7,"elapsed_since_start_ns":"1777358022394000000","timestamp":1777358022.393999},{"value":1.2597424E7,"elapsed_since_start_ns":"1777358022495000000","timestamp":1777358022.495000},{"value":1.2617904E7,"elapsed_since_start_ns":"1777358022594000000","timestamp":1777358022.593999},{"value":1.2892512E7,"elapsed_since_start_ns":"1777358022694000000","timestamp":1777358022.694000},{"value":1.294576E7,"elapsed_since_start_ns":"1777358022794000000","timestamp":1777358022.794000}]},"screen_frame_rates":{"unit":"hz","values":[{"value":60.000003814697266,"elapsed_since_start_ns":"71057630775779","timestamp":1777358020.888000}]}},"platform":"android","release":"io.sentry.samples.android@8.38.0+2","environment":"debug","version":"2","content_type":"perfetto","timestamp":1777358020.855000}
U2N

Expand Down
5 changes: 5 additions & 0 deletions relay-server/src/envelope/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum ContentType {
TraceAttachment,
/// `application/vnd.sentry.attachment-ref+json`
AttachmentRef,
/// `application/x-perfetto-trace`
PerfettoTrace,
Comment thread
jjbayer marked this conversation as resolved.
/// All integration content types.
Integration(Integration),
}
Expand All @@ -60,6 +62,7 @@ impl ContentType {
Self::TraceMetricContainer => "application/vnd.sentry.items.trace-metric+json",
Self::TraceAttachment => "application/vnd.sentry.trace-attachment",
Self::AttachmentRef => "application/vnd.sentry.attachment-ref+json",
Self::PerfettoTrace => "application/x-perfetto-trace",
Self::Integration(integration) => integration.as_content_type(),
}
}
Expand Down Expand Up @@ -109,6 +112,8 @@ impl ContentType {
|| ct.eq_ignore_ascii_case("application/vnd.sentry.attachment-ref")
{
Some(Self::AttachmentRef)
} else if ct.eq_ignore_ascii_case(Self::PerfettoTrace.as_str()) {
Some(Self::PerfettoTrace)
} else {
Integration::from_content_type(ct).map(Self::Integration)
}
Expand Down
Loading
Loading