Repository navigation
fix: Count batched logs and metrics in client reports - #9530
Merged
Merged
Conversation
The transport recorded a quantity of 1 for the log_item and trace_metric categories whenever a log or trace_metric envelope item was rate limited, evicted from the disk cache, or failed to send. Each of these envelope items batches many logs or metrics, so the client report undercounted the discarded telemetry. Use the item_count from the envelope item header as the quantity, and fall back to 1 when the header carries none. This follows the client report spec clarification in getsentry/sentry-docs#19854.
Size Analysis1 component analyzed iOS Builds
|
📲 Install BuildsiOS
|
Add transport tests that batch five logs and three metrics, so the recorded quantity is checked against counts that differ from the two item fixture envelopes.
itaybre
marked this pull request as ready for review
November 3, 2026 18:19
itaybre
requested review from
NinjaLikesCheez and
philprime
and removed request for
a team
November 3, 2026 18:19
antonis
approved these changes
Nov 4, 2026
antonis
left a comment
Contributor
There was a problem hiding this comment.
LGTM and aligned with the doc 🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client reports now count every log and metric batched into a
logortrace_metricenvelope item when the envelope is rate limited, evicted from the disk cache, or fails to send with a 4xx or 5xx response. The transport previously recorded a quantity of 1 for thelog_itemandtrace_metriccategories per envelope item, which undercounted discarded telemetry. Thelog_byteandtrace_metric_bytecategories were already correct.Quantity from the envelope item header
The transport reads the
item_countfrom the envelope item header and uses it as the client report quantity, falling back to 1 when the header carries none.SentryEnvelopeItemexposes the count through a new@_spi(Private)accessor so the Objective-C transport can read it. This implements the spec clarification from getsentry/sentry-docs#19854.Not covered here: the same spec update also requires
buffer_overflowoutcomes for logs and metrics, which the SDK does not record yet.