219.10. メトリクスタイプタイマー

metrics:timer:metricname[?options]

219.10.1. オプション

名前デフォルト説明

action

-

開始または停止

action または無効な値が指定されていない場合、タイマーの更新なしで警告がログに記録されます。すでに実行中のタイマーでアクション start が呼び出された場合、または実行されていないタイマーで stop が呼び出された場合、何も更新されず、警告がログに記録されます。

// 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");

TimerContext オブジェクトは、異なる Metrics コンポーネントの呼び出し間で Exchange プロパティーとして格納されます。

219.10.2. ヘッダー

メッセージヘッダーを使用して、Metrics コンポーネント URI で指定されたアクション値をオーバーライドできます。

名前説明想定されるタイプ

CamelMetricsTimerAction

URI のタイマーアクションをオーバーライドする

org.apache.camel.component.metrics.timer.TimerEndpoint.TimerAction

// sets timer action using header
from("direct:in")
    .setHeader(MetricsConstants.HEADER_TIMER_ACTION, TimerAction.start)
    .to("metrics:timer:simple.timer")
    .to("direct:out");