Preserve original exception in jetty http client wrappers (#7455)

Same issue as in
https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/7452
This commit is contained in:
Lauri Tulmin 2022-12-21 10:26:44 +02:00 committed by GitHub
parent d38bc4d2a4
commit e683fd9bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import static java.util.stream.Collectors.toList;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
@ -71,6 +72,8 @@ public final class JettyClientWrapUtil {
(proxy, method, args) -> {
try (Scope ignored = context.makeCurrent()) {
return method.invoke(listener, args);
} catch (InvocationTargetException exception) {
throw exception.getCause();
}
});
}

View File

@ -10,6 +10,7 @@ import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
@ -118,6 +119,8 @@ public class JettyHttpClient9TracingInterceptor
(proxy, method, args) -> {
try (Scope ignored = context.makeCurrent()) {
return method.invoke(listener, args);
} catch (InvocationTargetException exception) {
throw exception.getCause();
}
});