如何将opentrace拦截器添加到resttemplate?

f87krz0w  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(329)

我想在我的spring(而不是boot)应用程序中跟踪通过restemplate发送的所有http请求。
我找到班了 BraveClientHttpRequestInterceptor 我有担心,因为这个类是不赞成的,我没有看到任何建议的替代品。如果你知道这个选择-请告诉我。
所以我决定试试不推荐的 BraveClientHttpRequestInterceptor 但我没发现有多不稳定 BraveClientHttpRequestInterceptor 我有以下配置:

@Bean
public RestTemplate restTemplate(BraveClientHttpRequestInterceptor bci) {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setInterceptors(bci);
    return restTemplate;
}

谢谢你的帮助。

9avjhtql

9avjhtql1#

您可以尝试为设置日志级别 org.springframework.web.client.RestTemplateDEBUG .
你也可以在上面找到其他可能的解决方案https://www.baeldung.com/spring-resttemplate-logging
请告诉我这是否有用。

相关问题