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

Don't report network errors to Sentry #2178

Merged

Conversation

natikgadzhi
Copy link
Contributor

Summary

This pull request makes it so if Sentry encounters one of the network errors when sending data to Sentry, it won't report that error to Sentry and just re-raise it upstream instead.

Closes #1787.

Changes

::Net::HTTP has quite a few possible errors, but I opted to rescue potential network errors (alongside SocketError that was already rescued) instead of rescuing StandardError, so that if something exotic comes up, the user does get a report in Sentry still.

Also added a changelog entry.

/cc @sl0thentr0py does that look like an adequate approach to you?

Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Merging #2178 (5da83ac) into master (c92b0c8) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head 5da83ac differs from pull request most recent head d8a76a8. Consider uploading reports for the commit d8a76a8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2178      +/-   ##
==========================================
- Coverage   97.34%   97.31%   -0.03%     
==========================================
  Files          99       99              
  Lines        3690     3691       +1     
==========================================
  Hits         3592     3592              
- Misses         98       99       +1     
Components Coverage Δ
sentry-ruby 98.03% <100.00%> (+<0.01%) ⬆️
sentry-rails 94.98% <ø> (ø)
sentry-sidekiq 94.50% <ø> (ø)
sentry-resque 92.06% <ø> (-1.59%) ⬇️
sentry-delayed_job 94.44% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-ruby/lib/sentry/transport/http_transport.rb 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@natikgadzhi
Copy link
Contributor Author

@st0012 and this one, pending the changelog resolution ;-)

@@ -14,6 +14,13 @@ class HTTPTransport < Transport
RATE_LIMIT_HEADER = "x-sentry-rate-limits"
USER_AGENT = "sentry-ruby/#{Sentry::VERSION}"

NET_HTTP_ERRORS = [
Copy link
Member

Choose a reason for hiding this comment

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

should we maybe use this list from bundler? it has a few more types

Copy link
Contributor Author

@natikgadzhi natikgadzhi Nov 27, 2023

Choose a reason for hiding this comment

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

We can!

Pros:

  • Better coverage! (I didn't think about Zlib errors)

Cons:

  • Assumes Bundler is there. Or wait.

UPD: I think I misunderstood you. I think it's better to just copy that constant over to our code, than require 'bundler' into sentry-ruby?

Copy link
Member

Choose a reason for hiding this comment

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

yes just copy over

@natikgadzhi
Copy link
Contributor Author

@sl0thentr0py, done — copied the list from Bundler, with two gotchas:

  • We don't do ::Net::HTTP::Persistent, so it doesn't make sense to intercept it (I think?)
  • Bundler did not catch ECONNREFUSED, so I added it to our list.

I think in general, having the most common errors is enough. If we miss an error, that's not the end of the world, that's just going to get reported upstream, no big deal. We just need to get 95% right. Right?

@sl0thentr0py
Copy link
Member

yep all good

@sl0thentr0py
Copy link
Member

you'll need to move the changelog entry to a new 'Unreleased' section at the top now that i made a release

@natikgadzhi natikgadzhi force-pushed the ng/bugfix/net-http-errors-upstream branch from 5da83ac to becc566 Compare November 27, 2023 16:54
@natikgadzhi natikgadzhi force-pushed the ng/bugfix/net-http-errors-upstream branch from becc566 to d8a76a8 Compare November 27, 2023 16:56
@natikgadzhi
Copy link
Contributor Author

Done! AFK for 2 hours.

Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

ty!

@sl0thentr0py sl0thentr0py merged commit 4c8110c into getsentry:master Nov 27, 2023
95 checks passed
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.

Net::HTTP errors are sent upstream
2 participants