Migrate to new instrumentation API
This commit is contained in:
parent
277e7a1a3c
commit
5e67e6e5ba
|
@ -20,11 +20,13 @@ 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.Collections;
|
||||||
|
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.agent.builder.AgentBuilder;
|
|
||||||
import net.bytebuddy.asm.Advice;
|
import net.bytebuddy.asm.Advice;
|
||||||
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import scala.Tuple2;
|
import scala.Tuple2;
|
||||||
import scala.concurrent.Future;
|
import scala.concurrent.Future;
|
||||||
import scala.runtime.AbstractFunction1;
|
import scala.runtime.AbstractFunction1;
|
||||||
|
@ -32,7 +34,7 @@ import scala.util.Try;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public final class AkkaHttpClientInstrumentation extends Instrumenter.Configurable {
|
public final class AkkaHttpClientInstrumentation extends Instrumenter.Default {
|
||||||
public AkkaHttpClientInstrumentation() {
|
public AkkaHttpClientInstrumentation() {
|
||||||
super("akka-http", "akka-http-client");
|
super("akka-http", "akka-http-client");
|
||||||
}
|
}
|
||||||
|
@ -42,30 +44,30 @@ public final class AkkaHttpClientInstrumentation extends Instrumenter.Configurab
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HelperInjector HELPER_INJECTOR =
|
@Override
|
||||||
new HelperInjector(
|
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||||
AkkaHttpClientInstrumentation.class.getName() + "$OnCompleteHandler",
|
return named("akka.http.scaladsl.HttpExt");
|
||||||
AkkaHttpClientInstrumentation.class.getName() + "$AkkaHttpHeaders",
|
}
|
||||||
AkkaHttpClientTransformFlow.class.getName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AgentBuilder apply(final AgentBuilder agentBuilder) {
|
public String[] helperClassNames() {
|
||||||
return agentBuilder
|
return new String[] {
|
||||||
.type(named("akka.http.scaladsl.HttpExt"))
|
AkkaHttpClientInstrumentation.class.getName() + "$OnCompleteHandler",
|
||||||
.transform(DDTransformers.defaultTransformers())
|
AkkaHttpClientInstrumentation.class.getName() + "$AkkaHttpHeaders",
|
||||||
.transform(HELPER_INJECTOR)
|
AkkaHttpClientTransformFlow.class.getName()
|
||||||
.transform(
|
};
|
||||||
DDAdvice.create()
|
}
|
||||||
.advice(
|
|
||||||
named("singleRequest")
|
@Override
|
||||||
.and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))),
|
public Map<ElementMatcher, String> transformers() {
|
||||||
SingleRequestAdvice.class.getName()))
|
final Map<ElementMatcher, String> transformers = new HashMap<>();
|
||||||
.transform(
|
transformers.put(
|
||||||
DDAdvice.create()
|
named("singleRequest").and(takesArgument(0, named("akka.http.scaladsl.model.HttpRequest"))),
|
||||||
.advice(
|
SingleRequestAdvice.class.getName());
|
||||||
named("superPool").and(returns(named("akka.stream.scaladsl.Flow"))),
|
transformers.put(
|
||||||
SuperPoolAdvice.class.getName()))
|
named("superPool").and(returns(named("akka.stream.scaladsl.Flow"))),
|
||||||
.asDecorator();
|
SuperPoolAdvice.class.getName());
|
||||||
|
return transformers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SingleRequestAdvice {
|
public static class SingleRequestAdvice {
|
||||||
|
|
Loading…
Reference in New Issue