getsentry / sentry-ruby

Sentry SDK for Ruby
https://sentry.io/for/ruby
MIT License
934 stars 494 forks source link

Implement Truncation Logic for Custom contexts #2381

Open kerenkhatiwada opened 2 months ago

kerenkhatiwada commented 2 months ago

Describe the idea

Reported by user: Currently, the sentry-ruby SDK truncates messages sent via Sentry.capture_exception and Sentry.capture_message to 8 KB, utilizing the Sentry::Event::MAX_MESSAGE_SIZE_IN_BYTES constant. However, this truncation logic is not applied to data stored in the Sentry::Scope @extra hash, which can bypass these checks and lead to oversized events being dropped without notification.

The request is that the sentry-ruby SDK truncations logic for strings stored in the Custom contexts. This would ensure that large messages added to the Custom contexts are handled similarly to messages, preventing potential data loss and ensuring consistency across the SDK.

Why do you think it's beneficial to most of the users

users will be better protected from silent event drops due to oversized data

Possible implementation

┆Issue is synchronized with this Jira Improvement by Unito