Skip to content
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
405a5c1
feat(profiling): Add Perfetto trace format support
markushi Feb 25, 2026
1687276
style(profiling): Format Perfetto module with cargo fmt
markushi Feb 25, 2026
2cbf111
fix(profiling): Remove private intra-doc link in expand_perfetto
markushi Feb 25, 2026
9ee2661
Merge remote-tracking branch 'origin/master' into feat/markushi/perfe…
markushi Feb 26, 2026
9d4693c
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Feb 26, 2026
4407d9e
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Mar 5, 2026
e67fa58
Extend profile chunk to support blob attachment via meta_length
markushi Mar 5, 2026
c4fa16e
Improve code generation script and docs
markushi Mar 10, 2026
1e6df1f
Guard perfetto processing by feature flag
markushi Mar 10, 2026
0a58b24
Address some more PR comments, add missing tests
markushi Mar 18, 2026
f729460
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Mar 19, 2026
685ec0a
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Mar 23, 2026
49f3bd9
feat(profiling): Use separate intern tables per Perfetto field and in…
markushi Mar 23, 2026
5c6e457
fix(profiling): Fix clippy lint and add changelog entry
markushi Mar 23, 2026
2f78475
fix(profiling): Apply first timestamp delta in StreamingProfilePacket
markushi Mar 27, 2026
6e5f11c
fix(profiling): Resolve thread ID for StreamingProfilePacket via Trac…
markushi Apr 1, 2026
06467d1
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Apr 1, 2026
253120d
fix(profiling): Resolve Perfetto samples eagerly to survive increment…
markushi Apr 1, 2026
ff63cc3
fix(profiling): Avoid redundant full JSON parse to extract content_type
markushi Apr 1, 2026
1c1dad6
fix(profiling): Check content_type before calling expand_perfetto
markushi Apr 1, 2026
1e14dc6
fix(profiling): Read content_type from metadata and remove dead write
markushi Apr 1, 2026
b2f35cb
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Apr 1, 2026
a58ed23
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Apr 3, 2026
6e8987b
Address PR feedback
markushi Apr 15, 2026
b105db6
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Apr 15, 2026
f3f0496
Add e2e tests, remove packets which weren't need for Android profiling
markushi Apr 28, 2026
e1c0bac
Ensure profile meta data is not dropped
markushi Apr 28, 2026
34acd48
Fix lint errors
markushi Apr 28, 2026
7238762
Address PR feedback
markushi Apr 29, 2026
8899544
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Apr 30, 2026
db555e6
Update Changelog
markushi Apr 30, 2026
75b8fee
Simplify python tests, don't overwrite timeouts
markushi May 8, 2026
ad44bf3
Make comments doc friendly
markushi May 8, 2026
338c601
Improve ownership handling, introduce helper function for intern_strings
markushi May 8, 2026
afb382f
Use uuid::Uuid::from_bytes_le, avoid uncessary hex/string roundtrip
markushi May 8, 2026
0990673
Apply style suggestions
markushi May 8, 2026
aecdb7c
Add doc for new pub struct DebugImage
markushi May 8, 2026
ac8dc49
Fix unneeded rename
markushi May 8, 2026
9945807
Merge branch 'master' into feat/markushi/perfetto-profiling-support
markushi Jun 1, 2026
d057317
Fix Changelog
markushi Jun 3, 2026
b46f029
Merge branch 'master' into feat/markushi/perfetto-profiling-support
jjbayer Jun 9, 2026
d34106a
fix: Manually parse trace packets
jjbayer Jun 11, 2026
a6fd768
comment
jjbayer Jun 11, 2026
c5ae574
keep optional optional
jjbayer Jun 11, 2026
bef7f17
lint
jjbayer Jun 11, 2026
dd8d044
restore local unwrap_or
jjbayer Jun 11, 2026
be742c9
Merge branch 'master' into feat/markushi/perfetto-profiling-support
jjbayer Jun 11, 2026
5fd1156
fix: upper bound for frame_ids
jjbayer Jun 11, 2026
bef7314
bound on path segments
jjbayer Jun 11, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

**Features**:

- Add Perfetto trace format support for continuous profiling. ([#5659](https://github.com/getsentry/relay/pull/5659))
- Add metadata support for the `/upload` endpoint. ([#6028](https://github.com/getsentry/relay/pull/6028))
- Infer user agents and client addresses in the V2 standalone span pipeline. ([#6047](https://github.com/getsentry/relay/pull/6047))
- Conditionally allow additional exceptions on minidumps. ([#6063](https://github.com/getsentry/relay/pull/6063))
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4770,6 +4770,7 @@ dependencies = [
"hashbrown 0.15.5",
"insta",
"itertools 0.14.0",
"prost 0.14.3",
"relay-base-schema",
"relay-dynamic-config",
"relay-event-schema",
Expand Down
22 changes: 22 additions & 0 deletions relay-dynamic-config/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ pub enum Feature {
/// Serialized as `organizations:continuous-profiling`.
#[serde(rename = "organizations:continuous-profiling")]
ContinuousProfiling,
/// Enable Perfetto binary trace processing for continuous profiling.
///
/// When enabled, compound profile chunk items with `content_type: "perfetto"` are
/// expanded from binary Perfetto format into the Sample v2 JSON format.
///
/// Serialized as `organizations:continuous-profiling-perfetto`.
#[serde(rename = "organizations:continuous-profiling-perfetto")]
ContinuousProfilingPerfetto,
Comment thread
jjbayer marked this conversation as resolved.
/// Enable log ingestion for our log product (this is not internal logging).
///
/// Serialized as `organizations:ourlogs-ingestion`.
Expand Down Expand Up @@ -201,4 +209,18 @@ mod tests {
r#"["organizations:session-replay"]"#
);
}

#[test]
fn test_continuous_profiling_perfetto_serde() {
// Verify the serialized name matches what Sentry's backend sends.
let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
assert_eq!(
serialized,
r#""organizations:continuous-profiling-perfetto""#
);

let deserialized: Feature =
serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
}
}
1 change: 1 addition & 0 deletions relay-profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ chrono = { workspace = true }
data-encoding = { workspace = true }
hashbrown = { workspace = true }
itertools = { workspace = true }
prost = { workspace = true }
relay-base-schema = { workspace = true }
relay-dynamic-config = { workspace = true }
relay-event-schema = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions relay-profiling/protos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Perfetto Proto Definitions

`perfetto_trace.proto` contains a minimal subset of the
[Perfetto trace proto definitions](https://github.com/google/perfetto/tree/master/protos/perfetto/trace)
needed to decode profiling data. Field numbers match the upstream definitions.

The generated Rust code is checked in at `../src/perfetto/proto.rs`.

## Regenerating

Prerequisites:
- `protoc`: https://github.com/protocolbuffers/protobuf/releases (or `brew install protobuf`)
- `protoc-gen-prost`: `cargo install protoc-gen-prost`

Then run:
```sh
./relay-profiling/protos/generate.sh
```
59 changes: 59 additions & 0 deletions relay-profiling/protos/generate.sh
Comment thread
jjbayer marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#
# Regenerates the checked-in Rust protobuf bindings for Perfetto trace types
# using protoc with the protoc-gen-prost plugin.
#
# Usage:
# ./relay-profiling/protos/generate.sh

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROTO_FILE="$SCRIPT_DIR/perfetto_trace.proto"
OUTPUT_FILE="$SCRIPT_DIR/../src/perfetto/proto.rs"

if ! command -v protoc &>/dev/null; then
echo "error: protoc is not installed." >&2
echo " Install it from https://github.com/protocolbuffers/protobuf/releases" >&2
echo " or: brew install protobuf" >&2
exit 1
fi
echo "Using protoc: $(command -v protoc) ($(protoc --version))"

if ! command -v protoc-gen-prost &>/dev/null; then
echo "error: protoc-gen-prost is not installed." >&2
echo " Install it with: cargo install protoc-gen-prost" >&2
exit 1
fi
echo "Using protoc-gen-prost: $(command -v protoc-gen-prost)"

if [[ ! -f "$PROTO_FILE" ]]; then
echo "error: proto file not found at $PROTO_FILE" >&2
exit 1
fi

TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT

echo "Generating Rust bindings..."
protoc \
--prost_out="$TMPDIR" \
--proto_path="$SCRIPT_DIR" \
"$PROTO_FILE"

# protoc-gen-prost mirrors the proto package path in the output directory.
GENERATED=$(find "$TMPDIR" -name '*.rs' -type f | head -1)

if [[ -z "$GENERATED" || ! -f "$GENERATED" ]]; then
echo "error: no generated .rs file found in $TMPDIR" >&2
exit 1
fi

if [[ ! -s "$GENERATED" ]]; then
echo "error: generated file is empty" >&2
exit 1
fi

cp "$GENERATED" "$OUTPUT_FILE"
echo "Updated $OUTPUT_FILE"
echo "Done."
88 changes: 88 additions & 0 deletions relay-profiling/protos/perfetto_trace.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Minimal subset of the Perfetto trace proto definitions needed to decode
// profiling data. Field numbers match the upstream definitions at
// https://github.com/google/perfetto/tree/master/protos/perfetto/trace

syntax = "proto2";
package perfetto.protos;

message Trace {
repeated TracePacket packet = 1;
}

message TracePacket {
optional uint64 timestamp = 8;

oneof optional_trusted_packet_sequence_id {
uint32 trusted_packet_sequence_id = 10;
}

optional InternedData interned_data = 12;
optional uint32 sequence_flags = 13;

// Only the oneof variants we care about; prost will skip the rest.
oneof data {
ClockSnapshot clock_snapshot = 6;
PerfSample perf_sample = 66;
}
}

// --- clock sync ---------------------------------------------------------------

message ClockSnapshot {
message Clock {
optional uint32 clock_id = 1;
optional uint64 timestamp = 2;
}
repeated Clock clocks = 1;
optional uint32 primary_trace_clock = 2;
}

// --- interned data -----------------------------------------------------------

message InternedData {
repeated InternedString function_names = 5;
repeated Frame frames = 6;
repeated Callstack callstacks = 7;
repeated InternedString build_ids = 16;
repeated InternedString mapping_paths = 17;
repeated Mapping mappings = 19;
}

message InternedString {
optional uint64 iid = 1;
optional bytes str = 2;
}

// --- profiling common --------------------------------------------------------

message Frame {
optional uint64 iid = 1;
optional uint64 function_name_id = 2;
optional uint64 mapping_id = 3;
optional uint64 rel_pc = 4;
}

message Mapping {
optional uint64 iid = 1;
optional uint64 build_id = 2;
optional uint64 start_offset = 3;
optional uint64 start = 4;
optional uint64 end = 5;
optional uint64 load_bias = 6;
repeated uint64 path_string_ids = 7;
optional uint64 exact_offset = 8;
}

message Callstack {
optional uint64 iid = 1;
repeated uint64 frame_ids = 2;
}

// --- profiling packets -------------------------------------------------------

message PerfSample {
optional uint32 cpu = 1;
optional uint32 pid = 2;
optional uint32 tid = 3;
optional uint64 callstack_iid = 4;
}
29 changes: 17 additions & 12 deletions relay-profiling/src/debug_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,45 @@ use uuid::{Error as UuidError, Uuid};

use crate::utils;

/// The type of a debug image.
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(rename_all = "lowercase")]
enum ImageType {
pub enum ImageType {
Comment thread
markushi marked this conversation as resolved.
MachO,
Symbolic,
Sourcemap,
Proguard,
Jvm,
}

/// A debug information image referenced by a profile.
Comment thread
sentry[bot] marked this conversation as resolved.
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct DebugImage {
/// Path or name of the code file (e.g. shared library or executable).
#[serde(skip_serializing_if = "Option::is_none", alias = "name")]
code_file: Option<NativeImagePath>,
pub code_file: Option<NativeImagePath>,
/// Debug identifier for symbolication.
#[serde(skip_serializing_if = "Option::is_none", alias = "id")]
debug_id: Option<DebugId>,
pub debug_id: Option<DebugId>,
/// The type of debug image (e.g. `symbolic`, `proguard`).
#[serde(rename = "type")]
image_type: ImageType,

pub image_type: ImageType,
/// Start address of the image in virtual memory.
#[serde(skip_serializing_if = "Option::is_none")]
image_addr: Option<Addr>,

pub image_addr: Option<Addr>,
/// Preferred load address of the image in virtual memory.
#[serde(skip_serializing_if = "Option::is_none")]
image_vmaddr: Option<Addr>,

pub image_vmaddr: Option<Addr>,
/// Size of the image in bytes.
#[serde(
default,
deserialize_with = "utils::deserialize_number_from_string",
skip_serializing_if = "utils::is_zero"
)]
image_size: u64,

pub image_size: u64,
/// Optional UUID, used as the build ID for proguard images.
#[serde(skip_serializing_if = "Option::is_none", alias = "build_id")]
uuid: Option<Uuid>,
pub uuid: Option<Uuid>,
}

pub fn get_proguard_image(uuid: &str) -> Result<DebugImage, UuidError> {
Expand Down
Loading
Loading