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

feat: Add ureq transport support #419

Merged
merged 2 commits into from
Jan 28, 2022
Merged

feat: Add ureq transport support #419

merged 2 commits into from
Jan 28, 2022

Conversation

MarijnS95
Copy link
Contributor

Ureq is easy to use, smaller than the other http crates and doesn't pull in as many crate dependencies either, which is why we are actively switching to it and in need of an ureq transport in Sentry too.

sentry/Cargo.toml Outdated Show resolved Hide resolved
sentry/Cargo.toml Outdated Show resolved Hide resolved
sentry/src/transports/curl.rs Outdated Show resolved Hide resolved
sentry/src/transports/ureq.rs Outdated Show resolved Hide resolved
sentry/src/transports/ureq.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

probably should update the docs wrt to this as well

sentry/src/transports/ureq.rs Outdated Show resolved Hide resolved
sentry/src/transports/ureq.rs Outdated Show resolved Hide resolved
sentry/src/transports/ureq.rs Outdated Show resolved Hide resolved
sentry/Cargo.toml Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2022

Codecov Report

Merging #419 (d0b60d9) into master (d0d5abc) will decrease coverage by 0.58%.
The diff coverage is 16.00%.

@@            Coverage Diff             @@
##           master     #419      +/-   ##
==========================================
- Coverage   81.68%   81.10%   -0.59%     
==========================================
  Files          71       72       +1     
  Lines        8092     8165      +73     
==========================================
+ Hits         6610     6622      +12     
- Misses       1482     1543      +61     

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

i think this looks good, what do you think of the feature names/usage? I'm not objecting to the current layout if you prefer it this way.

Comment on lines 109 to 112
//! - `ureq`: Enables the ureq transport.
//! - `ureq-tls`: Enables `rustls` support for `ureq`. Please note that this has to be enabled for
//! https support, and cannot be enabled by default.
//! - `ureq-native-tls`: Enables `native-tls` support for `ureq`.
Copy link
Contributor

Choose a reason for hiding this comment

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

you could recommend here to prefer setting one of ureq-tls or ureq-native-tls and mention they automatically pull in ureq.

Or maybe even go further and rename ureq to ureq_base_ or something and make it internal only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a better plan, I don't think a Sentry transport without https makes a lot of sense 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@flub I opted to go for ureq and ureq-native-tls. No ureq_base_ though, as there's only httpdate support here after we get rid of tokio.

@@ -44,6 +44,9 @@ surf-h1 = ["surf_/h1-client", "httpdate"]
surf = ["surf_/curl-client", "httpdate", "tokio"]
native-tls = ["reqwest_/default-tls"]
rustls = ["reqwest_/rustls-tls"]
ureq = ["ureq_", "httpdate", "tokio"]
Copy link
Contributor

Choose a reason for hiding this comment

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

do you happen to know why this needs the tokio dependency? I thought ureq was blocking? I have the same question for the surf dependency as well to be fair, but that's clearly out of scope here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of the TransportThread every backend seems to use. surf has a clear requestr.await, I think that's async driven by tokio too? Perhaps you meant curl which - just like ureq - only has a single async move { rl } and is blocking otherwise.

Getting rid of tokio is our next stop unless it's simpler/cleaner to implement this directly. Is a Transport - or at least the send_envelope function - supposed to return quickly or is it fine if we perform a blocking request here?

Copy link
Member

Choose a reason for hiding this comment

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

It would be fair to split the TransportThread into two sync/async variants for transports that are based on one or the other in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, the TrnasportThread builds an internal Tokio runtime... that is indeed a bit needless for sync transports and weird for the surf one. would be nice to fix this sometime indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll pick this up in a followup PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -44,6 +44,9 @@ surf-h1 = ["surf_/h1-client", "httpdate"]
surf = ["surf_/curl-client", "httpdate", "tokio"]
native-tls = ["reqwest_/default-tls"]
rustls = ["reqwest_/rustls-tls"]
ureq = ["ureq_", "httpdate", "tokio"]
Copy link
Member

Choose a reason for hiding this comment

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

It would be fair to split the TransportThread into two sync/async variants for transports that are based on one or the other in the future.

Ureq is easy to use, smaller than the other http crates and doesn't pull
in as many crate dependencies either, which is why [we] are actively
switching to it and in need of an `ureq` transport in Sentry too.

[we]: https://github.com/Traverse-Research
@flub flub enabled auto-merge (squash) January 28, 2022 11:00
@flub flub merged commit 34f6c0a into getsentry:master Jan 28, 2022
@MarijnS95 MarijnS95 deleted the ureq branch January 28, 2022 11:06
flub pushed a commit that referenced this pull request Jan 31, 2022
…ts (#422)

These transport backends don't need the overhead of a tokio runtime and
all the dependency crates that come with it, when they are already
blocking on their own.  A simple Rust thread and mpsc channel is enough.
The transport thread implementation is duplicated between a tokio and
non-tokio module that are used by reqwest/surf, and curl/ureq
respectively.

See also
#419 (comment)
where this was briefly discussed.
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.

None yet

4 participants