Author: buildbot Date: Sun Jul 16 22:19:41 2017 New Revision: 1015561 Log: Production update by buildbot for camel
Modified: websites/production/camel/content/cache/main.pageCache websites/production/camel/content/metrics-component.html Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/camel/content/metrics-component.html ============================================================================== --- websites/production/camel/content/metrics-component.html (original) +++ websites/production/camel/content/metrics-component.html Sun Jul 16 22:19:41 2017 @@ -86,16 +86,16 @@ <tbody> <tr> <td valign="top" width="100%"> -<div class="wiki-content maincontent"><h2 id="MetricsComponent-MetricsComponent">Metrics Component</h2><p><strong>Available as of Camel 2.14</strong></p><p>The <strong>metrics:</strong> component allows to collect various metrics directly from Camel routes. Supported metric types are <a shape="rect" href="#MetricsComponent-counter">counter</a>, <a shape="rect" href="#MetricsComponent-histogram">histogram</a>, <a shape="rect" href="#MetricsComponent-meter">meter</a> and <a shape="rect" href="#MetricsComponent-timer">timer</a>. <a shape="rect" class="external-link" href="http://metrics.codahale.com/" rel="nofollow">Metrics</a> provides simple way to measure behaviour of application. Configurable reporting backend is enabling different integration options for collecting and visualizing statistics. The component also provides a <code>MetricsRoutePolicyFactory</code> which allows to expose route statistics using codehale metrics, see bottom of page for details.</p><p>Maven users will need to add the following dependency to their <code>pom.xml</code> for this component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<div class="wiki-content maincontent"><h2 id="MetricsComponent-MetricsComponent">Metrics Component</h2><p><strong>Available as of Camel 2.14</strong></p><p>The <strong><code>metrics:</code></strong> component allows to collect various metrics directly from Camel routes. Supported metric types are <a shape="rect" href="#MetricsComponent-counter">counter</a>, <a shape="rect" href="#MetricsComponent-histogram">histogram</a>, <a shape="rect" href="#MetricsComponent-meter">meter</a> and <a shape="rect" href="#MetricsComponent-timer">timer</a>. <a shape="rect" class="external-link" href="http://metrics.codahale.com/" rel="nofollow">Metrics</a> provides simple way to measure behavior of application. Configurable reporting backend is enabling different integration options for collecting and visualizing statistics.</p><p>The <span><strong><code>metrics</code></strong></span> component also provides a <strong><code>MetricsRoutePolicyFacto ry</code></strong> that allows route statistics to be exposed using Codahale metrics. See bottom of page for details.</p><p>Maven users will need to add the following dependency to their <strong><code>pom.xml</code></strong> for this component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-metrics</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>]]></script> -</div></div><h3 id="MetricsComponent-URIformat">URI format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h3 id="MetricsComponent-URIFormat">URI Format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[metrics:[ meter | counter | histogram | timer ]:metricname[?options]]]></script> -</div></div><h3 id="MetricsComponent-registryMetricRegistry"><span class="confluence-anchor-link" id="MetricsComponent-registry"></span><span style="line-height: 1.5625;">Metric Registry</span></h3><p>Camel Metrics Component uses by default <code>MetricRegistry</code> with <code>Slf4jReporter</code> and 60 second reporting interval. Default registry can be replaced with custom one by providing bean with name <code>metricRegistry</code> in Camel registry. <span style="line-height: 1.4285715;">For example using Spring Java Configuration.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h3 id="MetricsComponent-registryMetricRegistry"><span class="confluence-anchor-link" id="MetricsComponent-registry"></span><span style="line-height: 1.5625;">Metric Registry</span></h3><p>Camel Metrics Component uses by default <strong><code>MetricRegistry</code></strong> with <strong><code>Slf4jReporter</code></strong> and 60 second reporting interval. Default registry can be replaced with custom one by providing bean with name <strong><code>metricRegistry</code></strong> in Camel registry. </p><p><span style="line-height: 1.4285715;">For example using Spring Java Configuration:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[@Configuration public static class MyConfig extends SingleRouteCamelConfiguration { @@ -116,14 +116,14 @@ public static class MyConfig extends Sin return registry; } }]]></script> -</div></div><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p><code>MetricRegistry</code> uses internal thread(s) for reporting. There is no public API in DropWizard version 3.0.1 for users to clean up on exit. Thus using Camel Metrics Component leads to Java classloader leak and my cause <code>OutOfMemoryErrors</code> in some cases.</p></div></div><h3 id="MetricsComponent-Usage">Usage</h3><p>Each metric has type and name. Supported types are <a shape="rect" href="#MetricsComponent-counter">counter</a>, <a shape="rect" href="#MetricsComponent-histogram">histogram</a>, <a shape="rect" href="#MetricsComponent-meter">meter</a> and <a shape="rect" href="#MetricsComponent-timer">timer</a>. Metric name is simple string. If metric type is not provided then type meter is used by default.</p><h4 id="MetricsC omponent-Headers">Headers</h4><p>Metric name defined in URI can be overridden by using header with name <code>CamelMetricsName</code>.</p><p>For example</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p><strong><code>MetricRegistry</code></strong> uses internal thread(s) for reporting. There is no public API in DropWizard version 3.0.1 for users to clean up on exit. Thus using Camel Metrics Component leads to Java classloader leak and my cause <strong><code>OutOfMemoryErrors</code></strong> in some cases.</p></div></div><h3 id="MetricsComponent-Usage">Usage</h3><p>Each metric has type and name. Supported types are <a shape="rect" href="#MetricsComponent-counter">counter</a>, <a shape="rect" href="#MetricsComponent-histogram">histogram</a>, <a shape="rect" href="#MetricsComponent-meter">meter</a> and <a shape="rect" href="#MetricsComponent-timer">timer</a>. Metric name is simple string. If metric type is not provided then type meter is us ed by default.</p><h4 id="MetricsComponent-Headers">Headers</h4><p>Metric name defined in URI can be overridden by using header with name <strong><code>CamelMetricsName</code>.</strong></p><p>For example</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:in") .setHeader(MetricsConstants.HEADER_METRIC_NAME, constant("new.name")) .to("metrics:counter:name.not.used") .to("direct:out");]]></script> -</div></div><p>will update counter with name <code>new.name</code> instead of <code>name.not.used</code>.</p><p>All Metrics specific headers are removed from the message once Metrics endpoint finishes processing of exchange. While processing exchange Metrics endpoint will catch all exceptions and write log entry using level <code>warn</code>.</p><h3 id="MetricsComponent-counterMetricstypecounter"><span class="confluence-anchor-link" id="MetricsComponent-counter"></span>Metrics type counter</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>will update counter with name <strong><code>new.name</code></strong> instead of <strong><code>name.not.used</code></strong>.</p><p>All <span><strong><code>metrics</code></strong></span> specific headers are removed from the message once Metrics endpoint finishes processing of exchange. While processing the exchange <span><strong><code>metrics</code></strong></span> endpoint any exceptions thrown are caught and written to as a log entry at level <strong><code>warn</code></strong>.</p><h3 id="MetricsComponent-counterMetricsTypeCounter"><span class="confluence-anchor-link" id="MetricsComponent-counter"></span>Metrics Type Counter</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[metrics:counter:metricname[?options]]]></script> -</div></div><h4 id="MetricsComponent-Options"><span style="line-height: 1.5;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">increment </td><td colspan="1" rowspan="1" class="confluenceTd">-</td><td colspan="1" rowspan="1" class="confluenceTd">Long value to add to the counter</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">decrement</td><td colspan="1" rowspan="1" class="confluenceTd">-</td><td colspan="1" rowspan="1" class="confluenceTd">Long value to subtract from the counter</td></tr></tbody></table></div><p>If neither <code>increment</code> or <code>decrement</code> is defined then counter value will be incremented by one. If <code>increment</code> and <code>decrement</code> are both d efined only increment operation is called.<span style="line-height: 1.4285715;"> </span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Options"><span style="line-height: 1.5;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>increment</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>-</code></td><td colspan="1" rowspan="1" class="confluenceTd">Long value to add to the counter</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>decrement</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>-</code></td><td colspan="1" rowspan="1" class="confluenceTd">Long value to subtract from the counter</td></tr></tbody></table></div><p>If neither <strong><code>increment</code></strong> or <strong><code>decrement</code></strong> is defined then counter value will be inc remented by one. If <strong><code>increment</code></strong> and <strong><code>decrement</code></strong> are both defined only <strong><code>increment</code></strong> operation is called.<span style="line-height: 1.4285715;"> </span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// update counter simple.counter by 7 from("direct:in") .to("metric:counter:simple.counter?increment=7") @@ -138,7 +138,7 @@ from("direct:in") from("direct:in") .to("metric:counter:simple.counter?decrement=3") .to("direct:out");]]></script> -</div></div><h4 id="MetricsComponent-Headers.1">Headers</h4><p><span style="line-height: 1.4285715;">Message headers can be used to override <code>increment</code> and <code>decrement</code> values specified in Metrics component URI.</span></p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">CamelMetricsCounterIncrement </td><td colspan="1" rowspan="1" class="confluenceTd">Override increment value in URI</td><td colspan="1" rowspan="1" class="confluenceTd">Long</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">CamelMetricsCounterDecrement </td><td colspan="1" rowspan="1" class="confluenceTd">Override decrement value in URI</td><td colspan="1" rowspan="1" class="confluenceTd">Long</td></tr></tbody></ta ble></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Headers.1">Headers</h4><p><span style="line-height: 1.4285715;">Message headers can be used to override <strong><code>increment</code></strong> and <strong><code>decrement</code></strong> values specified in the <strong><code>metrics</code></strong> component URI.</span></p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>CamelMetricsCounterIncrement</code></td><td colspan="1" rowspan="1" class="confluenceTd">Override increment value in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><code>Long</code></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>CamelMetricsCounterDecrement</code></td><td colspan="1" rowspan="1" class="confluenceTd">Override de crement value in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><code>Long</code></td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// update counter simple.counter by 417 from("direct:in") .setHeader(MetricsConstants.HEADER_COUNTER_INCREMENT, constant(417L)) @@ -152,7 +152,7 @@ from("direct:in") .to("mock:out");]]></script> </div></div><h3 id="MetricsComponent-histogramMetrictypehistogram"><span class="confluence-anchor-link" id="MetricsComponent-histogram"></span>Metric type histogram</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[metrics:histogram:metricname[?options]]]></script> -</div></div><h4 id="MetricsComponent-Options.1">Options</h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">value</td><td colspan="1" rowspan="1" class="confluenceTd">-</td><td colspan="1" rowspan="1" class="confluenceTd">Value to use in histogram</td></tr></tbody></table></div><p>If no <code>value</code> is not set nothing is added to histogram and warning is logged.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Options.1">Options</h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>value</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>-</code></td><td colspan="1" rowspan="1" class="confluenceTd">Value to use in histogram</td></tr></tbody></table></div><p>If no <strong><code>value</code></strong> is not set nothing is added to histogram and warning is logged.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// adds value 9923 to simple.histogram from("direct:in") .to("metric:histogram:simple.histogram?value=9923") @@ -162,15 +162,15 @@ from("direct:in") from("direct:in") .to("metric:histogram:simple.histogram") .to("direct:out");]]></script> -</div></div><h4 id="MetricsComponent-Headers.2">Headers</h4><p>Message header can be used to override value specified in Metrics component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">CamelMetricsHistogramValue</td><td colspan="1" rowspan="1" class="confluenceTd">Override histogram value in URI</td><td colspan="1" rowspan="1" class="confluenceTd">Long</td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// adds value 992 to simple.histogram +</div></div><h4 id="MetricsComponent-Headers.2">Headers</h4><p>Message header can be used to override value specified in <span><strong><code>metrics</code></strong></span> component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>CamelMetricsHistogramValue</code></td><td colspan="1" rowspan="1" class="confluenceTd">Override histogram value in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><code>Long</code></td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// Adds value 992 to simple.histogram from("direct:in") .setHeader(MetricsConstants.HEADER_HISTOGRAM_VALUE, constant(992L)) .to("metric:histogram:simple.histogram?value=700") .to("direct:out")]]></script> </div></div><h3 id="MetricsComponent-meterMetrictypemeter"><span class="confluence-anchor-link" id="MetricsComponent-meter"></span>Metric type meter</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[metrics:meter:metricname[?options]]]></script> -</div></div><h4 id="MetricsComponent-Options.2"><span style="line-height: 1.4285715;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">mark </td><td colspan="1" rowspan="1" class="confluenceTd">-</td><td colspan="1" rowspan="1" class="confluenceTd">Long value to use as mark</td></tr></tbody></table></div><p><span style="line-height: 1.4285715;">If <code>mark</code> is not set then <code>meter.mark()</code> is called without argument.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Options.2"><span style="line-height: 1.4285715;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>mark</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>-</code></td><td colspan="1" rowspan="1" class="confluenceTd">Long value to use as mark</td></tr></tbody></table></div><p><span style="line-height: 1.4285715;">If <strong><code>mark</code></strong> is not set then <strong><code>meter.mark()</code></strong> is called without argument.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// marks simple.meter without value from("direct:in") .to("metric:simple.meter") @@ -180,7 +180,7 @@ from("direct:in") from("direct:in") .to("metric:meter:simple.meter?mark=81") .to("direct:out");]]></script> -</div></div><h4 id="MetricsComponent-Headers.3">Headers</h4><p>Message header can be used to override <code>mark</code> value specified in Metrics component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">CamelMetricsMeterMark</td><td colspan="1" rowspan="1" class="confluenceTd">Override mark value in URI</td><td colspan="1" rowspan="1" class="confluenceTd">Long</td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Headers.3">Headers</h4><p>Message header can be used to override <strong><code>mark</code></strong> value specified in <span><strong><code>metrics</code></strong></span> component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>CamelMetricsMeterMark</code></td><td colspan="1" rowspan="1" class="confluenceTd">Override mark value in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><code>Long</code></td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// updates meter simple.meter with value 345 from("direct:in") .setHeader(MetricsConstants.HEADER_METER_MARK, constant(345L)) @@ -188,38 +188,39 @@ from("direct:in") .to("direct:out");]]></script> </div></div><h3 id="MetricsComponent-timerMetricstypetimer"><span class="confluence-anchor-link" id="MetricsComponent-timer"></span>Metrics type timer</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: text; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[metrics:timer:metricname[?options]]]></script> -</div></div><h4 id="MetricsComponent-Options.3"><span style="line-height: 1.4285715;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">action</td><td colspan="1" rowspan="1" class="confluenceTd">-</td><td colspan="1" rowspan="1" class="confluenceTd">start or stop</td></tr></tbody></table></div><p><span style="line-height: 1.4285715;">If no <code>action</code> or invalid value is provided then warning is logged without any timer update. If action <code>start</code> is called on already running timer or <code>stop</code> is called on not running timer then nothing is updated and warning is logged.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h4 id="MetricsComponent-Options.3"><span style="line-height: 1.4285715;">Options</span></h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>action</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>-</code></td><td colspan="1" rowspan="1" class="confluenceTd">start or stop</td></tr></tbody></table></div><p><span style="line-height: 1.4285715;">If no <strong><code>action</code></strong> or invalid value is provided then warning is logged without any timer update. If action <strong><code>start</code></strong> is called on already running timer or <strong><code>stop</code></strong> is called on not running timer then nothing is updated and warning is logged.</span></p><div class="code panel pdl" s tyle="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// measure time taken by route "calculate" from("direct:in") .to("metrics:timer:simple.timer?action=start") .to("direct:calculate") .to("metrics:timer:simple.timer?action=stop");]]></script> -</div></div><p><code>TimerContext</code> objects are stored as Exchange properties between different Metrics component calls.</p><h4 id="MetricsComponent-Headers.4">Headers</h4><p>Message header can be used to override action value specified in Metrics component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">CamelMetricsTimerAction</td><td colspan="1" rowspan="1" class="confluenceTd">Override timer action in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><code>org.apache.camel.component.metrics.timer.TimerEndpoint.TimerAction</code></td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p><strong><code>TimerContext</code></strong> objects are stored as <strong><code>Exchange</code></strong> properties between different <span><strong><code>metrics</code></strong></span> component calls.</p><h4 id="MetricsComponent-Headers.4">Headers</h4><p>Message header can be used to override action value specified in <span><strong><code>metrics</code></strong></span> component URI.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th><th colspan="1" rowspan="1" class="confluenceTh">Expected type</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>CamelMetricsTimerAction</code></td><td colspan="1" rowspan="1" class="confluenceTd">Override timer action in URI</td><td colspan="1" rowspan="1" class="confluenceTd"><strong><code>org.apache.camel.component.metrics.timer.TimerEndpoint.TimerAction</code></str ong></td></tr></tbody></table></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[// sets timer action using header from("direct:in") .setHeader(MetricsConstants.HEADER_TIMER_ACTION, TimerAction.start) .to("metric:timer:simple.timer") .to("direct:out");]]></script> -</div></div><h3 id="MetricsComponent-MetricsRoutePolicyFactory">MetricsRoutePolicyFactory</h3><p>This factory allows to add a <a shape="rect" href="routepolicy.html">RoutePolicy</a> for each route which exposes route utilization statistics using codehale metrics. This factory can be used in Java and XML as the examples below demonstrates. </p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Instead of using the MetricsRoutePolicyFactory you can define a MetricsRoutePolicy per route you want to instrument, in case you only want to instrument a few selected routes.</p></div></div><p>From Java you just add the factory to the <code>CamelContext</code> as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h3 id="MetricsComponent-MetricsRoutePolicyFactory"><code>MetricsRoutePolicyFactory</code></h3><p>This factory allows to add a <a shape="rect" href="routepolicy.html">RoutePolicy</a> for each route which exposes route utilization statistics using CodaHale metrics. This factory can be used in Java and XML as the examples below demonstrates. </p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Instead of using the <strong><code>MetricsRoutePolicyFactory</code></strong> you can define a <strong><code>MetricsRoutePolicy</code></strong> per route you want to instrument, in case you only want to instrument a few selected routes.</p></div></div><p>From Java you just add the factory to the <strong><code>CamelContext</code></strong> as shown below:</p><div class="code panel pdl" sty le="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.addRoutePolicyFactory(new MetricsRoutePolicyFactory());]]></script> -</div></div><p>And from XML DSL you define a <bean> as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>And from XML DSL you define a <strong><code><bean></code></strong> as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <!-- use camel-metrics route policy to gather metrics for all routes --> <bean id="metricsRoutePolicyFactory" class="org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory"/>]]></script> -</div></div><p>The <code>MetricsRoutePolicyFactory</code> and <code>MetricsRoutePolicy</code> supports the following options:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">useJmx</td><td colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1" rowspan="1" class="confluenceTd">Whether to report fine grained statistics to JMX by using the <code>com.codahale.metrics.JmxReporter</code>.<br clear="none">Notice that if JMX is enabled on <a shape="rect" href="camelcontext.html">CamelContext</a> then a <code>MetricsRegistryService</code> mbean is enlisted under the services type in the JMX tree. That mbean has a single operation to output the statistics using json. Setting <code>useJmx</code> to true is onl y needed if you want fine grained mbeans per statistics type.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">jmxDomain</td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.camel.metrics</td><td colspan="1" rowspan="1" class="confluenceTd">The JMX domain name</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">prettyPrint</td><td colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1" rowspan="1" class="confluenceTd">Whether to use pretty print when outputting statistics in json format</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">metricsRegistry</td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">Allow to use a shared <code>com.codahale.metrics.MetricRegistry</code>. If none is provided then Camel will create a shared instance used by the this CamelContext.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">rateUnit</td><td colspan="1" rowspan="1 " class="confluenceTd">TimeUnit.SECONDS</td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for rate in the metrics reporter or when dumping the statistics as json.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">durationUnit</td><td colspan="1" rowspan="1" class="confluenceTd">TimeUnit.MILLISECONDS</td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for duration in the metrics reporter or when dumping the statistics as json.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">namePattern</td><td colspan="1" rowspan="1" class="confluenceTd">##name##.##routeId##.##type##</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.17:</strong> The name pattern to use. Uses dot as separators, but you can change that. The values ##name##, ##routeId##, and ##type## will be replaced with actual value. Where ###name### is the name of the CamelContext. ###routeId### is the name of the route. And ###type### is the value of re sponses.</td></tr></tbody></table></div><p> </p><p>From Java code tou can get hold of the <code>com.codahale.metrics.MetricRegistry</code><span> from the <code>org.apache.camel.component.metrics.routepolicy.MetricsRegistryService</code> as shown below:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>The <strong><code>MetricsRoutePolicyFactory</code></strong> and <strong><code>MetricsRoutePolicy</code></strong> supports the following options:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>useJmx</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd">Whether to report fine grained statistics to JMX by using the <strong><code>com.codahale.metrics.JmxReporter</code></strong>.<br clear="none">Notice that if JMX is enabled on <a shape="rect" href="camelcontext.html">CamelContext</a> then a <strong><code>MetricsRegistryService</code></strong> mbean is enlisted under the services type in the JMX tree. That MBean has a si ngle operation to output the statistics using JSON. Setting <strong><code>useJmx</code></strong> to true is only needed if you want fine grained MBeans per statistics type.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>jmxDomain</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>org.apache.camel.metrics</code></td><td colspan="1" rowspan="1" class="confluenceTd">The JMX domain name.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>prettyPrint</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd">Whether to use pretty print when outputting statistics in JSON format.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>metricsRegistry</code></td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">Allow to use a shared <strong><code>com.codahale.metrics.MetricRegistry</code></strong> . If one is not configured Camel will create a shared instance for use by the <strong><code>CamelContext</code></strong>.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>rateUnit</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>TimeUnit.SECONDS</code></td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for rate in the metrics reporter or when dumping the statistics as JSON.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>durationUnit</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>TimeUnit.MILLISECONDS</code></td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for duration in the metrics reporter or when dumping the statistics as JSON.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>namePattern</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>##name##.##routeId##.##type##</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p><stro ng>Camel 2.17</strong>: The name pattern to use. Uses dot as separators, but you can change that. The values <strong><code>##name##</code></strong>, <strong><code>##routeId##</code></strong>, and <strong><code>##type##</code></strong> will be replaced with actual value. Where <strong><code>###name###</code></strong> is the name of the <strong><code>CamelContext. ###routeId###</code></strong> is the id of the route, where <strong><code>###type###</code></strong> is the value of responses.</p></td></tr></tbody></table></div><p> </p><p>In Java you can get the <strong><code>com.codahale.metrics.MetricRegistry</code></strong><span> from the <strong><code>org.apache.camel.component.metrics.routepolicy.MetricsRegistryService</code></strong> as shown below:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[MetricRegistryService registryService = context.hasService(MetricsRegistryService.class); + if (registryService != null) { MetricsRegistry registry = registryService.getMetricsRegistry(); - ... + // ... }]]></script> -</div></div><h3 id="MetricsComponent-MetricsMessageHistoryFactory">MetricsMessageHistoryFactory</h3><p><strong>Available as of Camel 2.17</strong></p><p>This factory allows to use metrics to capture <a shape="rect" href="message-history.html">Message History</a> performance statistics while routing messages. It works by using a metrics Timer for each node in all the routes. This factory can be used in Java and XML as the examples below demonstrates. </p><p>From Java you just set the factory to the <code>CamelContext</code> as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><h3 id="MetricsComponent-MetricsMessageHistoryFactory"><code>MetricsMessageHistoryFactory</code></h3><p><strong>Available as of Camel 2.17</strong></p><p>This factory allows to use metrics to capture <a shape="rect" href="message-history.html">Message History</a> performance statistics while routing messages. It works by using a metrics Timer for each node in all the routes. This factory can be used in Java and XML as the examples below demonstrates. </p><p>In Java set the factory on the <strong><code>CamelContext</code></strong> as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.setMessageHistoryFactory(new MetricsMessageHistoryFactory());]]></script> -</div></div><p>And from XML DSL you define a <bean> as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>And from XML DSL you define a <strong><code><bean></code></strong> as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <!-- use camel-metrics message history to gather metrics for all messages being routed --> <bean id="metricsMessageHistoryFactory" class="org.apache.camel.component.metrics.messagehistory.MetricsMessageHistoryFactory"/>]]></script> -</div></div><p>The following options is supported on the factory:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">useJmx</td><td colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1" rowspan="1" class="confluenceTd">Whether to report fine grained statistics to JMX by using the <code>com.codahale.metrics.JmxReporter</code>.<br clear="none">Notice that if JMX is enabled on <a shape="rect" href="camelcontext.html">CamelContext</a> then a <code>MetricsRegistryService</code> mbean is enlisted under the services type in the JMX tree. That mbean has a single operation to output the statistics using json. Setting <code>useJmx</code> to true is only needed if you want fine grained mbeans per statistics type.</td></tr ><tr><td colspan="1" rowspan="1" class="confluenceTd">jmxDomain</td><td >colspan="1" rowspan="1" class="confluenceTd">org.apache.camel.metrics</td><td >colspan="1" rowspan="1" class="confluenceTd">The JMX domain >name</td></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd">prettyPrint</td><td colspan="1" rowspan="1" >class="confluenceTd">false</td><td colspan="1" rowspan="1" >class="confluenceTd">Whether to use pretty print when outputting statistics >in json format</td></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd">metricsRegistry</td><td colspan="1" rowspan="1" >class="confluenceTd"> </td><td colspan="1" rowspan="1" >class="confluenceTd">Allow to use a shared ><code>com.codahale.metrics.MetricRegistry</code>. If none is provided then >Camel will create a shared instance used by the this >CamelContext.</td></tr><tr><td colspan="1" rowspan="1" >class="confluenceTd">rateUnit</td><td colspan="1" rowspan="1" >class="confluenceTd">TimeUnit.SECONDS</td><td colspan="1" rowspan="1 " class="confluenceTd">The unit to use for rate in the metrics reporter or when dumping the statistics as json.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">durationUnit</td><td colspan="1" rowspan="1" class="confluenceTd">TimeUnit.MILLISECONDS</td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for duration in the metrics reporter or when dumping the statistics as json.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">namePattern</td><td colspan="1" rowspan="1" class="confluenceTd">##name##.##routeId##.<span>###id###.</span>##type##</td><td colspan="1" rowspan="1" class="confluenceTd">The name pattern to use. Uses dot as separators, but you can change that. The values ##name##, ##routeId##, ##type##, and ###id### will be replaced with actual value. <span>Where ###name### is the name of the CamelContext. ###routeId### is the name of the route. </span>The ###id### pattern represents the node id. And ###type### is the value of history.</t d></tr></tbody></table></div><p>At runtime the metrics can be accessed from Java API or JMX which allows to gather the data as json output.</p><p>From Java code you can do get the service from the CamelContext as shown:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>The following options is supported on the factory:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>useJmx</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd">Whether to report fine grained statistics to JMX by using the <strong><code>com.codahale.metrics.JmxReporter</code></strong>.<br clear="none">Notice that if JMX is enabled on <a shape="rect" href="camelcontext.html">CamelContext</a> then a <strong><code>MetricsRegistryService</code></strong> MBean is enlisted under the services type in the JMX tree. That MBean has a single operation to output the statistics using JSON. Setting <strong><code>useJmx</code></strong> to true is only needed if you want fine grained MBeans per statistics type.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>jmxDomain</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>org.apache.camel.metrics</code></td><td colspan="1" rowspan="1" class="confluenceTd">The JMX domain name.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>prettyPrint</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd">Whether to use pretty print when outputting statistics in JSON format.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>metricsRegistry</code></td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd">Allow to use a shared <strong><code>com.codahale.metrics.MetricRegistry</code></strong>. If one is not provided Camel will create a shared instance for use by the <strong><code>CamelContext</ code></strong>.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>rateUnit</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>TimeUnit.SECONDS</code></td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for rate in the metrics reporter or when dumping the statistics as JSON.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>durationUnit</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>TimeUnit.MILLISECONDS</code></td><td colspan="1" rowspan="1" class="confluenceTd">The unit to use for duration in the metrics reporter or when dumping the statistics as JSON</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>namePattern</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>##name##.##routeId##.###id###.##type##</code></p></td><td colspan="1" rowspan="1" class="confluenceTd">The name pattern to use. Uses dot as separators, but you can change that. The values <strong><code> ##name##</code></strong>, <strong><code>##routeId##</code></strong>, <strong><code>##type##</code></strong>, and <strong><code>###id###</code></strong> will be replaced with actual value. <span>Where <strong><code>###name###</code></strong> is the name of the <strong><code>CamelContext.###routeId###</code></strong> is the name of the route. </span>The <strong><code>###id###</code></strong> pattern represents the node id, where <strong><code>###type###</code></strong> is the value of history.</td></tr></tbody></table></div><p>At runtime the metrics can be accessed from Java API or JMX which allows to gather the data as JSON output.</p><p>In Java, get the service from the <strong>CamelContext</strong> as shown:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[MetricsMessageHistoryService service = context.hasService(MetricsMessageHistoryService.class); String json = service.dumpStatisticsAsJson();]]></script> -</div></div><p>And the JMX API the MBean is registered in the <code>type=services</code> tree with <code>name=MetricsMessageHistoryService</code>. </p><p> </p></div> +</div></div><p>And the JMX API the MBean is registered in the <strong><code>type=services</code> tree with <code>name=MetricsMessageHistoryService</code></strong>. </p><p> </p></div> </td> <td valign="top"> <div class="navigation">