@ -36,7 +36,7 @@ Arthas is born to solve these issues. You can trouble-shoot your production issu
Contents
--------
English version is on the way, if you would like to contribute, please leave a message [here](https://github.com/alibaba/arthas/issues/51)
English version has just been finished. If you would like to make it better, please check [here](https://github.com/alibaba/arthas/issues/51) and submit your PM.
Monitor the `class-pattern`&`method-pattern` matched methods invoking traces.
Monitor methods calling stack traces.
F.Y.I
1. `monitor` is a persistent command, it never returns until `Ctrl+C` to manually stop it.
2. the server runs the tasks in the background;
3. injected code will become invalid automatically once the tasks being terminated;
4. in theory, Arthas commands will not change any original behaviors.
1. `monitor` is a persistent command, it never returns until you press `Ctrl+C` to manually stop it;
2. the server runs the jobs in the background;
3. injected monitoring code will become invalid automatically once the monitoring jobs being terminated;
4. in theory, Arthas will not change any original behaviors but if it does, please do not hesitate to start an [issue](https://github.com/alibaba/arthas/issues).
### Properties monitored
@ -29,8 +29,8 @@ F.Y.I
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|[E]|turn on regx matching while the default is wildcards matching|
|`[c:]`|cycle of output with default value: `120 s`|
|[E]|turn on regex matching while the default is wildcard matching|
| unsafe | false | Enable system-level class enhancement; JVM might crash, if you turn it on (use with great caution :exclamation:) |
| dump | false | Enable support for dumping enhanced class to external file; if turned on, class file will be dumped to`/${application dir}/arthas-class-dump/`,please check console output for specific location |
| dump | false | Enable support for dumping enhanced class to external files; if turned on, class file will be dumped to`/${application dir}/arthas-class-dump/`,please check console output for specific location |
| json-format | false | Enable output in JSON format |
| disable-sub-class | false | Disabling child class matching: by default child class will be matched while matching target class; if you wish exact matching, you should turn it off |
Abbreviated from “Search-Class”; with the help of this command, you can search out all the loaded classes in JVM. Supported options are: `[d]`、`[E]`、`[f]` and `[x:]`.
Abbreviated from *Search-Class*; with the help of this command, you can search out all the loaded classes in JVM. Supported options are: `[d]`、`[E]`、`[f]` and `[x:]`.
Options
-------
@ -16,12 +16,12 @@ Options
|*method-pattern*|pattern for the method name|
|[d]|print the details of the current class including the source file, class declaration, the class loaders and the like.<br/>F.Y.I if a class is loaded by several class loaders, then the class will be printed several times|
|[E]|turn on regx matching while the default is wildcards matching|
|[f]|print the fields info of the current class, which should be used along with `-d`|
|[f]|print the fields info of the current class, which ***must*** be used with `-d`|
|[x:]|the depth to print the static fields, whose default is `0` - directly invoke the `toString()`|
Tip:
1. *class-patten* supports full qualified class name (e.g. com.taobao.test.AAA and com/taobao/test/AAA)
2. `sc` turned on the `sub-class` matching in default mode, if you do want to hide the `sub-class` please just turn it off via`options disable-sub-class true`.
2. `sc` turned on the `sub-class` matching in default mode; if you do want to hide `sub-class`, you can just turn it off with [options](options.md) as`options disable-sub-class true`.
@ -11,16 +11,16 @@ Most of the time, we know the method being invoked but not always we know **HOW
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|*condition-express*|condition expression|
|[E]|turn on regx matching while the default is wildcards matching|
|`[n:]`|calling times|
|*condition-expression*|condition expression|
|[E]|turn on regex matching while the default is wildcard matching|
|[n:]|calling times|
F.Y.I
1. any valid OGNL expression as `"{params,returnObj}"` supported;
2. filter by time cost as `trace *StringUtils isBlank '$cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
2. filter by time cost as `trace *StringUtils isBlank '#cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
Attention:
1. `$cost` can be used in `watch/stack/trace`;
1. `#cost` can be used in `watch/stack/trace`;
2. using `#cost` in Arthas 3.0 instead of `$cost`.
@ -32,7 +32,7 @@ Advanced:
### Usage
The quoting rules: if there are quotes within the expression, use another type of quotes to quote the whole expression.
The quoting rules: if there are quotes within the expression, use another type of quotes to quote the whole expression (single `''` or double `""` quotes).
Only the calling trace of the time cost higher than `4ms`presented now.
F.Y.I
1. just like JProfile and the like commercial software, you can `trace` down the specified method calling in Arthas;
1. like JProfile and other similar commercial software, you can `trace` down the specified method calling stack with time cost in Arthas;
2. there will be some overhead using `trace` but not much;
3. the time cost is an instructive clue for troubleshooting, which means it's not that accurate ignoring the cost it itself causes; the deeper or more the call is, the accuracy is becoming worse;
3. the time cost is an instructive clue for troubleshooting, which means it's not that accurate ignoring the cost it itself causes; the deeper or more the call is, the worse accuracy the time cost will be;
4. `[0,0,0ms,11]xxx:yyy() [throws Exception]`,the same method calling aggregated into one line here while `throws Exception` indicates there is an exception.
Check the parameters, return values and exceptions of the methods at different times.
Check the `parameters`, `return values` and `exceptions` of the methods at different times.
`watch` is a powerful command but due to its feasibility and complexity, it's quite hard to locate the issue effectively.
In such difficulties, `tt` comes into play.
With the help of `tt` (abbreviated from *TimeTunnel*), you can check the contexts of the methods at different times.
With the help of `tt` (*TimeTunnel*), you can check the contexts of the methods at different times in execution history.
### Usage
@ -37,7 +37,7 @@ Let's record the whole calling contexts:
- `-n 3`
limit the number of the records (avoid overflow for too many records; with `-n` option, Arthas can automatically stop recording once the records reach the limit)
limit the number of the records (avoid overflow for too many records; with `-n` option, Arthas can automatically stop recording once the records reach the specified limit)
#### Property
@ -46,8 +46,8 @@ Let's record the whole calling contexts:
|INDEX|the index for each call based on time|
|TIMESTAMP|time to invoke the method|
|COST(ms)|time cost of the method call|
|IS-RET|end with normal return|
|IS-EXP|end with exceptions|
|IS-RET|whether method exits with normal return|
|IS-EXP|whether method failed with exceptions|
|OBJECT|`hashCode()` of the object invoking the method|
|CLASS|class name of the object invoking the method|
|METHOD|method being invoked|
@ -55,7 +55,7 @@ Let's record the whole calling contexts:
#### Condition expression
Tips:
1. `tt -t *Test print params[0].length==1` with different amount of parameters;
1. `tt -t *Test print params[0].length==1` with different amounts of parameters;
2. `tt -t *Test print 'params[1] instanceof Integer'` with different types of parameters;
3. `tt -t *Test print params[0].mobile=="13989838402"` with specified parameter.
@ -67,7 +67,7 @@ Advanced:
### Searching for records
#### A specified time range
#### All the recorded
```
$ tt -l
@ -147,7 +147,7 @@ $
### Re-produce
Since Arthas stores the context of the call, you can even re-produce the method calling after some modifications with extra option `-p`.
Since Arthas stores the context of the call, you can even *replay* the method calling afterwards with extra option `-p` to re-produce the issue for advanced troubleshooting.
```
$ tt -i 1003 -p
@ -189,6 +189,6 @@ $
```
F.Y.I
1. the calling stack is little different using Arthas now instead of the original method;
2. **Loss** of the thread local variables will be a fact since there is no way for Arthas to record the thread local info.
3. **Potential** modifications of objects can happen since only a reference will be recorded by Arthas while later process might modify objects without Arthas's watch.
1. the calling stack is little different using Arthas now unlike the original;
2. **Loss** of the thread local variables will be a undeniable fact since there is no way for Arthas to record the thread local info (*If you find one, please share with us in [issues tracker](https://github.com/alibaba/arthas/issues)*).
3. **Potential** modifications of objects can happen since only a reference will be recorded while later operations might modify objects without Arthas's watch.
Monitor methods in data aspect including `return values`, `exceptions` and `parameters`.
With the help of [OGNL](https://en.wikipedia.org/wiki/OGNL), you can easily check the details of variables.
With the help of [OGNL](https://en.wikipedia.org/wiki/OGNL), you can easily check the details of variables when methods being invoked.
### Parameters & Options
There are four different scenarios for `watch` command, which makes it a rather complicated command in Arthas.
There are four different scenarios for `watch` command, which makes it rather complicated.
|Name|Specification|
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|*express*|expression to monitor|
|*condition-express*|condition expression to filter|
|*expression*|expression to monitor|
|*condition-expression*|condition expression to filter|
|[b]|before method being invoked|
|[e]|encountering exceptions|
|[s]|returned normally|
|[f]|returned normally and abnormally|
|[E]|turn on regex matching while the default is wildcards matching|
|[e]|when method encountering exceptions|
|[s]|when method exits normally|
|[f]|when method exits (either succeed or fail with exceptions)|
|[E]|turn on regex matching while the default is wildcard matching|
|[x:]|the depth to print the specified property with default value: 1|
F.Y.I
1. any valid OGNL expression as `"{params,returnObj}"` supported
2. there are four *watching* points: `-b`, `-e`, `-s` and `-f` (the first three are off in default while `-f` on);
3. at the *watching* point, Arthas will use the *expression* to evaluate the variables and print them out;
4. `in-parameters` and `out-parameters` are different since they can be modified within the invoked methods; `params` stands for `in-parameters` in `-b`while `out-parameters` in other *watching* points;
5. there is no `return values` and `exceptions` when using `-b`.
4. `in parameters` and `out parameters` are different since they can be modified within the invoked methods; `params` stands for `in parameters` in `-b`while `out parameters` in other *watching* points;
5. there are no `return values` and `exceptions` when using `-b`.
Advanced:
@ -57,7 +57,7 @@ A demo:
return list.size();
}
```
#### Check the `out-parameters` and `return value`