Ree*_*shi 8 health-monitoring spring-boot spring-boot-actuator prometheus spring-micrometer
@Counted 如何运作?我在控制器中的方法上添加了 @Counted 注释,并期望看到控制器有多少次点击。但我看不到添加到 URL http://localhost:8080/actuator/prometheus 上的指标。
@Counted(value = "counted.success.test",description = "testCounter")
Run Code Online (Sandbox Code Playgroud)
您需要添加 aCountedAspect作为 bean,然后在调用该方法时创建指标:
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class Config {
@Bean
CountedAspect countedAspect(MeterRegistry registry) {
return new CountedAspect(registry);
}
Run Code Online (Sandbox Code Playgroud)
(不记得为什么我们添加了@EnableAspectJAutoProxy(proxyTargetClass = true))
尽管这种工具并不完美,但一旦您重构代码,标签class和标签就会发生变化,并且您的 Grafana 仪表板可能不再工作。method
| 归档时间: |
|
| 查看次数: |
7660 次 |
| 最近记录: |