<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>
<p><ttclass="docutils literal">trace</tt> can track the calling path specified by <ttclass="docutils literal">class-pattern</tt> / <ttclass="docutils literal">method-pattern</tt>, 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 <ttclass="docutils literal">"{params,returnObj}"</tt>. All OGNL expressions are supported as long as they are legal to the grammar.</p>
<p>Thanks for <ttclass="docutils literal">advice</tt>’s data structure, it is possible to observe from varieties of different angles. Inside <ttclass="docutils literal">advice</tt> parameter, all necessary information for notification can be found.</p>
<p>Pls. refer to <aclass="reference internal"href="advice-class.html"><spanclass="doc">core parameters in expression</span></a> for more details.</p>
<ulclass="simple">
<li>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</li>
<li>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></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: <ttclass="docutils literal">trace *StringUtils isBlank '#cost>100'</tt> means trace result will only be output when the executing time exceeds 100ms.</p>
<div><ttclass="docutils literal">watch</tt>/<ttclass="docutils literal">stack</tt>/<ttclass="docutils literal">trace</tt>, these three commands all support <ttclass="docutils literal">#cost</tt>.</div></blockquote>
<p><ttclass="docutils literal">trace</tt> 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>Only the call path which’s time cost is higher than <ttclass="docutils literal">10ms</tt> will be shown. This feature is handy to focus on what’s needed to focus when troubleshoot.</div></blockquote>
<li>Here Arthas provides the similar functionality JProfile and other commercial software provide. Compared to these professional softwares, Arthas doesn’t deduce the time cost <ttclass="docutils literal">trace</tt> itself takes, therefore it is not as accurate as these softwares offer. More classes and methods on the calling path, more inaccurate <ttclass="docutils literal">trace</tt> output is, but it is still helpful for diagnostics where the bottleneck is.</li>
<li>“[12.033735ms]” means the method on the node takes <ttclass="docutils literal">12.033735</tt> ms.</li>
<li>“[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 <ttclass="docutils literal">0.005428</tt> ms, the maximum time cost is <ttclass="docutils literal">0.094064</tt> ms, and the total time cost for all method calls (<ttclass="docutils literal">3</tt> times in total) to “demo:call()” is <ttclass="docutils literal">0.105228ms</tt>. If “throws Exception” appears in this line, it means some exceptions have been thrown from this method calls.</li>
<li>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.</li>
<spanid="trace-multiple-classes-or-multiple-methods"></span><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>.