【发布时间】:2021-12-09 12:39:22
【问题描述】:
我有一个由 Prometheus 监控的 Apache Camel 应用程序。因此,我将 Micrometer 添加到了我的 POM(参见 Spring 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会增加,但随后会使用 default error handler,由于某些原因,这是不希望的。
问题
为什么CamelExchangesFailed_total 指标没有增加?有没有办法使用自定义错误处理程序计算所有失败的路由?
【问题讨论】:
-
因为当错误处理程序处理失败时,增加的指标是:“CamelExchangesFailuresHandled”
-
@TacheDeChoco 适用于 3.7 版。我必须先更新。谢谢你。如果你写一个详细的答案,我会接受它。