Skip to content

chore(client-reports): Add Client Report aggregator#1145

Open
szokeasaurusrex wants to merge 1 commit into
szokeasaurusrex/client-report-protocolfrom
szokeasaurusrex/client-report-aggregator
Open

chore(client-reports): Add Client Report aggregator#1145
szokeasaurusrex wants to merge 1 commit into
szokeasaurusrex/client-report-protocolfrom
szokeasaurusrex/client-report-aggregator

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Jun 9, 2026

Copy link
Copy Markdown
Member

Create a client report aggregator in sentry-core.

The aggregator lives on the EnvelopeSender next to the Transport. The EnvelopeSender itself is owned by a Client.

The aggregator is entirely lock-free. Instead of the map shape suggested by the SDK-wide client reports spec, the aggregator stores a counter for every discard reason/data category combination. There are currently 15 discard reasons and 15 data categories allowed by the spec, some of which may be inapplicable to the Rust SDK. If we implement all of these in the SDK, the aggregator will consume approximately 1.8 KiB of fixed memory per instance (15 * 15 64-bit atomic counters).

The alternative would be a HashMap keyed by (category, reason). A HashMap would consume less memory while the aggregator is empty, but recording losses would require synchronization and could allocate memory. The fixed counter array is a reasonable tradeoff for now, and we can revisit the representation if this becomes a practical concern.

Resolves #1002
Resolves RUST-154

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 66c55a9 to 2fc5269 Compare June 9, 2026 13:40
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 2569c8a to cfe64ee Compare June 9, 2026 13:40
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 2fc5269 to 6bd618a Compare June 9, 2026 14:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from cfe64ee to a71a9bd Compare June 9, 2026 14:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 6bd618a to 1f9b20f Compare June 9, 2026 14:43
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from a71a9bd to eeb5a2e Compare June 9, 2026 14:43
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 1f9b20f to a1c5872 Compare June 9, 2026 15:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from eeb5a2e to 9546535 Compare June 9, 2026 15:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from a1c5872 to 41afa32 Compare June 9, 2026 15:38
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from 38019f7 to be6bd6b Compare June 9, 2026 15:49
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from ad0ada5 to c738dd0 Compare June 9, 2026 16:02
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from be6bd6b to a23c912 Compare June 9, 2026 16:02
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from c738dd0 to ece93f5 Compare June 10, 2026 09:29
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from 03b04a4 to eb40b58 Compare June 10, 2026 09:31
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from 181f46f to dbf16e8 Compare June 10, 2026 13:52
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from 51b3812 to cebc324 Compare June 10, 2026 14:30
@szokeasaurusrex szokeasaurusrex changed the title WIP: Aggregation chore(client-reports): Add Client Report aggregator Jun 10, 2026
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

RUST-154

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from cebc324 to 65568db Compare June 10, 2026 14:59
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 10, 2026 15:00
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner June 10, 2026 15:00
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 543b2cc to 1121016 Compare June 12, 2026 10:08
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 65568db to 08adad0 Compare June 12, 2026 10:08
Comment thread sentry-core/src/client/client_reports/inner.rs
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 08adad0 to ce47300 Compare June 12, 2026 12:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 1121016 to 7360117 Compare June 12, 2026 12:37
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from cd4d502 to 2fd0c53 Compare June 12, 2026 13:41
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 37c14e9 to 66d30cb Compare June 12, 2026 15:28
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 2fd0c53 to 3f24715 Compare June 12, 2026 15:28
Create a client report aggregator in `sentry-core`.

The aggregator lives on the `EnvelopeSender` next to the `Transport`. The `EnvelopeSender` itself is owned by a `Client`.

The aggregator is entirely lock-free. Instead of the map shape suggested by the [SDK-wide client reports spec](https://develop.sentry.dev/sdk/telemetry/client-reports/#aggregation), the aggregator stores a counter for every discard reason/data category combination. There are currently [15 discard reasons](https://develop.sentry.dev/sdk/telemetry/client-reports/#discard-reasons-1) and [15 data categories](https://develop.sentry.dev/sdk/foundations/transport/rate-limiting/#definitions) allowed by the spec, some of which may be inapplicable to the Rust SDK. If we implement all of these in the SDK, the aggregator will consume approximately 1.8 KiB of fixed memory per instance (15 * 15 64-bit atomic counters).

The alternative would be a HashMap keyed by `(category, reason)`. A HashMap would consume less memory while the aggregator is empty, but recording losses would require synchronization and could allocate memory. The fixed counter array is a reasonable tradeoff for now, and we can revisit the representation if this becomes a practical concern.

Resolves [#1002](#1002)
Resolves [RUST-154](https://linear.app/getsentry/issue/RUST-154/add-shared-client-report-aggregator-and-send-client-reports-option)
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 66d30cb to d6a827e Compare June 12, 2026 15:49
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 3f24715 to 3438068 Compare June 12, 2026 15:49
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