Skip to content

Commit

Permalink
OverallExecuteEventListener.SNAPSHOT_DATA_KEY => OverallExecuteEventL…
Browse files Browse the repository at this point in the history
…istener.OVERALL_SPAN_CONTINUATION
  • Loading branch information
terrymanu committed Aug 22, 2018
1 parent 719b472 commit d4511ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
*/
public final class OverallExecuteEventListener extends OpenTracingListener<OverallExecutionEvent> {

private static final String SNAPSHOT_DATA_KEY = "OPENTRACING_SNAPSHOT_DATA";

public static final String OVERALL_SPAN_CONTINUATION = "OVERALL_SPAN_CONTINUATION";
private static final String OPERATION_NAME_PREFIX = "/Sharding-Sphere/execute/";

private static final ThreadLocal<ActiveSpan> SPAN = new ThreadLocal<>();

/**
Expand All @@ -58,7 +58,7 @@ protected void beforeExecute(final OverallExecutionEvent event) {
ActiveSpan activeSpan = ShardingTracer.get().buildSpan(OPERATION_NAME_PREFIX).withTag(Tags.COMPONENT.getKey(), ShardingTags.COMPONENT_NAME).startActive();
SPAN.set(activeSpan);
if (event.isParallelExecute()) {
ExecutorDataMap.getDataMap().put(SNAPSHOT_DATA_KEY, activeSpan.capture());
ExecutorDataMap.getDataMap().put(OVERALL_SPAN_CONTINUATION, activeSpan.capture());
}
}

Expand All @@ -81,4 +81,5 @@ protected ActiveSpan getFailureSpan() {
public static boolean isTrunkThread() {
return null != SPAN.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public final class SQLExecuteEventListener extends OpenTracingListener<SQLExecut

private static final String OPERATION_NAME_PREFIX = "/Sharding-Sphere/execute/";

private static final String SNAPSHOT_DATA_KEY = "OPENTRACING_SNAPSHOT_DATA";

private final ThreadLocal<Span> branchSpan = new ThreadLocal<>();

private final ThreadLocal<ActiveSpan> trunkInBranchSpan = new ThreadLocal<>();
Expand All @@ -59,8 +57,8 @@ public void listen(final SQLExecutionEvent event) {

@Override
protected void beforeExecute(final SQLExecutionEvent event) {
if (ExecutorDataMap.getDataMap().containsKey(SNAPSHOT_DATA_KEY) && !OverallExecuteEventListener.isTrunkThread() && null == branchSpan.get()) {
trunkInBranchSpan.set(((ActiveSpan.Continuation) ExecutorDataMap.getDataMap().get(SNAPSHOT_DATA_KEY)).activate());
if (ExecutorDataMap.getDataMap().containsKey(OverallExecuteEventListener.OVERALL_SPAN_CONTINUATION) && !OverallExecuteEventListener.isTrunkThread() && null == branchSpan.get()) {
trunkInBranchSpan.set(((ActiveSpan.Continuation) ExecutorDataMap.getDataMap().get(OverallExecuteEventListener.OVERALL_SPAN_CONTINUATION)).activate());
}
if (null == branchSpan.get()) {
branchSpan.set(ShardingTracer.get().buildSpan(OPERATION_NAME_PREFIX).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
Expand Down

0 comments on commit d4511ab

Please sign in to comment.