From be215940e26e3a017a3ed2e763b6836fe482c1f1 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Sat, 18 May 2024 00:54:09 +0300 Subject: [PATCH] Backport: Fix undertow http response customizer with http2 (#11387) --- ...ion.java => HttpServerConnectionInstrumentation.java} | 9 ++++++--- .../undertow/UndertowInstrumentationModule.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) rename instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/{HttpTransferEncodingInstrumentation.java => HttpServerConnectionInstrumentation.java} (83%) diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpTransferEncodingInstrumentation.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpServerConnectionInstrumentation.java similarity index 83% rename from instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpTransferEncodingInstrumentation.java rename to instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpServerConnectionInstrumentation.java index 4f6b6e46b801..ef96d35eaedd 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpTransferEncodingInstrumentation.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/HttpServerConnectionInstrumentation.java @@ -7,6 +7,7 @@ import static io.opentelemetry.javaagent.instrumentation.undertow.UndertowSingletons.helper; import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.namedOneOf; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; import io.opentelemetry.context.Context; @@ -18,16 +19,18 @@ import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; -public class HttpTransferEncodingInstrumentation implements TypeInstrumentation { +public class HttpServerConnectionInstrumentation implements TypeInstrumentation { @Override public ElementMatcher typeMatcher() { - return named("io.undertow.server.protocol.http.HttpTransferEncoding"); + return namedOneOf( + "io.undertow.server.protocol.http.HttpServerConnection", + "io.undertow.server.protocol.http2.Http2ServerConnection"); } @Override public void transform(TypeTransformer transformer) { transformer.applyAdviceToMethod( - named("createSinkConduit") + named("getSinkConduit") .and(takesArgument(0, named("io.undertow.server.HttpServerExchange"))), this.getClass().getName() + "$ResponseAdvice"); } diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowInstrumentationModule.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowInstrumentationModule.java index 10871858f449..98b88e2990a0 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowInstrumentationModule.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowInstrumentationModule.java @@ -32,6 +32,6 @@ public List typeInstrumentations() { return asList( new HandlerInstrumentation(), new HttpServerExchangeInstrumentation(), - new HttpTransferEncodingInstrumentation()); + new HttpServerConnectionInstrumentation()); } }