Master Java Debugging with Arthas tt: Capture, Replay, and Analyze Method Calls
This article explains how to use Arthas's tt (TimeTunnel) command to record method parameters, return values, timestamps, and execution details, compare it with the watch command, and replay recorded calls, accompanied by field definitions and a practical Java demo.
Arthas is an open‑source Java diagnostic tool. The tt command, short for TimeTunnel, records every invocation of a specified method, capturing input arguments, return information, execution timestamps, duration, and other metadata, and allows those recordings to be replayed for analysis.
Key Differences from watch
While the watch command also observes method calls, it requires strong familiarity with Ognl expressions to filter the desired data. In contrast, tt is simpler to use and additionally supports recording and replaying capabilities, making it a powerful tool for troubleshooting.
Recorded Field Definitions
INDEX : Record number of the time slice.
TIMESTAMP : The native time when the method executed.
COST(ms) : Execution duration in milliseconds.
IS-RET : Whether the method returned normally.
IS-EXP : Whether the method exited by throwing an exception.
OBJECT : hashCode() of the executing object (maps to the JVM memory address).
CLASS : Name of the class containing the method.
METHOD : Name of the executed method.
Demo Code Using tt
package com.fun;
import com.alibaba.fastjson.JSONObject;
import com.fun.frame.httpclient.FanLibrary;
import org.apache.http.client.methods.HttpGet;
import java.util.Arrays;
import java.util.List;
public class AR extends FanLibrary {
public static int times = 0;
public static void main(String[] args) {
while (true) {
String url = "https://api.apiopen.top/getAllUrl";
HttpGet get = getHttpGet(url);
JSONObject response = getHttpResponse(get);
// output(response);
output(test());
sleep(5000);
}
}
static String test() {
times++;
for (int i = 0; i < 5; i++) {
getRandomInt(100);
}
List list = Arrays.asList(32, 432, 432, 423, 423, 32);
list.stream().forEach(x -> aaa(x));
return DEFAULT_STRING + times;
}
static Integer aaa(Object a) {
sleep(100);
return 915 * 516;
}
}The demo continuously sends HTTP requests, processes responses, and invokes the test method, whose execution can be captured and replayed with tt for detailed inspection.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
