-
Notifications
You must be signed in to change notification settings - Fork 910
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 library instrumentation for java http client #8138
Conversation
import java.net.http.HttpResponse; | ||
|
||
/** Entrypoint for instrumenting Java HTTP Client. */ | ||
public final class JavaHttpClientTelemetry { |
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.
I named the public api classes JavaHttpClient..
but some of the other classes still use JdkHttpClient...
. I think we should choose how we want to call this and name all the classes in the same way.
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.
+1 on renaming everything from Jdk*
to Java*
.../src/main/java/io/opentelemetry/instrumentation/httpclient/internal/OpenTelemetryClient.java
Outdated
Show resolved
Hide resolved
I think the |
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.
Should I also implement context propagation for
BodyHandler
in library instrumentation or should I just delete it? I guess it could come handy if someone builds a customBodyHandler
and wants to emit spans from there, though this doesn't feel too likely. I'd like deleting it more.
it looks like we don't have any tests for custom BodyHandler? I'm fine deleting it and adding it if there's demand.
import java.net.http.HttpResponse; | ||
|
||
/** Entrypoint for instrumenting Java HTTP Client. */ | ||
public final class JavaHttpClientTelemetry { |
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.
+1 on renaming everything from Jdk*
to Java*
.../src/main/java/io/opentelemetry/instrumentation/httpclient/internal/OpenTelemetryClient.java
Outdated
Show resolved
Hide resolved
public final class OpenTelemetryClient extends HttpClient { | ||
private final HttpClient client; | ||
private final Instrumenter<HttpRequest, HttpResponse<?>> instrumenter; | ||
private final HttpHeadersSetter headersSetter; |
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.
maybe could delete HttpHeadersSetter
, moving its one method to this class, and pass in ContextPropagators
here?
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.
I think it is better to keep it because javaagent
instrumentation does not use OpenTelemetryClient
, but uses HttpHeadersSetter
Co-authored-by: Trask Stalnaker <[email protected]>
Resolves #8069
The javaagent instrumentation also supports propagating context into BodyHandler implemented in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/BodyHandlerWrapper.java I think the initial idea behind it was that this allowed propagating context into callbacks. Because this didn't work for
connectionErrorUnopenedPortWithCallback
test later we also added wrapping completable future to take care of propagating context into callbacks. Should I also implement context propagation forBodyHandler
in library instrumentation or should I just delete it? I guess it could come handy if someone builds a customBodyHandler
and wants to emit spans from there, though this doesn't feel too likely. I'd like deleting it more.