Skip to content

feat(profiling): Add Perfetto trace format support#5659

Draft
markushi wants to merge 5 commits intomasterfrom
feat/markushi/perfetto-profiling-support
Draft

feat(profiling): Add Perfetto trace format support#5659
markushi wants to merge 5 commits intomasterfrom
feat/markushi/perfetto-profiling-support

Conversation

@markushi
Copy link
Member

Add support for ingesting binary Perfetto traces (.pftrace) as profile chunks. This enables Android SDKs to send native CPU profiling data captured via Perfetto's perf_event_open and in-process stack sampling mechanisms.

The SDK sends an envelope with a ProfileChunk metadata item paired with a new ProfileChunkData item containing the raw Perfetto protobuf. Relay decodes the trace, extracts CPU profiling samples (PerfSample and StreamingProfilePacket), converts them to the internal Sample v2 format, and forwards both the expanded JSON and the original binary blob to Kafka for downstream processing by Snuba/Vroom.

Key changes:

  • New perfetto module in relay-profiling for protobuf decoding and conversion to Sample v2, handling interned strings, callstacks, mappings, and clock synchronization
  • New ProfileChunkData envelope item type for binary profile payloads
  • Pairing logic in profile chunk processing to associate metadata with binary data items
  • Raw profile blob preserved through to the Kafka message for further processing downstream
  • New error variants and discard reasons for Perfetto-specific failures

markushi and others added 5 commits February 25, 2026 09:16
Add support for ingesting binary Perfetto traces (.pftrace) as profile
chunks. The SDK sends an envelope with a ProfileChunk metadata item
paired with a ProfileChunkData item containing the raw Perfetto protobuf.

Relay decodes the Perfetto trace, extracts CPU profiling samples
(PerfSample and StreamingProfilePacket), converts them to the internal
Sample v2 format, and forwards both the expanded JSON and the original
binary blob to Kafka for downstream processing.

Key changes:
- New `perfetto` module in relay-profiling for protobuf decoding and
  conversion to Sample v2
- New `ProfileChunkData` envelope item type for binary profile payloads
- Pairing logic to associate ProfileChunk metadata with ProfileChunkData
- Raw profile blob preserved through to Kafka for further processing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	relay-server/src/envelope/item.rs
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.

1 participant