<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered">Questions and answers</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas">Fork me at GitHub</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md#">Compile and debug/CONTRIBUTING</a></li>
<div><p>Trace method calling path, and output the time cost for each node in the path.</p>
</div></blockquote>
<p><codeclass="docutils literal notranslate"><spanclass="pre">trace</span></code> can track the calling path specified by <codeclass="docutils literal notranslate"><spanclass="pre">class-pattern</span></code> / <codeclass="docutils literal notranslate"><spanclass="pre">method-pattern</span></code>, and calculate the time cost on the whole path.</p>
</table><p>There’s one thing worthy noting here is observation expression. The observation expression supports OGNL grammar, for example, you can come up a expression like this <codeclass="docutils literal notranslate"><spanclass="pre">"{params,returnObj}"</span></code>. All OGNL expressions are supported as long as they are legal to the grammar.</p>
<p>Thanks for <codeclass="docutils literal notranslate"><spanclass="pre">advice</span></code>’s data structure, it is possible to observe from varieties of different angles. Inside <codeclass="docutils literal notranslate"><spanclass="pre">advice</span></code> parameter, all necessary information for notification can be found.</p>
<li><p>Pls. also refer to <aclass="reference external"href="https://github.com/alibaba/arthas/issues/71">https://github.com/alibaba/arthas/issues/71</a> for more advanced usage</p></li>
<li><p>OGNL official site: <aclass="reference external"href="https://commons.apache.org/proper/commons-ognl/language-guide.html">https://commons.apache.org/proper/commons-ognl/language-guide.html</a></p></li>
<p>Many times what we are interested is the exact trace result when the method call takes time over one particular period. It is possible to achieve this in Arthas, for example: <codeclass="docutils literal notranslate"><spanclass="pre">trace</span><spanclass="pre">*StringUtils</span><spanclass="pre">isBlank</span><spanclass="pre">'#cost>100'</span></code> means trace result will only be output when the executing time exceeds 100ms.</p>
<div><p><codeclass="docutils literal notranslate"><spanclass="pre">watch</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">stack</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">trace</span></code>, these three commands all support <codeclass="docutils literal notranslate"><spanclass="pre">#cost</span></code>.</p>
<h2>Notice<aclass="headerlink"href="#notice"title="Permalink to this headline">¶</a></h2>
<p><codeclass="docutils literal notranslate"><spanclass="pre">trace</span></code> is handy to help discovering and locating the performance flaws in your system, but pls. note Arthas can only trace the first level method call each time.</p>
<div><p>Only the call path which’s time cost is higher than <codeclass="docutils literal notranslate"><spanclass="pre">10ms</span></code> will be shown. This feature is handy to focus on what’s needed to focus when troubleshoot.</p>
<li><p>Here Arthas provides the similar functionality JProfile and other commercial software provide. Compared to these professional softwares, Arthas doesn’t deduce the time cost <codeclass="docutils literal notranslate"><spanclass="pre">trace</span></code> itself takes, therefore it is not as accurate as these softwares offer. More classes and methods on the calling path, more inaccurate <codeclass="docutils literal notranslate"><spanclass="pre">trace</span></code> output is, but it is still helpful for diagnostics where the bottleneck is.</p></li>
<li><p>“[12.033735ms]” means the method on the node takes <codeclass="docutils literal notranslate"><spanclass="pre">12.033735</span></code> ms.</p></li>
<li><p>“[min=0.005428ms,max=0.094064ms,total=0.105228ms,count=3] demo:call()” means aggregating all same method calls into one single line. The minimum time cost is <codeclass="docutils literal notranslate"><spanclass="pre">0.005428</span></code> ms, the maximum time cost is <codeclass="docutils literal notranslate"><spanclass="pre">0.094064</span></code> ms, and the total time cost for all method calls (<codeclass="docutils literal notranslate"><spanclass="pre">3</span></code> times in total) to “demo:call()” is <codeclass="docutils literal notranslate"><spanclass="pre">0.105228ms</span></code>. If “throws Exception” appears in this line, it means some exceptions have been thrown from this method calls.</p></li>
<li><p>The total time cost may not equal to the sum of the time costs each sub method call takes, this is because Arthas instrumented code takes time too.</p></li>
<h3>trace multiple classes or multiple methods<aclass="headerlink"href="#trace-multiple-classes-or-multiple-methods"title="Permalink to this headline">¶</a></h3>
<p>The trace command will only trace the subcalls in the method to the trace, and will not trace down multiple layers. Because traces are expensive, multi-layer traces can lead to a lot of classes and methods that ultimately have to be traced.</p>
<p>You can use the regular expression to match multiple classes and methods on the path to achieve a multi-layer trace effect to some extent.</p>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.