Merge tag 'v0.44.0' into dd-merge
This commit is contained in:
commit
701b282b17
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.tooling;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.skipClassLoader;
|
||||
import static io.opentelemetry.auto.tooling.GlobalIgnoresMatcher.globalIgnoresMatcher;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.GlobalIgnoresMatcher.globalIgnoresMatcher;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
package io.opentelemetry.auto.tooling;
|
||||
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap;
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.AgentCachingPoolStrategy;
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.AgentLocationStrategy;
|
||||
|
||||
/**
|
||||
* This class contains class references for objects shared by the agent installer as well as muzzle
|
||||
|
|
|
@ -1,408 +0,0 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.hasSignature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.description.type.TypeList;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
/**
|
||||
* This class provides some custom ByteBuddy element matchers to use when applying instrumentation
|
||||
*/
|
||||
@Slf4j
|
||||
public class ByteBuddyElementMatchers {
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeExtendsClass(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher));
|
||||
}
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasInterface(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches any type description that declares a super type that matches the provided matcher.
|
||||
* Exceptions during matching process are logged and ignored.
|
||||
*
|
||||
* @param matcher The type to be checked for being a super type of the matched type.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that matches any type description that declares a super type that matches the
|
||||
* provided matcher.
|
||||
* @see ElementMatchers#hasSuperType(net.bytebuddy.matcher.ElementMatcher)
|
||||
*/
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasSuperType(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps another matcher to assure that an element is not matched in case that the matching causes
|
||||
* an {@link Exception}. Logs exception if it happens.
|
||||
*
|
||||
* @param matcher The element matcher that potentially throws an exception.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that returns {@code false} in case that the given matcher throws an
|
||||
* exception.
|
||||
*/
|
||||
public static <T> ElementMatcher.Junction<T> failSafe(
|
||||
final ElementMatcher<? super T> matcher, final String description) {
|
||||
return new SafeMatcher<>(matcher, false, description);
|
||||
}
|
||||
|
||||
private static TypeDescription safeAsErasure(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.asErasure();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get erasure for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An element matcher that matches a super type. This is different from {@link
|
||||
* net.bytebuddy.matcher.HasSuperTypeMatcher} in the following way:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Exceptions are logged
|
||||
* <li>When exception happens the rest of the inheritance subtree is discarded (since ByteBuddy
|
||||
* cannot load/parse type information for it) but search in other subtrees continues
|
||||
* </ul>
|
||||
*
|
||||
* <p>This is useful because this allows us to see when matcher's check is not complete (i.e. part
|
||||
* of it fails), at the same time it makes best effort instead of failing quickly (like {@code
|
||||
* failSafe(hasSuperType(...))} does) which means the code is more resilient to classpath
|
||||
* inconsistencies
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.HasSuperTypeMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
private static class SafeHasSuperTypeMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to any super type of the matched type. */
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
private final boolean interfacesOnly;
|
||||
/**
|
||||
* Creates a new matcher for a super type.
|
||||
*
|
||||
* @param matcher The matcher to apply to any super type of the matched type.
|
||||
*/
|
||||
public SafeHasSuperTypeMatcher(
|
||||
final ElementMatcher<? super TypeDescription.Generic> matcher,
|
||||
final boolean interfacesOnly) {
|
||||
this.matcher = matcher;
|
||||
this.interfacesOnly = interfacesOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final Set<TypeDescription> checkedInterfaces = new HashSet<>();
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (((!interfacesOnly || typeDefinition.isInterface())
|
||||
&& matcher.matches(typeDefinition.asGenericType()))
|
||||
|| hasInterface(typeDefinition, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a type's interfaces against the provided matcher.
|
||||
*
|
||||
* @param typeDefinition The type for which to check all implemented interfaces.
|
||||
* @param checkedInterfaces The interfaces that have already been checked.
|
||||
* @return {@code true} if any interface matches the supplied matcher.
|
||||
*/
|
||||
private boolean hasInterface(
|
||||
final TypeDefinition typeDefinition, final Set<TypeDescription> checkedInterfaces) {
|
||||
for (final TypeDefinition interfaceType : safeGetInterfaces(typeDefinition)) {
|
||||
final TypeDescription erasure = safeAsErasure(interfaceType);
|
||||
if (erasure != null) {
|
||||
if (checkedInterfaces.add(interfaceType.asErasure())
|
||||
&& (matcher.matches(interfaceType.asGenericType())
|
||||
|| hasInterface(interfaceType, checkedInterfaces))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeDefinition#getInterfaces() produces an interator which may throw an exception during
|
||||
* iteration if an interface is absent from the classpath.
|
||||
*
|
||||
* <p>This method exists to allow getting interfaces even if the lookup on one fails.
|
||||
*/
|
||||
private List<TypeDefinition> safeGetInterfaces(final TypeDefinition typeDefinition) {
|
||||
final List<TypeDefinition> interfaceTypes = new ArrayList<>();
|
||||
try {
|
||||
final Iterator<TypeDescription.Generic> interfaceIter =
|
||||
typeDefinition.getInterfaces().iterator();
|
||||
while (interfaceIter.hasNext()) {
|
||||
interfaceTypes.add(interfaceIter.next());
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get interfaces for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
}
|
||||
return interfaceTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeHasSuperType(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An element matcher that matches its argument's {@link TypeDescription.Generic} raw type against
|
||||
* the given matcher for a {@link TypeDescription}. As a wildcard does not define an erasure, a
|
||||
* runtime exception is thrown when this matcher is applied to a wildcard.
|
||||
*
|
||||
* <p>Catches and logs exception if it was thrown when getting erasure, returning false.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.ErasureMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
private static class SafeErasureMatcher<T extends TypeDefinition>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to the raw type of the matched element. */
|
||||
private final ElementMatcher<? super TypeDescription> matcher;
|
||||
|
||||
/**
|
||||
* Creates a new erasure matcher.
|
||||
*
|
||||
* @param matcher The matcher to apply to the raw type.
|
||||
*/
|
||||
public SafeErasureMatcher(final ElementMatcher<? super TypeDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final TypeDescription erasure = safeAsErasure(target);
|
||||
if (erasure == null) {
|
||||
return false;
|
||||
} else {
|
||||
// We would like matcher exceptions to propagate
|
||||
return matcher.matches(erasure);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeErasure(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A fail-safe matcher catches exceptions that are thrown by a delegate matcher and returns an
|
||||
* alternative value.
|
||||
*
|
||||
* <p>Logs exception if it was thrown.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.FailSafeMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
private static class SafeMatcher<T> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The delegate matcher that might throw an exception. */
|
||||
private final ElementMatcher<? super T> matcher;
|
||||
|
||||
/** The fallback value in case of an exception. */
|
||||
private final boolean fallback;
|
||||
|
||||
/** The text description to log if exception happens. */
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Creates a new fail-safe element matcher.
|
||||
*
|
||||
* @param matcher The delegate matcher that might throw an exception.
|
||||
* @param fallback The fallback value in case of an exception.
|
||||
* @param description Descriptive string to log along with exception.
|
||||
*/
|
||||
public SafeMatcher(
|
||||
final ElementMatcher<? super T> matcher, final boolean fallback, final String description) {
|
||||
this.matcher = matcher;
|
||||
this.fallback = fallback;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
try {
|
||||
return matcher.matches(target);
|
||||
} catch (final Exception e) {
|
||||
log.debug(description, e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeMatcher(try(" + matcher + ") or " + fallback + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private static String safeTypeDefinitionName(final TypeDefinition td) {
|
||||
try {
|
||||
return td.getTypeName();
|
||||
} catch (final IllegalStateException ex) {
|
||||
final String message = ex.getMessage();
|
||||
if (message.startsWith("Cannot resolve type description for ")) {
|
||||
return message.replace("Cannot resolve type description for ", "");
|
||||
} else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add javadoc
|
||||
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasSuperMethod(
|
||||
final ElementMatcher<? super MethodDescription> matcher) {
|
||||
return new HasSuperMethodMatcher<>(matcher);
|
||||
}
|
||||
|
||||
// TODO: add javadoc
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
private static class HasSuperMethodMatcher<T extends MethodDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super MethodDescription> matcher;
|
||||
|
||||
public HasSuperMethodMatcher(final ElementMatcher<? super MethodDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final MethodDescription target) {
|
||||
if (target.isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
final Junction<MethodDescription> signatureMatcher = hasSignature(target.asSignatureToken());
|
||||
TypeDefinition declaringType = target.getDeclaringType();
|
||||
final Set<TypeDefinition> checkedInterfaces = new HashSet<>();
|
||||
|
||||
while (declaringType != null) {
|
||||
for (final MethodDescription methodDescription : declaringType.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(declaringType.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
declaringType = safeGetSuperClass(declaringType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesInterface(
|
||||
final TypeList.Generic interfaces,
|
||||
final Junction<MethodDescription> signatureMatcher,
|
||||
final Set<TypeDefinition> checkedInterfaces) {
|
||||
for (final TypeDefinition type : interfaces) {
|
||||
if (!checkedInterfaces.contains(type)) {
|
||||
checkedInterfaces.add(type);
|
||||
for (final MethodDescription methodDescription : type.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(type.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hasSuperMethodMatcher(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private static TypeDefinition safeGetSuperClass(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.getSuperClass();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get super class for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SafeExtendsClassMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
public SafeExtendsClassMatcher(final ElementMatcher<? super TypeDescription.Generic> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (matcher.matches(typeDefinition.asGenericType())) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,13 +15,14 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.failSafe;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.failSafe;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
import io.opentelemetry.auto.config.Config;
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.ExceptionHandlers;
|
||||
import io.opentelemetry.auto.tooling.context.FieldBackedProvider;
|
||||
import io.opentelemetry.auto.tooling.context.InstrumentationContextProvider;
|
||||
import io.opentelemetry.auto.tooling.context.NoopContextProvider;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
package io.opentelemetry.auto.tooling.bytebuddy;
|
||||
|
||||
import static net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class AgentCachingPoolStrategy implements PoolStrategy {
|
|||
static final int LOADER_CAPACITY = 64;
|
||||
static final int TYPE_CAPACITY = 64;
|
||||
|
||||
static final int BOOTSTRAP_HASH = 0;
|
||||
static final int BOOTSTRAP_HASH = 7236344; // Just a random number
|
||||
|
||||
/**
|
||||
* Cache of recent ClassLoader WeakReferences; used to...
|
||||
|
@ -155,7 +155,7 @@ public class AgentCachingPoolStrategy implements PoolStrategy {
|
|||
this.loaderRef = loaderRef;
|
||||
this.className = className;
|
||||
|
||||
hashCode = (int) (31 * this.loaderHash) ^ className.hashCode();
|
||||
hashCode = 31 * this.loaderHash + className.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,12 +175,13 @@ public class AgentCachingPoolStrategy implements PoolStrategy {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Fastpath loaderRef equivalence -- works because of WeakReference cache used
|
||||
// Also covers the bootstrap null loaderRef case
|
||||
if (loaderRef == that.loaderRef) {
|
||||
// still need to check name
|
||||
return className.equals(that.className);
|
||||
} else if (className.equals(that.className)) {
|
||||
if (className.equals(that.className)) {
|
||||
// Fastpath loaderRef equivalence -- works because of WeakReference cache used
|
||||
// Also covers the bootstrap null loaderRef case
|
||||
if (loaderRef == that.loaderRef) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// need to perform a deeper loader check -- requires calling Reference.get
|
||||
// which can strengthen the Reference, so deliberately done last
|
||||
|
|
@ -13,8 +13,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
package io.opentelemetry.auto.tooling.bytebuddy;
|
||||
|
||||
import io.opentelemetry.auto.tooling.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy;
|
||||
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.asm.TypeConstantAdjustment;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.dynamic.DynamicType;
|
||||
import net.bytebuddy.utility.JavaModule;
|
||||
|
||||
public class AgentTransformers {
|
||||
|
||||
private static final AgentBuilder.Transformer CONSTANT_ADJUSTER =
|
||||
new AgentBuilder.Transformer() {
|
||||
@Override
|
||||
public DynamicType.Builder<?> transform(
|
||||
final DynamicType.Builder<?> builder,
|
||||
final TypeDescription typeDescription,
|
||||
final ClassLoader classLoader,
|
||||
final JavaModule javaModule) {
|
||||
return builder.visit(TypeConstantAdjustment.INSTANCE);
|
||||
}
|
||||
};
|
||||
|
||||
public static AgentBuilder.Transformer defaultTransformers() {
|
||||
return CONSTANT_ADJUSTER;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
package io.opentelemetry.auto.tooling.bytebuddy;
|
||||
|
||||
import io.opentelemetry.auto.bootstrap.ExceptionLogger;
|
||||
import net.bytebuddy.ClassFileVersion;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling;
|
||||
package io.opentelemetry.auto.tooling.bytebuddy;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
|
@ -21,7 +21,7 @@ import net.bytebuddy.description.type.TypeDescription;
|
|||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class GlobalIgnoresMatcher<T extends TypeDescription>
|
||||
public class GlobalIgnoresMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private static final Pattern COM_MCHANGE_PROXY =
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
/**
|
||||
* This class provides some custom ByteBuddy element matchers to use when applying instrumentation
|
||||
*/
|
||||
@Slf4j
|
||||
public class AgentElementMatchers {
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> extendsClass(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher));
|
||||
}
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasInterface(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches any type description that declares a super type that matches the provided matcher.
|
||||
* Exceptions during matching process are logged and ignored.
|
||||
*
|
||||
* @param matcher The type to be checked for being a super type of the matched type.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that matches any type description that declares a super type that matches the
|
||||
* provided matcher.
|
||||
* @see ElementMatchers#hasSuperType(net.bytebuddy.matcher.ElementMatcher)
|
||||
*/
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasSuperType(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), false);
|
||||
}
|
||||
// TODO: add javadoc
|
||||
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasSuperMethod(
|
||||
final ElementMatcher<? super MethodDescription> matcher) {
|
||||
return new HasSuperMethodMatcher<>(matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps another matcher to assure that an element is not matched in case that the matching causes
|
||||
* an {@link Exception}. Logs exception if it happens.
|
||||
*
|
||||
* @param matcher The element matcher that potentially throws an exception.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that returns {@code false} in case that the given matcher throws an
|
||||
* exception.
|
||||
*/
|
||||
public static <T> ElementMatcher.Junction<T> failSafe(
|
||||
final ElementMatcher<? super T> matcher, final String description) {
|
||||
return new LoggingFailSafeMatcher<>(matcher, false, description);
|
||||
}
|
||||
|
||||
static String safeTypeDefinitionName(final TypeDefinition td) {
|
||||
try {
|
||||
return td.getTypeName();
|
||||
} catch (final IllegalStateException ex) {
|
||||
final String message = ex.getMessage();
|
||||
if (message.startsWith("Cannot resolve type description for ")) {
|
||||
return message.replace("Cannot resolve type description for ", "");
|
||||
} else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.SafeHasSuperTypeMatcher.safeGetSuperClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.hasSignature;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeList;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
// TODO: add javadoc
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class HasSuperMethodMatcher<T extends MethodDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super MethodDescription> matcher;
|
||||
|
||||
public HasSuperMethodMatcher(final ElementMatcher<? super MethodDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final MethodDescription target) {
|
||||
if (target.isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
final Junction<MethodDescription> signatureMatcher = hasSignature(target.asSignatureToken());
|
||||
TypeDefinition declaringType = target.getDeclaringType();
|
||||
final Set<TypeDefinition> checkedInterfaces = new HashSet<>();
|
||||
|
||||
while (declaringType != null) {
|
||||
for (final MethodDescription methodDescription : declaringType.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(declaringType.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
declaringType = safeGetSuperClass(declaringType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesInterface(
|
||||
final TypeList.Generic interfaces,
|
||||
final Junction<MethodDescription> signatureMatcher,
|
||||
final Set<TypeDefinition> checkedInterfaces) {
|
||||
for (final TypeDefinition type : interfaces) {
|
||||
if (!checkedInterfaces.contains(type)) {
|
||||
checkedInterfaces.add(type);
|
||||
for (final MethodDescription methodDescription : type.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(type.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hasSuperMethodMatcher(" + matcher + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* A fail-safe matcher catches exceptions that are thrown by a delegate matcher and returns an
|
||||
* alternative value.
|
||||
*
|
||||
* <p>Logs exception if it was thrown.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.FailSafeMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class LoggingFailSafeMatcher<T> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The delegate matcher that might throw an exception. */
|
||||
private final ElementMatcher<? super T> matcher;
|
||||
|
||||
/** The fallback value in case of an exception. */
|
||||
private final boolean fallback;
|
||||
|
||||
/** The text description to log if exception happens. */
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Creates a new fail-safe element matcher.
|
||||
*
|
||||
* @param matcher The delegate matcher that might throw an exception.
|
||||
* @param fallback The fallback value in case of an exception.
|
||||
* @param description Descriptive string to log along with exception.
|
||||
*/
|
||||
public LoggingFailSafeMatcher(
|
||||
final ElementMatcher<? super T> matcher, final boolean fallback, final String description) {
|
||||
this.matcher = matcher;
|
||||
this.fallback = fallback;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
try {
|
||||
return matcher.matches(target);
|
||||
} catch (final Exception e) {
|
||||
log.debug(description, e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeMatcher(try(" + matcher + ") or " + fallback + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeTypeDefinitionName;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* An element matcher that matches its argument's {@link TypeDescription.Generic} raw type against
|
||||
* the given matcher for a {@link TypeDescription}. As a wildcard does not define an erasure, a
|
||||
* runtime exception is thrown when this matcher is applied to a wildcard.
|
||||
*
|
||||
* <p>Catches and logs exception if it was thrown when getting erasure, returning false.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.ErasureMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class SafeErasureMatcher<T extends TypeDefinition> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to the raw type of the matched element. */
|
||||
private final ElementMatcher<? super TypeDescription> matcher;
|
||||
|
||||
/**
|
||||
* Creates a new erasure matcher.
|
||||
*
|
||||
* @param matcher The matcher to apply to the raw type.
|
||||
*/
|
||||
public SafeErasureMatcher(final ElementMatcher<? super TypeDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final TypeDescription erasure = safeAsErasure(target);
|
||||
if (erasure == null) {
|
||||
return false;
|
||||
} else {
|
||||
// We would like matcher exceptions to propagate
|
||||
return matcher.matches(erasure);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeErasure(" + matcher + ")";
|
||||
}
|
||||
|
||||
static TypeDescription safeAsErasure(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.asErasure();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get erasure for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.SafeHasSuperTypeMatcher.safeGetSuperClass;
|
||||
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
class SafeExtendsClassMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
public SafeExtendsClassMatcher(final ElementMatcher<? super TypeDescription.Generic> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (matcher.matches(typeDefinition.asGenericType())) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeTypeDefinitionName;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.SafeErasureMatcher.safeAsErasure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* An element matcher that matches a super type. This is different from {@link
|
||||
* net.bytebuddy.matcher.HasSuperTypeMatcher} in the following way:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Exceptions are logged
|
||||
* <li>When exception happens the rest of the inheritance subtree is discarded (since ByteBuddy
|
||||
* cannot load/parse type information for it) but search in other subtrees continues
|
||||
* </ul>
|
||||
*
|
||||
* <p>This is useful because this allows us to see when matcher's check is not complete (i.e. part
|
||||
* of it fails), at the same time it makes best effort instead of failing quickly (like {@code
|
||||
* failSafe(hasSuperType(...))} does) which means the code is more resilient to classpath
|
||||
* inconsistencies
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.HasSuperTypeMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class SafeHasSuperTypeMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to any super type of the matched type. */
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
private final boolean interfacesOnly;
|
||||
/**
|
||||
* Creates a new matcher for a super type.
|
||||
*
|
||||
* @param matcher The matcher to apply to any super type of the matched type.
|
||||
*/
|
||||
public SafeHasSuperTypeMatcher(
|
||||
final ElementMatcher<? super TypeDescription.Generic> matcher, final boolean interfacesOnly) {
|
||||
this.matcher = matcher;
|
||||
this.interfacesOnly = interfacesOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final Set<TypeDescription> checkedInterfaces = new HashSet<>();
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (((!interfacesOnly || typeDefinition.isInterface())
|
||||
&& matcher.matches(typeDefinition.asGenericType()))
|
||||
|| hasInterface(typeDefinition, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a type's interfaces against the provided matcher.
|
||||
*
|
||||
* @param typeDefinition The type for which to check all implemented interfaces.
|
||||
* @param checkedInterfaces The interfaces that have already been checked.
|
||||
* @return {@code true} if any interface matches the supplied matcher.
|
||||
*/
|
||||
private boolean hasInterface(
|
||||
final TypeDefinition typeDefinition, final Set<TypeDescription> checkedInterfaces) {
|
||||
for (final TypeDefinition interfaceType : safeGetInterfaces(typeDefinition)) {
|
||||
final TypeDescription erasure = safeAsErasure(interfaceType);
|
||||
if (erasure != null) {
|
||||
if (checkedInterfaces.add(interfaceType.asErasure())
|
||||
&& (matcher.matches(interfaceType.asGenericType())
|
||||
|| hasInterface(interfaceType, checkedInterfaces))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeDefinition#getInterfaces() produces an interator which may throw an exception during
|
||||
* iteration if an interface is absent from the classpath.
|
||||
*
|
||||
* <p>This method exists to allow getting interfaces even if the lookup on one fails.
|
||||
*/
|
||||
private List<TypeDefinition> safeGetInterfaces(final TypeDefinition typeDefinition) {
|
||||
final List<TypeDefinition> interfaceTypes = new ArrayList<>();
|
||||
try {
|
||||
final Iterator<TypeDescription.Generic> interfaceIter =
|
||||
typeDefinition.getInterfaces().iterator();
|
||||
while (interfaceIter.hasNext()) {
|
||||
interfaceTypes.add(interfaceIter.next());
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get interfaces for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
}
|
||||
return interfaceTypes;
|
||||
}
|
||||
|
||||
static TypeDefinition safeGetSuperClass(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.getSuperClass();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get super class for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeHasSuperType(" + matcher + ")";
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.tooling.context;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
|
|
@ -19,7 +19,7 @@ import ch.qos.logback.classic.Level
|
|||
import ch.qos.logback.classic.Logger
|
||||
import ch.qos.logback.core.read.ListAppender
|
||||
import io.opentelemetry.auto.bootstrap.ExceptionLogger
|
||||
import io.opentelemetry.auto.tooling.ExceptionHandlers
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.ExceptionHandlers
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.agent.ByteBuddyAgent
|
||||
import net.bytebuddy.agent.builder.AgentBuilder
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.test
|
||||
|
||||
import io.opentelemetry.auto.tooling.AgentLocationStrategy
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.AgentLocationStrategy
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.agent.builder.AgentBuilder
|
||||
import spock.lang.Shared
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.tooling
|
||||
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.AgentCachingPoolStrategy
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
import net.bytebuddy.dynamic.ClassFileLocator
|
||||
|
@ -230,7 +231,8 @@ class CacheProviderTest extends AgentSpecification {
|
|||
}
|
||||
|
||||
@Override
|
||||
void close() throws IOException {}
|
||||
void close() throws IOException {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher
|
||||
|
||||
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.A
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.B
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.C
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.F
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.G
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.Trace
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.TracedClass
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.UntracedClass
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.description.method.MethodDescription
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasSuperMethod
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith
|
||||
import static net.bytebuddy.matcher.ElementMatchers.none
|
||||
|
||||
class HasSuperMethodMatcherTest extends AgentSpecification {
|
||||
|
||||
def "test matcher #type.simpleName #method"() {
|
||||
expect:
|
||||
hasSuperMethod(isAnnotatedWith(Trace)).matches(argument) == result
|
||||
|
||||
where:
|
||||
type | method | result
|
||||
A | "a" | false
|
||||
B | "b" | true
|
||||
C | "c" | false
|
||||
F | "f" | true
|
||||
G | "g" | false
|
||||
TracedClass | "a" | true
|
||||
UntracedClass | "a" | false
|
||||
UntracedClass | "b" | true
|
||||
|
||||
argument = new MethodDescription.ForLoadedMethod(type.getDeclaredMethod(method))
|
||||
}
|
||||
|
||||
def "test constructor never matches"() {
|
||||
setup:
|
||||
def method = Mock(MethodDescription)
|
||||
def matcher = hasSuperMethod(none())
|
||||
|
||||
when:
|
||||
def result = matcher.matches(method)
|
||||
|
||||
then:
|
||||
!result
|
||||
1 * method.isConstructor() >> true
|
||||
0 * _
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def method = Mock(MethodDescription)
|
||||
def matcher = hasSuperMethod(none())
|
||||
def sigToken = new MethodDescription.ForLoadedMethod(A.getDeclaredMethod("a")).asSignatureToken()
|
||||
|
||||
when:
|
||||
def result = matcher.matches(method)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
1 * method.isConstructor() >> false
|
||||
1 * method.asSignatureToken() >> sigToken
|
||||
1 * method.getDeclaringType() >> null
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher
|
||||
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.A
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.B
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.F
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.G
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeExtendsClassMatcherTest extends AgentSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
extendsClass(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | B | false
|
||||
A | F | false
|
||||
G | F | false
|
||||
F | F | true
|
||||
F | G | true
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = extendsClass(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * type.getTypeName() >> "type-name"
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher
|
||||
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.A
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.B
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.E
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.F
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.G
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeHasInterfaceMatcherTest extends AgentSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
hasInterface(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | A | true
|
||||
A | B | true
|
||||
B | A | false
|
||||
A | E | true
|
||||
A | F | true
|
||||
F | A | false
|
||||
F | F | false
|
||||
F | G | false
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = hasInterface(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.isInterface() >> true
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getInterfaces() >> { throw new Exception("getInterfaces exception") }
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
2 * type.getTypeName() >> "type-name"
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher
|
||||
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.A
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.B
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.E
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.F
|
||||
import io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses.G
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeHasSuperTypeMatcherTest extends AgentSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
safeHasSuperType(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | A | true
|
||||
A | B | true
|
||||
B | A | false
|
||||
A | E | true
|
||||
A | F | true
|
||||
F | A | false
|
||||
F | F | true
|
||||
F | G | true
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = safeHasSuperType(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getInterfaces() >> { throw new Exception("getInterfaces exception") }
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
2 * type.getTypeName() >> "type-name"
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher
|
||||
|
||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||
import net.bytebuddy.matcher.ElementMatcher
|
||||
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.failSafe
|
||||
|
||||
class SafeMatcherTest extends AgentSpecification {
|
||||
|
||||
def mockMatcher = Mock(ElementMatcher)
|
||||
|
||||
def "test matcher"() {
|
||||
setup:
|
||||
def matcher = failSafe(mockMatcher, "test")
|
||||
|
||||
when:
|
||||
def result = matcher.matches(new Object())
|
||||
|
||||
then:
|
||||
1 * mockMatcher.matches(_) >> match
|
||||
result == match
|
||||
|
||||
where:
|
||||
match << [true, false]
|
||||
}
|
||||
|
||||
def "test matcher exception"() {
|
||||
setup:
|
||||
def matcher = failSafe(mockMatcher, "test")
|
||||
|
||||
when:
|
||||
def result = matcher.matches(new Object())
|
||||
|
||||
then:
|
||||
1 * mockMatcher.matches(_) >> { throw new Exception("matcher exception") }
|
||||
0 * _
|
||||
noExceptionThrown()
|
||||
!result // default to false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface A {
|
||||
void a();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface B extends A {
|
||||
@Trace
|
||||
void b();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface C extends A, B {
|
||||
void c();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface D extends A, B, C {
|
||||
@Trace
|
||||
void d();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface E extends B, C, D {
|
||||
void e();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public abstract class F implements E {
|
||||
@Trace
|
||||
public abstract void f();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public abstract class G extends F {
|
||||
public void g() {}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
public @interface Trace {}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public class TracedClass extends UntracedClass {
|
||||
@Trace
|
||||
@Override
|
||||
public void g() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void f() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void e() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void d() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void c() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void b() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void a() {}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.opentelemetry.auto.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public class UntracedClass extends G {
|
||||
@Override
|
||||
public void g() {}
|
||||
|
||||
@Override
|
||||
public void f() {}
|
||||
|
||||
@Override
|
||||
public void e() {}
|
||||
|
||||
@Override
|
||||
public void d() {}
|
||||
|
||||
@Override
|
||||
public void c() {}
|
||||
|
||||
@Override
|
||||
public void b() {}
|
||||
|
||||
@Override
|
||||
public void a() {}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package datadog.trace.instrumentation.rmi.server;
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.rmi.ThreadLocalContext.THREAD_LOCAL_CONTEXT;
|
||||
import static datadog.trace.instrumentation.rmi.server.RmiServerDecorator.DECORATE;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
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 com.google.auto.service.AutoService;
|
||||
import datadog.trace.agent.tooling.Instrumenter;
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
|
||||
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
@AutoService(Instrumenter.class)
|
||||
public final class RmiServerInstrumentation extends Instrumenter.Default {
|
||||
|
||||
public RmiServerInstrumentation() {
|
||||
super("rmi", "rmi-server");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] helperClassNames() {
|
||||
return new String[] {
|
||||
"datadog.trace.agent.decorator.ServerDecorator",
|
||||
"datadog.trace.agent.decorator.BaseDecorator",
|
||||
packageName + ".RmiServerDecorator"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(extendsClass(named("java.rmi.server.RemoteServer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
isMethod().and(isPublic()).and(not(isStatic())), getClass().getName() + "$ServerAdvice");
|
||||
}
|
||||
|
||||
public static class ServerAdvice {
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class, inline = true)
|
||||
public static AgentScope onEnter(
|
||||
@Advice.This final Object thiz, @Advice.Origin final Method method) {
|
||||
final AgentSpan.Context context = THREAD_LOCAL_CONTEXT.getAndResetContext();
|
||||
|
||||
final AgentSpan span;
|
||||
if (context == null) {
|
||||
span = startSpan("rmi.request");
|
||||
} else {
|
||||
span = startSpan("rmi.request", context);
|
||||
}
|
||||
|
||||
span.setTag(DDTags.RESOURCE_NAME, DECORATE.spanNameForMethod(method))
|
||||
.setTag("span.origin.type", thiz.getClass().getCanonicalName());
|
||||
|
||||
DECORATE.afterStart(span);
|
||||
return activateSpan(span, true);
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void stopSpan(
|
||||
@Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) {
|
||||
if (scope == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DECORATE.onError(scope, throwable);
|
||||
|
||||
scope.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.apachehttpasyncclient;
|
|||
import static io.opentelemetry.auto.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpasyncclient.HttpHeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -54,7 +54,7 @@ public class ApacheHttpAsyncClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("org.apache.http.nio.client.HttpAsyncClient"));
|
||||
return hasInterface(named("org.apache.http.nio.client.HttpAsyncClient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.apachehttpasyncclient;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -46,7 +46,7 @@ public class ApacheHttpClientRedirectInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("org.apache.http.client.RedirectStrategy"));
|
||||
return hasInterface(named("org.apache.http.client.RedirectStrategy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.apachehttpclient.v3_0;
|
|||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.v3_0.ApacheHttpClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.v3_0.ApacheHttpClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.v3_0.HttpHeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
|
@ -51,7 +51,7 @@ public class ApacheHttpClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(named("org.apache.commons.httpclient.HttpClient"));
|
||||
return extendsClass(named("org.apache.commons.httpclient.HttpClient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.apachehttpclient;
|
|||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.ApacheHttpClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.ApacheHttpClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.apachehttpclient.HttpHeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -59,7 +59,7 @@ public class ApacheHttpClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.apache.http.client.HttpClient")));
|
||||
return not(isInterface()).and(hasInterface(named("org.apache.http.client.HttpClient")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.aws.v0;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -43,7 +43,7 @@ public final class RequestInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return nameStartsWith("com.amazonaws.")
|
||||
.and(safeExtendsClass(named("com.amazonaws.AmazonWebServiceRequest")));
|
||||
.and(extendsClass(named("com.amazonaws.AmazonWebServiceRequest")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.aws.v2;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -41,8 +41,7 @@ public final class AwsClientInstrumentation extends AbstractAwsClientInstrumenta
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return nameStartsWith("software.amazon.awssdk.")
|
||||
.and(not(isInterface()))
|
||||
.and(
|
||||
safeHasInterface(named("software.amazon.awssdk.core.client.builder.SdkClientBuilder")));
|
||||
.and(hasInterface(named("software.amazon.awssdk.core.client.builder.SdkClientBuilder")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.aws.v2;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.aws.v2.TracingExecutionInterceptor.ScopeHolder.CURRENT;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -46,7 +46,7 @@ public final class AwsHttpClientInstrumentation extends AbstractAwsClientInstrum
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return nameStartsWith("software.amazon.awssdk.")
|
||||
.and(
|
||||
safeExtendsClass(
|
||||
extendsClass(
|
||||
named(
|
||||
"software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage")
|
||||
.or(
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.classloading;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
|
||||
|
@ -59,7 +59,7 @@ public final class ClassloadingInstrumentation extends Instrumenter.Default {
|
|||
return not(named("java.lang.ClassLoader"))
|
||||
.and(not(named("com.ibm.oti.vm.BootstrapClassLoader")))
|
||||
.and(not(named("io.opentelemetry.auto.bootstrap.AgentClassLoader")))
|
||||
.and(safeHasSuperType(named("java.lang.ClassLoader")));
|
||||
.and(extendsClass(named("java.lang.ClassLoader")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.couchbase.client;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -48,7 +48,7 @@ public class CouchbaseNetworkInstrumentation extends Instrumenter.Default {
|
|||
// Exact class because private fields are used
|
||||
return nameStartsWith("com.couchbase.client.")
|
||||
.<TypeDescription>and(
|
||||
safeExtendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler")));
|
||||
extendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.dropwizard.view;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -50,7 +50,7 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.dropwizard.views.ViewRenderer")));
|
||||
return not(isInterface()).and(hasInterface(named("io.dropwizard.views.ViewRenderer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.finatra;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.finatra.FinatraDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.finatra.FinatraDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -68,7 +68,7 @@ public class FinatraInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return nameStartsWith("com.twitter.finatra.")
|
||||
.and(not(isInterface()))
|
||||
.and(safeExtendsClass(named("com.twitter.finatra.http.internal.routing.Route")));
|
||||
.and(extendsClass(named("com.twitter.finatra.http.internal.routing.Route")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,7 +47,7 @@ public class CriteriaInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -49,7 +49,7 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Query")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.hibernate.core.v3_3;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -54,7 +54,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SessionFactory")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SessionFactory")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
returns(
|
||||
named("org.hibernate.Session")
|
||||
.or(named("org.hibernate.StatelessSession"))
|
||||
.or(safeHasInterface(named("org.hibernate.Session"))))),
|
||||
.or(hasInterface(named("org.hibernate.Session"))))),
|
||||
SessionFactoryInstrumentation.class.getName() + "$SessionFactoryAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.hibernate.core.v3_3;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.SessionMethodUtils.SCOPE_ONLY_METHODS;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -65,7 +65,7 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(
|
||||
safeHasInterface(
|
||||
hasInterface(
|
||||
named("org.hibernate.Session").or(named("org.hibernate.StatelessSession"))));
|
||||
}
|
||||
|
||||
|
@ -114,11 +114,11 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
SessionInstrumentation.class.getName() + "$GetTransactionAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Query")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Query")))),
|
||||
SessionInstrumentation.class.getName() + "$GetQueryAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Criteria")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Criteria")))),
|
||||
SessionInstrumentation.class.getName() + "$GetCriteriaAdvice");
|
||||
|
||||
return transformers;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,7 +47,7 @@ public class TransactionInstrumentation extends AbstractHibernateInstrumentation
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,7 +47,7 @@ public class CriteriaInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -49,7 +49,7 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Query")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.hibernate.core.v4_0;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SessionFactory")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SessionFactory")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.hibernate.core.v4_0;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.instrumentation.hibernate.SessionMethodUtils.SCOPE_ONLY_METHODS;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -61,7 +61,7 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,11 +108,11 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
SessionInstrumentation.class.getName() + "$GetTransactionAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Query")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Query")))),
|
||||
SessionInstrumentation.class.getName() + "$GetQueryAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Criteria")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Criteria")))),
|
||||
SessionInstrumentation.class.getName() + "$GetCriteriaAdvice");
|
||||
|
||||
return transformers;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,7 +47,7 @@ public class TransactionInstrumentation extends AbstractHibernateInstrumentation
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_3;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -62,7 +62,7 @@ public class ProcedureCallInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.procedure.ProcedureCall")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.procedure.ProcedureCall")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_3;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -68,13 +68,13 @@ public class SessionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.procedure.ProcedureCall")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.procedure.ProcedureCall")))),
|
||||
SessionInstrumentation.class.getName() + "$GetProcedureCallAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.http_url_connection;
|
|||
import static io.opentelemetry.auto.instrumentation.http_url_connection.HeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.http_url_connection.HttpUrlConnectionDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.http_url_connection.HttpUrlConnectionDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -55,7 +55,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
|||
.or(ElementMatchers.<TypeDescription>nameStartsWith("sun.net"))
|
||||
// This class is a simple delegator. Skip because it does not update its `connected` field.
|
||||
.and(not(named("sun.net.www.protocol.https.HttpsURLConnectionImpl")))
|
||||
.and(safeExtendsClass(named("java.net.HttpURLConnection")));
|
||||
.and(extendsClass(named("java.net.HttpURLConnection")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.hystrix;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.hystrix.HystrixDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static io.opentelemetry.trace.Span.Kind.INTERNAL;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -45,7 +45,7 @@ public class HystrixInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(
|
||||
return extendsClass(
|
||||
named("com.netflix.hystrix.HystrixCommand")
|
||||
.or(named("com.netflix.hystrix.HystrixObservableCommand")));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
@ -118,6 +118,8 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
ElementMatcher.Junction<TypeDescription> matcher = not(isInterface());
|
||||
final ElementMatcher.Junction<TypeDescription> hasExecutorInterfaceMatcher =
|
||||
hasInterface(named(Executor.class.getName()));
|
||||
if (!TRACE_ALL_EXECUTORS) {
|
||||
matcher =
|
||||
matcher.and(
|
||||
|
@ -136,15 +138,16 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
|
|||
}
|
||||
}
|
||||
|
||||
if (!whitelisted) {
|
||||
if (!whitelisted
|
||||
&& log.isDebugEnabled()
|
||||
&& hasExecutorInterfaceMatcher.matches(target)) {
|
||||
log.debug("Skipping executor instrumentation for {}", target.getName());
|
||||
}
|
||||
return whitelisted;
|
||||
}
|
||||
});
|
||||
}
|
||||
return matcher.and(
|
||||
safeHasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
|
||||
return matcher.and(hasExecutorInterfaceMatcher); // Apply expensive matcher last.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -59,7 +59,7 @@ public final class AkkaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME)));
|
||||
return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -93,19 +93,23 @@ public final class FutureInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
final ElementMatcher.Junction<TypeDescription> hasFutureInterfaceMatcher =
|
||||
hasInterface(named(Future.class.getName()));
|
||||
return not(isInterface())
|
||||
.and(
|
||||
new ElementMatcher<TypeDescription>() {
|
||||
@Override
|
||||
public boolean matches(final TypeDescription target) {
|
||||
final boolean whitelisted = WHITELISTED_FUTURES.contains(target.getName());
|
||||
if (!whitelisted) {
|
||||
if (!whitelisted
|
||||
&& log.isDebugEnabled()
|
||||
&& hasFutureInterfaceMatcher.matches(target)) {
|
||||
log.debug("Skipping future instrumentation for {}", target.getName());
|
||||
}
|
||||
return whitelisted;
|
||||
}
|
||||
})
|
||||
.and(safeHasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
|
||||
.and(hasFutureInterfaceMatcher); // Apply expensive matcher last.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -57,7 +57,7 @@ public final class JavaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(ForkJoinTask.class.getName())));
|
||||
return not(isInterface()).and(extendsClass(named(ForkJoinTask.class.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -50,7 +50,7 @@ public final class RunnableCallableInstrumentation extends Instrumenter.Default
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named(Runnable.class.getName()).or(named(Callable.class.getName()))));
|
||||
.and(hasInterface(named(Runnable.class.getName()).or(named(Callable.class.getName()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -59,7 +59,7 @@ public final class ScalaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME)));
|
||||
return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jul;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -41,7 +41,7 @@ public class JavaUtilLoggingEventInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(named("java.util.logging.Logger"));
|
||||
return extendsClass(named("java.util.logging.Logger"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,9 +17,9 @@ package io.opentelemetry.auto.instrumentation.jaxrs1;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs1.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs1.JaxRsAnnotationsDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.hasSuperMethod;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.classLoaderHasClasses;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasSuperMethod;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.jaxrs2;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -44,7 +44,7 @@ public abstract class AbstractRequestContextInstrumentation extends Instrumenter
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestContext")));
|
||||
.and(hasInterface(named("javax.ws.rs.container.ContainerRequestContext")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jaxrs2;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class ContainerRequestFilterInstrumentation extends Instrumenter.Default
|
|||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestFilter")));
|
||||
.and(hasInterface(named("javax.ws.rs.container.ContainerRequestFilter")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,8 +17,8 @@ package io.opentelemetry.auto.instrumentation.jaxrs2;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.hasSuperMethod;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasSuperMethod;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.jaxrs2;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -49,7 +49,7 @@ public final class JaxRsAsyncResponseInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("javax.ws.rs.container.AsyncResponse"));
|
||||
return hasInterface(named("javax.ws.rs.container.AsyncResponse"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,8 @@ import static io.opentelemetry.auto.decorator.HttpServerDecorator.SPAN_ATTRIBUTE
|
|||
import static io.opentelemetry.auto.instrumentation.jaxrs.v1.InjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs.v1.JaxRsClientV1Decorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs.v1.JaxRsClientV1Decorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -49,7 +49,7 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("com.sun.jersey.api.client.ClientHandler"));
|
||||
return hasInterface(named("com.sun.jersey.api.client.ClientHandler"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,10 +67,8 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
|
|||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
named("handle")
|
||||
.and(
|
||||
takesArgument(
|
||||
0, safeExtendsClass(named("com.sun.jersey.api.client.ClientRequest"))))
|
||||
.and(returns(safeExtendsClass(named("com.sun.jersey.api.client.ClientResponse")))),
|
||||
.and(takesArgument(0, extendsClass(named("com.sun.jersey.api.client.ClientRequest"))))
|
||||
.and(returns(extendsClass(named("com.sun.jersey.api.client.ClientResponse")))),
|
||||
JaxRsClientV1Instrumentation.class.getName() + "$HandleAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jaxrs;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -40,7 +40,7 @@ public final class JaxRsClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(named("javax.ws.rs.client.ClientBuilder"));
|
||||
return extendsClass(named("javax.ws.rs.client.ClientBuilder"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,7 @@ public final class JaxRsClientInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
named("build").and(returns(safeHasInterface(named("javax.ws.rs.client.Client")))),
|
||||
named("build").and(returns(hasInterface(named("javax.ws.rs.client.Client")))),
|
||||
JaxRsClientInstrumentation.class.getName() + "$ClientBuilderAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jdbc;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -42,7 +42,7 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Connection")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Connection")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,7 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
|
|||
nameStartsWith("prepare")
|
||||
.and(takesArgument(0, String.class))
|
||||
// Also include CallableStatement, which is a sub type of PreparedStatement
|
||||
.and(returns(safeHasInterface(named("java.sql.PreparedStatement")))),
|
||||
.and(returns(hasInterface(named("java.sql.PreparedStatement")))),
|
||||
ConnectionInstrumentation.class.getName() + "$ConnectionPrepareAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.jdbc;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.DataSourceDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.DataSourceDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -56,7 +56,7 @@ public final class DataSourceInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.sql.DataSource")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.sql.DataSource")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jdbc;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -45,7 +45,7 @@ public final class DriverInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Driver")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Driver")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.jdbc;
|
|||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCUtils.connectionFromStatement;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -52,7 +52,7 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.PreparedStatement")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.PreparedStatement")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.jdbc;
|
|||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.jdbc.JDBCUtils.connectionFromStatement;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -52,7 +52,7 @@ public final class StatementInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Statement")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Statement")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.jetty8;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -45,7 +45,7 @@ public final class JettyHandlerInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("org.eclipse.jetty.server.Handler")))
|
||||
.and(hasInterface(named("org.eclipse.jetty.server.Handler")))
|
||||
.and(not(named("org.eclipse.jetty.server.handler.HandlerWrapper")));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.jms;
|
|||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.CONSUMER_DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.MessageExtractAdapter.GETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -50,7 +50,7 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageConsumer")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageConsumer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.jms;
|
|||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.CONSUMER_DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.MessageExtractAdapter.GETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CONSUMER;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -49,7 +49,7 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageListener")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.jms;
|
|||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.PRODUCER_DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.JMSDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.jms.MessageInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.PRODUCER;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -51,7 +51,7 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageProducer")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageProducer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.jsp;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jsp.JSPDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.jsp.JSPDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -45,7 +45,7 @@ public final class JSPInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.servlet.jsp.HttpJspPage")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.servlet.jsp.HttpJspPage")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.log4jevents.v2_0;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -43,7 +43,7 @@ public class Log4jEventInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(named("org.apache.logging.log4j.spi.AbstractLogger"));
|
||||
return extendsClass(named("org.apache.logging.log4j.spi.AbstractLogger"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.netty40;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,8 +47,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.netty40;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -63,7 +63,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.netty41;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,8 +47,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.netty41;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -63,7 +63,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.otapi;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -38,7 +37,7 @@ public class OpenTelemetryApiInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(named("unshaded.io.opentelemetry.OpenTelemetry"));
|
||||
return named("unshaded.io.opentelemetry.OpenTelemetry");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.play24;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -37,7 +37,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("play.api.mvc.Action"));
|
||||
return hasInterface(named("play.api.mvc.Action"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.play26;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -37,7 +37,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("play.api.mvc.Action"));
|
||||
return hasInterface(named("play.api.mvc.Action"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.playws1;
|
|||
import static io.opentelemetry.auto.instrumentation.playws1.HeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.playws1.PlayWSClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.playws1.PlayWSClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// CachingAsyncHttpClient rejects overrides to AsyncHandler
|
||||
// It also delegates to another AsyncHttpClient
|
||||
return safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
return hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient")));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.playws2;
|
|||
import static io.opentelemetry.auto.instrumentation.playws2.HeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.playws2.PlayWSClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.playws2.PlayWSClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -51,7 +51,7 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
// It also delegates to another AsyncHttpClient
|
||||
return nameStartsWith("play.")
|
||||
.<TypeDescription>and(
|
||||
safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient"))));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.playws21;
|
|||
import static io.opentelemetry.auto.instrumentation.playws21.HeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.playws21.PlayWSClientDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.instrumentation.playws21.PlayWSClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// CachingAsyncHttpClient rejects overrides to AsyncHandler
|
||||
// It also delegates to another AsyncHttpClient
|
||||
return safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
return hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient")));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.RabbitDecorato
|
|||
import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.RabbitDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.TextMapExtractAdapter.GETTER;
|
||||
import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.TextMapInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
import static io.opentelemetry.trace.Span.Kind.PRODUCER;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.canThrow;
|
||||
|
@ -70,7 +70,7 @@ public class RabbitChannelInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("com.rabbitmq.client.Channel")));
|
||||
return not(isInterface()).and(hasInterface(named("com.rabbitmq.client.Channel")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.rabbitmq.amqp;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.RabbitCommandInstrumentation.SpanHolder.CURRENT_RABBIT_SPAN;
|
||||
import static io.opentelemetry.auto.instrumentation.rabbitmq.amqp.RabbitDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -43,7 +43,7 @@ public class RabbitCommandInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("com.rabbitmq.client.Command")));
|
||||
return not(isInterface()).and(hasInterface(named("com.rabbitmq.client.Command")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.ratpack;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -41,7 +41,7 @@ public final class ContinuationInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return nameStartsWith("ratpack.exec.")
|
||||
.<TypeDescription>and(safeHasInterface(named("ratpack.exec.internal.Continuation")));
|
||||
.<TypeDescription>and(hasInterface(named("ratpack.exec.internal.Continuation")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.ratpack;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -40,7 +40,7 @@ public class ServerErrorHandlerInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface().or(isAbstract()))
|
||||
.and(safeHasInterface(named("ratpack.error.ServerErrorHandler")));
|
||||
.and(hasInterface(named("ratpack.error.ServerErrorHandler")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.reactor.core;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -53,7 +53,7 @@ public final class FluxAndMonoInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isAbstract())
|
||||
.and(
|
||||
safeExtendsClass(
|
||||
extendsClass(
|
||||
named("reactor.core.publisher.Mono").or(named("reactor.core.publisher.Flux"))));
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue