Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.grizzly;

import static net.bytebuddy.matcher.ElementMatchers.named;

import io.opentelemetry.context.Scope;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

public class FilterChainContextInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.glassfish.grizzly.filterchain.FilterChainContext");
}

@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
named("resume"), FilterChainContextInstrumentation.class.getName() + "$ResumeAdvice");
}

@SuppressWarnings("unused")
public static class ResumeAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope onEnter() {
return Java8BytecodeBridge.rootContext().makeCurrent();
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(@Advice.Enter Scope scope) {
if (scope != null) {
scope.close();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
new FilterInstrumentation(),
new HttpCodecFilterInstrumentation(),
new HttpServerFilterInstrumentation(),
new HttpHandlerInstrumentation());
new HttpHandlerInstrumentation(),
new FilterChainContextInstrumentation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ class GrizzlyAsyncTest extends GrizzlyTest {
false
}

@Override
boolean testHttpPipelining() {
false
}

@Override
boolean verifyServerSpanEndTime() {
// server spans are ended inside of the JAX-RS controller spans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> implements
false
}

@Override
boolean testHttpPipelining() {
false
}

@Override
boolean verifyServerSpanEndTime() {
// server spans are ended inside of the controller spans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class GrizzlyTest extends HttpServerTest<HttpServer> implements AgentTestTrait {
false
}

@Override
boolean testHttpPipelining() {
false
}

static class SimpleExceptionMapper implements ExceptionMapper<Throwable> {

@Override
Expand Down