LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

arthas-trace

Trace Java method execution paths and timing.

TLDR

Trace method execution
$ trace [com.example.MyClass] [myMethod]
copy
Trace with condition
$ trace [com.example.MyClass] [myMethod] '#cost > 100'
copy
Trace all methods in class
$ trace [com.example.MyClass] *
copy
Trace with invocation count
$ trace -n [5] [com.example.MyClass] [myMethod]
copy
Trace using regex class/method matching
$ trace -E [com\.example\.(Foo|Bar)] [myMethod]
copy

SYNOPSIS

trace [-n count] [-E] [--skipJDKMethod value] class-pattern method-pattern [condition-express]

DESCRIPTION

trace is an Arthas command that traces method execution paths and timing. It shows the call hierarchy within a method invocation, highlighting which sub-methods consume the most time.This is invaluable for identifying performance bottlenecks without adding logging or profiling instrumentation.

PARAMETERS

class-pattern

Class name (supports wildcards)
method-pattern
Method name (supports wildcards)
-n count
Stop after count invocations (default: 100)
-E
Enable regular-expression matching for the class and method patterns (default is wildcard matching)
--skipJDKMethod value
Skip tracing JDK methods (default: true)
--exclude-class-pattern pattern
Exclude classes matching this pattern from the trace
-m count, --maxMatch count
Maximum number of matched classes to instrument (default: 50)
-v
Print verbose detail of the condition-express evaluation
condition-express
OGNL condition (e.g., '#cost > 100' traces only invocations slower than 100ms)

OUTPUT

Shows call tree with:- Method names- Execution time- Nested call structure

INSTALL

yay -S arthas
copy

CAVEATS

Deep traces may produce verbose output. Performance overhead increases with trace depth. Use conditions to limit output.

HISTORY

trace is a core diagnostic command in Arthas, essential for performance troubleshooting in production Java applications.

SEE ALSO

RESOURCES

Copied to clipboard
Kai