Recording HTTP Exchanges

你可以通过在应用程序配置中提供类型为 HttpExchangeRepository 的 Bean 来启用 HTTP 交换记录。为了方便起见,Spring Boot 提供 InMemoryHttpExchangeRepository,默认情况下它存储最后 100 个请求响应交换。与跟踪解决方案相比,InMemoryHttpExchangeRepository 受到限制,我们建议仅将其用于开发环境。对于生产环境,我们建议使用诸如 Zipkin 或 OpenTelemetry 等生产就绪的跟踪或 observability 解决方案。或者,你可以创建自己的 HttpExchangeRepository

You can enable recording of HTTP exchanges by providing a bean of type HttpExchangeRepository in your application’s configuration. For convenience, Spring Boot offers InMemoryHttpExchangeRepository, which, by default, stores the last 100 request-response exchanges. InMemoryHttpExchangeRepository is limited compared to tracing solutions, and we recommend using it only for development environments. For production environments, we recommend using a production-ready tracing or observability solution, such as Zipkin or OpenTelemetry. Alternatively, you can create your own HttpExchangeRepository.

您可以使用 httpexchanges 端点获取存储在 HttpExchangeRepository 中的请求-响应交换的信息。

You can use the httpexchanges endpoint to obtain information about the request-response exchanges that are stored in the HttpExchangeRepository.

Custom HTTP Exchange Recording

要自定义每个记录的交换中包含的项目,可以使用 configprop:management.httpexchanges.recording.include[] 配置属性。

To customize the items that are included in each recorded exchange, use the configprop:management.httpexchanges.recording.include[] configuration property.

要完全禁用重新编码,请将 configprop:management.httpexchanges.recording.enabled[] 设置为 false

To disable recoding entirely, set configprop:management.httpexchanges.recording.enabled[] to false.