Jax-Ws annotation instrumentation should not apply to static methods (#8391)

This commit is contained in:
Lauri Tulmin 2023-04-28 14:13:59 +03:00 committed by GitHub
parent 26a00e0b24
commit d0ee3da709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View File

@ -12,8 +12,10 @@ import static io.opentelemetry.javaagent.instrumentation.jaxrs.v1_0.JaxrsSinglet
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.not;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
@ -47,6 +49,7 @@ public class JaxrsAnnotationsInstrumentation implements TypeInstrumentation {
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod()
.and(not(isStatic()))
.and(
hasSuperMethod(
isAnnotatedWith(

View File

@ -11,8 +11,10 @@ import static io.opentelemetry.javaagent.instrumentation.jaxrs.v2_0.JaxrsAnnotat
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.not;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
@ -48,6 +50,7 @@ public class JaxrsAnnotationsInstrumentation implements TypeInstrumentation {
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod()
.and(not(isStatic()))
.and(
hasSuperMethod(
isAnnotatedWith(

View File

@ -11,8 +11,10 @@ import static io.opentelemetry.javaagent.instrumentation.jaxrs.v3_0.JaxrsAnnotat
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.not;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
@ -48,6 +50,7 @@ public class JaxrsAnnotationsInstrumentation implements TypeInstrumentation {
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod()
.and(not(isStatic()))
.and(
hasSuperMethod(
isAnnotatedWith(

View File

@ -15,7 +15,9 @@ import static net.bytebuddy.matcher.ElementMatchers.inheritsAnnotation;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
@ -50,6 +52,7 @@ public class JwsAnnotationsInstrumentation implements TypeInstrumentation {
transformer.applyAdviceToMethod(
isMethod()
.and(isPublic())
.and(not(isStatic()))
.and(
hasSuperMethod(
methodIsDeclaredByType(inheritsAnnotation(named(JWS_WEB_SERVICE_ANNOTATION))))),