我有一个由Prometheus监控的Apache Camel应用程序。因此,我将Micrometer添加到我的POM中(请参阅Sping Boot Auto-Configuration),并将MicrometerRoutePolicyFactory
添加到我的应用程序中(请参阅Using Micrometer Route Policy Factory)。但是度量CamelExchangesFailed_total
并没有改变,尽管路由失败了。
来源
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
@Bean
public MicrometerRoutePolicyFactory micrometerRoutePolicyFactory() {
return new MicrometerRoutePolicyFactory();
}
@Bean
public EndpointRouteBuilder route() {
return new EndpointRouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(deadLetterChannel("log:dead"));
from(timer("testTimer").repeatCount(1)).throwException(new RuntimeException());
}
};
}
}
日志
INFO 5060 --- [ restartedMain] o.a.c.i.e.InternalRouteStartupManager : Route: route1 started and consuming from: timer://testTimer
INFO 5060 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Total 1 routes, of which 1 are started
INFO 5060 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.5.0 (camel-1) started in 0.007 seconds
INFO 5060 --- [ restartedMain] test.TestApplication : Started TestApplication in 6.626 seconds (JVM running for 7.503)
INFO 5060 --- [on(3)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
INFO 5060 --- [on(3)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
INFO 5060 --- [on(3)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms
INFO 5060 --- [mer://testTimer] dead : Exchange[ExchangePattern: InOnly, BodyType: null, Body: [Body is null]]
度量
# HELP CamelExchangesFailed_total
# TYPE CamelExchangesFailed_total counter
CamelExchangesFailed_total{application="test",camelContext="camel-1",routeId="route1",serviceName="MicrometerRoutePolicyService",} 0.0
# HELP CamelExchangesSucceeded_total
# TYPE CamelExchangesSucceeded_total counter
CamelExchangesSucceeded_total{application="test",camelContext="camel-1",routeId="route1",serviceName="MicrometerRoutePolicyService",} 1.0
研究
- 如果我删除了自定义错误处理程序,则指标
CamelExchangesFailed_total
会增加,但随后会使用默认错误处理程序,出于某些原因,这是不希望的。
问题
为什么CamelExchangesFailed_total
度量没有增加?有没有办法用一个自定义的错误处理程序来计算所有失败的路由?
1条答案
按热度按时间cngwdvgl1#
Apache Camel LTS版本3.7.0增加了一个新的指标
CamelExchangesFailuresHandled_total
,这是一个已处理错误的计数器,请参见CAMEL-15908:与CAMEL-15255类似,我们可以将一些其他计数器度量添加到MicrometerRoutePolicy中,用于:
度量