java - How to count number of requests in spring boot app?
问题描述
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
解决方案
一个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();
}
推荐阅读
- java - 数组插入 sqlite helper 问题插入
- angular - 在翻译元素内旋转动画
- reactjs - 使用 id/object 策略保存数据但仍保存订单
- python - 如何使用熊猫将包含“=”左侧的单元格内容拆分为列标题,将右侧拆分为行值
- java - Java中的Base64编码问题
- python - 打印 TimedeltaIndex 中的元素
- c - 使用 atoi 函数将字符串转换为整数时出现分段错误
- sql-server - 仅当值为 FALSE 时才运行触发器
- javascript - 如何检测对子 vue/nux 自定义指令的点击
- javascript - 在 javascript 中从 html 获取输入