diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentInstaller.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentInstaller.java index acefaec782..df3479a238 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentInstaller.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentInstaller.java @@ -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; diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentTooling.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentTooling.java index bfc3060f2b..768e10f827 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentTooling.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentTooling.java @@ -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 diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ByteBuddyElementMatchers.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ByteBuddyElementMatchers.java deleted file mode 100644 index 6f4bb2cf9e..0000000000 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ByteBuddyElementMatchers.java +++ /dev/null @@ -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 ElementMatcher.Junction safeExtendsClass( - final ElementMatcher matcher) { - return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher)); - } - - public static ElementMatcher.Junction safeHasInterface( - final ElementMatcher 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 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 ElementMatcher.Junction safeHasSuperType( - final ElementMatcher 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 The type of the matched object. - * @return A matcher that returns {@code false} in case that the given matcher throws an - * exception. - */ - public static ElementMatcher.Junction failSafe( - final ElementMatcher 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: - * - *
    - *
  • Exceptions are logged - *
  • 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 - *
- * - *

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 The type of the matched entity. - * @see net.bytebuddy.matcher.HasSuperTypeMatcher - */ - @HashCodeAndEqualsPlugin.Enhance - private static class SafeHasSuperTypeMatcher - extends ElementMatcher.Junction.AbstractBase { - - /** The matcher to apply to any super type of the matched type. */ - private final ElementMatcher 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 matcher, - final boolean interfacesOnly) { - this.matcher = matcher; - this.interfacesOnly = interfacesOnly; - } - - @Override - public boolean matches(final T target) { - final Set 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 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. - * - *

This method exists to allow getting interfaces even if the lookup on one fails. - */ - private List safeGetInterfaces(final TypeDefinition typeDefinition) { - final List interfaceTypes = new ArrayList<>(); - try { - final Iterator 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. - * - *

Catches and logs exception if it was thrown when getting erasure, returning false. - * - * @param The type of the matched entity. - * @see net.bytebuddy.matcher.ErasureMatcher - */ - @HashCodeAndEqualsPlugin.Enhance - private static class SafeErasureMatcher - extends ElementMatcher.Junction.AbstractBase { - - /** The matcher to apply to the raw type of the matched element. */ - private final ElementMatcher matcher; - - /** - * Creates a new erasure matcher. - * - * @param matcher The matcher to apply to the raw type. - */ - public SafeErasureMatcher(final ElementMatcher 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. - * - *

Logs exception if it was thrown. - * - * @param The type of the matched entity. - * @see net.bytebuddy.matcher.FailSafeMatcher - */ - @HashCodeAndEqualsPlugin.Enhance - private static class SafeMatcher extends ElementMatcher.Junction.AbstractBase { - - /** The delegate matcher that might throw an exception. */ - private final ElementMatcher 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 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 ElementMatcher.Junction hasSuperMethod( - final ElementMatcher matcher) { - return new HasSuperMethodMatcher<>(matcher); - } - - // TODO: add javadoc - @HashCodeAndEqualsPlugin.Enhance - private static class HasSuperMethodMatcher - extends ElementMatcher.Junction.AbstractBase { - - private final ElementMatcher matcher; - - public HasSuperMethodMatcher(final ElementMatcher matcher) { - this.matcher = matcher; - } - - @Override - public boolean matches(final MethodDescription target) { - if (target.isConstructor()) { - return false; - } - final Junction signatureMatcher = hasSignature(target.asSignatureToken()); - TypeDefinition declaringType = target.getDeclaringType(); - final Set 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 signatureMatcher, - final Set 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 - extends ElementMatcher.Junction.AbstractBase { - - private final ElementMatcher matcher; - - public SafeExtendsClassMatcher(final ElementMatcher 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; - } - } -} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Instrumenter.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Instrumenter.java index f400e0e40c..139bc5ca35 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Instrumenter.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/Instrumenter.java @@ -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; diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentCachingPoolStrategy.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentCachingPoolStrategy.java similarity index 94% rename from agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentCachingPoolStrategy.java rename to agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentCachingPoolStrategy.java index e9fb7616b8..8fabf6b09a 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentCachingPoolStrategy.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentCachingPoolStrategy.java @@ -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 diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentLocationStrategy.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentLocationStrategy.java similarity index 95% rename from agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentLocationStrategy.java rename to agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentLocationStrategy.java index 086d2ca029..86a65784ee 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/AgentLocationStrategy.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentLocationStrategy.java @@ -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; diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentTransformers.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentTransformers.java new file mode 100644 index 0000000000..56433755b6 --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/AgentTransformers.java @@ -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; + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ExceptionHandlers.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/ExceptionHandlers.java similarity index 98% rename from agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ExceptionHandlers.java rename to agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/ExceptionHandlers.java index a4197f5243..c51600dbbc 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/ExceptionHandlers.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/ExceptionHandlers.java @@ -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; diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/GlobalIgnoresMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/GlobalIgnoresMatcher.java similarity index 97% rename from agent-tooling/src/main/java/io/opentelemetry/auto/tooling/GlobalIgnoresMatcher.java rename to agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/GlobalIgnoresMatcher.java index 4caf764d75..95ac55748d 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/GlobalIgnoresMatcher.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/GlobalIgnoresMatcher.java @@ -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 +public class GlobalIgnoresMatcher extends ElementMatcher.Junction.AbstractBase { private static final Pattern COM_MCHANGE_PROXY = diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/AgentElementMatchers.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/AgentElementMatchers.java new file mode 100644 index 0000000000..fa5e373e3f --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/AgentElementMatchers.java @@ -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 ElementMatcher.Junction extendsClass( + final ElementMatcher matcher) { + return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher)); + } + + public static ElementMatcher.Junction hasInterface( + final ElementMatcher 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 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 ElementMatcher.Junction safeHasSuperType( + final ElementMatcher matcher) { + return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), false); + } + // TODO: add javadoc + public static ElementMatcher.Junction hasSuperMethod( + final ElementMatcher 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 The type of the matched object. + * @return A matcher that returns {@code false} in case that the given matcher throws an + * exception. + */ + public static ElementMatcher.Junction failSafe( + final ElementMatcher 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 "?"; + } + } + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcher.java new file mode 100644 index 0000000000..2c08a743d4 --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcher.java @@ -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 + extends ElementMatcher.Junction.AbstractBase { + + private final ElementMatcher matcher; + + public HasSuperMethodMatcher(final ElementMatcher matcher) { + this.matcher = matcher; + } + + @Override + public boolean matches(final MethodDescription target) { + if (target.isConstructor()) { + return false; + } + final Junction signatureMatcher = hasSignature(target.asSignatureToken()); + TypeDefinition declaringType = target.getDeclaringType(); + final Set 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 signatureMatcher, + final Set 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 + ")"; + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/LoggingFailSafeMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/LoggingFailSafeMatcher.java new file mode 100644 index 0000000000..b866495422 --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/LoggingFailSafeMatcher.java @@ -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. + * + *

Logs exception if it was thrown. + * + * @param The type of the matched entity. + * @see net.bytebuddy.matcher.FailSafeMatcher + */ +@Slf4j +@HashCodeAndEqualsPlugin.Enhance +class LoggingFailSafeMatcher extends ElementMatcher.Junction.AbstractBase { + + /** The delegate matcher that might throw an exception. */ + private final ElementMatcher 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 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 + ")"; + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeErasureMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeErasureMatcher.java new file mode 100644 index 0000000000..d40af0576f --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeErasureMatcher.java @@ -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. + * + *

Catches and logs exception if it was thrown when getting erasure, returning false. + * + * @param The type of the matched entity. + * @see net.bytebuddy.matcher.ErasureMatcher + */ +@Slf4j +@HashCodeAndEqualsPlugin.Enhance +class SafeErasureMatcher extends ElementMatcher.Junction.AbstractBase { + + /** The matcher to apply to the raw type of the matched element. */ + private final ElementMatcher matcher; + + /** + * Creates a new erasure matcher. + * + * @param matcher The matcher to apply to the raw type. + */ + public SafeErasureMatcher(final ElementMatcher 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; + } + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcher.java new file mode 100644 index 0000000000..368918f69c --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcher.java @@ -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 + extends ElementMatcher.Junction.AbstractBase { + + private final ElementMatcher matcher; + + public SafeExtendsClassMatcher(final ElementMatcher 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; + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcher.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcher.java new file mode 100644 index 0000000000..158125973d --- /dev/null +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcher.java @@ -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: + * + *

    + *
  • Exceptions are logged + *
  • 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 + *
+ * + *

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 The type of the matched entity. + * @see net.bytebuddy.matcher.HasSuperTypeMatcher + */ +@Slf4j +@HashCodeAndEqualsPlugin.Enhance +class SafeHasSuperTypeMatcher + extends ElementMatcher.Junction.AbstractBase { + + /** The matcher to apply to any super type of the matched type. */ + private final ElementMatcher 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 matcher, final boolean interfacesOnly) { + this.matcher = matcher; + this.interfacesOnly = interfacesOnly; + } + + @Override + public boolean matches(final T target) { + final Set 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 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. + * + *

This method exists to allow getting interfaces even if the lookup on one fails. + */ + private List safeGetInterfaces(final TypeDefinition typeDefinition) { + final List interfaceTypes = new ArrayList<>(); + try { + final Iterator 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 + ")"; + } +} diff --git a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/context/FieldBackedProvider.java b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/context/FieldBackedProvider.java index b6ece42c04..00a5805d06 100644 --- a/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/context/FieldBackedProvider.java +++ b/agent-tooling/src/main/java/io/opentelemetry/auto/tooling/context/FieldBackedProvider.java @@ -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; diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ExceptionHandlerTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ExceptionHandlerTest.groovy index e23051efa8..68047541ac 100644 --- a/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ExceptionHandlerTest.groovy +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ExceptionHandlerTest.groovy @@ -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 diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ResourceLocatingTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ResourceLocatingTest.groovy index a7e69eaeae..4452e25418 100644 --- a/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ResourceLocatingTest.groovy +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/test/ResourceLocatingTest.groovy @@ -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 diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/CacheProviderTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/CacheProviderTest.groovy index 846796f394..e3027a82e6 100644 --- a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/CacheProviderTest.groovy +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/CacheProviderTest.groovy @@ -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 { + } } } } diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcherTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcherTest.groovy new file mode 100644 index 0000000000..5ff55c55fa --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/HasSuperMethodMatcherTest.groovy @@ -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 * _ + } +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcherTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcherTest.groovy new file mode 100644 index 0000000000..eac0619848 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeExtendsClassMatcherTest.groovy @@ -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 * _ + } +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasInterfaceMatcherTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasInterfaceMatcherTest.groovy new file mode 100644 index 0000000000..914ed21874 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasInterfaceMatcherTest.groovy @@ -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 * _ + } +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcherTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcherTest.groovy new file mode 100644 index 0000000000..49be8508bf --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeHasSuperTypeMatcherTest.groovy @@ -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 * _ + } +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeMatcherTest.groovy b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeMatcherTest.groovy new file mode 100644 index 0000000000..6ec5a758e9 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/SafeMatcherTest.groovy @@ -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 + } +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/A.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/A.java new file mode 100644 index 0000000000..0a7840c7dc --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/A.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/B.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/B.java new file mode 100644 index 0000000000..cf85b870c8 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/B.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/C.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/C.java new file mode 100644 index 0000000000..53596d148f --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/C.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/D.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/D.java new file mode 100644 index 0000000000..a5267a22da --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/D.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/E.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/E.java new file mode 100644 index 0000000000..2c599eb98e --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/E.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/F.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/F.java new file mode 100644 index 0000000000..23fb3fc8ec --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/F.java @@ -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(); +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/G.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/G.java new file mode 100644 index 0000000000..e385a9f282 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/G.java @@ -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() {} +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/Trace.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/Trace.java new file mode 100644 index 0000000000..860b4542da --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/Trace.java @@ -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 {} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/TracedClass.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/TracedClass.java new file mode 100644 index 0000000000..3eef2b7f64 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/TracedClass.java @@ -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() {} +} diff --git a/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/UntracedClass.java b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/UntracedClass.java new file mode 100644 index 0000000000..e8a3d589e1 --- /dev/null +++ b/agent-tooling/src/test/groovy/io/opentelemetry/auto/tooling/bytebuddy/matcher/testclasses/UntracedClass.java @@ -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() {} +} diff --git a/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java b/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java new file mode 100644 index 0000000000..bfef355e10 --- /dev/null +++ b/dd-java-agent/instrumentation/rmi/src/main/java/datadog/trace/instrumentation/rmi/server/RmiServerInstrumentation.java @@ -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 typeMatcher() { + return not(isInterface()).and(extendsClass(named("java.rmi.server.RemoteServer"))); + } + + @Override + public Map, 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(); + } + } +} diff --git a/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java b/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java index 0198bca74f..6bddc9b8b3 100644 --- a/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java +++ b/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java @@ -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 typeMatcher() { - return safeHasInterface(named("org.apache.http.nio.client.HttpAsyncClient")); + return hasInterface(named("org.apache.http.nio.client.HttpAsyncClient")); } @Override diff --git a/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpClientRedirectInstrumentation.java b/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpClientRedirectInstrumentation.java index 57ebdfa614..07ef67675b 100644 --- a/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpClientRedirectInstrumentation.java +++ b/instrumentation/apache-httpasyncclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpasyncclient/ApacheHttpClientRedirectInstrumentation.java @@ -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 typeMatcher() { - return safeHasInterface(named("org.apache.http.client.RedirectStrategy")); + return hasInterface(named("org.apache.http.client.RedirectStrategy")); } @Override diff --git a/instrumentation/apache-httpclient-3.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/v3_0/ApacheHttpClientInstrumentation.java b/instrumentation/apache-httpclient-3.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/v3_0/ApacheHttpClientInstrumentation.java index dc71c76ace..ee9ca11fba 100644 --- a/instrumentation/apache-httpclient-3.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/v3_0/ApacheHttpClientInstrumentation.java +++ b/instrumentation/apache-httpclient-3.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/v3_0/ApacheHttpClientInstrumentation.java @@ -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 typeMatcher() { - return safeHasSuperType(named("org.apache.commons.httpclient.HttpClient")); + return extendsClass(named("org.apache.commons.httpclient.HttpClient")); } @Override diff --git a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/ApacheHttpClientInstrumentation.java b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/ApacheHttpClientInstrumentation.java index 33ab159719..ee93ad69fa 100644 --- a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/ApacheHttpClientInstrumentation.java +++ b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/auto/instrumentation/apachehttpclient/ApacheHttpClientInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.apache.http.client.HttpClient"))); + return not(isInterface()).and(hasInterface(named("org.apache.http.client.HttpClient"))); } @Override diff --git a/instrumentation/aws-java-sdk-1.11/src/main/java/io/opentelemetry/auto/instrumentation/aws/v0/RequestInstrumentation.java b/instrumentation/aws-java-sdk-1.11/src/main/java/io/opentelemetry/auto/instrumentation/aws/v0/RequestInstrumentation.java index a39039b120..4445ae5fe6 100644 --- a/instrumentation/aws-java-sdk-1.11/src/main/java/io/opentelemetry/auto/instrumentation/aws/v0/RequestInstrumentation.java +++ b/instrumentation/aws-java-sdk-1.11/src/main/java/io/opentelemetry/auto/instrumentation/aws/v0/RequestInstrumentation.java @@ -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 typeMatcher() { return nameStartsWith("com.amazonaws.") - .and(safeExtendsClass(named("com.amazonaws.AmazonWebServiceRequest"))); + .and(extendsClass(named("com.amazonaws.AmazonWebServiceRequest"))); } @Override diff --git a/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsClientInstrumentation.java b/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsClientInstrumentation.java index 032b8663cd..6799ba0739 100644 --- a/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsClientInstrumentation.java +++ b/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsClientInstrumentation.java @@ -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 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 diff --git a/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsHttpClientInstrumentation.java b/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsHttpClientInstrumentation.java index 16ea6bdf94..77ae42474c 100644 --- a/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsHttpClientInstrumentation.java +++ b/instrumentation/aws-java-sdk-2.2/src/main/java/io/opentelemetry/auto/instrumentation/aws/v2/AwsHttpClientInstrumentation.java @@ -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 typeMatcher() { return nameStartsWith("software.amazon.awssdk.") .and( - safeExtendsClass( + extendsClass( named( "software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage") .or( diff --git a/instrumentation/classloading/src/main/java/io/opentelemetry/auto/instrumentation/classloading/ClassloadingInstrumentation.java b/instrumentation/classloading/src/main/java/io/opentelemetry/auto/instrumentation/classloading/ClassloadingInstrumentation.java index 815d680186..ae6a48802d 100644 --- a/instrumentation/classloading/src/main/java/io/opentelemetry/auto/instrumentation/classloading/ClassloadingInstrumentation.java +++ b/instrumentation/classloading/src/main/java/io/opentelemetry/auto/instrumentation/classloading/ClassloadingInstrumentation.java @@ -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 diff --git a/instrumentation/couchbase-2.6/src/main/java/io/opentelemetry/auto/instrumentation/couchbase/client/CouchbaseNetworkInstrumentation.java b/instrumentation/couchbase-2.6/src/main/java/io/opentelemetry/auto/instrumentation/couchbase/client/CouchbaseNetworkInstrumentation.java index 2e15325ae6..f2f1a51d2b 100644 --- a/instrumentation/couchbase-2.6/src/main/java/io/opentelemetry/auto/instrumentation/couchbase/client/CouchbaseNetworkInstrumentation.java +++ b/instrumentation/couchbase-2.6/src/main/java/io/opentelemetry/auto/instrumentation/couchbase/client/CouchbaseNetworkInstrumentation.java @@ -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.") .and( - safeExtendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler"))); + extendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler"))); } @Override diff --git a/instrumentation/dropwizard-views-0.7/src/main/java/io/opentelemetry/auto/instrumentation/dropwizard/view/DropwizardViewInstrumentation.java b/instrumentation/dropwizard-views-0.7/src/main/java/io/opentelemetry/auto/instrumentation/dropwizard/view/DropwizardViewInstrumentation.java index 8b2653e340..d9df598903 100644 --- a/instrumentation/dropwizard-views-0.7/src/main/java/io/opentelemetry/auto/instrumentation/dropwizard/view/DropwizardViewInstrumentation.java +++ b/instrumentation/dropwizard-views-0.7/src/main/java/io/opentelemetry/auto/instrumentation/dropwizard/view/DropwizardViewInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("io.dropwizard.views.ViewRenderer"))); + return not(isInterface()).and(hasInterface(named("io.dropwizard.views.ViewRenderer"))); } @Override diff --git a/instrumentation/finatra-2.9/src/main/java/io/opentelemetry/auto/instrumentation/finatra/FinatraInstrumentation.java b/instrumentation/finatra-2.9/src/main/java/io/opentelemetry/auto/instrumentation/finatra/FinatraInstrumentation.java index 258a6e1d31..254f20c094 100644 --- a/instrumentation/finatra-2.9/src/main/java/io/opentelemetry/auto/instrumentation/finatra/FinatraInstrumentation.java +++ b/instrumentation/finatra-2.9/src/main/java/io/opentelemetry/auto/instrumentation/finatra/FinatraInstrumentation.java @@ -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 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 diff --git a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/CriteriaInstrumentation.java b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/CriteriaInstrumentation.java index cd727be302..dffbcd1d58 100644 --- a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/CriteriaInstrumentation.java +++ b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/CriteriaInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria"))); } @Override diff --git a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java index 12c68e8c62..c735e4c74e 100644 --- a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java +++ b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Query"))); } @Override diff --git a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionFactoryInstrumentation.java b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionFactoryInstrumentation.java index 55e2f4b8d4..9b4c537764 100644 --- a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionFactoryInstrumentation.java +++ b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionFactoryInstrumentation.java @@ -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 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"); } diff --git a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionInstrumentation.java b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionInstrumentation.java index 16920730bc..fb7ef4ff48 100644 --- a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionInstrumentation.java +++ b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/SessionInstrumentation.java @@ -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 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; diff --git a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/TransactionInstrumentation.java b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/TransactionInstrumentation.java index dad471bcff..fd9b56aec7 100644 --- a/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/TransactionInstrumentation.java +++ b/instrumentation/hibernate/core-3.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v3_3/TransactionInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction"))); } @Override diff --git a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/CriteriaInstrumentation.java b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/CriteriaInstrumentation.java index 7c473dd613..1c095c37f0 100644 --- a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/CriteriaInstrumentation.java +++ b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/CriteriaInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria"))); } @Override diff --git a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java index 9b1412e7d5..ec7da7e135 100644 --- a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java +++ b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Query"))); } @Override diff --git a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionFactoryInstrumentation.java b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionFactoryInstrumentation.java index 06d7dac5e6..79a1f4d316 100644 --- a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionFactoryInstrumentation.java +++ b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionFactoryInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.SessionFactory"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.SessionFactory"))); } @Override diff --git a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionInstrumentation.java b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionInstrumentation.java index de7364b8f9..8bf010fd1e 100644 --- a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionInstrumentation.java +++ b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/SessionInstrumentation.java @@ -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 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; diff --git a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/TransactionInstrumentation.java b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/TransactionInstrumentation.java index 3d4ea521d3..9fdd09ac21 100644 --- a/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/TransactionInstrumentation.java +++ b/instrumentation/hibernate/core-4.0/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_0/TransactionInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction"))); } @Override diff --git a/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/ProcedureCallInstrumentation.java b/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/ProcedureCallInstrumentation.java index e3a5292cbb..d60be83788 100644 --- a/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/ProcedureCallInstrumentation.java +++ b/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/ProcedureCallInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.procedure.ProcedureCall"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.procedure.ProcedureCall"))); } @Override diff --git a/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/SessionInstrumentation.java b/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/SessionInstrumentation.java index 6154f1c759..80f58a770b 100644 --- a/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/SessionInstrumentation.java +++ b/instrumentation/hibernate/core-4.3/src/main/java/io/opentelemetry/auto/instrumentation/hibernate/core/v4_3/SessionInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("org.hibernate.SharedSessionContract"))); + return not(isInterface()).and(hasInterface(named("org.hibernate.SharedSessionContract"))); } @Override public Map, 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"); } diff --git a/instrumentation/http-url-connection/src/main/java/io/opentelemetry/auto/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java b/instrumentation/http-url-connection/src/main/java/io/opentelemetry/auto/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java index 016e606917..6f80c60a29 100644 --- a/instrumentation/http-url-connection/src/main/java/io/opentelemetry/auto/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java +++ b/instrumentation/http-url-connection/src/main/java/io/opentelemetry/auto/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java @@ -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.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 diff --git a/instrumentation/hystrix-1.4/src/main/java/io/opentelemetry/auto/instrumentation/hystrix/HystrixInstrumentation.java b/instrumentation/hystrix-1.4/src/main/java/io/opentelemetry/auto/instrumentation/hystrix/HystrixInstrumentation.java index 4fd0529e48..e8a86fdeef 100644 --- a/instrumentation/hystrix-1.4/src/main/java/io/opentelemetry/auto/instrumentation/hystrix/HystrixInstrumentation.java +++ b/instrumentation/hystrix-1.4/src/main/java/io/opentelemetry/auto/instrumentation/hystrix/HystrixInstrumentation.java @@ -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 typeMatcher() { - return safeExtendsClass( + return extendsClass( named("com.netflix.hystrix.HystrixCommand") .or(named("com.netflix.hystrix.HystrixObservableCommand"))); } diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java index 4b73db5057..001958ee95 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java @@ -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 typeMatcher() { ElementMatcher.Junction matcher = not(isInterface()); + final ElementMatcher.Junction 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 diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java index c9c459ec82..4c8c80fabf 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME))); + return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME))); } @Override diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/FutureInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/FutureInstrumentation.java index cda2e65ad0..0aeb78312d 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/FutureInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/FutureInstrumentation.java @@ -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 typeMatcher() { + final ElementMatcher.Junction hasFutureInterfaceMatcher = + hasInterface(named(Future.class.getName())); return not(isInterface()) .and( new ElementMatcher() { @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 diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java index 9a40275c42..815cbf7ad3 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named(ForkJoinTask.class.getName()))); + return not(isInterface()).and(extendsClass(named(ForkJoinTask.class.getName()))); } @Override diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/RunnableCallableInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/RunnableCallableInstrumentation.java index 2ced58d647..7cc92f5f10 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/RunnableCallableInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/RunnableCallableInstrumentation.java @@ -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 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 diff --git a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java index c90b95d202..aae2fd9745 100644 --- a/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java +++ b/instrumentation/java-concurrent/src/main/java/io/opentelemetry/auto/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME))); + return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME))); } @Override diff --git a/instrumentation/java-util-logging-events/src/main/java/io/opentelemetry/auto/instrumentation/jul/JavaUtilLoggingEventInstrumentation.java b/instrumentation/java-util-logging-events/src/main/java/io/opentelemetry/auto/instrumentation/jul/JavaUtilLoggingEventInstrumentation.java index 8503c64d89..84baf284d3 100644 --- a/instrumentation/java-util-logging-events/src/main/java/io/opentelemetry/auto/instrumentation/jul/JavaUtilLoggingEventInstrumentation.java +++ b/instrumentation/java-util-logging-events/src/main/java/io/opentelemetry/auto/instrumentation/jul/JavaUtilLoggingEventInstrumentation.java @@ -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 typeMatcher() { - return safeHasSuperType(named("java.util.logging.Logger")); + return extendsClass(named("java.util.logging.Logger")); } @Override diff --git a/instrumentation/jax-rs-annotations-1.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs1/JaxRsAnnotationsInstrumentation.java b/instrumentation/jax-rs-annotations-1.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs1/JaxRsAnnotationsInstrumentation.java index e3f29172ad..a7f04e2426 100644 --- a/instrumentation/jax-rs-annotations-1.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs1/JaxRsAnnotationsInstrumentation.java +++ b/instrumentation/jax-rs-annotations-1.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs1/JaxRsAnnotationsInstrumentation.java @@ -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; diff --git a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java index c2e07bf094..6a003b48dd 100644 --- a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java +++ b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/AbstractRequestContextInstrumentation.java @@ -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 typeMatcher() { return not(isInterface()) - .and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestContext"))); + .and(hasInterface(named("javax.ws.rs.container.ContainerRequestContext"))); } @Override diff --git a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java index 95c2a456cb..a1308de247 100644 --- a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java +++ b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/ContainerRequestFilterInstrumentation.java @@ -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 typeMatcher() { return not(isInterface()) - .and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestFilter"))); + .and(hasInterface(named("javax.ws.rs.container.ContainerRequestFilter"))); } @Override diff --git a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java index c34918e4ae..57d2ef5bf8 100644 --- a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java +++ b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java @@ -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; diff --git a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAsyncResponseInstrumentation.java b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAsyncResponseInstrumentation.java index 87aebb50aa..6773bd12a5 100644 --- a/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAsyncResponseInstrumentation.java +++ b/instrumentation/jax-rs-annotations-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs2/JaxRsAsyncResponseInstrumentation.java @@ -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 typeMatcher() { - return safeHasInterface(named("javax.ws.rs.container.AsyncResponse")); + return hasInterface(named("javax.ws.rs.container.AsyncResponse")); } @Override diff --git a/instrumentation/jax-rs-client-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java b/instrumentation/jax-rs-client-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java index ac42bb4263..8fbc23b1bf 100644 --- a/instrumentation/jax-rs-client-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java +++ b/instrumentation/jax-rs-client-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java @@ -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 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, 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"); } diff --git a/instrumentation/jax-rs-client-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/JaxRsClientInstrumentation.java b/instrumentation/jax-rs-client-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/JaxRsClientInstrumentation.java index b00a2b5922..1d62046e97 100644 --- a/instrumentation/jax-rs-client-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/JaxRsClientInstrumentation.java +++ b/instrumentation/jax-rs-client-2.0/src/main/java/io/opentelemetry/auto/instrumentation/jaxrs/JaxRsClientInstrumentation.java @@ -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 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, 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"); } diff --git a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java index f03b0d3658..621e32e4be 100644 --- a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java @@ -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 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"); } diff --git a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java index 39bbff323b..9b8b738926 100644 --- a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.sql.DataSource"))); + return not(isInterface()).and(hasInterface(named("javax.sql.DataSource"))); } @Override diff --git a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java index 3803366fc4..65e1189f94 100644 --- a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("java.sql.Driver"))); + return not(isInterface()).and(hasInterface(named("java.sql.Driver"))); } @Override diff --git a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java index 2b989e8a28..26b81c59dc 100644 --- a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("java.sql.PreparedStatement"))); + return not(isInterface()).and(hasInterface(named("java.sql.PreparedStatement"))); } @Override diff --git a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java index a90be297b0..75bbfc92d1 100644 --- a/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("java.sql.Statement"))); + return not(isInterface()).and(hasInterface(named("java.sql.Statement"))); } @Override diff --git a/instrumentation/jetty-8.0/src/main/java/io/opentelemetry/auto/instrumentation/jetty8/JettyHandlerInstrumentation.java b/instrumentation/jetty-8.0/src/main/java/io/opentelemetry/auto/instrumentation/jetty8/JettyHandlerInstrumentation.java index 00401ea0eb..d41321c422 100644 --- a/instrumentation/jetty-8.0/src/main/java/io/opentelemetry/auto/instrumentation/jetty8/JettyHandlerInstrumentation.java +++ b/instrumentation/jetty-8.0/src/main/java/io/opentelemetry/auto/instrumentation/jetty8/JettyHandlerInstrumentation.java @@ -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 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"))); } diff --git a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java index c6faac9dec..6f6eccd220 100644 --- a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java +++ b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageConsumerInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageConsumer"))); + return not(isInterface()).and(hasInterface(named("javax.jms.MessageConsumer"))); } @Override diff --git a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java index f304b19719..365a85fa82 100644 --- a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java +++ b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageListenerInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageListener"))); + return not(isInterface()).and(hasInterface(named("javax.jms.MessageListener"))); } @Override diff --git a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java index d4671c1a47..c5be5b1975 100644 --- a/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java +++ b/instrumentation/jms-1.1/src/main/java/io/opentelemetry/auto/instrumentation/jms/JMSMessageProducerInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageProducer"))); + return not(isInterface()).and(hasInterface(named("javax.jms.MessageProducer"))); } @Override diff --git a/instrumentation/jsp-2.3/src/main/java/io/opentelemetry/auto/instrumentation/jsp/JSPInstrumentation.java b/instrumentation/jsp-2.3/src/main/java/io/opentelemetry/auto/instrumentation/jsp/JSPInstrumentation.java index 006ec42711..8b109cf267 100644 --- a/instrumentation/jsp-2.3/src/main/java/io/opentelemetry/auto/instrumentation/jsp/JSPInstrumentation.java +++ b/instrumentation/jsp-2.3/src/main/java/io/opentelemetry/auto/instrumentation/jsp/JSPInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.servlet.jsp.HttpJspPage"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.jsp.HttpJspPage"))); } @Override diff --git a/instrumentation/log4j-events-2.0/src/main/java/io/opentelemetry/auto/instrumentation/log4jevents/v2_0/Log4jEventInstrumentation.java b/instrumentation/log4j-events-2.0/src/main/java/io/opentelemetry/auto/instrumentation/log4jevents/v2_0/Log4jEventInstrumentation.java index 3700cc8bd7..a0d7ca45c4 100644 --- a/instrumentation/log4j-events-2.0/src/main/java/io/opentelemetry/auto/instrumentation/log4jevents/v2_0/Log4jEventInstrumentation.java +++ b/instrumentation/log4j-events-2.0/src/main/java/io/opentelemetry/auto/instrumentation/log4jevents/v2_0/Log4jEventInstrumentation.java @@ -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 typeMatcher() { - return safeHasSuperType(named("org.apache.logging.log4j.spi.AbstractLogger")); + return extendsClass(named("org.apache.logging.log4j.spi.AbstractLogger")); } @Override diff --git a/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/ChannelFutureListenerInstrumentation.java b/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/ChannelFutureListenerInstrumentation.java index 68b114bdf9..4177fcdb0e 100644 --- a/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/ChannelFutureListenerInstrumentation.java +++ b/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/ChannelFutureListenerInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()) - .and(safeHasInterface(named("io.netty.channel.ChannelFutureListener"))); + return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener"))); } @Override diff --git a/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/NettyChannelPipelineInstrumentation.java b/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/NettyChannelPipelineInstrumentation.java index 6faece4eb1..6af7f8a3dd 100644 --- a/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/NettyChannelPipelineInstrumentation.java +++ b/instrumentation/netty-4.0/src/main/java/io/opentelemetry/auto/instrumentation/netty40/NettyChannelPipelineInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline"))); + return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline"))); } @Override diff --git a/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/ChannelFutureListenerInstrumentation.java b/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/ChannelFutureListenerInstrumentation.java index 00f0998a46..526084cfba 100644 --- a/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/ChannelFutureListenerInstrumentation.java +++ b/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/ChannelFutureListenerInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()) - .and(safeHasInterface(named("io.netty.channel.ChannelFutureListener"))); + return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener"))); } @Override diff --git a/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/NettyChannelPipelineInstrumentation.java b/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/NettyChannelPipelineInstrumentation.java index 057a0c4686..b1a8c2173c 100644 --- a/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/NettyChannelPipelineInstrumentation.java +++ b/instrumentation/netty-4.1/src/main/java/io/opentelemetry/auto/instrumentation/netty41/NettyChannelPipelineInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline"))); + return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline"))); } @Override diff --git a/instrumentation/opentelemetry-api-0.2/src/main/java/io/opentelemetry/auto/instrumentation/otapi/OpenTelemetryApiInstrumentation.java b/instrumentation/opentelemetry-api-0.2/src/main/java/io/opentelemetry/auto/instrumentation/otapi/OpenTelemetryApiInstrumentation.java index 001ce1c664..1fa703dc78 100644 --- a/instrumentation/opentelemetry-api-0.2/src/main/java/io/opentelemetry/auto/instrumentation/otapi/OpenTelemetryApiInstrumentation.java +++ b/instrumentation/opentelemetry-api-0.2/src/main/java/io/opentelemetry/auto/instrumentation/otapi/OpenTelemetryApiInstrumentation.java @@ -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 typeMatcher() { - return safeHasSuperType(named("unshaded.io.opentelemetry.OpenTelemetry")); + return named("unshaded.io.opentelemetry.OpenTelemetry"); } @Override diff --git a/instrumentation/play-2.4/src/main/java/io/opentelemetry/auto/instrumentation/play24/PlayInstrumentation.java b/instrumentation/play-2.4/src/main/java/io/opentelemetry/auto/instrumentation/play24/PlayInstrumentation.java index 18af37ce81..56301c1b99 100644 --- a/instrumentation/play-2.4/src/main/java/io/opentelemetry/auto/instrumentation/play24/PlayInstrumentation.java +++ b/instrumentation/play-2.4/src/main/java/io/opentelemetry/auto/instrumentation/play24/PlayInstrumentation.java @@ -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 typeMatcher() { - return safeHasInterface(named("play.api.mvc.Action")); + return hasInterface(named("play.api.mvc.Action")); } @Override diff --git a/instrumentation/play-2.6/src/main/java/io/opentelemetry/auto/instrumentation/play26/PlayInstrumentation.java b/instrumentation/play-2.6/src/main/java/io/opentelemetry/auto/instrumentation/play26/PlayInstrumentation.java index bc57e04fe8..c7694968f5 100644 --- a/instrumentation/play-2.6/src/main/java/io/opentelemetry/auto/instrumentation/play26/PlayInstrumentation.java +++ b/instrumentation/play-2.6/src/main/java/io/opentelemetry/auto/instrumentation/play26/PlayInstrumentation.java @@ -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 typeMatcher() { - return safeHasInterface(named("play.api.mvc.Action")); + return hasInterface(named("play.api.mvc.Action")); } @Override diff --git a/instrumentation/play-ws-1.0/src/main/java/io/opentelemetry/auto/instrumentation/playws1/PlayWSClientInstrumentation.java b/instrumentation/play-ws-1.0/src/main/java/io/opentelemetry/auto/instrumentation/playws1/PlayWSClientInstrumentation.java index 59b170b22c..cb3fbf93b4 100644 --- a/instrumentation/play-ws-1.0/src/main/java/io/opentelemetry/auto/instrumentation/playws1/PlayWSClientInstrumentation.java +++ b/instrumentation/play-ws-1.0/src/main/java/io/opentelemetry/auto/instrumentation/playws1/PlayWSClientInstrumentation.java @@ -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 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"))); } diff --git a/instrumentation/play-ws-2.0/src/main/java/io/opentelemetry/auto/instrumentation/playws2/PlayWSClientInstrumentation.java b/instrumentation/play-ws-2.0/src/main/java/io/opentelemetry/auto/instrumentation/playws2/PlayWSClientInstrumentation.java index e0f678696b..cf07ece95f 100644 --- a/instrumentation/play-ws-2.0/src/main/java/io/opentelemetry/auto/instrumentation/playws2/PlayWSClientInstrumentation.java +++ b/instrumentation/play-ws-2.0/src/main/java/io/opentelemetry/auto/instrumentation/playws2/PlayWSClientInstrumentation.java @@ -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.") .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")))); } diff --git a/instrumentation/play-ws-2.1/src/main/java/io/opentelemetry/auto/instrumentation/playws21/PlayWSClientInstrumentation.java b/instrumentation/play-ws-2.1/src/main/java/io/opentelemetry/auto/instrumentation/playws21/PlayWSClientInstrumentation.java index 471d0f9d47..dee89bb90f 100644 --- a/instrumentation/play-ws-2.1/src/main/java/io/opentelemetry/auto/instrumentation/playws21/PlayWSClientInstrumentation.java +++ b/instrumentation/play-ws-2.1/src/main/java/io/opentelemetry/auto/instrumentation/playws21/PlayWSClientInstrumentation.java @@ -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 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"))); } diff --git a/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitChannelInstrumentation.java b/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitChannelInstrumentation.java index 41644f9686..e8f0cae65d 100644 --- a/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitChannelInstrumentation.java +++ b/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitChannelInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("com.rabbitmq.client.Channel"))); + return not(isInterface()).and(hasInterface(named("com.rabbitmq.client.Channel"))); } @Override diff --git a/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitCommandInstrumentation.java b/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitCommandInstrumentation.java index c123d432b3..d9c12f15fa 100644 --- a/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitCommandInstrumentation.java +++ b/instrumentation/rabbitmq-amqp-2.7/src/main/java/io/opentelemetry/auto/instrumentation/rabbitmq/amqp/RabbitCommandInstrumentation.java @@ -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 typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("com.rabbitmq.client.Command"))); + return not(isInterface()).and(hasInterface(named("com.rabbitmq.client.Command"))); } @Override diff --git a/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ContinuationInstrumentation.java b/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ContinuationInstrumentation.java index 8f446b10ee..dea321077b 100644 --- a/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ContinuationInstrumentation.java +++ b/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ContinuationInstrumentation.java @@ -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 typeMatcher() { return nameStartsWith("ratpack.exec.") - .and(safeHasInterface(named("ratpack.exec.internal.Continuation"))); + .and(hasInterface(named("ratpack.exec.internal.Continuation"))); } @Override diff --git a/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ServerErrorHandlerInstrumentation.java b/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ServerErrorHandlerInstrumentation.java index c0bf057e6e..b5f301368e 100644 --- a/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ServerErrorHandlerInstrumentation.java +++ b/instrumentation/ratpack-1.4/src/main/java/io/opentelemetry/auto/instrumentation/ratpack/ServerErrorHandlerInstrumentation.java @@ -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 typeMatcher() { return not(isInterface().or(isAbstract())) - .and(safeHasInterface(named("ratpack.error.ServerErrorHandler"))); + .and(hasInterface(named("ratpack.error.ServerErrorHandler"))); } @Override diff --git a/instrumentation/reactor-core-3.1/src/main/java/io/opentelemetry/auto/instrumentation/reactor/core/FluxAndMonoInstrumentation.java b/instrumentation/reactor-core-3.1/src/main/java/io/opentelemetry/auto/instrumentation/reactor/core/FluxAndMonoInstrumentation.java index c1acf1bf95..ca0dae3554 100644 --- a/instrumentation/reactor-core-3.1/src/main/java/io/opentelemetry/auto/instrumentation/reactor/core/FluxAndMonoInstrumentation.java +++ b/instrumentation/reactor-core-3.1/src/main/java/io/opentelemetry/auto/instrumentation/reactor/core/FluxAndMonoInstrumentation.java @@ -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 typeMatcher() { return not(isAbstract()) .and( - safeExtendsClass( + extendsClass( named("reactor.core.publisher.Mono").or(named("reactor.core.publisher.Flux")))); } diff --git a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java index 6ed2a6938e..c9f3d6825b 100644 --- a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java +++ b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/client/RmiClientInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.rmi.client; import static io.opentelemetry.auto.instrumentation.rmi.client.RmiClientDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.rmi.client.RmiClientDecorator.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.isInterface; @@ -47,7 +47,7 @@ public final class RmiClientInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named("sun.rmi.server.UnicastRef"))); + return not(isInterface()).and(extendsClass(named("sun.rmi.server.UnicastRef"))); } @Override diff --git a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/client/RmiClientContextInstrumentation.java b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/client/RmiClientContextInstrumentation.java index 30d44bd108..dc854accee 100644 --- a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/client/RmiClientContextInstrumentation.java +++ b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/client/RmiClientContextInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.rmi.context.client; import static io.opentelemetry.auto.instrumentation.rmi.context.ContextPayload.TRACER; import static io.opentelemetry.auto.instrumentation.rmi.context.ContextPropagator.PROPAGATOR; -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.isConstructor; import static net.bytebuddy.matcher.ElementMatchers.isInterface; @@ -68,7 +68,7 @@ public class RmiClientContextInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named("sun.rmi.transport.StreamRemoteCall"))); + return not(isInterface()).and(extendsClass(named("sun.rmi.transport.StreamRemoteCall"))); } @Override diff --git a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/server/RmiServerContextInstrumentation.java b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/server/RmiServerContextInstrumentation.java index 4e808aef73..50e371a8ff 100644 --- a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/server/RmiServerContextInstrumentation.java +++ b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/context/server/RmiServerContextInstrumentation.java @@ -16,7 +16,7 @@ package io.opentelemetry.auto.instrumentation.rmi.context.server; import static io.opentelemetry.auto.instrumentation.rmi.context.ContextPropagator.CONTEXT_CALL_ID; -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; @@ -43,7 +43,7 @@ public class RmiServerContextInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named("sun.rmi.transport.ObjectTable"))); + return not(isInterface()).and(extendsClass(named("sun.rmi.transport.ObjectTable"))); } @Override diff --git a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java index 1e87851423..978116ba5a 100644 --- a/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java +++ b/instrumentation/rmi/src/main/java/io/opentelemetry/auto/instrumentation/rmi/server/RmiServerInstrumentation.java @@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.rmi.server; import static io.opentelemetry.auto.bootstrap.instrumentation.rmi.ThreadLocalContext.THREAD_LOCAL_CONTEXT; import static io.opentelemetry.auto.instrumentation.rmi.server.RmiServerDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.rmi.server.RmiServerDecorator.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.SERVER; import static java.util.Collections.singletonMap; import static net.bytebuddy.matcher.ElementMatchers.isInterface; @@ -61,7 +61,7 @@ public final class RmiServerInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named("java.rmi.server.RemoteServer"))); + return not(isInterface()).and(extendsClass(named("java.rmi.server.RemoteServer"))); } @Override diff --git a/instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet2/Servlet2Instrumentation.java b/instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet2/Servlet2Instrumentation.java index 07a319a6f9..ee7b26e46f 100644 --- a/instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet2/Servlet2Instrumentation.java +++ b/instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet2/Servlet2Instrumentation.java @@ -15,8 +15,8 @@ */ package io.opentelemetry.auto.instrumentation.servlet2; -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.safeHasSuperType; import static java.util.Collections.singletonMap; import static net.bytebuddy.matcher.ElementMatchers.isInterface; import static net.bytebuddy.matcher.ElementMatchers.isPublic; diff --git a/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/AsyncContextInstrumentation.java b/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/AsyncContextInstrumentation.java index 5683d9582e..3f50061e31 100644 --- a/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/AsyncContextInstrumentation.java +++ b/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/AsyncContextInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.servlet3; import static io.opentelemetry.auto.decorator.HttpServerDecorator.SPAN_ATTRIBUTE; import static io.opentelemetry.auto.instrumentation.servlet3.Servlet3Decorator.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; @@ -56,7 +56,7 @@ public final class AsyncContextInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.servlet.AsyncContext"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.AsyncContext"))); } @Override diff --git a/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/Servlet3Instrumentation.java b/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/Servlet3Instrumentation.java index 7303b296e9..149f1f4217 100644 --- a/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/Servlet3Instrumentation.java +++ b/instrumentation/servlet/request-3.0/src/main/java/io/opentelemetry/auto/instrumentation/servlet3/Servlet3Instrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.servlet3; -import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType; +import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType; import static java.util.Collections.singletonMap; import static net.bytebuddy.matcher.ElementMatchers.isInterface; import static net.bytebuddy.matcher.ElementMatchers.isPublic; diff --git a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java index e94eb458cf..2edab3ca5c 100644 --- a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java +++ b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/RequestDispatcherInstrumentation.java @@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.servlet.dispatcher; import static io.opentelemetry.auto.decorator.HttpServerDecorator.SPAN_ATTRIBUTE; import static io.opentelemetry.auto.instrumentation.servlet.dispatcher.RequestDispatcherDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.servlet.dispatcher.RequestDispatcherDecorator.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; @@ -55,7 +55,7 @@ public final class RequestDispatcherInstrumentation extends Instrumenter.Default @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.servlet.RequestDispatcher"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.RequestDispatcher"))); } @Override diff --git a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/ServletContextInstrumentation.java b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/ServletContextInstrumentation.java index 4e8d8fa4e9..56a6cdd36d 100644 --- a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/ServletContextInstrumentation.java +++ b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/dispatcher/ServletContextInstrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.servlet.dispatcher; -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; @@ -42,7 +42,7 @@ public final class ServletContextInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.servlet.ServletContext"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.ServletContext"))); } @Override diff --git a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/filter/FilterInstrumentation.java b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/filter/FilterInstrumentation.java index 487533bd99..842324d1f8 100644 --- a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/filter/FilterInstrumentation.java +++ b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/filter/FilterInstrumentation.java @@ -16,7 +16,7 @@ package io.opentelemetry.auto.instrumentation.servlet.filter; import static io.opentelemetry.auto.instrumentation.servlet.filter.FilterDecorator.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; @@ -56,7 +56,7 @@ public final class FilterInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeHasInterface(named("javax.servlet.Filter"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.Filter"))); } @Override diff --git a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletInstrumentation.java b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletInstrumentation.java index b8bb271121..692eda632f 100644 --- a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletInstrumentation.java +++ b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.servlet.http; import static io.opentelemetry.auto.instrumentation.servlet.http.HttpServletDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.servlet.http.HttpServletDecorator.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.isProtected; @@ -59,7 +59,7 @@ public final class HttpServletInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return not(isInterface()).and(safeExtendsClass(named("javax.servlet.http.HttpServlet"))); + return not(isInterface()).and(extendsClass(named("javax.servlet.http.HttpServlet"))); } /** diff --git a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletResponseInstrumentation.java b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletResponseInstrumentation.java index 97912d399c..02b1db63d8 100644 --- a/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletResponseInstrumentation.java +++ b/instrumentation/servlet/src/main/java/io/opentelemetry/auto/instrumentation/servlet/http/HttpServletResponseInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.servlet.http; import static io.opentelemetry.auto.instrumentation.servlet.http.HttpServletResponseDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.servlet.http.HttpServletResponseDecorator.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.named; @@ -53,8 +53,7 @@ public final class HttpServletResponseInstrumentation extends Instrumenter.Defau @Override public ElementMatcher typeMatcher() { - return not(isInterface()) - .and(safeHasInterface(named("javax.servlet.http.HttpServletResponse"))); + return not(isInterface()).and(hasInterface(named("javax.servlet.http.HttpServletResponse"))); } @Override diff --git a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/DefaultWebClientInstrumentation.java b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/DefaultWebClientInstrumentation.java index bc6336ff9d..81d6000075 100644 --- a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/DefaultWebClientInstrumentation.java +++ b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/DefaultWebClientInstrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.springwebflux.client; -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.isPublic; @@ -52,8 +52,7 @@ public class DefaultWebClientInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { - return safeHasInterface( - named("org.springframework.web.reactive.function.client.ExchangeFunction")); + return hasInterface(named("org.springframework.web.reactive.function.client.ExchangeFunction")); } @Override diff --git a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/HandlerAdapterInstrumentation.java b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/HandlerAdapterInstrumentation.java index 3b0dc1adb4..50e8c950e7 100644 --- a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/HandlerAdapterInstrumentation.java +++ b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/HandlerAdapterInstrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.springwebflux.server; -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 final class HandlerAdapterInstrumentation extends AbstractWebfluxInstrume public ElementMatcher typeMatcher() { return not(isInterface()) .and(not(isAbstract())) - .and(safeHasInterface(named("org.springframework.web.reactive.HandlerAdapter"))); + .and(hasInterface(named("org.springframework.web.reactive.HandlerAdapter"))); } @Override diff --git a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/RouterFunctionInstrumentation.java b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/RouterFunctionInstrumentation.java index 94c3af7875..69bbe46ce2 100644 --- a/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/RouterFunctionInstrumentation.java +++ b/instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/server/RouterFunctionInstrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.springwebflux.server; -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; @@ -43,7 +43,7 @@ public final class RouterFunctionInstrumentation extends AbstractWebfluxInstrume public ElementMatcher typeMatcher() { return not(isAbstract()) .and( - safeExtendsClass( + extendsClass( // TODO: this doesn't handle nested routes (DefaultNestedRouterFunction) named( "org.springframework.web.reactive.function.server.RouterFunctions$DefaultRouterFunction"))); diff --git a/instrumentation/spring-webmvc-3.1/src/main/java/io/opentelemetry/auto/instrumentation/springweb/HandlerAdapterInstrumentation.java b/instrumentation/spring-webmvc-3.1/src/main/java/io/opentelemetry/auto/instrumentation/springweb/HandlerAdapterInstrumentation.java index 6457d58a22..0237eadff3 100644 --- a/instrumentation/spring-webmvc-3.1/src/main/java/io/opentelemetry/auto/instrumentation/springweb/HandlerAdapterInstrumentation.java +++ b/instrumentation/spring-webmvc-3.1/src/main/java/io/opentelemetry/auto/instrumentation/springweb/HandlerAdapterInstrumentation.java @@ -18,7 +18,7 @@ package io.opentelemetry.auto.instrumentation.springweb; import static io.opentelemetry.auto.decorator.HttpServerDecorator.SPAN_ATTRIBUTE; import static io.opentelemetry.auto.instrumentation.springweb.SpringWebHttpServerDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.springweb.SpringWebHttpServerDecorator.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; @@ -50,7 +50,7 @@ public final class HandlerAdapterInstrumentation extends Instrumenter.Default { @Override public ElementMatcher typeMatcher() { return not(isInterface()) - .and(safeHasInterface(named("org.springframework.web.servlet.HandlerAdapter"))); + .and(hasInterface(named("org.springframework.web.servlet.HandlerAdapter"))); } @Override diff --git a/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java b/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java index 657e77d898..fa888ec4e1 100644 --- a/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java +++ b/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java @@ -16,7 +16,7 @@ package io.opentelemetry.auto.instrumentation.trace_annotation; import static io.opentelemetry.auto.instrumentation.trace_annotation.TraceConfigInstrumentation.PACKAGE_CLASS_NAME_REGEX; -import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType; +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; diff --git a/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceConfigInstrumentation.java b/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceConfigInstrumentation.java index 4ef1980623..981d6b2590 100644 --- a/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceConfigInstrumentation.java +++ b/instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/trace_annotation/TraceConfigInstrumentation.java @@ -15,7 +15,7 @@ */ package io.opentelemetry.auto.instrumentation.trace_annotation; -import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType; +import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType; import static net.bytebuddy.matcher.ElementMatchers.named; import com.google.auto.service.AutoService; @@ -61,8 +61,8 @@ public class TraceConfigInstrumentation implements Instrumenter { private final Map> classMethodsToTrace; - private boolean validateConfigString(String configString) { - for (String segment : configString.split(";")) { + private boolean validateConfigString(final String configString) { + for (final String segment : configString.split(";")) { if (!segment.trim().matches(CONFIG_FORMAT)) { return false; } diff --git a/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioAsyncInstrumentation.java b/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioAsyncInstrumentation.java index 8291a533f8..36475e6755 100644 --- a/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioAsyncInstrumentation.java +++ b/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioAsyncInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.twilio; import static io.opentelemetry.auto.instrumentation.twilio.TwilioClientDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.twilio.TwilioClientDecorator.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.isAbstract; @@ -52,7 +52,7 @@ public class TwilioAsyncInstrumentation extends Instrumenter.Default { /** Match any child class of the base Twilio service classes. */ @Override public ElementMatcher typeMatcher() { - return safeExtendsClass( + return extendsClass( named("com.twilio.base.Creator") .or(named("com.twilio.base.Deleter")) .or(named("com.twilio.base.Fetcher")) diff --git a/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioSyncInstrumentation.java b/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioSyncInstrumentation.java index 2c99ac33c6..20241495d8 100644 --- a/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioSyncInstrumentation.java +++ b/instrumentation/twilio-6.6/src/main/java/io/opentelemetry/auto/instrumentation/twilio/TwilioSyncInstrumentation.java @@ -17,7 +17,7 @@ package io.opentelemetry.auto.instrumentation.twilio; import static io.opentelemetry.auto.instrumentation.twilio.TwilioClientDecorator.DECORATE; import static io.opentelemetry.auto.instrumentation.twilio.TwilioClientDecorator.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.isAbstract; @@ -50,7 +50,7 @@ public class TwilioSyncInstrumentation extends Instrumenter.Default { public net.bytebuddy.matcher.ElementMatcher< ? super net.bytebuddy.description.type.TypeDescription> typeMatcher() { - return safeExtendsClass( + return extendsClass( named("com.twilio.base.Creator") .or(named("com.twilio.base.Deleter")) .or(named("com.twilio.base.Fetcher"))