220.11. MicrometerMessageHistoryFactory
이 팩토리에서는 메시지를 라우팅하는 동안 메트릭을 사용하여 메시지 기록 성능 통계를 캡처할 수 있습니다. 모든 경로의 각 노드에 대해 마이크로미터 타이머를 사용하여 작동합니다. 아래 예시와 같이 Java 및 XML에서 이 팩토리를 사용할 수 있습니다.
Java에서 다음과 같이 말리타리를 CamelContext
로 설정했습니다.
context.setMessageHistoryFactory(new MicrometerMessageHistoryFactory());
context.setMessageHistoryFactory(new MicrometerMessageHistoryFactory());
XML DSL에서 다음과 같이 <bean>을 정의합니다.
<!-- use camel-micrometer message history to gather metrics for all messages being routed --> <bean id="metricsMessageHistoryFactory" class="org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory"/>
<!-- use camel-micrometer message history to gather metrics for all messages being routed -->
<bean id="metricsMessageHistoryFactory" class="org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory"/>
다음 옵션은 팩토리에서 지원됩니다.
이름 | 기본 | 설명 |
---|---|---|
prettyPrint | false | json 형식으로 통계를 출력할 때 매우 인쇄할지 여부 |
meterRegistry |
|
공유 |
durationUnit | TimeUnit.MILLISECONDS | 통계를 json으로 덤프할 때 기간에 사용할 단위입니다. |
런타임 시 Java API 또는ECDHE에서 메트릭에 액세스할 수 있으므로 json 출력으로 데이터를 수집할 수 있습니다.
Java 코드에서 다음과 같이 CamelContext에서 서비스를 가져올 수 있습니다.
MicrometerMessageHistoryService service = context.hasService(MicrometerMessageHistoryService.class); String json = service.dumpStatisticsAsJson();
MicrometerMessageHistoryService service = context.hasService(MicrometerMessageHistoryService.class);
String json = service.dumpStatisticsAsJson();
CamelContext에서ECDHE가 활성화된 경우, DestinationRule은 name=MicrometerMessageHistory
를 사용하여 type=services
트리에 등록됩니다.