Skip to content

Commit

Permalink
Merge pull request scouter-project#742 from scouter-project/feature/s…
Browse files Browse the repository at this point in the history
…pring-reactive-coroutine-gunlee

[agent.java] reactive support misc
  • Loading branch information
gunlee01 authored Aug 25, 2020
2 parents 0fafca2 + a26ce98 commit ab9a4e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ public static void start(TraceContext o) {
}
}

public static void takeoverTxid(TraceContext o, long oldTxid) {
txidLocal.set(o.txid);
entryByTxid.remove(oldTxid);
entryByTxid.put(o.txid, o);
}

public static void startByCoroutine(TraceContext o) {
txidByCoroutine.set(o.txid);
}
Expand Down Expand Up @@ -262,13 +268,12 @@ public static void clearAllContext(TraceContext o) {
entryByTxid.remove(o.txid);
if (conf._psts_progressive_reactor_thread_trace_enabled) {
txidThreadMap.remove(o.txid);
} else {
entryByThreadId.remove(o.threadId);
}

txidByCoroutine.set(null);
if (!o.isReactiveStarted) { //do not clear txidLocal in reactive
txidLocal.set(null);
entryByThreadId.remove(o.threadId);
}

clearForceDiscard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,11 @@ public static Object startAsyncPossibleService(Object keyObject, String fullName
}
localContext.service = true;
if (id.gxid != 0) localContext.context.gxid = id.gxid;
if (id.callee != 0) localContext.context.txid = id.callee;
if (id.callee != 0) {
long oldTxid = localContext.context.txid;
localContext.context.txid = id.callee;
TraceContextManager.takeoverTxid(localContext.context, oldTxid);
}
if (id.caller != 0) localContext.context.caller = id.caller;

String serviceName = StringUtil.removeLastString(className, '/') + "#" + methodName + "() -- " + fullName;
Expand Down Expand Up @@ -1492,7 +1496,11 @@ public static Object callRunnableCallInvoked(Object callRunnableObj) {
}
localContext.service = true;
if (id.gxid != 0) localContext.context.gxid = id.gxid;
if (id.callee != 0) localContext.context.txid = id.callee;
if (id.callee != 0) {
long oldTxid = localContext.context.txid;
localContext.context.txid = id.callee;
TraceContextManager.takeoverTxid(localContext.context, oldTxid);
}
if (id.caller != 0) localContext.context.caller = id.caller;

return localContext;
Expand Down

0 comments on commit ab9a4e6

Please sign in to comment.