Merge pull request #645 from DataDog/tyler/instrumenter-signature

Apply proper generic signature for Instrumenter.Default transformers()
This commit is contained in:
Tyler Benson 2019-01-07 14:18:52 -08:00 committed by GitHub
commit 7da0cc7f50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 329 additions and 345 deletions

View File

@ -17,6 +17,7 @@ import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule;
@ -161,11 +162,11 @@ public interface Instrumenter {
private class PostMatchHook implements AgentBuilder.RawMatcher {
@Override
public boolean matches(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final Class<?> classBeingRedefined,
final ProtectionDomain protectionDomain) {
postMatch(typeDescription, classLoader, module, classBeingRedefined, protectionDomain);
return true;
}
@ -206,14 +207,14 @@ public interface Instrumenter {
* @param protectionDomain protection domain of the class under load.
*/
public void postMatch(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {}
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final Class<?> classBeingRedefined,
final ProtectionDomain protectionDomain) {}
/** @return A map of matcher->advice */
public abstract Map<? extends ElementMatcher, String> transformers();
public abstract Map<? extends ElementMatcher<? super MethodDescription>, String> transformers();
/**
* A map of {class-name -> context-class-name}. Keys (and their subclasses) will be associated

View File

@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import scala.Tuple2;
@ -63,8 +64,8 @@ public final class AkkaHttpClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
// This is mainly for compatibility with 10.0
transformers.put(
named("singleRequest").and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))),

View File

@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import scala.Function1;
@ -58,14 +59,14 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
// Instrumenting akka-streams bindAndHandle api was previously attempted.
// This proved difficult as there was no clean way to close the async scope
// in the graph logic after the user's request handler completes.
//
// Instead, we're instrumenting the bindAndHandle function helpers by
// wrapping the scala functions with our own handlers.
final Map<ElementMatcher, String> transformers = new HashMap<>();
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
named("bindAndHandleSync").and(takesArgument(0, named("scala.Function1"))),
AkkaHttpSyncAdvice.class.getName());

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.apachehttpclient;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -22,10 +23,10 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.io.IOException;
import java.net.URI;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.implementation.bytecode.assign.Assigner;
import net.bytebuddy.matcher.ElementMatcher;
@ -57,8 +58,8 @@ public class ApacheHttpClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
return Collections.singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(not(isAbstract()))
.and(named("execute"))
@ -137,7 +138,7 @@ public class ApacheHttpClientInstrumentation extends Instrumenter.Default {
if (throwable != null) {
Tags.ERROR.set(span, Boolean.TRUE);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
span.log(singletonMap(ERROR_OBJECT, throwable));
span.finish();
}
scope.close();

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.aws.v0;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresField;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -8,10 +9,10 @@ import com.amazonaws.handlers.RequestHandler2;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.util.GlobalTracer;
import java.util.HashMap;
import java.util.List;
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;
@ -41,10 +42,8 @@ public final class AWSClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(isConstructor(), AWSClientAdvice.class.getName());
return transformers;
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(isConstructor(), AWSClientAdvice.class.getName());
}
public static class AWSClientAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.couchbase.client;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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;
@ -19,10 +20,10 @@ import io.opentracing.noop.NoopSpan;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import rx.Observable;
@ -54,8 +55,8 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(returns(named("rx.Observable"))),
CouchbaseClientAdvice.class.getName());
}
@ -152,7 +153,7 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
final Span span = spanRef.getAndSet(null);
if (span != null) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
span.log(singletonMap(ERROR_OBJECT, throwable));
span.finish();
}
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.couchbase.client;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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;
@ -19,10 +20,10 @@ import io.opentracing.noop.NoopSpan;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import rx.Observable;
@ -54,8 +55,8 @@ public class CouchbaseClusterInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(returns(named("rx.Observable"))),
CouchbaseClientAdvice.class.getName());
}
@ -146,7 +147,7 @@ public class CouchbaseClusterInstrumentation extends Instrumenter.Default {
final Span span = spanRef.getAndSet(null);
if (span != null) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
span.log(singletonMap(ERROR_OBJECT, throwable));
span.finish();
}
}

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.datastax.cassandra;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPrivate;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -11,9 +12,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Constructor;
import java.util.HashMap;
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;
@ -39,12 +40,10 @@ public class CassandraClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPrivate()).and(named("newSession")).and(takesArguments(0)),
CassandraClientAdvice.class.getName());
return transformers;
}
public static class CassandraClientAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.dropwizard.view;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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;
@ -19,9 +20,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
@ -38,15 +39,13 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("render"))
.and(takesArgument(0, named("io.dropwizard.views.View")))
.and(isPublic()),
RenderAdvice.class.getName());
return transformers;
}
public static class RenderAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.elasticsearch5;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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;
@ -18,9 +19,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.elasticsearch.client.ResponseListener;
@ -43,9 +44,8 @@ public class Elasticsearch5RestClientInstrumentation extends Instrumenter.Defaul
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("performRequestAsync"))
@ -54,7 +54,6 @@ public class Elasticsearch5RestClientInstrumentation extends Instrumenter.Defaul
.and(takesArgument(1, named("java.lang.String"))) // endpoint
.and(takesArgument(5, named("org.elasticsearch.client.ResponseListener"))),
ElasticsearchRestClientAdvice.class.getName());
return transformers;
}
public static class ElasticsearchRestClientAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.elasticsearch2;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,9 +17,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.elasticsearch.action.Action;
@ -53,16 +54,14 @@ public class Elasticsearch2TransportClientInstrumentation extends Instrumenter.D
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("execute"))
.and(takesArgument(0, named("org.elasticsearch.action.Action")))
.and(takesArgument(1, named("org.elasticsearch.action.ActionRequest")))
.and(takesArgument(2, named("org.elasticsearch.action.ActionListener"))),
ElasticsearchTransportClientAdvice.class.getName());
return transformers;
}
public static class ElasticsearchTransportClientAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.elasticsearch5_3;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,9 +17,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.elasticsearch.action.Action;
@ -54,16 +55,14 @@ public class Elasticsearch53TransportClientInstrumentation extends Instrumenter.
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("execute"))
.and(takesArgument(0, named("org.elasticsearch.action.Action")))
.and(takesArgument(1, named("org.elasticsearch.action.ActionRequest")))
.and(takesArgument(2, named("org.elasticsearch.action.ActionListener"))),
ElasticsearchTransportClientAdvice.class.getName());
return transformers;
}
public static class ElasticsearchTransportClientAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.elasticsearch5;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,9 +17,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.elasticsearch.action.Action;
@ -53,16 +54,14 @@ public class Elasticsearch5TransportClientInstrumentation extends Instrumenter.D
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("execute"))
.and(takesArgument(0, named("org.elasticsearch.action.Action")))
.and(takesArgument(1, named("org.elasticsearch.action.ActionRequest")))
.and(takesArgument(2, named("org.elasticsearch.action.ActionListener"))),
ElasticsearchTransportClientAdvice.class.getName());
return transformers;
}
public static class ElasticsearchTransportClientAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.elasticsearch6;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,9 +17,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.elasticsearch.action.Action;
@ -57,16 +58,14 @@ public class Elasticsearch6TransportClientInstrumentation extends Instrumenter.D
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("execute"))
.and(takesArgument(0, named("org.elasticsearch.action.Action")))
.and(takesArgument(1, named("org.elasticsearch.action.ActionRequest")))
.and(takesArgument(2, named("org.elasticsearch.action.ActionListener"))),
Elasticsearch6TransportClientAdvice.class.getName());
return transformers;
}
public static class Elasticsearch6TransportClientAdvice {

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.grpc.client;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -7,10 +8,10 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import io.grpc.ClientInterceptor;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.List;
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;
@ -37,9 +38,8 @@ public class GrpcClientBuilderInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
isMethod().and(named("build")), AddInterceptorAdvice.class.getName());
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(isMethod().and(named("build")), AddInterceptorAdvice.class.getName());
}
public static class AddInterceptorAdvice {

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.grpc.server;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -7,10 +8,10 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import io.grpc.ServerInterceptor;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.List;
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;
@ -35,9 +36,8 @@ public class GrpcServerBuilderInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
isMethod().and(named("build")), AddInterceptorAdvice.class.getName());
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(isMethod().and(named("build")), AddInterceptorAdvice.class.getName());
}
public static class AddInterceptorAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.http_url_connection;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -23,11 +24,11 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -56,13 +57,12 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
@Override
public Map<String, String> contextStore() {
return Collections.singletonMap(
"java.net.HttpURLConnection", getClass().getName() + "$HttpUrlState");
return singletonMap("java.net.HttpURLConnection", getClass().getName() + "$HttpUrlState");
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("connect").or(named("getOutputStream")).or(named("getInputStream"))),
@ -217,7 +217,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
public void finishSpan(final Throwable throwable) {
try (final Scope scope = GlobalTracer.get().scopeManager().activate(span, true)) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
span.log(singletonMap(ERROR_OBJECT, throwable));
}
span = null;
finished = true;

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.http_url_connection;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.is;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -16,9 +17,9 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
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;
@ -37,12 +38,10 @@ public class UrlInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(named("openConnection")),
ConnectionErrorAdvice.class.getName());
return transformers;
}
public static class ConnectionErrorAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.hystrix;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -15,9 +16,9 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
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;
@ -36,11 +37,9 @@ public class HystrixCommandInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(named("run").or(named("getFallback"))), TraceAdvice.class.getName());
return transformers;
}
public static class TraceAdvice {

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.hystrix;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
@ -9,9 +10,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.context.TraceScope;
import io.opentracing.Scope;
import io.opentracing.util.GlobalTracer;
import java.util.HashMap;
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;
@ -29,12 +30,10 @@ public class HystrixThreadPoolInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(named("schedule")).and(takesArguments(1)),
EnableAsyncAdvice.class.getName());
return transformers;
}
public static class EnableAsyncAdvice {

View File

@ -30,6 +30,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -143,8 +144,8 @@ public final class ExecutorInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
named("execute").and(takesArgument(0, Runnable.class)),
SetExecuteRunnableStateAdvice.class.getName());

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.java.concurrent;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
@ -20,6 +21,7 @@ import java.util.Map;
import java.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -98,11 +100,9 @@ public final class FutureInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("cancel").and(returns(boolean.class)), CanceledFutureAdvice.class.getName());
return transformers;
}
public static class CanceledFutureAdvice {

View File

@ -18,6 +18,7 @@ import java.util.Map;
import java.util.concurrent.Callable;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -51,8 +52,8 @@ public final class RunnableCallableInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(named("run").and(takesArguments(0)), RunnableAdvice.class.getName());
transformers.put(named("call").and(takesArguments(0)), CallableAdvice.class.getName());
return transformers;

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.java.concurrent;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@ -7,12 +8,12 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -43,8 +44,8 @@ public class ThreadPoolExecutorInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
return Collections.singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isConstructor()
.and(takesArgument(4, named("java.util.concurrent.BlockingQueue")))
.and(takesArguments(7)),

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.jaxrs;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -16,12 +17,12 @@ import io.opentracing.util.GlobalTracer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -40,9 +41,8 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isAnnotatedWith(
named("javax.ws.rs.Path")
.or(named("javax.ws.rs.DELETE"))
@ -52,7 +52,6 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default
.or(named("javax.ws.rs.POST"))
.or(named("javax.ws.rs.PUT"))),
JaxRsAnnotationsAdvice.class.getName());
return transformers;
}
public static class JaxRsAnnotationsAdvice {

View File

@ -19,6 +19,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.glassfish.jersey.client.ClientRequest;
@ -45,8 +46,8 @@ public final class JerseyClientConnectionErrorInstrumentation extends Instrument
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(isMethod().and(isPublic()).and(named("invoke")), InvokeAdvice.class.getName());
transformers.put(
isMethod().and(isPublic()).and(named("submit")).and(returns(Future.class)),

View File

@ -20,6 +20,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration;
@ -46,8 +47,8 @@ public final class ResteasyClientConnectionErrorInstrumentation extends Instrume
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(isMethod().and(isPublic()).and(named("invoke")), InvokeAdvice.class.getName());
transformers.put(
isMethod().and(isPublic()).and(named("submit")).and(returns(Future.class)),

View File

@ -1,15 +1,16 @@
package datadog.trace.instrumentation.jaxrs;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.client.ClientBuilder;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -35,12 +36,10 @@ public final class JaxRsClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("build").and(returns(safeHasSuperType(named("javax.ws.rs.client.Client")))),
ClientBuilderAdvice.class.getName());
return transformers;
}
public static class ClientBuilderAdvice {

View File

@ -8,6 +8,7 @@ import datadog.trace.agent.tooling.Utils;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule;
@ -25,11 +26,11 @@ public final class JBossClassloadingInstrumentation extends Instrumenter.Default
@Override
public void postMatch(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final Class<?> classBeingRedefined,
final ProtectionDomain protectionDomain) {
// Set the system prop to tell jboss to delegate classloads for datadog bootstrap classes
final StringBuilder ddPrefixes = new StringBuilder("");
for (int i = 0; i < Utils.BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
@ -47,7 +48,7 @@ public final class JBossClassloadingInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return Collections.emptyMap();
}
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.jdbc;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -12,9 +13,9 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.JDBCMaps;
import java.sql.PreparedStatement;
import java.util.HashMap;
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;
@ -31,15 +32,13 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
nameStartsWith("prepare")
.and(takesArgument(0, String.class))
// Also include CallableStatement, which is a sub type of PreparedStatement
.and(returns(safeHasSuperType(named(PreparedStatement.class.getName())))),
ConnectionPrepareAdvice.class.getName());
return transformers;
}
public static class ConnectionPrepareAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.jdbc;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@ -26,9 +27,9 @@ import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
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;
@ -44,12 +45,10 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
nameStartsWith("execute").and(takesArguments(0)).and(isPublic()),
PreparedStatementAdvice.class.getName());
return transformers;
}
public static class PreparedStatementAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.jdbc;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@ -26,9 +27,9 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collections;
import java.util.HashMap;
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;
@ -45,12 +46,10 @@ public final class StatementInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
nameStartsWith("execute").and(takesArgument(0, String.class)).and(isPublic()),
StatementAdvice.class.getName());
return transformers;
}
public static class StatementAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.jedis;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -15,9 +16,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import redis.clients.jedis.Protocol.Command;
@ -43,15 +44,13 @@ public final class JedisInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("sendCommand"))
.and(takesArgument(1, named("redis.clients.jedis.Protocol$Command"))),
JedisAdvice.class.getName());
return transformers;
}
public static class JedisAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.jetty8;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -9,8 +10,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -43,9 +44,8 @@ public final class HandlerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("handle")
.and(takesArgument(0, named("java.lang.String")))
.and(takesArgument(1, named("org.eclipse.jetty.server.Request")))
@ -53,6 +53,5 @@ public final class HandlerInstrumentation extends Instrumenter.Default {
.and(takesArgument(3, named("javax.servlet.http.HttpServletResponse")))
.and(isPublic()),
JettyHandlerAdvice.class.getName());
return transformers;
}
}

View File

@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -49,8 +50,8 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
named("receive").and(takesArguments(0).or(takesArguments(1))).and(isPublic()),
ConsumerAdvice.class.getName());

View File

@ -3,6 +3,7 @@ package datadog.trace.instrumentation.jms;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static datadog.trace.instrumentation.jms.JmsUtil.toResourceName;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -21,11 +22,11 @@ import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.jms.Message;
import javax.jms.MessageListener;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -47,12 +48,10 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("onMessage").and(takesArgument(0, named("javax.jms.Message"))).and(isPublic()),
MessageListenerAdvice.class.getName());
return transformers;
}
public static class MessageListenerAdvice {

View File

@ -27,6 +27,7 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -48,8 +49,8 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
named("send").and(takesArgument(0, named("javax.jms.Message"))).and(isPublic()),
ProducerAdvice.class.getName());

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.jsp;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -19,13 +20,13 @@ import io.opentracing.util.GlobalTracer;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.HttpJspPage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.slf4j.LoggerFactory;
@ -43,15 +44,13 @@ public final class JSPInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("_jspService")
.and(takesArgument(0, named("javax.servlet.http.HttpServletRequest")))
.and(takesArgument(1, named("javax.servlet.http.HttpServletResponse")))
.and(isPublic()),
HttpJspPageAdvice.class.getName());
return transformers;
}
public static class HttpJspPageAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.jsp;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
@ -14,9 +15,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.apache.jasper.JspCompilationContext;
@ -34,12 +35,10 @@ public final class JasperJSPCompilationContextInstrumentation extends Instrument
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("compile").and(takesArguments(0)).and(isPublic()),
JasperJspCompilationContext.class.getName());
return transformers;
}
public static class JasperJspCompilationContext {

View File

@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Iterator;
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;
import org.apache.kafka.clients.consumer.ConsumerRecord;
@ -50,8 +51,8 @@ public final class KafkaConsumerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(isPublic())

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.kafka_clients;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -16,9 +17,9 @@ import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.apache.kafka.clients.producer.Callback;
@ -51,16 +52,14 @@ public final class KafkaProducerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("send"))
.and(takesArgument(0, named("org.apache.kafka.clients.producer.ProducerRecord")))
.and(takesArgument(1, named("org.apache.kafka.clients.producer.Callback"))),
ProducerAdvice.class.getName());
return transformers;
}
public static class ProducerAdvice {

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.kafka_streams;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPackagePrivate;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -19,9 +20,9 @@ import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import org.apache.kafka.streams.processor.internals.StampedRecord;
@ -51,15 +52,13 @@ public class KafkaStreamsProcessorInstrumentation {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPackagePrivate())
.and(named("nextRecord"))
.and(returns(named("org.apache.kafka.streams.processor.internals.StampedRecord"))),
StartSpanAdvice.class.getName());
return transformers;
}
public static class StartSpanAdvice {
@ -108,12 +107,10 @@ public class KafkaStreamsProcessorInstrumentation {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(named("process")).and(takesArguments(0)),
StopSpanAdvice.class.getName());
return transformers;
}
public static class StopSpanAdvice {

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.kafka_streams;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -8,9 +9,9 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
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;
import org.apache.kafka.clients.consumer.ConsumerRecord;
@ -30,16 +31,14 @@ public class KafkaStreamsSourceNodeRecordDeserializerInstrumentation extends Ins
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("deserialize"))
.and(takesArgument(0, named("org.apache.kafka.clients.consumer.ConsumerRecord")))
.and(returns(named("org.apache.kafka.clients.consumer.ConsumerRecord"))),
SaveHeadersAdvice.class.getName());
return transformers;
}
public static class SaveHeadersAdvice {

View File

@ -1,13 +1,14 @@
package datadog.trace.instrumentation.lettuce;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -34,14 +35,12 @@ public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("dispatch"))
.and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand"))),
// Cannot reference class directly here because it would lead to class load failure on Java7
PACKAGE + ".LettuceAsyncCommandsAdvice");
return transformers;
}
}

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.lettuce;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPrivate;
import static net.bytebuddy.matcher.ElementMatchers.nameEndsWith;
@ -10,8 +11,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -42,9 +43,8 @@ public final class LettuceClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPrivate())
.and(returns(named("io.lettuce.core.ConnectionFuture")))
@ -53,6 +53,5 @@ public final class LettuceClientInstrumentation extends Instrumenter.Default {
.and(takesArgument(1, named("io.lettuce.core.RedisURI"))),
// Cannot reference class directly here because it would lead to class load failure on Java7
PACKAGE + ".ConnectionFutureAdvice");
return transformers;
}
}

View File

@ -11,6 +11,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -42,8 +43,8 @@ public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(named("createMono"))

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.mongo;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -12,9 +13,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
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;
@ -49,12 +50,10 @@ public final class MongoClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(named("build")).and(takesArguments(0)),
MongoClientAdvice.class.getName());
return transformers;
}
public static class MongoClientAdvice {

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.mongo;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -12,9 +13,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
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;
@ -47,12 +48,10 @@ public final class MongoAsyncClientInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(named("build")).and(takesArguments(0)),
MongoAsyncClientAdvice.class.getName());
return transformers;
}
public static class MongoAsyncClientAdvice {

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.netty40;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,10 +17,9 @@ import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
@ -49,14 +49,12 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("operationComplete"))
.and(takesArgument(0, named("io.netty.channel.ChannelFuture"))),
OperationCompleteAdvice.class.getName());
return transformers;
}
public static class OperationCompleteAdvice {
@ -87,7 +85,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
.withTag(Tags.COMPONENT.getKey(), "netty")
.start();
Tags.ERROR.set(errorSpan, true);
errorSpan.log(Collections.singletonMap(ERROR_OBJECT, cause));
errorSpan.log(singletonMap(ERROR_OBJECT, cause));
errorSpan.finish();
return scope;

View File

@ -33,6 +33,7 @@ import io.opentracing.util.GlobalTracer;
import java.util.HashMap;
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;
@ -66,8 +67,8 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(nameStartsWith("add"))

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.netty41;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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.named;
@ -16,10 +17,9 @@ import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
@ -49,14 +49,12 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(named("operationComplete"))
.and(takesArgument(0, named("io.netty.channel.ChannelFuture"))),
OperationCompleteAdvice.class.getName());
return transformers;
}
public static class OperationCompleteAdvice {
@ -87,7 +85,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
.withTag(Tags.COMPONENT.getKey(), "netty")
.start();
Tags.ERROR.set(errorSpan, true);
errorSpan.log(Collections.singletonMap(ERROR_OBJECT, cause));
errorSpan.log(singletonMap(ERROR_OBJECT, cause));
errorSpan.finish();
return scope;

View File

@ -33,6 +33,7 @@ import io.opentracing.util.GlobalTracer;
import java.util.HashMap;
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;
@ -66,8 +67,8 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(nameStartsWith("add"))

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.okhttp3;
import static datadog.trace.instrumentation.okhttp3.OkHttpClientSpanDecorator.STANDARD_TAGS;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@ -9,9 +10,9 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
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;
import okhttp3.Interceptor;
@ -48,12 +49,10 @@ public class OkHttp3Instrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isConstructor().and(takesArgument(0, named("okhttp3.OkHttpClient$Builder"))),
OkHttp3Advice.class.getName());
return transformers;
}
public static class OkHttp3Advice {

View File

@ -1,13 +1,14 @@
package datadog.trace.instrumentation.osgi;
import static java.util.Collections.emptyMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.Utils;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule;
@ -26,11 +27,11 @@ public final class OSGIClassloadingInstrumentation extends Instrumenter.Default
@Override
public void postMatch(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final Class<?> classBeingRedefined,
final ProtectionDomain protectionDomain) {
// Set the system prop to tell osgi to delegate classloads for datadog bootstrap classes
final StringBuilder ddPrefixes = new StringBuilder("");
for (int i = 0; i < Utils.BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
@ -51,7 +52,7 @@ public final class OSGIClassloadingInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.emptyMap();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return emptyMap();
}
}

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.play;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@ -19,12 +20,12 @@ import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMap;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.slf4j.LoggerFactory;
@ -58,14 +59,12 @@ public final class PlayInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("apply")
.and(takesArgument(0, named("play.api.mvc.Request")))
.and(returns(named("scala.concurrent.Future"))),
PlayAdvice.class.getName());
return transformers;
}
public static class PlayAdvice {
@ -187,7 +186,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
public static void onError(final Span span, final Throwable t) {
Tags.ERROR.set(span, Boolean.TRUE);
span.log(Collections.singletonMap(ERROR_OBJECT, t));
span.log(singletonMap(ERROR_OBJECT, t));
Tags.HTTP_STATUS.set(span, 500);
}
}

View File

@ -39,6 +39,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -64,9 +65,10 @@ public class RabbitChannelInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
// We want the advice applied in a specific order, so use an ordered map.
final Map<ElementMatcher, String> transformers = new LinkedHashMap<>();
final Map<ElementMatcher<? super MethodDescription>, String> transformers =
new LinkedHashMap<>();
transformers.put(
isMethod()
.and(

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.rabbitmq.amqp;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -14,9 +15,9 @@ import datadog.trace.api.DDTags;
import datadog.trace.api.interceptor.MutableSpan;
import io.opentracing.Span;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
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;
@ -41,8 +42,8 @@ public class RabbitCommandInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
return Collections.singletonMap(isConstructor(), CommandConstructorAdvice.class.getName());
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(isConstructor(), CommandConstructorAdvice.class.getName());
}
public static class CommandConstructorAdvice {

View File

@ -12,6 +12,7 @@ import datadog.trace.instrumentation.ratpack.impl.RatpackHttpClientAdvice;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -53,8 +54,8 @@ public final class RatpackHttpClientInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
named("request")
.and(

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.ratpack;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
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.isStatic;
@ -13,9 +14,9 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.instrumentation.ratpack.impl.RatpackServerAdvice;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -54,12 +55,10 @@ public final class RatpackInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isStatic()).and(named("buildBaseRegistry")),
RatpackServerAdvice.RatpackServerRegistryAdvice.class.getName());
return transformers;
}
@AutoService(Instrumenter.class)
@ -89,12 +88,10 @@ public final class RatpackInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("register").and(takesArguments(ACTION_TYPE_DESCRIPTION)),
RatpackServerAdvice.ExecStarterAdvice.class.getName());
return transformers;
}
}
@ -126,12 +123,10 @@ public final class RatpackInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("fork").and(returns(named("ratpack.exec.ExecStarter"))),
RatpackServerAdvice.ExecutionAdvice.class.getName());
return transformers;
}
}
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.servlet2;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -9,8 +10,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -23,14 +24,12 @@ public final class FilterChain2Instrumentation extends AbstractServlet2Instrumen
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("doFilter")
.and(takesArgument(0, named("javax.servlet.ServletRequest")))
.and(takesArgument(1, named("javax.servlet.ServletResponse")))
.and(isPublic()),
Servlet2Advice.class.getName());
return transformers;
}
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.servlet2;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -9,8 +10,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -23,14 +24,12 @@ public final class HttpServlet2Instrumentation extends AbstractServlet2Instrumen
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("service")
.and(takesArgument(0, named("javax.servlet.http.HttpServletRequest")))
.and(takesArgument(1, named("javax.servlet.http.HttpServletResponse")))
.and(isProtected()),
Servlet2Advice.class.getName());
return transformers;
}
}

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.servlet3;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static datadog.trace.instrumentation.servlet3.Servlet3Advice.SERVLET_SPAN;
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;
@ -14,12 +15,12 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import io.opentracing.Span;
import io.opentracing.propagation.Format;
import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.Map;
import javax.servlet.AsyncContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -41,8 +42,8 @@ public final class AsyncContextInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
return Collections.singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod().and(isPublic()).and(named("dispatch")), DispatchAdvice.class.getName());
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.servlet3;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -9,8 +10,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -35,14 +36,12 @@ public final class FilterChain3Instrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("doFilter")
.and(takesArgument(0, named("javax.servlet.ServletRequest")))
.and(takesArgument(1, named("javax.servlet.ServletResponse")))
.and(isPublic()),
Servlet3Advice.class.getName());
return transformers;
}
}

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.servlet3;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -9,8 +10,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -35,14 +36,12 @@ public final class HttpServlet3Instrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("service")
.and(takesArgument(0, named("javax.servlet.http.HttpServletRequest")))
.and(takesArgument(1, named("javax.servlet.http.HttpServletResponse")))
.and(isProtected()),
Servlet3Advice.class.getName());
return transformers;
}
}

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.slf4j.mdc;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isTypeInitializer;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -11,10 +12,10 @@ import datadog.trace.api.GlobalTracer;
import datadog.trace.context.ScopeListener;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule;
@ -46,20 +47,19 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
@Override
public void postMatch(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final Class<?> classBeingRedefined,
final ProtectionDomain protectionDomain) {
if (classBeingRedefined != null) {
MDCAdvice.mdcClassInitialized(classBeingRedefined);
}
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
isTypeInitializer(), MDCAdvice.class.getName());
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(isTypeInitializer(), MDCAdvice.class.getName());
}
@Override
@ -74,7 +74,7 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
final Method putMethod = mdcClass.getMethod("put", String.class, String.class);
final Method removeMethod = mdcClass.getMethod("remove", String.class);
GlobalTracer.get().addScopeListener(new MDCScopeListener(putMethod, removeMethod));
} catch (NoSuchMethodException e) {
} catch (final NoSuchMethodException e) {
org.slf4j.LoggerFactory.getLogger(mdcClass).debug("Failed to add MDC span listener", e);
}
}
@ -96,7 +96,7 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
null, CorrelationIdentifier.getTraceIdKey(), CorrelationIdentifier.getTraceId());
putMethod.invoke(
null, CorrelationIdentifier.getSpanIdKey(), CorrelationIdentifier.getSpanId());
} catch (Exception e) {
} catch (final Exception e) {
log.debug("Exception setting mdc context", e);
}
}
@ -106,7 +106,7 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
try {
removeMethod.invoke(null, CorrelationIdentifier.getTraceIdKey());
removeMethod.invoke(null, CorrelationIdentifier.getSpanIdKey());
} catch (Exception e) {
} catch (final Exception e) {
log.debug("Exception removing mdc context", e);
}
}

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.sparkjava;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
@ -10,9 +11,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.api.DDTags;
import io.opentracing.Scope;
import io.opentracing.util.GlobalTracer;
import java.util.HashMap;
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;
import spark.route.HttpMethod;
@ -36,15 +37,13 @@ public class RoutesInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("find")
.and(takesArgument(0, named("spark.route.HttpMethod")))
.and(returns(named("spark.routematch.RouteMatch")))
.and(isPublic()),
RoutesAdvice.class.getName());
return transformers;
}
public static class RoutesAdvice {

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap;
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;
import org.springframework.web.servlet.ModelAndView;
@ -35,8 +36,8 @@ public final class DispatcherServletInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(isProtected())

View File

@ -2,6 +2,7 @@ package datadog.trace.instrumentation.springweb;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT;
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;
@ -20,11 +21,11 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.springframework.web.HttpRequestHandler;
@ -46,8 +47,8 @@ public final class HandlerAdapterInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(nameStartsWith("handle"))
@ -129,7 +130,7 @@ public final class HandlerAdapterInstrumentation extends Instrumenter.Default {
if (throwable != null) {
final Span span = scope.span();
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
span.log(singletonMap(ERROR_OBJECT, throwable));
}
scope.close();
}

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.springwebflux;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -8,8 +9,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -34,8 +35,8 @@ public final class DispatcherHandlerInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("handle"))

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.springwebflux;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -8,8 +9,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -29,8 +30,8 @@ public final class HandlerFunctionAdapterInstrumentation extends Instrumenter.De
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("handle"))

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.springwebflux;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
import static net.bytebuddy.matcher.ElementMatchers.named;
@ -8,8 +9,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -35,8 +36,8 @@ public final class RequestMappingInfoHandlerMappingInstrumentation extends Instr
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isProtected())
.and(named("handleMatch"))

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.springwebflux;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresField;
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
@ -12,8 +13,8 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -42,8 +43,8 @@ public final class RouterFunctionInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
return Collections.<ElementMatcher, String>singletonMap(
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
isMethod()
.and(isPublic())
.and(named("route"))

View File

@ -14,6 +14,7 @@ import java.lang.reflect.Method;
import java.util.HashMap;
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;
import net.spy.memcached.MemcachedClient;
@ -49,8 +50,8 @@ public final class MemcachedClientInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(
isMethod()
.and(isPublic())

View File

@ -12,11 +12,11 @@ import com.google.common.collect.Sets;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.api.Trace;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -83,9 +83,8 @@ public final class TraceAnnotationsInstrumentation extends Instrumenter.Default
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(isAnnotatedWith(methodTraceMatcher), TraceAdvice.class.getName());
return transformers;
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return Collections.singletonMap(
isAnnotatedWith(methodTraceMatcher), TraceAdvice.class.getName());
}
}

View File

@ -121,7 +121,7 @@ public class TraceConfigInstrumentation implements Instrumenter {
}
@Override
public Map<ElementMatcher, String> transformers() {
public Map<ElementMatcher<? super MethodDescription>, String> transformers() {
ElementMatcher.Junction<MethodDescription> methodMatchers = null;
for (final String methodName : methodNames) {
if (methodMatchers == null) {
@ -131,7 +131,7 @@ public class TraceConfigInstrumentation implements Instrumenter {
}
}
final Map<ElementMatcher, String> transformers = new HashMap<>();
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put(methodMatchers, TraceAdvice.class.getName());
return transformers;
}

View File

@ -1,10 +1,11 @@
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
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;
@ -20,10 +21,8 @@ public class IBMResourceLevelInstrumentation extends Instrumenter.Default {
}
@Override
public Map<ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>();
transformers.put(named("toString"), ToStringAdvice.class.getName());
return transformers;
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(named("toString"), ToStringAdvice.class.getName());
}
public static class ToStringAdvice {

View File

@ -10,6 +10,7 @@ import datadog.trace.bootstrap.InstrumentationContext;
import java.util.HashMap;
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;
@ -25,8 +26,8 @@ public class ContextTestInstrumentation extends Instrumenter.Default {
}
@Override
public Map<? extends ElementMatcher, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(2);
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>(7);
transformers.put(named("isInstrumented"), MarkInstrumentedAdvice.class.getName());
transformers.put(
named("incrementContextCount"), StoreAndIncrementApiUsageAdvice.class.getName());