MicroProfile指标在WildFly 25上不显示自定义指标 [英] MicroProfile Metrics do not show custom metrics on Wildfly 25

查看:0
本文介绍了MicroProfile指标在WildFly 25上不显示自定义指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Javax/jaxars,并且使用的是我不太熟悉的WildFly 25服务器。

在搜索类似于Spring的Actuator的东西时,我无意中发现了服务器默认公开的指标和健康端点,以及它向应用程序端点添加自定义计数器、量规等的能力。

但是,无论我做什么,这些自定义终结点都不会在默认的http://localhost:9990/metrics URL下公开。

我正在遵循GitHub存储库下WildFly提供的指南: https://github.com/wildfly/quickstart/tree/main/microprofile-metrics

教程中的一些危险信号似乎不适用于我尝试执行的任何操作。

  1. 本指南建议,如果我们想要获取JSON格式的指标,则需要使用以下标题:";Accepted: application/json";,它仍然返回默认的Prometheus格式,包括邮政编码和Curl格式。
  2. 本指南还建议指标/供应商指标/应用程序指标/基础返回不同作用域的指标,在我的测试中,它们返回的指标都相同。

就教程代码而言,我尝试在Jakarta EE 8 Full&;Web发行版上运行它,但它抛出以下错误:

Artifact microprofile-metrics:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit."microprofile-metrics.war".undertow-deployment" => "java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter Caused by: java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter

我尝试用不同版本的Java(1.8、11、17)编译代码,希望可以解决问题,但无济于事。

但是,使用WildFly预览EE 9.1分发版似乎可以停止引发错误,但自定义度量值仍然不起作用。

有我在尝试期间添加到两个发行版的子系统(取自Standalone.xml):

    <extension module="org.wildfly.extension.health"/>
    <extension module="org.wildfly.extension.metrics"/>
    <extension module="org.wildfly.extension.microprofile.config-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.fault-tolerance-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.health-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.jwt-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.openapi-smallrye"/>
    <extension module="org.wildfly.extension.microprofile.opentracing-smallrye"/>
    <extension module="org.wildfly.extension.undertow"/>

(为简洁起见省略其他部分)

我还尝试通过创建以下BAT并启动它来启用统计信息:

call standalone.bat -Dwildfly.statistics-enabled=true

我使用的是IntelliJ,因此我尝试在IDE中执行相同的操作:

(在启动过程中将";Enable Statistics&q;选项同时添加到VM Options&;以确保其工作)

以下是我使用的依赖项,基于我的服务器版本:

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.wildfly.bom</groupId>
        <artifactId>wildfly-microprofile</artifactId>
        <version>25.0.0.Final</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.wildfly.bom</groupId>
        <artifactId>wildfly-jakartaee8-with-tools</artifactId>
        <version>25.0.0.Final</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

<dependencies>
    <!-- Import the MicroProfile Metrics API, we use provided scope as the API is included in the server -->
    <dependency>
      <groupId>org.eclipse.microprofile.metrics</groupId>
      <artifactId>microprofile-metrics-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- Import the CDI API, we use provided scope as the API is included in the server -->
    <dependency>
      <groupId>jakarta.enterprise</groupId>
      <artifactId>jakarta.enterprise.cdi-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- Import the Jakarta REST API, we use provided scope as the API is included in the server -->
    <dependency>
      <groupId>org.jboss.spec.javax.ws.rs</groupId>
      <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

推荐答案

约翰。我是WildFly的指标/MP指标组件负责人,因此希望我能帮助您解决问题。

在我对挖掘WF源代码感到非常兴奋之前,您能确认您使用的是哪种配置吗?看起来您使用的是Standalone.xml配置。虽然这确实有指标扩展,但它不是MP指标。为此,您需要使用stand-microprofile.xml.

希望您的问题就是这么简单。如果没有,让我知道,我们会更深入地调查。:)

这篇关于MicroProfile指标在WildFly 25上不显示自定义指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆