Skip to content

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Nov 14, 2025

📜 Description

Detect oversized events and reduce their size by removing breadcrumbs and reducing stack trace size.
Also add onOversizedError callback that allows customers to customize what's dropped.

💡 Motivation and Context

So we can be more lenient with truncation in SDK and only perform it if required to reduce event size.

Closes #4822

💚 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 14, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against c7ee1e2

@adinauer adinauer marked this pull request as draft November 14, 2025 08:41
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 318.48 ms 378.24 ms 59.76 ms
Size 1.58 MiB 2.13 MiB 556.43 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 357.79 ms 421.84 ms 64.05 ms
ae7fed0 293.84 ms 380.22 ms 86.38 ms
9fbb112 404.51 ms 475.65 ms 71.14 ms
27d7cf8 397.90 ms 498.65 ms 100.75 ms
a416a65 333.78 ms 410.37 ms 76.59 ms
d217708 411.22 ms 430.86 ms 19.63 ms
539ca63 313.51 ms 355.43 ms 41.92 ms
23d6b12 354.10 ms 408.38 ms 54.28 ms
14ff5ee 419.75 ms 495.73 ms 75.98 ms
ce0a49e 532.00 ms 609.96 ms 77.96 ms

App size

Revision Plain With Sentry Diff
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
ae7fed0 1.58 MiB 2.12 MiB 551.77 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
a416a65 1.58 MiB 2.12 MiB 555.26 KiB
d217708 1.58 MiB 2.10 MiB 532.97 KiB
539ca63 1.58 MiB 2.12 MiB 551.41 KiB
23d6b12 1.58 MiB 2.10 MiB 532.31 KiB
14ff5ee 1.58 MiB 2.10 MiB 535.08 KiB
ce0a49e 1.58 MiB 2.10 MiB 532.94 KiB

Previous results on branch: feat/detect-oversized-error-events

Startup times

Revision Plain With Sentry Diff
238dc90 318.98 ms 361.46 ms 42.48 ms
73f341a 312.72 ms 354.90 ms 42.18 ms
0c31c0a 310.15 ms 354.83 ms 44.68 ms
21ae207 310.42 ms 355.09 ms 44.67 ms
606e793 329.40 ms 395.16 ms 65.76 ms

App size

Revision Plain With Sentry Diff
238dc90 1.58 MiB 2.13 MiB 556.43 KiB
73f341a 1.58 MiB 2.13 MiB 556.24 KiB
0c31c0a 1.58 MiB 2.13 MiB 556.43 KiB
21ae207 1.58 MiB 2.13 MiB 556.42 KiB
606e793 1.58 MiB 2.13 MiB 556.48 KiB

* Enables event size limiting with {@link EventSizeLimitingEventProcessor}. When enabled, events
* exceeding 1MB will have breadcrumbs and stack frames reduced to stay under the limit.
*/
private boolean enableEventSizeLimiting = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

Kepping this opt-in for now, we could turn it on by default in the next major.

* @return the modified event (should ideally be reduced in size)
*/
@NotNull
SentryEvent execute(@NotNull SentryEvent event, @NotNull Hint hint);
Copy link
Member Author

@adinauer adinauer Nov 14, 2025

Choose a reason for hiding this comment

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

IMO running this between beforeSend and passing this on to the transport is the best place to check since customers might be adding large amounts of data in beforeSend, so first reducing size and then adding back to it could easily cause the event to become too large again.

@adinauer adinauer marked this pull request as ready for review November 17, 2025 13:49
Copy link
Member

@markushi markushi 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 me! I'm a bit worried about the extra overhead of serializing to determine final size on mobile, but as this is opt-in for now, all good 👍

final @NotNull List<SentryStackFrame> truncatedFrames = new ArrayList<>();
truncatedFrames.addAll(frames.subList(0, FRAMES_PER_SIDE));
truncatedFrames.addAll(frames.subList(frames.size() - FRAMES_PER_SIDE, frames.size()));
stacktrace.setFrames(truncatedFrames);
Copy link
Member

Choose a reason for hiding this comment

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

We could extract this into a truncateFrames(frames) method and re-use it.

@adinauer adinauer merged commit 1b841a7 into main Nov 19, 2025
62 of 63 checks passed
@adinauer adinauer deleted the feat/detect-oversized-error-events branch November 19, 2025 12:51
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.

Detect oversized events and attempt to reduce their size

4 participants