Skip to content

feat(client-reports): Client report protocol#1144

Open
szokeasaurusrex wants to merge 3 commits into
szokeasaurusrex/envelope-type-improvementfrom
szokeasaurusrex/client-report-protocol
Open

feat(client-reports): Client report protocol#1144
szokeasaurusrex wants to merge 3 commits into
szokeasaurusrex/envelope-type-improvementfrom
szokeasaurusrex/client-report-protocol

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Jun 9, 2026

Copy link
Copy Markdown
Member

Added the client report protocol.

Resolves #1001
Resolves RUST-153

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against d6a827e

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 7872da8 to 131cae7 Compare June 9, 2026 13:40
@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/transport-options branch from 131cae7 to 91aa345 Compare June 9, 2026 14:37
@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/transport-options branch from 91aa345 to 8ab55da Compare June 9, 2026 14:42
@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/transport-options branch from 8ab55da to 15eeea4 Compare June 9, 2026 15:08
@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/transport-options branch from 15eeea4 to ffbee4e Compare June 9, 2026 15:38
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from 41afa32 to ad0ada5 Compare June 9, 2026 15:49
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from ffbee4e to ac9351c Compare June 9, 2026 16:02
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch 2 times, most recently from c738dd0 to ece93f5 Compare June 10, 2026 09:29
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch 2 times, most recently from 9e08f3a to f8521cc Compare June 10, 2026 09:31
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from ece93f5 to 181f46f Compare June 10, 2026 09:31
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from f8521cc to 193723f Compare June 10, 2026 13:52
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 181f46f to dbf16e8 Compare June 10, 2026 13:52
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

RUST-153

Comment on lines +27 to +47
/// The reason why a telemetry item was discarded.
///
/// Valid discard reasons are listed in the [develop docs]; this enum may only define a subset of
/// these data categories, but we will add further categories as we begin using them in the SDK.
///
/// [develop docs]: https://develop.sentry.dev/sdk/telemetry/client-reports/#discard-reasons-1
#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone, Copy)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum DiscardReason {}

/// The category of data which was dropped.
///
/// Valid categories are listed in the [develop docs]; this enum may only define a subset of these
/// valid data categories, but we will add further categories as we begin using them in the SDK.
///
/// [develop docs]: https://develop.sentry.dev/sdk/foundations/transport/rate-limiting/#definitions
#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone, Copy)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum DataCategory {}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are intentionally empty right now; I am planning to add variants as needed in future PRs.

Comment thread CHANGELOG.md

- Added [`TransportFactory::create_transport_with_options`](https://docs.rs/sentry-core/latest/sentry_core/trait.TransportFactory.html#method.create_transport_with_options), which constructs transports from [`TransportOptions`](https://docs.rs/sentry-core/latest/sentry_core/struct.TransportOptions.html) instead of full [`ClientOptions`](https://docs.rs/sentry-core/latest/sentry_core/struct.ClientOptions.html) ([#1142](https://github.com/getsentry/sentry-rust/pull/1142)).
- Added transport-specific options types and `with_options` constructors for built-in HTTP transports, including `ReqwestHttpTransportOptions`, `CurlHttpTransportOptions`, `UreqHttpTransportOptions`, and `EmbeddedSVCHttpTransportOptions` ([#1142](https://github.com/getsentry/sentry-rust/pull/1142)).
- Added client report protocol types in `sentry-types`, including [`ClientReport`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/struct.ClientReport.html), [`ClientReportItem`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/struct.ClientReportItem.html), [`DataCategory`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.DataCategory.html), and [`DiscardReason`](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.DiscardReason.html), plus support for serializing [`client_report` envelope items](https://docs.rs/sentry-types/latest/sentry_types/protocol/v7/enum.EnvelopeItem.html#variant.ClientReport) ([#1144](https://github.com/getsentry/sentry-rust/pull/1144)).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These docs.rs links of course do not work yet, but should be accurate after release.

@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 10, 2026 14:31
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner June 10, 2026 14:31
Comment thread sentry-types/src/protocol/envelope.rs
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/transport-options branch from 193723f to 87946bc Compare June 12, 2026 10:08
@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/transport-options branch from 87946bc to f0916b0 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
Comment thread sentry-types/src/protocol/client_report/mod.rs Outdated
Comment thread sentry-types/src/protocol/envelope.rs
Comment thread sentry-types/src/protocol/envelope.rs
@szokeasaurusrex szokeasaurusrex changed the base branch from szokeasaurusrex/transport-options to szokeasaurusrex/envelope-type-improvement June 12, 2026 15:28
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 37c14e9 to 66d30cb Compare June 12, 2026 15:28
This will allow us to add additional construction options, either to all transports or to individual transports, in the future without breaking the public API. This will be useful in #1004, as we will need to provide transports with a handle to record data losses.

For users who use a custom transport/transport factory, this change may produce a minor behavior breakage, as the `&ClientOptions` received by the `create_transport` method (or the closure, in the case of transport factories which are just closures) will no longer contain all of the options set when init-ing the SDK, only those options which are also present in `TransportOptions`. As the API remains fully compatible, however, we are not considering this to be a public API breakage, and will release these changes in a minor/patch release.

References [#1004](#1004)
References [RUST-156](https://linear.app/getsentry/issue/RUST-156/record-transport-drops-and-attach-client-report-envelopes)
szokeasaurusrex added a commit that referenced this pull request Jun 12, 2026
This refactor should force us to make sure we add EnvelopeItemTypes corresponding to new EnvelopeItems: basically this sort of error should become impossible: #1144 (comment).
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-type-improvement branch from 4130136 to 263bcb0 Compare June 12, 2026 15:49
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/client-report-protocol branch from 66d30cb to d6a827e Compare June 12, 2026 15:49

@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 d6a827e. Configure here.

}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub(super) struct ClientReportList(Vec<ClientReportItem>);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Client report JSON nesting wrong

High Severity

ClientReportList is a single-field tuple struct around Vec<ClientReportItem> with derived Serialize/Deserialize but no #[serde(transparent)]. Serde encodes tuple structs as JSON arrays, so discarded_events becomes a nested array (e.g. [[]] or [[{...}]]) instead of the flat array the client-report protocol expects, breaking envelope serialization and deserialization against Relay and other SDKs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d6a827e. Configure here.

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