Skip to content

fix: Count batched logs and metrics in client reports - #9530

Merged
itaybre merged 4 commits into
mainfrom
fix/client-report-item-quantity
Nov 4, 2026
Merged

itaybre merged 4 commits into
mainfrom
fix/client-report-item-quantity

Conversation

@itaybre

@itaybre itaybre commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Client reports now count every log and metric batched into a log or trace_metric envelope 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 the log_item and trace_metric categories per envelope item, which undercounted discarded telemetry. The log_byte and trace_metric_byte categories were already correct.

Quantity from the envelope item header

The transport reads the item_count from the envelope item header and uses it as the client report quantity, falling back to 1 when the header carries none. SentryEnvelopeItem exposes 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_overflow outcomes for logs and metrics, which the SDK does not record yet.

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.
@itaybre itaybre added the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Nov 3, 2026
@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Size Analysis

1 component analyzed

iOS Builds

Name Configuration Version Download Size Install Size
SDK-Size (iOS)
io.sentry.sample.SDK-Size
Release 9.32.0 (1) 1.2 MB (+89 B) 3.2 MB (0 B)

Configure sentry-cocoa status check rules

@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.32.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

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
itaybre marked this pull request as ready for review November 3, 2026 18:19
@itaybre
itaybre requested review from a team and noahsmartin as code owners November 3, 2026 18:19
@itaybre
itaybre requested review from NinjaLikesCheez and philprime and removed request for a team November 3, 2026 18:19

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM and aligned with the doc 🚀

@itaybre
itaybre enabled auto-merge (squash) November 4, 2026 14:06
@itaybre
itaybre merged commit 0bfd8a3 into main Nov 4, 2026
273 checks passed
@itaybre
itaybre deleted the fix/client-report-item-quantity branch November 4, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants