Update hystrix-1.4 to new agent api
MODIFY
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixDecorator.java
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixDecorator.java
@@ -3,7 +3,7 @@ package datadog.trace.instrumentation.hystrix;
import com.netflix.hystrix.HystrixInvokableInfo;
import datadog.trace.agent.decorator.BaseDecorator;
import datadog.trace.api.DDTags;
-import io.opentracing.Span;
+import datadog.trace.instrumentation.api.AgentSpan;
public class HystrixDecorator extends BaseDecorator {
public static HystrixDecorator DECORATE = new HystrixDecorator();
@@ -24,7 +24,7 @@ public class HystrixDecorator extends BaseDecorator {
}
public void onCommand(
- final Span span, final HystrixInvokableInfo<?> command, final String methodName) {
+ final AgentSpan span, final HystrixInvokableInfo<?> command, final String methodName) {
if (command != null) {
final String commandName = command.getCommandKey().name();
final String groupName = command.getCommandGroup().name();

MODIFY
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixInstrumentation.java
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixInstrumentation.java
@@ -8,8 +8,8 @@ import static net.bytebuddy.matcher.ElementMatchers.returns;
import com.google.auto.service.AutoService;
import com.netflix.hystrix.HystrixInvokableInfo;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.instrumentation.api.AgentSpan;
import datadog.trace.instrumentation.rxjava.TracedOnSubscribe;
-import io.opentracing.Span;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.asm.Advice;
@@ -98,7 +98,7 @@ public class HystrixInstrumentation extends Instrumenter.Default {
}
@Override
- protected void afterStart(final Span span) {
+ protected void afterStart(final AgentSpan span) {
super.afterStart(span);
DECORATE.onCommand(span, command, methodName);

MODIFY
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixThreadPoolInstrumentation.java
dd-java-agent/instrumentation/hystrix-1.4/src/main/java/datadog/trace/instrumentation/hystrix/HystrixThreadPoolInstrumentation.java
package datadog.trace.instrumentation.hystrix;
+import static datadog.trace.instrumentation.api.AgentTracer.activeScope;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -8,8 +9,6 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.context.TraceScope;
-import io.opentracing.Scope;
-import io.opentracing.util.GlobalTracer;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
@@ -40,10 +39,10 @@ public class HystrixThreadPoolInstrumentation extends Instrumenter.Default {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static boolean enableAsyncTracking() {
- final Scope scope = GlobalTracer.get().scopeManager().active();
- if (scope instanceof TraceScope) {
- if (!((TraceScope) scope).isAsyncPropagating()) {
- ((TraceScope) scope).setAsyncPropagation(true);
+ final TraceScope scope = activeScope();
+ if (scope != null) {
+ if (!scope.isAsyncPropagating()) {
+ scope.setAsyncPropagation(true);
return true;
}
}
@@ -53,9 +52,9 @@ public class HystrixThreadPoolInstrumentation extends Instrumenter.Default {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void disableAsyncTracking(@Advice.Enter final boolean wasEnabled) {
if (wasEnabled) {
- final Scope scope = GlobalTracer.get().scopeManager().active();
- if (scope instanceof TraceScope) {
- ((TraceScope) scope).setAsyncPropagation(false);
+ final TraceScope scope = activeScope();
+ if (scope != null) {
+ scope.setAsyncPropagation(false);
}
}
}

Update hystrix-1.4 to new agent api