Vertx: avoid doulbe wrapping exception handler
MODIFY
instrumentation/vertx-http-client/vertx-http-client-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v3_0/client/HttpRequestInstrumentation.java
instrumentation/vertx-http-client/vertx-http-client-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v3_0/client/HttpRequestInstrumentation.java
@@ -207,7 +207,7 @@ public class HttpRequestInstrumentation implements TypeInstrumentation {
if (handler != null) {
ContextStore<HttpClientRequest, Contexts> contextStore =
InstrumentationContext.get(HttpClientRequest.class, Contexts.class);
- handler = new ExceptionHandlerWrapper(tracer(), request, contextStore, handler);
+ handler = ExceptionHandlerWrapper.wrap(tracer(), request, contextStore, handler);
}
}
}

MODIFY
instrumentation/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/HttpRequestInstrumentation.java
instrumentation/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/HttpRequestInstrumentation.java
@@ -209,7 +209,7 @@ public class HttpRequestInstrumentation implements TypeInstrumentation {
if (handler != null) {
ContextStore<HttpClientRequest, Contexts> contextStore =
InstrumentationContext.get(HttpClientRequest.class, Contexts.class);
- handler = new ExceptionHandlerWrapper(tracer(), request, contextStore, handler);
+ handler = ExceptionHandlerWrapper.wrap(tracer(), request, contextStore, handler);
}
}
}

MODIFY
instrumentation/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/ExceptionHandlerWrapper.java
instrumentation/vertx-http-client/vertx-http-client-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/ExceptionHandlerWrapper.java
@@ -16,7 +16,7 @@ public class ExceptionHandlerWrapper implements Handler<Throwable> {
private final ContextStore<HttpClientRequest, Contexts> contextStore;
private final Handler<Throwable> handler;
- public ExceptionHandlerWrapper(
+ private ExceptionHandlerWrapper(
AbstractVertxClientTracer tracer,
HttpClientRequest request,
ContextStore<HttpClientRequest, Contexts> contextStore,
@@ -27,6 +27,18 @@ public class ExceptionHandlerWrapper implements Handler<Throwable> {
this.handler = handler;
}
+ public static Handler<Throwable> wrap(
+ AbstractVertxClientTracer tracer,
+ HttpClientRequest request,
+ ContextStore<HttpClientRequest, Contexts> contextStore,
+ Handler<Throwable> handler) {
+ if (handler instanceof ExceptionHandlerWrapper) {
+ return handler;
+ }
+
+ return new ExceptionHandlerWrapper(tracer, request, contextStore, handler);
+ }
+
@Override
public void handle(Throwable throwable) {
Contexts contexts = contextStore.get(request);

Vertx: avoid doulbe wrapping exception handler (#3848)