Skip to content

Send Less Client Reports When Rate Limited #2370

@philipphofmann

Description

@philipphofmann

Description

The Dart SDK attaches the client report before applying the rate limit in the client.

Future<SentryId?> _attachClientReportsAndSend(SentryEnvelope envelope) {
final clientReport = _options.recorder.flush();
envelope.addClientReport(clientReport);
return _taskQueue.enqueue(
() => _options.transport.send(envelope),
SentryId.empty(),
);
}

In the http_trasnport, it then applies the rate limit

Future<SentryId?> send(SentryEnvelope envelope) async {
final filteredEnvelope = _rateLimiter.filter(envelope);
if (filteredEnvelope == null) {
return SentryId.empty();
}
filteredEnvelope.header.sentAt = _options.clock();

Because clients can assume that client reports never get rate limited (develop docs), the Dart SDK continues to send an envelope with a client report even when the SDK is fully rate-limited and should drop all envelope items. Instead, the Dart SDK should only add the client report envelope item if the envelope has items to send.

The downside of this is that when the SDK is fully rate-limited for a long time or the user drops all events in beforeSend, the SDK may never send a client report. This can be addressed by checking in the HTTP transport if the ClientReports has more than x discarded events (I guess 10 is a good start), and then send an envelope with only the client report. This is related to getsentry/sentry-cocoa#4468.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions