Skip to content

feat: Record log_byte client reports#8186

Merged
itaybre merged 9 commits into
getsentry:mainfrom
tsushanth:fix-trace-metric-byte-data-category
Jul 2, 2026
Merged

feat: Record log_byte client reports#8186
itaybre merged 9 commits into
getsentry:mainfrom
tsushanth:fix-trace-metric-byte-data-category

Conversation

@tsushanth

@tsushanth tsushanth commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Record the log_byte client outcome (the byte size of dropped logs) alongside the existing log_item count, so we report the volume of discarded log data as required by the client reports spec.

This covers logs dropped in the transport (rate limit, cache overflow, send errors) and by the beforeSendLog callback.

💡 Motivation and Context

Fixes #8175.

💚 How did you test it?

Added unit tests for each drop path and for the byte-size calculation, including the encoding-failure fallback.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

Adds kSentryDataCategoryLogByte (= "log_byte") as a new data category
alongside the existing kSentryDataCategoryLogItem. The byte category
tracks how many bytes of log envelope data were discarded, matching the
client-reports spec at https://develop.sentry.dev/sdk/telemetry/client-reports/

Changes:
- SentryDataCategory.h: add kSentryDataCategoryLogByte = 15; shift
  kSentryDataCategoryUnknown to 16
- SentryDataCategoryMapper.h/m: add kSentryDataCategoryNameLogByte
  constant ("log_byte") and wire it through sentryDataCategoryForString,
  nameForSentryDataCategory
- SentryHttpTransport.m: add recordLostLogBytes:reason: helper that
  records item.data.length bytes under kSentryDataCategoryLogByte; call
  it alongside the existing recordLostEvent / recordLostSpans calls in
  envelopeItemDropped:withCategory:, envelopeItemDeleted:withCategory:,
  and recordLostEventFor:
- SentryDataCategoryMapperTests.swift: extend integer, string, and
  name-to-category round-trip tests to cover kSentryDataCategoryLogByte
@NinjaLikesCheez NinjaLikesCheez added the ready-to-merge Use this label to trigger all PR workflows label Jun 25, 2026
@NinjaLikesCheez

Copy link
Copy Markdown
Member

Likewise here - thanks for your contribution! I've kicked off the CI, but would like another member of the team to verify this.

I'd also suggest stacking it on #8185 so that the 'unknown' enum is correctly incremented across the changes.

@philprime philprime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Almost LGTM, needs some alignment and a CHANGELOG entry

Comment thread Sources/Sentry/SentryHttpTransport.m

@philipphofmann philipphofmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot @tsushanth

Comment thread Sources/Sentry/SentryHttpTransport.m Outdated
Comment thread Sources/Sentry/SentryHttpTransport.m Outdated
@tsushanth
tsushanth force-pushed the fix-trace-metric-byte-data-category branch from 099c205 to 10a3c60 Compare July 1, 2026 14:13
@tsushanth

Copy link
Copy Markdown
Contributor Author

Added CHANGELOG entry under ## Unreleased > ### Features. Also noted that @NinjaLikesCheez suggested stacking this on #8185 — happy to do that if it makes review easier, just let me know.

Comment thread CHANGELOG.md Outdated
Comment thread Sources/Sentry/SentryHttpTransport.m Outdated
Comment thread Sources/Sentry/SentryHttpTransport.m Outdated
Comment thread CHANGELOG.md Outdated
Comment thread Sources/Sentry/SentryHttpTransport.m
Add HTTP transport tests for log_byte recording on the rate-limit,
cache-overflow, and send-error drop paths. Document why beforeSendLog
only records log_item.
@philipphofmann philipphofmann changed the title feat: add trace_metric_byte to DataCategory feat: Record log_byte client reports Jul 2, 2026
Comment thread Sources/Sentry/SentryClient.m Outdated
Record log_item and log_byte client outcomes when a log is dropped by
beforeSendLog. The byte size is computed on a background queue so the
calling thread isn't blocked.

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

Comment thread Sources/Sentry/SentryClient.m
@philipphofmann

Copy link
Copy Markdown
Member

@tsushanth, thanks a lot for your help. I took the freedom and finished the PR. @itaybre, @philprime or @NinjaLikesCheez please give this PR another review, because I can't review my own code please.

Comment thread Sources/Swift/Tools/SentryLogClientReport.swift Outdated
@itaybre
itaybre enabled auto-merge (squash) July 2, 2026 11:45

@itaybre itaybre 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

@itaybre
itaybre merged commit b70f8c7 into getsentry:main Jul 2, 2026
309 of 311 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire log_byte client outcome reporting

5 participants