【问题标题】:Why is CamelExchangesFailed_total metrics not increased?为什么 CamelExchangesFailed_total 指标没有增加?
【发布时间】: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 版。我必须先更新。谢谢你。如果你写一个详细的答案,我会接受它。

标签: apache-camel micrometer


【解决方案1】:

Apache Camel LTS 版本 3.7.0 添加了一个新指标 CamelExchangesFailuresHandled_total,这是处理错误的计数器,请参阅 CAMEL-15908

与 CAMEL-15255 类似,我们可以为 MicrometerRoutePolicy 添加一些额外的计数器指标:

  • 处理的交易总数
  • 处理的失败次数
  • 外部重新投递次数

指标

# 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
# HELP CamelExchangesFailuresHandled_total  
# TYPE CamelExchangesFailuresHandled_total counter
CamelExchangesFailuresHandled_total{application="test",camelContext="camel-1",routeId="route1",serviceName="MicrometerRoutePolicyService",} 1.0

【讨论】:

    猜你喜欢
    • 2021-04-06
    • 2017-04-03
    • 1970-01-01
    • 2019-09-28
    • 2016-06-19
    • 2015-11-26
    • 2018-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多