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