219.5. Metric Registry

Camel Metrics 구성 요소는 기본적으로 60초 보고 간격이 있는 Slf4jReporter 와 함께 MetricRegistry 인스턴스를 사용합니다. 이 기본 레지스트리는 MetricRegistry 빈을 제공하여 사용자 지정 레지스트리로 교체할 수 있습니다. 애플리케이션에 여러 개의 MetricRegistry 빈이 있는 경우 metricRegistry 라는 이름이 있는 빈이 사용됩니다.

Spring Java 구성을 사용하는 예는 다음과 같습니다.

@Configuration
public static class MyConfig extends SingleRouteCamelConfiguration {

    @Bean
    @Override
    public RouteBuilder route() {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // define Camel routes here
            }
        };
    }

    @Bean(name = MetricsComponent.METRIC_REGISTRY_NAME)
    public MetricRegistry getMetricRegistry() {
        MetricRegistry registry = ...;
        return registry;
    }
}

또는 CDI 사용:

class MyBean extends RouteBuilder {

    @Override
    public void configure() {
      from("...")
          // Register the 'my-meter' meter in the MetricRegistry below
          .to("metrics:meter:my-meter");
    }

    @Produces
    // If multiple MetricRegistry beans
    // @Named(MetricsComponent.METRIC_REGISTRY_NAME)
    MetricRegistry registry() {
        MetricRegistry registry = new MetricRegistry();
        // ...
        return registry;
    }
}