Skip to content

Commit

Permalink
Merge branch 'master' into joey/aws-sns
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyzhao2018 authored May 24, 2024
2 parents 483b389 + f89dfd6 commit 4c00b5e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public static void registerAsSupplier() {
@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresAnnotation(
ElementMatcher.Junction<? super NamedElement> matcher) {
ElementMatcher<? super NamedElement> matcher) {
return ElementMatchers.isAnnotatedWith(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresField(
ElementMatcher.Junction<? super FieldDescription> matcher) {
ElementMatcher<? super FieldDescription> matcher) {
return ElementMatchers.declaresField(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return ElementMatchers.declaresMethod(matcher);
}

Expand All @@ -49,31 +49,31 @@ public ElementMatcher.Junction<TypeDescription> concreteClass() {

@Override
public ElementMatcher.Junction<TypeDescription> extendsClass(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return new SafeHasSuperTypeMatcher<>(matcher, false, true, false);
}

@Override
public ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return new SafeHasSuperTypeMatcher<>(matcher, true, true, true);
}

@Override
public ElementMatcher.Junction<TypeDescription> hasInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return new SafeHasSuperTypeMatcher<>(matcher, true, false, true);
}

@Override
public ElementMatcher.Junction<TypeDescription> hasSuperType(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return new SafeHasSuperTypeMatcher<>(matcher, false, true, true);
}

@Override
public ElementMatcher.Junction<MethodDescription> hasSuperMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return new HasSuperMethodMatcher<>(matcher);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public static ElementMatcher.Junction<TypeDescription> declaresAnnotation(
}

public static ElementMatcher.Junction<TypeDescription> declaresField(
ElementMatcher.Junction<? super FieldDescription> matcher) {
ElementMatcher<? super FieldDescription> matcher) {
return SUPPLIER.declaresField(matcher);
}

public static ElementMatcher.Junction<TypeDescription> declaresMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return SUPPLIER.declaresMethod(matcher);
}

Expand All @@ -45,12 +45,12 @@ public static ElementMatcher.Junction<TypeDescription> concreteClass() {
}

public static ElementMatcher.Junction<TypeDescription> extendsClass(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return SUPPLIER.extendsClass(matcher);
}

public static ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return SUPPLIER.implementsInterface(matcher);
}

Expand All @@ -60,19 +60,19 @@ public static ElementMatcher.Junction<TypeDescription> implementsInterface(
* <p>Use this when matching return or parameter types that could be classes or interfaces.
*/
public static ElementMatcher.Junction<TypeDescription> hasInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return SUPPLIER.hasInterface(matcher);
}

/** Considers both interfaces and super-classes when matching the target type's hierarchy. */
public static ElementMatcher.Junction<TypeDescription> hasSuperType(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return SUPPLIER.hasSuperType(matcher);
}

/** Targets methods whose declaring class has a super-type that declares a matching method. */
public static ElementMatcher.Junction<MethodDescription> hasSuperMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return SUPPLIER.hasSuperMethod(matcher);
}

Expand Down Expand Up @@ -106,30 +106,30 @@ public static synchronized void registerIfAbsent(Supplier supplier) {

public interface Supplier {
ElementMatcher.Junction<TypeDescription> declaresAnnotation(
ElementMatcher.Junction<? super NamedElement> matcher);
ElementMatcher<? super NamedElement> matcher);

ElementMatcher.Junction<TypeDescription> declaresField(
ElementMatcher.Junction<? super FieldDescription> matcher);
ElementMatcher<? super FieldDescription> matcher);

ElementMatcher.Junction<TypeDescription> declaresMethod(
ElementMatcher.Junction<? super MethodDescription> matcher);
ElementMatcher<? super MethodDescription> matcher);

ElementMatcher.Junction<TypeDescription> concreteClass();

ElementMatcher.Junction<TypeDescription> extendsClass(
ElementMatcher.Junction<? super TypeDescription> matcher);
ElementMatcher<? super TypeDescription> matcher);

ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher.Junction<? super TypeDescription> matcher);
ElementMatcher<? super TypeDescription> matcher);

ElementMatcher.Junction<TypeDescription> hasInterface(
ElementMatcher.Junction<? super TypeDescription> matcher);
ElementMatcher<? super TypeDescription> matcher);

ElementMatcher.Junction<TypeDescription> hasSuperType(
ElementMatcher.Junction<? super TypeDescription> matcher);
ElementMatcher<? super TypeDescription> matcher);

ElementMatcher.Junction<MethodDescription> hasSuperMethod(
ElementMatcher.Junction<? super MethodDescription> matcher);
ElementMatcher<? super MethodDescription> matcher);

ElementMatcher.Junction<TypeDescription> declaresContextField(
String keyClassName, String contextClassName);
Expand All @@ -141,21 +141,21 @@ public static HierarchyMatchers.Supplier simpleChecks() {
@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresAnnotation(
ElementMatcher.Junction<? super NamedElement> matcher) {
ElementMatcher<? super NamedElement> matcher) {
return ElementMatchers.isAnnotatedWith(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresField(
ElementMatcher.Junction<? super FieldDescription> matcher) {
ElementMatcher<? super FieldDescription> matcher) {
return ElementMatchers.declaresField(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> declaresMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return ElementMatchers.declaresMethod(matcher);
}

Expand All @@ -168,35 +168,35 @@ public ElementMatcher.Junction<TypeDescription> concreteClass() {
@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> extendsClass(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return ElementMatchers.hasSuperClass(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return ElementMatchers.hasSuperType(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> hasInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return ElementMatchers.hasSuperType(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<TypeDescription> hasSuperType(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return ElementMatchers.hasSuperType(matcher);
}

@Override
@SuppressForbidden
public ElementMatcher.Junction<MethodDescription> hasSuperMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return ElementMatchers.isDeclaredBy(
ElementMatchers.hasSuperType(ElementMatchers.declaresMethod(matcher)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ public static void registerAsSupplier() {

@Override
public ElementMatcher.Junction<TypeDescription> declaresAnnotation(
ElementMatcher.Junction<? super NamedElement> matcher) {
ElementMatcher<? super NamedElement> matcher) {
return Memoizer.prepare(ANNOTATION, matcher, false);
}

@Override
public ElementMatcher.Junction<TypeDescription> declaresField(
ElementMatcher.Junction<? super FieldDescription> matcher) {
ElementMatcher<? super FieldDescription> matcher) {
return Memoizer.prepare(FIELD, matcher, false);
}

@Override
public ElementMatcher.Junction<TypeDescription> declaresMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return Memoizer.prepare(METHOD, matcher, false);
}

Expand All @@ -53,31 +53,31 @@ public ElementMatcher.Junction<TypeDescription> concreteClass() {

@Override
public ElementMatcher.Junction<TypeDescription> extendsClass(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return Memoizer.prepare(CLASS, matcher, true);
}

@Override
public ElementMatcher.Junction<TypeDescription> implementsInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return Memoizer.isClass.and(Memoizer.prepare(INTERFACE, matcher, true));
}

@Override
public ElementMatcher.Junction<TypeDescription> hasInterface(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return Memoizer.prepare(INTERFACE, matcher, true);
}

@Override
public ElementMatcher.Junction<TypeDescription> hasSuperType(
ElementMatcher.Junction<? super TypeDescription> matcher) {
ElementMatcher<? super TypeDescription> matcher) {
return Memoizer.isClass.and(Memoizer.prepare(TYPE, matcher, true));
}

@Override
public ElementMatcher.Junction<MethodDescription> hasSuperMethod(
ElementMatcher.Junction<? super MethodDescription> matcher) {
ElementMatcher<? super MethodDescription> matcher) {
return new HasSuperMethod(Memoizer.prepare(METHOD, matcher, true), matcher);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static MemoizingMatcher withMatcherId(ElementMatcher matcher) {

/** Prepares a matcher for memoization. */
static <T> MemoizingMatcher prepare(
MatcherKind kind, ElementMatcher.Junction<T> matcher, boolean inherited) {
MatcherKind kind, ElementMatcher<T> matcher, boolean inherited) {

MemoizingMatcher memoizingMatcher =
memoizingMatcherCache.computeIfAbsent(matcher, Memoizer::withMatcherId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public UrlInstrumentation() {
super("urlconnection", "httpurlconnection");
}

@Override
protected boolean defaultEnabled() {
return false;
}

@Override
public String instrumentedType() {
return "java.net.URL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import datadog.trace.agent.test.naming.VersionedNamingTestBase
import datadog.trace.api.DDSpanTypes
import datadog.trace.bootstrap.DatadogClassLoader
import datadog.trace.bootstrap.instrumentation.api.Tags
import datadog.trace.bootstrap.instrumentation.decorator.UrlConnectionDecorator

import static datadog.trace.agent.test.utils.PortUtils.UNUSABLE_PORT
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
Expand Down Expand Up @@ -68,53 +67,6 @@ abstract class UrlConnectionTest extends VersionedNamingTestBase {
url = new URI("$scheme://localhost:$UNUSABLE_PORT").toURL()
}

def "trace request with connection failure to a local file with broken url path"() {
setup:
def url = new URI("file:/some-random-file%abc").toURL()

when:
injectSysConfig(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "$renameService")
runUnderTrace("someTrace") {
url.openConnection()
}

then:
thrown IllegalArgumentException

expect:
assertTraces(1) {
trace(2) {
span {
operationName "someTrace"
parent()
errored true
tags {
errorTags IllegalArgumentException, String
defaultTags()
}
}
span {
operationName operation(url.protocol)
resourceName "$url.path"
spanType DDSpanTypes.HTTP_CLIENT
childOf span(0)
errored true
tags {
"$Tags.COMPONENT" UrlConnectionDecorator.COMPONENT
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
// FIXME: These tags really make no sense for non-http connections, why do we set them?
"$Tags.HTTP_URL" "$url"
errorTags IllegalArgumentException, String
defaultTagsNoPeerService()
}
}
}
}

where:
renameService << [false, true]
}

def "DatadogClassloader ClassNotFoundException doesn't create span"() {
given:
ClassLoader datadogLoader = new DatadogClassLoader()
Expand Down

0 comments on commit 4c00b5e

Please sign in to comment.