Skip to content

Commit ed3bb40

Browse files
author
YunaiV
committed
增加 actuate httptrace 示例
1 parent 6ca4a5c commit ed3bb40

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.2.2.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>lab-34-actuator-demo-httptrace</artifactId>
14+
15+
<dependencies>
16+
<!-- 实现对 Spring MVC 的自动化配置 -->
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
22+
<!-- 实现对 Actuator 的自动化配置 -->
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-actuator</artifactId>
26+
</dependency>
27+
</dependencies>
28+
29+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cn.iocoder.springboot.lab34.actuatordemo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.iocoder.springboot.lab34.actuatordemo.config;
2+
3+
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
4+
import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
@Configuration
9+
public class ActuateConfig {
10+
11+
@Bean
12+
public HttpTraceRepository httpTraceRepository() {
13+
return new InMemoryHttpTraceRepository();
14+
}
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
management:
2+
endpoint:
3+
# HttpTrace 端点配置项
4+
httptrace:
5+
enabled: true # 是否开启。默认为 true 开启
6+
# HttpTrace 的具体配置项,对应 HttpTraceProperties 配置类
7+
trace:
8+
http:
9+
enabled: true # 是否开启。默认为 true 开启。
10+
include: # 包含的 trace 项的数组。默认不包含 COOKIE_HEADERS、AUTHORIZATION_HEADER 项。
11+
12+
endpoints:
13+
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
14+
web:
15+
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
16+
exposure:
17+
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
18+
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
management:
2+
endpoint:
3+
# HttpTrace 端点配置项
4+
httptrace:
5+
enabled: true # 是否开启。默认为 true 开启
6+
# HttpTrace 的具体配置项,对应 HttpTraceProperties 配置类
7+
trace:
8+
http:
9+
enabled: true # 是否开启。默认为 true 开启。
10+
include: # 包含的 trace 项的数组。默认不包含 COOKIE_HEADERS、AUTHORIZATION_HEADER 项。
11+
12+
endpoints:
13+
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
14+
web:
15+
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
16+
exposure:
17+
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
18+
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
19+

lab-34/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<module>lab-34-actuator-demo-health</module>
1717
<module>lab-34-actuator-demo-info</module>
1818
<module>lab-34-actuator-demo-metrics</module>
19+
<module>lab-34-actuator-demo-httptrace</module>
1920
</modules>
2021

2122

0 commit comments

Comments
 (0)