diff --git a/pom.xml b/pom.xml index c0cd3b5..73e31af 100644 --- a/pom.xml +++ b/pom.xml @@ -112,14 +112,9 @@ ${hystrix.configurator.version} - io.opentracing - opentracing-api - ${opentracing.version} - - - io.opentracing - opentracing-util - ${opentracing.version} + io.appform.opentracing.annotations + opentracing-annotations + 1.0.4 junit diff --git a/src/main/java/io/appform/core/hystrix/GenericHystrixCommand.java b/src/main/java/io/appform/core/hystrix/GenericHystrixCommand.java index 72644c1..7f5eeee 100644 --- a/src/main/java/io/appform/core/hystrix/GenericHystrixCommand.java +++ b/src/main/java/io/appform/core/hystrix/GenericHystrixCommand.java @@ -19,14 +19,13 @@ import com.hystrix.configurator.core.HystrixConfigurationFactory; import com.netflix.hystrix.HystrixCommand; import com.netflix.hystrix.HystrixCommandProperties; -import io.opentracing.Scope; -import io.opentracing.Span; -import io.opentracing.Tracer; -import java.util.Map; - +import io.appform.opentracing.FunctionData; +import io.appform.opentracing.util.TracerUtil; import lombok.Getter; import org.slf4j.MDC; +import java.util.Map; + /** * Command that returns the single element */ @@ -50,8 +49,6 @@ public GenericHystrixCommand(String group, String traceId, String command) { public HystrixCommand executor(HandlerAdapter function) { final Map parentMDCContext = MDC.getCopyOfContextMap(); - final Tracer tracer = TracingHandler.getTracer(); - final Span parentActiveSpan = TracingHandler.getParentActiveSpan(tracer); final HystrixCommand.Setter setter = HystrixConfigurationFactory.getCommandConfiguration(commandKey(group, command)); return new HystrixCommand(setter) { @Override @@ -59,14 +56,12 @@ protected R run() throws Exception { if (parentMDCContext != null) { MDC.setContextMap(parentMDCContext); } - final Span span = TracingHandler.startChildSpan(tracer, parentActiveSpan, command); - final Scope scope = TracingHandler.activateSpan(tracer, span); - + TracerUtil.startNewSpanWithMDCTracing(new FunctionData("hystrix","hystrix.command:"+command)); MDC.put(TRACE_ID, traceId); try { return function.run(); } finally { - TracingHandler.closeScopeAndSpan(span, scope); + TracerUtil.destroyTracingForCurrentThread(); HystrixCommandProperties.ExecutionIsolationStrategy isolationStrategy = getProperties().executionIsolationStrategy().get(); if (isolationStrategy == HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE) {