Skip to content

Commit

Permalink
add gc operation output for DtTransferInfo in MTC #53
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Dec 12, 2015
1 parent ed73383 commit 1f0058c
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public String toString() {
", leafSpanIdInfo=" + leafSpanIdInfo +
'}';
}

// Output GC operation
@Override
protected void finalize() throws Throwable {
System.out.printf("DEBUG: gc DtTransferInfo traceId %s in thread %s: %s\n",
traceId, Thread.currentThread().getName(), this);
super.finalize();
}
}

private static MtContextThreadLocal<DtTransferInfo> transferInfo = new MtContextThreadLocal<DtTransferInfo>();
Expand All @@ -78,8 +86,12 @@ public static void main(String[] args) throws Exception {
}

Thread.sleep(1000);
System.out.println("Call System.gc");
// help to check GC status
System.gc();
System.out.println("Called System.gc");
Thread.sleep(1000);
System.out.println("Exit Main.");
}


Expand Down Expand Up @@ -108,6 +120,9 @@ static void rpcInvokeIn() {
// DistributedTracer Framework Code
////////////////////////////////////////////////
System.out.printf("Finished Rpc call %s with span %s.\n", traceId, leafSpanIdInfo);

// release context in ThreadLocal, avoid to be hold by thread, GC friendly.
transferInfo.remove();
}

static void syncMethod() {
Expand Down

0 comments on commit 1f0058c

Please sign in to comment.