I have a spring boot application whose metrics I want to later send to gcp. But for now I just need to find a way to count the total number of requests my application is handling either with actuator
or with micrometer
. Does anybody know how I could do something like this? Thanks In advance
问问题
2843 次
2 回答
1
一个spring-actuator
例子:
//add pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
使用执行器
@Bean
public SecurityWebFilterChain securityWebFilterChain(
ServerHttpSecurity http) {
return http.authorizeExchange()
.pathMatchers("/actuator/**").permitAll()
.anyExchange().authenticated()
.and().build();
}
于 2020-05-12T06:20:44.463 回答
0
看看Spring Boot Actuator - HttpTrace
默认情况下,最新版本未启用它,但您可以通过实现HttpTraceRepository
.
在此存储库中,您可以使用计数器来测量请求的数量,然后将其添加到 MetricRegistry。另一种选择是使用过滤器,然后在那里使用计数器。
于 2020-05-12T06:20:02.017 回答