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 java.util.Set;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule; import net.bytebuddy.utility.JavaModule;
@ -161,11 +162,11 @@ public interface Instrumenter {
private class PostMatchHook implements AgentBuilder.RawMatcher { private class PostMatchHook implements AgentBuilder.RawMatcher {
@Override @Override
public boolean matches( public boolean matches(
TypeDescription typeDescription, final TypeDescription typeDescription,
ClassLoader classLoader, final ClassLoader classLoader,
JavaModule module, final JavaModule module,
Class<?> classBeingRedefined, final Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) { final ProtectionDomain protectionDomain) {
postMatch(typeDescription, classLoader, module, classBeingRedefined, protectionDomain); postMatch(typeDescription, classLoader, module, classBeingRedefined, protectionDomain);
return true; return true;
} }
@ -206,14 +207,14 @@ public interface Instrumenter {
* @param protectionDomain protection domain of the class under load. * @param protectionDomain protection domain of the class under load.
*/ */
public void postMatch( public void postMatch(
TypeDescription typeDescription, final TypeDescription typeDescription,
ClassLoader classLoader, final ClassLoader classLoader,
JavaModule module, final JavaModule module,
Class<?> classBeingRedefined, final Class<?> classBeingRedefined,
ProtectionDomain protectionDomain) {} final ProtectionDomain protectionDomain) {}
/** @return A map of matcher->advice */ /** @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 * 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 java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
import scala.Tuple2; import scala.Tuple2;
@ -63,8 +64,8 @@ public final class AkkaHttpClientInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
// This is mainly for compatibility with 10.0 // This is mainly for compatibility with 10.0
transformers.put( transformers.put(
named("singleRequest").and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))), 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 java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
import scala.Function1; import scala.Function1;
@ -58,14 +59,14 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
// Instrumenting akka-streams bindAndHandle api was previously attempted. // Instrumenting akka-streams bindAndHandle api was previously attempted.
// This proved difficult as there was no clean way to close the async scope // 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. // in the graph logic after the user's request handler completes.
// //
// Instead, we're instrumenting the bindAndHandle function helpers by // Instead, we're instrumenting the bindAndHandle function helpers by
// wrapping the scala functions with our own handlers. // 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( transformers.put(
named("bindAndHandleSync").and(takesArgument(0, named("scala.Function1"))), named("bindAndHandleSync").and(takesArgument(0, named("scala.Function1"))),
AkkaHttpSyncAdvice.class.getName()); AkkaHttpSyncAdvice.class.getName());

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.datastax.cassandra; 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.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPrivate; import static net.bytebuddy.matcher.ElementMatchers.isPrivate;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
@ -11,9 +12,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.Tracer; import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -39,12 +40,10 @@ public class CassandraClientInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod().and(isPrivate()).and(named("newSession")).and(takesArguments(0)), isMethod().and(isPrivate()).and(named("newSession")).and(takesArguments(0)),
CassandraClientAdvice.class.getName()); CassandraClientAdvice.class.getName());
return transformers;
} }
public static class CassandraClientAdvice { 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 datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -19,9 +20,9 @@ import io.opentracing.Span;
import io.opentracing.tag.Tags; import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -38,15 +39,13 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod() isMethod()
.and(named("render")) .and(named("render"))
.and(takesArgument(0, named("io.dropwizard.views.View"))) .and(takesArgument(0, named("io.dropwizard.views.View")))
.and(isPublic()), .and(isPublic()),
RenderAdvice.class.getName()); RenderAdvice.class.getName());
return transformers;
} }
public static class RenderAdvice { public static class RenderAdvice {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.http_url_connection; package datadog.trace.instrumentation.http_url_connection;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.is;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -16,9 +17,9 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -37,12 +38,10 @@ public class UrlInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod().and(isPublic()).and(named("openConnection")), isMethod().and(isPublic()).and(named("openConnection")),
ConnectionErrorAdvice.class.getName()); ConnectionErrorAdvice.class.getName());
return transformers;
} }
public static class ConnectionErrorAdvice { 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 datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
@ -15,9 +16,9 @@ import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -36,11 +37,9 @@ public class HystrixCommandInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod().and(named("run").or(named("getFallback"))), TraceAdvice.class.getName()); isMethod().and(named("run").or(named("getFallback"))), TraceAdvice.class.getName());
return transformers;
} }
public static class TraceAdvice { public static class TraceAdvice {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.jdbc; package datadog.trace.instrumentation.jdbc;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith; import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named; 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.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.JDBCMaps; import datadog.trace.bootstrap.JDBCMaps;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -31,15 +32,13 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
nameStartsWith("prepare") nameStartsWith("prepare")
.and(takesArgument(0, String.class)) .and(takesArgument(0, String.class))
// Also include CallableStatement, which is a sub type of PreparedStatement // Also include CallableStatement, which is a sub type of PreparedStatement
.and(returns(safeHasSuperType(named(PreparedStatement.class.getName())))), .and(returns(safeHasSuperType(named(PreparedStatement.class.getName())))),
ConnectionPrepareAdvice.class.getName()); ConnectionPrepareAdvice.class.getName());
return transformers;
} }
public static class ConnectionPrepareAdvice { 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 datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith; import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@ -26,9 +27,9 @@ import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -44,12 +45,10 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
nameStartsWith("execute").and(takesArguments(0)).and(isPublic()), nameStartsWith("execute").and(takesArguments(0)).and(isPublic()),
PreparedStatementAdvice.class.getName()); PreparedStatementAdvice.class.getName());
return transformers;
} }
public static class PreparedStatementAdvice { 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 datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith; import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@ -26,9 +27,9 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -45,12 +46,10 @@ public final class StatementInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
nameStartsWith("execute").and(takesArgument(0, String.class)).and(isPublic()), nameStartsWith("execute").and(takesArgument(0, String.class)).and(isPublic()),
StatementAdvice.class.getName()); StatementAdvice.class.getName());
return transformers;
} }
public static class StatementAdvice { public static class StatementAdvice {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
@ -50,8 +51,8 @@ public final class KafkaConsumerInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put( transformers.put(
isMethod() isMethod()
.and(isPublic()) .and(isPublic())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
package datadog.trace.instrumentation.mongo; package datadog.trace.instrumentation.mongo;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod; import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -12,9 +13,9 @@ import datadog.trace.agent.tooling.Instrumenter;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -47,12 +48,10 @@ public final class MongoAsyncClientInstrumentation extends Instrumenter.Default
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod().and(isPublic()).and(named("build")).and(takesArguments(0)), isMethod().and(isPublic()).and(named("build")).and(takesArguments(0)),
MongoAsyncClientAdvice.class.getName()); MongoAsyncClientAdvice.class.getName());
return transformers;
} }
public static class MongoAsyncClientAdvice { 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 datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static io.opentracing.log.Fields.ERROR_OBJECT; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.named;
@ -16,10 +17,9 @@ import io.opentracing.Scope;
import io.opentracing.Span; import io.opentracing.Span;
import io.opentracing.tag.Tags; import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -49,14 +49,12 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
isMethod() isMethod()
.and(named("operationComplete")) .and(named("operationComplete"))
.and(takesArgument(0, named("io.netty.channel.ChannelFuture"))), .and(takesArgument(0, named("io.netty.channel.ChannelFuture"))),
OperationCompleteAdvice.class.getName()); OperationCompleteAdvice.class.getName());
return transformers;
} }
public static class OperationCompleteAdvice { public static class OperationCompleteAdvice {
@ -87,7 +85,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
.withTag(Tags.COMPONENT.getKey(), "netty") .withTag(Tags.COMPONENT.getKey(), "netty")
.start(); .start();
Tags.ERROR.set(errorSpan, true); Tags.ERROR.set(errorSpan, true);
errorSpan.log(Collections.singletonMap(ERROR_OBJECT, cause)); errorSpan.log(singletonMap(ERROR_OBJECT, cause));
errorSpan.finish(); errorSpan.finish();
return scope; return scope;

View File

@ -33,6 +33,7 @@ import io.opentracing.util.GlobalTracer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -66,8 +67,8 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put( transformers.put(
isMethod() isMethod()
.and(nameStartsWith("add")) .and(nameStartsWith("add"))

View File

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

View File

@ -33,6 +33,7 @@ import io.opentracing.util.GlobalTracer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -66,8 +67,8 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put( transformers.put(
isMethod() isMethod()
.and(nameStartsWith("add")) .and(nameStartsWith("add"))

View File

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

View File

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

View File

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

View File

@ -39,6 +39,7 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -64,9 +65,10 @@ public class RabbitChannelInstrumentation extends Instrumenter.Default {
} }
@Override @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. // 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( transformers.put(
isMethod() isMethod()
.and( .and(

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package datadog.trace.instrumentation.servlet2; package datadog.trace.instrumentation.servlet2;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isProtected; import static net.bytebuddy.matcher.ElementMatchers.isProtected;
import static net.bytebuddy.matcher.ElementMatchers.named; 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 com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -23,14 +24,12 @@ public final class HttpServlet2Instrumentation extends AbstractServlet2Instrumen
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); return singletonMap(
transformers.put(
named("service") named("service")
.and(takesArgument(0, named("javax.servlet.http.HttpServletRequest"))) .and(takesArgument(0, named("javax.servlet.http.HttpServletRequest")))
.and(takesArgument(1, named("javax.servlet.http.HttpServletResponse"))) .and(takesArgument(1, named("javax.servlet.http.HttpServletResponse")))
.and(isProtected()), .and(isProtected()),
Servlet2Advice.class.getName()); 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.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static datadog.trace.instrumentation.servlet3.Servlet3Advice.SERVLET_SPAN; 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.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod; import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic; import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@ -14,12 +15,12 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import io.opentracing.Span; import io.opentracing.Span;
import io.opentracing.propagation.Format; import io.opentracing.propagation.Format;
import io.opentracing.util.GlobalTracer; import io.opentracing.util.GlobalTracer;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import javax.servlet.AsyncContext; import javax.servlet.AsyncContext;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
@ -41,8 +42,8 @@ public final class AsyncContextInstrumentation extends Instrumenter.Default {
} }
@Override @Override
public Map<? extends ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return Collections.singletonMap( return singletonMap(
isMethod().and(isPublic()).and(named("dispatch")), DispatchAdvice.class.getName()); isMethod().and(isPublic()).and(named("dispatch")), DispatchAdvice.class.getName());
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -35,8 +36,8 @@ public final class DispatcherServletInstrumentation extends Instrumenter.Default
} }
@Override @Override
public Map<ElementMatcher, String> transformers() { public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
final Map<ElementMatcher, String> transformers = new HashMap<>(); final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
transformers.put( transformers.put(
isMethod() isMethod()
.and(isProtected()) .and(isProtected())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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