Skip to content

feat(transport): Add a timeout #4252

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

Merged
merged 13 commits into from
Apr 10, 2025
Merged

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Apr 8, 2025

For some reason, we don't define any timeouts in our default transport(s).

With this change:

  • We add a 30s total timeout for the whole connect+read cycle in the default HTTP transport
  • In the experimental HTTP/2 httpcore-based transport there is no way to set a single timeout, so we set 15s each for getting a connection from the pool, connecting, writing, and reading

Backend SDKs in general set wildly different timeouts, from 30s in Go to <5s in Ruby or PHP. I went for the higher end of the range here since this is mainly meant to prevent the SDK preventing process shutdown like described in #4247 -- we don't want to cut off legitimate requests that are just taking a long time. (I was considering going even higher, maybe to 60s -- but I think 30s is a good first shot at this and we can always change it later.)

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.53%. Comparing base (fb6d374) to head (f135ac3).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4252      +/-   ##
==========================================
- Coverage   79.54%   79.53%   -0.01%     
==========================================
  Files         142      142              
  Lines       15905    15907       +2     
  Branches     2723     2723              
==========================================
  Hits        12652    12652              
- Misses       2385     2389       +4     
+ Partials      868      866       -2     
Files with missing lines Coverage Δ
sentry_sdk/transport.py 80.04% <100.00%> (+0.09%) ⬆️

... and 6 files with indirect coverage changes

@sentrivana sentrivana linked an issue Apr 8, 2025 that may be closed by this pull request
@aivarsk
Copy link

aivarsk commented Apr 8, 2025

You missed the second pool options implementation around lines 772 for HTTP2 I guess

@aivarsk
Copy link

aivarsk commented Apr 8, 2025

And just a side note - I don't know what are the Sentry SaaS response times but 5 seconds might be too little for the read timeout. I think other software uses 15 seconds by default.

@sentrivana
Copy link
Contributor Author

sentrivana commented Apr 8, 2025

Gotcha, still working on this, not final yet -- planning on adding the timeout to the other transport and also need to decide on a good default

@sentrivana sentrivana changed the title feat(transport): Add a read/connect timeout feat(transport): Add a timeout Apr 9, 2025
@sentrivana sentrivana marked this pull request as ready for review April 10, 2025 07:36
@sentrivana sentrivana requested a review from a team as a code owner April 10, 2025 07:36
@sentrivana sentrivana requested a review from a team April 10, 2025 07:37
Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

looking good! 🚀

@sentrivana sentrivana merged commit 6000f87 into master Apr 10, 2025
138 checks passed
@sentrivana sentrivana deleted the ivana/add-transport-timeouts branch April 10, 2025 09:44
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.

Sentry-python does not set connection timeouts
3 participants