219.7. 지표 유형 카운터

metrics:counter:metricname[?options]

219.7.1. 옵션

이름기본설명

증가 

-

카운터에 추가할 긴 값

감소

-

카운터에서 뺀 긴 값

증분 또는 감소 가 정의되지 않은 경우 카운터 값은 1씩 증가합니다. 증가감소 가 모두 정의된 경우 증분 작업만 호출됩니다. 

// update counter simple.counter by 7
from("direct:in")
    .to("metric:counter:simple.counter?increment=7")
    .to("direct:out");
// increment counter simple.counter by 1
from("direct:in")
    .to("metric:counter:simple.counter")
    .to("direct:out");
// decrement counter simple.counter by 3
from("direct:in")
    .to("metrics:counter:simple.counter?decrement=3")
    .to("direct:out");

219.7.2. headers

메시지 헤더는 지표 구성 요소 URI에 지정된 증분감소 값을 재정의하는 데 사용할 수 있습니다.

이름설명예상 유형

CamelMetricsCounterIncrement 

URI의 덮어쓰기 증가 값

long

CamelMetricsCounterDecrement 

URI의 감소 값 덮어쓰기

long

// update counter simple.counter by 417
from("direct:in")
    .setHeader(MetricsConstants.HEADER_COUNTER_INCREMENT, constant(417L))
    .to("metrics:counter:simple.counter?increment=7")
    .to("direct:out");
// updates counter using simple language to evaluate body.length
from("direct:in")
    .setHeader(MetricsConstants.HEADER_COUNTER_INCREMENT, simple("${body.length}"))
    .to("metrics:counter:body.length")
    .to("mock:out");