Skip to content

Commit

Permalink
Remove JAXRS HttpClient instrumentation (open-telemetry#5430)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored and RashmiRam committed May 23, 2022
1 parent a8ea7cb commit 66de7a0
Show file tree
Hide file tree
Showing 31 changed files with 22 additions and 1,050 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
import java.net.HttpURLConnection;

Expand All @@ -27,6 +28,7 @@ public final class HttpUrlConnectionSingletons {
GlobalOpenTelemetry.get(),
"io.opentelemetry.http-url-connection",
HttpSpanNameExtractor.create(httpAttributesGetter))
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesGetter))
.addAttributesExtractor(HttpClientAttributesExtractor.create(httpAttributesGetter))
.addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter))
.addAttributesExtractor(PeerServiceAttributesExtractor.create(netAttributesGetter))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
plugins {
id("otel.javaagent-instrumentation")
}

muzzle {
pass {
group.set("javax.ws.rs")
module.set("javax.ws.rs-api")
versions.set("[2.0,)")
}
pass {
// We want to support the dropwizard clients too.
group.set("io.dropwizard")
module.set("dropwizard-client")
versions.set("[0.8.0,)")
assertInverse.set(true)
}
id("otel.javaagent-testing")
}

dependencies {
compileOnly("javax.ws.rs:javax.ws.rs-api:2.0.1")
compileOnly("javax.annotation:javax.annotation-api:1.3.2")

testInstrumentation(project(":instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-cxf-3.0:javaagent"))
testInstrumentation(project(":instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-jersey-2.0:javaagent"))
testInstrumentation(project(":instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-resteasy-3.0:javaagent"))
testInstrumentation(project(":instrumentation:http-url-connection:javaagent"))

testImplementation("javax.ws.rs:javax.ws.rs-api:2.0.1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTr

abstract class JaxRsClientTest extends HttpClientTest<Invocation.Builder> implements AgentTestTrait {

boolean testRedirects() {
false
}

@Override
Invocation.Builder buildRequest(String method, URI uri, Map<String, String> headers) {
return internalBuildRequest(uri, headers)
Expand Down Expand Up @@ -108,7 +112,7 @@ abstract class JaxRsClientTest extends HttpClientTest<Invocation.Builder> implem
"$SemanticAttributes.HTTP_METHOD" method
"$SemanticAttributes.HTTP_STATUS_CODE" statusCode
"$SemanticAttributes.HTTP_FLAVOR" "1.1"
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
"$SemanticAttributes.HTTP_USER_AGENT" { it == null || String }
}
}
serverSpan(it, 1, span(0))
Expand All @@ -131,11 +135,6 @@ class JerseyClientTest extends JaxRsClientTest {
return new JerseyClientBuilder().withConfig(config)
}

@Override
int maxRedirects() {
20
}

@Override
SingleConnection createSingleConnection(String host, int port) {
// Jersey JAX-RS client uses HttpURLConnection internally, which does not support pipelining nor
Expand All @@ -154,10 +153,6 @@ class ResteasyClientTest extends JaxRsClientTest {
.establishConnectionTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
}

boolean testRedirects() {
false
}

@Override
SingleConnection createSingleConnection(String host, int port) {
return new ResteasySingleConnection(host, port)
Expand All @@ -166,16 +161,24 @@ class ResteasyClientTest extends JaxRsClientTest {

class CxfClientTest extends JaxRsClientTest {

@Override
Throwable clientSpanError(URI uri, Throwable exception) {
switch (uri.toString()) {
case "http://localhost:61/": // unopened port
case "https://192.0.2.1/": // non routable address
if (exception.getCause() != null) {
exception = exception.getCause()
}
}
return exception
}

@Override
ClientBuilder builder() {
return new ClientBuilderImpl()
.property("http.connection.timeout", (long) CONNECT_TIMEOUT_MS)
}

boolean testRedirects() {
false
}

@Override
SingleConnection createSingleConnection(String host, int port) {
// CXF JAX-RS client uses HttpURLConnection internally, which does not support pipelining nor
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 66de7a0

Please sign in to comment.