记录 HTTP 交换
原文:https://docs.spring.io/spring-boot/reference/actuator/http-exchanges.html (Spring Boot 4.2.0)
可以通过在应用配置中提供 HttpExchangeRepository 类型的 bean 来启用 HTTP 交换记录。为方便起见,Spring Boot 提供了 InMemoryHttpExchangeRepository,默认情况下存储最后 100 个请求-响应交换。与追踪解决方案相比,InMemoryHttpExchangeRepository 功能有限,建议仅用于开发环境。对于生产环境,建议使用生产就绪的追踪或可观测性解决方案(如 Zipkin 或 OpenTelemetry)。也可以创建自己的 HttpExchangeRepository。
可以使用 httpexchanges 端点获取存储在 HttpExchangeRepository 中的请求-响应交换信息。
自定义 HTTP 交换记录
要定制每条记录交换中包含的项目,使用 management.httpexchanges.recording.include 配置属性。
要完全禁用记录,将 management.httpexchanges.recording.enabled 设置为 false。