Spring 集成 - 无法查看 MessageHandler、MessageChannel 和 MessageSource 的指标

Spring Integration - Unable to see metrics for MessageHandler, MessageChannel and MessageSource

我有一个 prometheus 指标注册表和 captor bean 注册如下所示:

"prometheusMeterRegistry": {
          "aliases": [],
          "scope": "singleton",
          "type": "io.micrometer.prometheus.PrometheusMeterRegistry",
          "resource": "class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]",
          "dependencies": [
              "prometheusConfig",
              "collectorRegistry",
              "micrometerClock"
              ]
 },

"integrationMicrometerMetricsCaptor": {
          "aliases": [],
          "scope": "singleton",
          "type": "org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor",
          "resource": null,
          "dependencies": []
},

但是,当我检查 actuator/prometheus 端点时,我没有看到提到的 MessageHandlerMessageChannelMessageSource 的任何指标 here.唯一可用的 spring-integeration 指标是:

spring_integration_sources 1.0

spring_integration_handlers 17.0

spring_integration_channels 15.0

我也 运行 通过我的流程获取数据,但仍然看不到指标。我错过了什么?

感谢您提供这么棒的样本!

所以,你的问题在这里:

<!-- Enable Spring Integration Metrics -->
<int:management/>

首先你不能这样做,因为 Spring Boot auto-configures 这是为了我们。 (我们可能需要改进 Spring 引导文档以提及该功能)。

其次你仍然可以这样做,但你需要使用这个选项:

        <xsd:attribute name="default-counts-enabled" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The default value for components that don't match 'counts-enabled-patterns'.
                    Defaults to false, or true when an Integration MBean Exporter is provided.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>

并将其设置为 true

在当前的 Spring 集成 5.4 版本中,它已被弃用。我们肯定会在接下来的 6.0.

中将其完全删除