Repository navigation
fix(logs, metrics): don't recurse when sdk_logger forwards to Sentry and the buffer is full - #3253
Open
pcbeingused33 wants to merge 1 commit into
Conversation
…and the buffer is full The drop message was logged after releasing the buffer mutex, so an sdk_logger that adds telemetry re-entered add_item, dropped again and logged again until the stack overflowed. Log it while holding the mutex, so the existing owned? guard stops the re-entrant call. Fixes getsentry#3252 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
PR risk: mediumFor commit Main concerns: reach. This label is a hint for reviewers, not an approval. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3252
Cause: when a telemetry buffer is full,
add_itemlogs "exceeded max capacity, dropping event" after releasing@mutex. Ifsdk_loggerforwards toSentry.logger, that message re-entersadd_item, is dropped too, logs again, and so on untilSystemStackError.Fix: emit that debug message while still holding the mutex, so the existing
@mutex.owned?guard returns early for the re-entrant call. This is the one log call moved back under the lock; it only runs on the drop path, andrecord_lost_eventstays outside.Tests: a new shared example (run for both the log and metric buffers) makes
sdk_logger.debugcalladd_itemagain on a full buffer, mirroring the forwarding logger from the issue. Without the change it fails withSystemStackError; with it, the message is logged once and the re-entrant call returns early.spec/sentry/log_event_buffer_spec.rbandspec/sentry/metric_event_buffer_spec.rbpass on Ruby 3.4, and RuboCop passes on the touched files.This change was prepared with AI assistance.