Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,9 @@
<version>${hystrix.configurator.version}</version>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
<version>${opentracing.version}</version>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
<version>${opentracing.version}</version>
<groupId>io.appform.opentracing.annotations</groupId>
<artifactId>opentracing-annotations</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/io/appform/core/hystrix/GenericHystrixCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -50,23 +49,19 @@ public GenericHystrixCommand(String group, String traceId, String command) {

public HystrixCommand<R> executor(HandlerAdapter<R> 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<R>(setter) {
@Override
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) {
Expand Down