Skip to content

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

Merged
szokeasaurusrex merged 8 commits into
szokeasaurusrex/envelope-loss-itemfrom
szokeasaurusrex/client-report-aggregator
Jun 24, 2026
Merged

szokeasaurusrex merged 8 commits into
szokeasaurusrex/envelope-loss-itemfrom
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-aggregator branch from 2569c8a to cfe64ee Compare June 9, 2026 13:40
@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-aggregator branch from a71a9bd to eeb5a2e Compare June 9, 2026 14:43
@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-aggregator branch 2 times, most recently from 38019f7 to be6bd6b Compare June 9, 2026 15:49
@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-aggregator branch 2 times, most recently from 03b04a4 to eb40b58 Compare June 10, 2026 09:31
@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-aggregator branch from 65568db to 08adad0 Compare June 12, 2026 10:08
@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-aggregator branch from 5895558 to a105ff7 Compare June 19, 2026 08:46
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from c03ddbc to 3e0bd89 Compare June 19, 2026 12:08
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from 3e0bd89 to 9ce6994 Compare June 19, 2026 16:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9ce6994. Configure here.

@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from 551e44c to 74e502d Compare June 21, 2026 16:36
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch from f8d53d4 to 0858d55 Compare June 22, 2026 08:12
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from 7428f26 to 4b4e4ba Compare June 22, 2026 15:54
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/client-report-aggregator branch 2 times, most recently from e908fd1 to 498749b Compare June 23, 2026 12:36
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-aggregator branch from 498749b to b78918c Compare June 24, 2026 12:28
@szokeasaurusrex
szokeasaurusrex merged commit a7afa4c into master Jun 24, 2026
42 of 49 checks passed
@szokeasaurusrex
szokeasaurusrex deleted the szokeasaurusrex/client-report-aggregator branch June 24, 2026 12:43
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.

2 participants