-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Add support for OpenTelemetry in HTTPClient #14360
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.ObjectReader; | ||
| import io.opentelemetry.api.OpenTelemetry; | ||
| import io.opentelemetry.instrumentation.apachehttpclient.v5_2.ApacheHttpClientTelemetry; | ||
| import java.io.IOException; | ||
| import java.io.UncheckedIOException; | ||
| import java.net.URI; | ||
|
|
@@ -113,13 +115,17 @@ private HTTPClient( | |
| ObjectMapper objectMapper, | ||
| Map<String, String> properties, | ||
| HttpClientConnectionManager connectionManager, | ||
| AuthSession session) { | ||
| AuthSession session, | ||
| OpenTelemetry openTelemetry) { | ||
| this.baseUri = baseUri; | ||
| this.baseHeaders = baseHeaders; | ||
| this.mapper = objectMapper; | ||
| this.authSession = session; | ||
|
|
||
| HttpClientBuilder clientBuilder = HttpClients.custom(); | ||
| HttpClientBuilder clientBuilder = | ||
| openTelemetry != null | ||
| ? ApacheHttpClientTelemetry.builder(openTelemetry).build().newHttpClientBuilder() | ||
| : HttpClients.custom(); | ||
|
|
||
| clientBuilder.setConnectionManager(connectionManager); | ||
|
|
||
|
|
@@ -482,6 +488,7 @@ public static class Builder { | |
| private HttpHost proxy; | ||
| private CredentialsProvider proxyCredentialsProvider; | ||
| private AuthSession authSession; | ||
| private OpenTelemetry telemetry; | ||
|
|
||
| private Builder(Map<String, String> properties) { | ||
| this.properties = properties; | ||
|
|
@@ -536,6 +543,12 @@ public Builder withAuthSession(AuthSession session) { | |
| return this; | ||
| } | ||
|
|
||
| public Builder withOpenTelemetry(OpenTelemetry openTelemetry) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to protect this with a precondition of this being not null ? |
||
| Preconditions.checkNotNull(openTelemetry, "Invalid openTelemetry for http client: null"); | ||
| this.telemetry = openTelemetry; | ||
| return this; | ||
| } | ||
|
|
||
| public HTTPClient build() { | ||
| withHeader(CLIENT_VERSION_HEADER, IcebergBuild.fullVersion()); | ||
| withHeader(CLIENT_GIT_COMMIT_SHORT_HEADER, IcebergBuild.gitCommitShortId()); | ||
|
|
@@ -579,7 +592,8 @@ public HTTPClient build() { | |
| mapper, | ||
| properties, | ||
| configureConnectionManager(properties), | ||
| authSession); | ||
| authSession, | ||
| telemetry); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ mockserver = "5.15.0" | |
| nessie = "0.106.1" | ||
| netty-buffer = "4.2.9.Final" | ||
| object-client-bundle = "3.3.2" | ||
| opentelemetry-httpclient = "2.23.0-alpha" | ||
| orc = "1.9.8" | ||
| parquet = "1.17.0" | ||
| roaringbitmap = "1.3.0" | ||
|
|
@@ -166,6 +167,7 @@ microprofile-openapi-api = { module = "org.eclipse.microprofile.openapi:micropro | |
| nessie-client = { module = "org.projectnessie.nessie:nessie-client", version.ref = "nessie" } | ||
| netty-buffer = { module = "io.netty:netty-buffer", version.ref = "netty-buffer" } | ||
| object-client-bundle = { module = "com.emc.ecs:object-client-bundle", version.ref = "object-client-bundle" } | ||
| opentelemetry-httpclient = { module = "io.opentelemetry.instrumentation:opentelemetry-apache-httpclient-5.2", version.ref = "opentelemetry-httpclient" } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pins an alpha OTel instrumentation artifact (2.20.1-alpha) and the module name is specifically opentelemetry-apache-httpclient-5.2 while Iceberg uses Apache HttpClient 5.6. Can we confirm this instrumentation is compatible with 5.6 (and that pulling opentelemetry-api-incubator alpha transitively is acceptable here)? |
||
| orc-core = { module = "org.apache.orc:orc-core", version.ref = "orc" } | ||
| parquet-avro = { module = "org.apache.parquet:parquet-avro", version.ref = "parquet" } | ||
| parquet-column = { module = "org.apache.parquet:parquet-column", version.ref = "parquet" } | ||
|
|
||
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.
do we need to update and LICENCE ?
Uh oh!
There was an error while loading. Please reload this page.
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 we update the root LICENSE file only when we copy code from another library. Am I wrong?
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.
Not fully aware but i think if we ship a dependency : https://github.com/apache/iceberg/blob/main/aws-bundle/LICENSE we just include it i think, not an expert in this though, just thought to bring since we are introducing a new dependency in the project
Uh oh!
There was an error while loading. Please reload this page.
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.
Ah, sorry I was only looking at LICENSE file in the root directory. Let me check other LICENSE files.
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.
@jbonofre Do you happen to know the answer to the question above?