Skip to content

Commit

Permalink
Backport: Fix undertow http response customizer with http2 (#11387)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed May 17, 2024
1 parent 0b73c5b commit be21594
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TypeDescription> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public List<TypeInstrumentation> typeInstrumentations() {
return asList(
new HandlerInstrumentation(),
new HttpServerExchangeInstrumentation(),
new HttpTransferEncodingInstrumentation());
new HttpServerConnectionInstrumentation());
}
}

0 comments on commit be21594

Please sign in to comment.