【发布时间】:2022-02-03 17:00:34
【问题描述】:
我正在编写我的第一个 spring boot (2.6.3) 应用程序。
这里是我正在使用的相关依赖项:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
我暴露了actuator的所有功能:
management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: '*'
info:
env:
enabled: true
所以我可以看到 url /actuator 列出的所有端点。
现在,我在一些方法中添加了一些注释,例如 @Counted 和 @Timed,我调用了它们,但它们没有出现在 /actuator/metrics中。
我该如何解决这个问题?
非常感谢您!
【问题讨论】:
-
千分尺开发人员说never count something you can time。计时器包括计数。
标签: java spring-boot metrics spring-boot-actuator