Skip to content

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Nov 5, 2025

📜 Description

Report discarded log size in bytes as part of client reports.

💡 Motivation and Context

Since log count is not shown to customers in UI, we want to report log size too.

💚 How did you test it?

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 315.89 ms 362.42 ms 46.53 ms
Size 1.58 MiB 2.12 MiB 553.97 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
806307f 357.85 ms 424.64 ms 66.79 ms
ee747ae 554.98 ms 611.50 ms 56.52 ms
17a0955 372.53 ms 446.70 ms 74.17 ms
2124a46 319.19 ms 415.04 ms 95.85 ms
9fbb112 404.51 ms 475.65 ms 71.14 ms
b6702b0 395.86 ms 409.98 ms 14.12 ms
ee747ae 357.79 ms 421.84 ms 64.05 ms
27d7cf8 314.17 ms 347.00 ms 32.83 ms
9fbb112 361.43 ms 427.57 ms 66.14 ms
96449e8 361.30 ms 423.39 ms 62.09 ms

App size

Revision Plain With Sentry Diff
806307f 1.58 MiB 2.10 MiB 533.42 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
17a0955 1.58 MiB 2.10 MiB 533.20 KiB
2124a46 1.58 MiB 2.12 MiB 551.51 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
b6702b0 1.58 MiB 2.12 MiB 551.79 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
96449e8 1.58 MiB 2.11 MiB 539.35 KiB

Previous results on branch: feat/report-discarded-log-bytes

Startup times

Revision Plain With Sentry Diff
fff4795 309.94 ms 370.50 ms 60.56 ms
28b566b 316.37 ms 364.56 ms 48.19 ms
38a53b3 368.63 ms 443.27 ms 74.63 ms
c63bfc6 368.17 ms 374.78 ms 6.60 ms

App size

Revision Plain With Sentry Diff
fff4795 1.58 MiB 2.12 MiB 551.81 KiB
28b566b 1.58 MiB 2.12 MiB 551.58 KiB
38a53b3 1.58 MiB 2.12 MiB 552.02 KiB
c63bfc6 1.58 MiB 2.12 MiB 553.32 KiB

Copy link
Member

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

Looks good for the most part, but reading the doc i understood we shouldn't count json characters in the byte size, which we are doing here
Perhaps a simple method in the log object that counts each key and value bytes is a good alternative?

@adinauer
Copy link
Member Author

adinauer commented Nov 6, 2025

We're currently discussing, whether this simplified count as if it were serialized is OK or if we want to replicate what relay is doing.

Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

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

Looks good!

To record: no scientific byte count needed, as users are not billed on logs that are dropped in the SDK. So while the logic differs slightly from relay, counting the bytes in the serialized JSON emitted by the SDK seems like the most pragmatic choice and good enough for this use case.

@adinauer adinauer mentioned this pull request Nov 11, 2025
8 tasks
@adinauer adinauer enabled auto-merge (squash) November 11, 2025 12:10
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Untracked Log Bytes Skew Reports

When processLogEvent drops a log event via event processors, it only records DataCategory.LogItem but not DataCategory.LogByte. This is inconsistent with beforeSendLog handling (lines 1189-1200) where both categories are recorded. Event processors can drop logs at lines 1172-1175 and 1179-1182, causing discarded log bytes to not be tracked in client reports for these code paths.

sentry/src/main/java/io/sentry/SentryClient.java#L472-L502

@Nullable
private SentryLogEvent processLogEvent(
@NotNull SentryLogEvent event, final @NotNull List<EventProcessor> eventProcessors) {
for (final EventProcessor processor : eventProcessors) {
try {
event = processor.process(event);
} catch (Throwable e) {
options
.getLogger()
.log(
SentryLevel.ERROR,
e,
"An exception occurred while processing log event by processor: %s",
processor.getClass().getName());
}
if (event == null) {
options
.getLogger()
.log(
SentryLevel.DEBUG,
"Log event was dropped by a processor: %s",
processor.getClass().getName());
options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.EVENT_PROCESSOR, DataCategory.LogItem);
break;
}
}
return event;
}

Fix in Cursor Fix in Web


@adinauer adinauer merged commit d464089 into main Nov 11, 2025
61 of 63 checks passed
@adinauer adinauer deleted the feat/report-discarded-log-bytes branch November 11, 2025 13:09
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.

5 participants