-
Notifications
You must be signed in to change notification settings - Fork 911
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
Add support for apache httpclient5 #2254
Conversation
Hi @laurit - can we start with library instrumentation for this? We should generally use the library's native support for instrumentation instead of intercepting execute where it's possible - so if we start with library instrumentation registering interceptors, I think we'll know how to then wire that into the javaagent code. |
@anuraaga This is an adaption of httpclient-4.0 instrumentation and works exactly the same way. The approach you suggested would work when http client is built by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is exact adaption of the instrumentation for 4.0, then I am Ok with this. But I somewhat agree with @anuraaga sentiment, so will let him decide if we accept this without library instrumentation.
I do want to discourage agent-only PRs in general to not box out non-agent users, but at the same time I feel very bad to delete working code. If @laurit doesn't have time for it though that's totally fine and I would recommend merging if this is just copy paste from our other instrumentation with package rename, let's not waste it. FYI the biggest thing on my mind is it's 2021 - if a new HTTP library is released without a proper instrumentation hook (which may be the case given the comment about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a skim and I'm ok with this. @laurit just to be clear thanks for doing this, regardless of where this ends up long term it's for our users. I really appreciate it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also port #2276 to this new instrumentation?
...y/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientInstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientInstrumentationModule.java
Outdated
Show resolved
Hide resolved
b04c320
to
a97b850
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@Override | ||
public T handleResponse(ClassicHttpResponse response) throws IOException, HttpException { | ||
tracer().end(context, response); | ||
try (Scope ignored = parentContext.makeCurrent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment added to #2276 just before merging (if this is still the same in httpclient5?):
try (Scope ignored = parentContext.makeCurrent()) { | |
// ending the span before executing the callback handler (and scoping the callback handler to | |
// the parent context), even though we are inside of a synchronous http client callback | |
// underneath HttpClient.execute(..), in order to not attribute other CLIENT span timings that | |
// may be performed in the callback handler to the http client span (and so we don't end up with | |
// nested CLIENT spans, which we currently suppress) | |
try (Scope ignored = parentContext.makeCurrent()) { |
bb53fb3
to
8f96bbc
Compare
Adds support for apache httpclient5 classic. Related to #2157 though the issue does not specify whether they are interested in class or async httpclient.