Skip to content

feat(chunk): Add attachments to profile chunks#92

Closed
markushi wants to merge 3 commits into
mainfrom
feat/raw-profile-support
Closed

feat(chunk): Add attachments to profile chunks#92
markushi wants to merge 3 commits into
mainfrom
feat/raw-profile-support

Conversation

@markushi

@markushi markushi commented Jun 14, 2026

Copy link
Copy Markdown
Member

Adds a generic attachments list to profile chunks, exposed through the Python API. Each attachment references a file stored in the object store — e.g. a raw perfetto trace kept alongside the Sentry-processed chunk — with a name (file name), an optional content_type, and a stored_id:

chunk.set_attachments([vroomrs.Attachment("raw_profile.pftrace", "application/x-perfetto", "aef123345")])
chunk.get_attachments()  # -> list[Attachment]

What changed

  • New Attachment pyclass plus get_attachments / set_attachments on ProfileChunk, with matching .pyi stubs.
  • attachments is added to the sample-v2 chunk format; it is omitted from JSON when empty.
  • content_type is intentionally a free-form string for now; it is passed through and not interpreted within this repo.

Changed treatment of legacy Android profiles

Chunk-format detection is now unified: from_json_vec and from_json_vec_and_platform share a single detection path that parses the minimum profile once. A chunk is treated as a legacy Android chunk when:

platform == "android" && (version is absent || sampled_profile is present)

Two consequences:

  • Android sample-v2 chunks are no longer misrouted. An android chunk that carries a version (and no sampled_profile) is now parsed as a sample-v2 chunk instead of the legacy Android format. This is required for android sample-v2 chunks to support attachments at all.
  • Interim fix for malformed legacy profiles. Some legacy Android profiles are sent with version set to "2" even though they don't follow the sample-v2 format. The sampled_profile check keeps these routed to the legacy Android format so they still parse correctly.

Design notes for reviewers

  • Attachments are sample-v2-only: the getter returns an empty list and the setter is a no-op on legacy Android-format chunks.
  • set_attachments replaces the whole list rather than appending, so it stays idempotent if the processing task retries.

This is the writer/in-process half of the cross-repo feature; the Go read path lives in getsentry/vroom#670 and the kafka message contract in sentry-kafka-schemas. Needs a vroomrs release + pin bump in sentry once it lands.

Add a generic `attachments` list to profile chunks, exposed through the
Python API (`get_attachments` / `set_attachments` and a new `Attachment`
class). Each attachment has a `name`, an optional `content_type`, and a
`stored_id` referencing an object in the object store, e.g. a raw
perfetto trace stored alongside the processed chunk.

Attachments are supported on sample v2 chunks only: the getter returns an
empty list and the setter is a no-op on legacy Android-format chunks.
`set_attachments` replaces the whole list, keeping it idempotent on
consumer retries.

Also route android profiles that carry a version through sample-format
detection, so android sample v2 chunks are no longer misrouted to the
legacy Android format.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
markushi and others added 2 commits June 17, 2026 14:19
Remove the no-op android attachments test and document the Attachment
fields, clarifying that content_type is intentionally a free-form string
that is passed through and not interpreted within this repo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…profile

Both from_json_vec and from_json_vec_and_platform now share a single
detection path, parsing the minimum profile once per entry point. A chunk
is treated as a legacy android chunk when its platform is android and it
either has no version or still carries a sampled_profile.

The sampled_profile check is an interim fix: some legacy android profiles
are sent with version "2" even though they do not follow the sample v2
format and must still be parsed as android chunks.

Also clarify that the Attachment name is a file name (e.g.
raw_profile.pftrace).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@markushi markushi closed this Jun 18, 2026
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