opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

[Feature]: Port opentelemetry-http to hyper 1.x

Open Cogitri opened this issue 1 year ago • 20 comments

Related Problems?

https://github.com/hyperium/tonic/issues/1307

Describe the solution you'd like:

Hyper 1.0 has been released and as such it'd be nice to upgrade opentelemetry-http's HttpClient to the new version

Considered Alternatives

No response

Additional Context

No response

Cogitri avatar Dec 05 '23 10:12 Cogitri

With the upgrade I think we should also upgrade the version of http to 1.0. However it's currently blocked because some of the http client implementation is still on pre 1.0 and having both http 1.0 create and http 0.2 create caused some issues.

We can either

  • Delete all http client that hasn't support http 1.0 yet(that means every http client except hyper) and upgrade the opentelemtry-http create to use the http 1.0 types. This will require some changes on downsteam create uses those http client defined in opentelemetry-http.
  • Wait until http clients to upgrade to http 1.0. However, some clients hasn't upgrade in a while so I am not sure if they will upgrade to 1.0 soon

TommyCpp avatar Dec 12 '23 06:12 TommyCpp

As I understand in the community meeting this week, it was agreed to go with the first option above i.e., delete all the HTTP clients not supporting HTTP 1.0, and bring them back once the support is there.

lalitb avatar Dec 13 '23 21:12 lalitb

Other than the http cteates. Tonic also depends on the http 0.2. We are currently blocked on it https://github.com/hyperium/tonic/issues/1579

TommyCpp avatar Dec 17 '23 23:12 TommyCpp

cc: @KallDrexx

hdost avatar Jan 09 '24 17:01 hdost

After going through this upgrade for our project, I would definitely advise waiting on this until when/if tonic updates. I had to abort our upgrade for now because of the tonic dependency, and couldn't get them to work side by side easily, at least in the few hours I tried.

KallDrexx avatar Jan 10 '24 15:01 KallDrexx

I take that back. It took some figuring out but in our product I was able to get hyper middle ware with hyper 1.0 and http 1.0 to work with tonic 0.2. So it looks like it should be possible to support both and not have to wait for tonic's upgrade (which doesn't seem to be progressing very fast).

KallDrexx avatar Jan 12 '24 15:01 KallDrexx

Would it need to be in the form of a temporary feature or something like that?

hdost avatar Jan 14 '24 08:01 hdost

I can look into the hyper middle ware or if you want feel free to take this issue @KallDrexx

TommyCpp avatar Jan 15 '24 17:01 TommyCpp

I should be able to take this up later in the week.

KallDrexx avatar Jan 16 '24 18:01 KallDrexx

I took an hour or two to look at this, and reqwest is another issue: https://github.com/seanmonstar/reqwest/issues/2039. It's possible to do, but since HttpClient otel trait requires sending http crate Requests and returning a http crate Response, a bunch of conversions have to occur.

KallDrexx avatar Jan 18 '24 17:01 KallDrexx

What do you think about https://github.com/algesten/ureq instead of reqwest?

frederikhors avatar Jan 18 '24 17:01 frederikhors

I totally forgot we discussed removing reqwest and other non-1.x compatible libraries, so ignore my last comment

KallDrexx avatar Jan 18 '24 17:01 KallDrexx

I think I'm going to have to pull my volunteering for this task. There's a lot of context here that I'm missing on why things are set up the way they are, that I find it hard to make any concrete decisions.

The opentelemetry-http crate seems to be just a wrapper for opentelemetry executing http requests on your behalf. This ends up having ramifications that we are not providing a composable abstraction. It's not clear to me why opentelemetry doesn't just provide a mechanism for adding specific headers to an existing request or extracting them from an existing response.

This is a fundamental difference because the http upgrade becomes significantly easier. We don't need a trait that takes in a Request<T> that's specific to http 1.x, but instead we have one version that takes in a reqwest::Request, another that takes in http::Request<T>, another that takes in a isachs::Request<T>. It can even take in a library specific RequestBuilder instead.

This means the user is still responsible for managing the client and building the request they want, and adding opentelemetry's info after the fact. This isn't a huge ordeal, because no matter what users still need to build the request they need anyway. It's also trivial for any user to create a wrapper to always add otel headers as needed.

So much of the code relies on these custom OpenTelemetry http client wrappings that it's not trivial to redo everything to remove reqwest.

And it just feels like the wrong abstraction from my point of view, but like I said, I do not know the original context of why things are set up the way they are.

KallDrexx avatar Jan 22 '24 15:01 KallDrexx

Any chance this will get prioritized? This effectively blocks consumers of opentelemetry_http crate from moving up to hyper 1.0. In my case, we already moved up and am now blocked from using HeaderExtractor as it causes a conflict between the version of http crate in hyper 1.0 and opentelemetry_http.

ramgdev avatar Feb 12 '24 21:02 ramgdev

It seems like [email protected] supports http@v1 - this should unblock this issue? @KallDrexx

dotansimha avatar Mar 21 '24 07:03 dotansimha

That probably unblocks this. I've been pretty slammed lately though so it might take me a bit to circle back around to this.

KallDrexx avatar Mar 25 '24 14:03 KallDrexx

And it just feels like the wrong abstraction from my point of view, but like I said, I do not know the original context of why things are set up the way they are.

As the person who was responsible for starting the opentelemetry-http crate (#415) please don't overestimate the amount of planning -- I think I was merely extracting a bunch of repetitive/related code into one place that seemed more coherent than what came before. If you are in a position to implement a more modular API, I think that would be great -- there are already traits for injecting/extracting headers so maybe those provide a useful starting point?

djc avatar Mar 25 '24 14:03 djc

I gave this a quick shot but got blocked on tonic, which has not yet merged an upgrade to http@1 (see https://github.com/hyperium/tonic/issues/1579 for details). This is an optional dependency of opentelemetry-otlp.

In theory, this doesn't block opentelemetry-http, but the crates are intertwined enough that separating these seemed counterproductive to me.

SamirTalwar avatar Mar 26 '24 12:03 SamirTalwar

I think it would be reasonable to attempt to separate the dependencies of opentelemetry-otlp and opentelemetry-http. They each have their own public API that does not need to share the underlying http implementation, no? Tonic might take a long time to port to hyper 1.0. There are users (including myself) that just want to use the header extractor and injector implementation of the opentelemetry-http crate. The published opentelemetry-otlp can continue to rely on [email protected] and [email protected] in the meantime. Thoughts?

jnicholls avatar Apr 08 '24 23:04 jnicholls

FWIF the roll_dice demo works with [email protected] https://github.com/open-telemetry/opentelemetry.io/pull/4242

I'm not sure if this is sufficient to support the proposal for separation of -otlp and -http, on its face, but it's evidence that at least the opentelemetry-sdk is fine with [email protected]. FWIF, in general, the ecosystem looks healthier if packages are relatively decoupled and are free to upgrade critical dependencies asyncrhonously. If they can't, it smells like poor separation of concerns. Understanding there's complexity etc. caveats - nonetheless.

ekquasar avatar Apr 17 '24 14:04 ekquasar