Repository navigation
fix(logs): don't drop the log batch when a message template can't be formatted - #3250
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…formatted
A literal % next to a placeholder, or a %{token} without its attribute,
raised from LogEvent#to_h during flush and lost every buffered log.
Send the raw body in that case.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
PR risk: mediumFor commit Main concerns: reach, data sent to Sentry, host performance. 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.
One structured log whose message template can't be formatted makes the SDK lose every log buffered with it.
Cause:
LogEvent#to_hformats the body with%/sprintfat flush time. These calls raise (ArgumentError,TypeError,KeyError), the error propagates out ofTelemetryEventBuffer#send_itemsafter the pending items have already been taken from the buffer, and the whole batch is lost.Fix: if formatting fails, send the raw body and write a debug message to the SDK logger. The template and parameter attributes are still attached.
Tests: three new cases in
log_event_spec.rbfail without the change and pass with it. RuboCop passes on the touched files.This change was prepared with AI assistance.