Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also check stringified breadcrumbs key when reducing payload size #1758

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Unreleased

### Bug Fixes

- Also check stringified breadcrumbs key when reducing payload size [#1758](https://github.com/getsentry/sentry-ruby/pull/1758)
- Fixes [#1757](https://github.com/getsentry/sentry-ruby/issues/1757)

## 5.2.0

### Features
Expand Down
7 changes: 6 additions & 1 deletion sentry-ruby/lib/sentry/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def serialize_envelope(envelope)
result = item.to_s

if result.bytesize > Event::MAX_SERIALIZED_PAYLOAD_SIZE
item.payload.delete(:breadcrumbs)
if item.payload.key?(:breadcrumbs)
item.payload.delete(:breadcrumbs)
elsif item.payload.key?("breadcrumbs")
item.payload.delete("breadcrumbs")
end

result = item.to_s
end

Expand Down
14 changes: 13 additions & 1 deletion sentry-ruby/spec/sentry/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,26 @@
expect(serialized_result.bytesize).to be > Sentry::Event::MAX_SERIALIZED_PAYLOAD_SIZE
end

it "sends the event and logs the action" do
it "deletes the event's breadcrumbs and sends it" do
expect(subject).to receive(:send_data)

subject.send_envelope(envelope)

expect(io.string).to match(/Sending envelope with items \[event\]/)
end

context "when the event hash has string keys" do
let(:envelope) { subject.envelope_from_event(event.to_json_compatible) }

it "deletes the event's breadcrumbs and sends it" do
expect(subject).to receive(:send_data)

subject.send_envelope(envelope)

expect(io.string).to match(/Sending envelope with items \[event\]/)
end
end

context "if it's still oversized" do
before do
100.times do |i|
Expand Down