Class AgentElementMatchers
- java.lang.Object
-
- io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers
-
public class AgentElementMatchers extends Object
This class provides some custom ByteBuddy element matchers to use when applying instrumentation.
-
-
Constructor Summary
Constructors Constructor Description AgentElementMatchers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends net.bytebuddy.description.type.TypeDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>extendsClass(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)static <T> net.bytebuddy.matcher.ElementMatcher.Junction<T>failSafe(net.bytebuddy.matcher.ElementMatcher<? super T> matcher, String description)Wraps another matcher to assure that an element is not matched in case that the matching causes anException.static <T extends net.bytebuddy.description.type.TypeDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>hasInterface(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)static <T extends net.bytebuddy.description.method.MethodDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>hasSuperMethod(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.method.MethodDescription> matcher)Matches a method and all its declarations up the class hierarchy including interfaces using provided matcher.static <T extends net.bytebuddy.description.type.TypeDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>implementsInterface(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)static <T extends net.bytebuddy.description.method.MethodDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>methodIsDeclaredByType(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)Matches method's declaring class against a given type matcher.static <T extends net.bytebuddy.description.type.TypeDescription>
net.bytebuddy.matcher.ElementMatcher.Junction<T>safeHasSuperType(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
-
-
-
Method Detail
-
extendsClass
public static <T extends net.bytebuddy.description.type.TypeDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> extendsClass(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
-
implementsInterface
public static <T extends net.bytebuddy.description.type.TypeDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> implementsInterface(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
-
hasInterface
public static <T extends net.bytebuddy.description.type.TypeDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> hasInterface(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
-
safeHasSuperType
public static <T extends net.bytebuddy.description.type.TypeDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> safeHasSuperType(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
-
methodIsDeclaredByType
public static <T extends net.bytebuddy.description.method.MethodDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> methodIsDeclaredByType(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.type.TypeDescription> matcher)
Matches method's declaring class against a given type matcher.- Type Parameters:
T- Type of the matched object- Parameters:
matcher- type matcher to match method's declaring type against.- Returns:
- a matcher that matches method's declaring class against a given type matcher.
-
hasSuperMethod
public static <T extends net.bytebuddy.description.method.MethodDescription> net.bytebuddy.matcher.ElementMatcher.Junction<T> hasSuperMethod(net.bytebuddy.matcher.ElementMatcher<? super net.bytebuddy.description.method.MethodDescription> matcher)
Matches a method and all its declarations up the class hierarchy including interfaces using provided matcher.- Type Parameters:
T- Type of the matched object- Parameters:
matcher- method matcher to apply to method declarations up the hierarchy.- Returns:
- A matcher that matches a method and all its declarations up the class hierarchy including interfaces.
-
failSafe
public static <T> net.bytebuddy.matcher.ElementMatcher.Junction<T> failSafe(net.bytebuddy.matcher.ElementMatcher<? super T> matcher, String description)Wraps another matcher to assure that an element is not matched in case that the matching causes anException. Logs exception if it happens.- Type Parameters:
T- The type of the matched object.- Parameters:
matcher- The element matcher that potentially throws an exception.- Returns:
- A matcher that returns
falsein case that the given matcher throws an exception.
-
-