我在试着让spring slueth在我们的系统中传播追踪ids。
在检查另一个服务的日志时,我注意到生成了新的Ids。
我想这可能是因为我使用了一个伪装的构建器,而我已经在使用okHttpClient了。
我遇到了以下内容:
https://github.com/spring-cloud/spring-cloud-sleuth/issues/594
How to implement Sleuth Tracing With Feign.Builder?
我的bean设置如下:
@Configuration
@RequiredArgsConstructor
public class OkHttpConfig {
private final Properties properties;
@Bean
public OkHttpClient okHttpClient() {
return new Builder()
.connectTimeout(properties.getHttpTimeoutMillis(), TimeUnit.MILLISECONDS)
.readTimeout(properties.getHttpTimeoutMillis(), TimeUnit.MILLISECONDS)
.writeTimeout(properties.getHttpTimeoutMillis(), TimeUnit.MILLISECONDS)
.connectionPool(new ConnectionPool(properties.getHttpPoolSize(),
properties.getHttpKeepAliveMillis(), TimeUnit.MILLISECONDS))
.build();
}@Configuration
public class HttpClientConfiguration {
@Autowired
private Properties properties;
@Autowired
private Client client;
@Bean
public SomeClient SomeClient(Client client, ObjectMapper objectMapper {
return feignClient(properties.getUrl(), SomeClient.class, client,
objectMapper);
}
public static <T> T feignClient(String baseUrl, Class<T> clientClass,
Client client, ObjectMapper objectMapper) {
return Feign.builder()
.client(client)
.decoder(new JacksonDecoder(objectMapper))
.encoder(new JacksonEncoder(objectMapper))
.target(clientClass, baseUrl);
}我希望客户端被包装在跟踪实现中,但我一直收到以下错误
Unsatisfied dependency expressed through field 'client'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'feign.Client' available:
expected at least 1 bean which qualifies as autowire candidate.Dependency annotations:使用以下版本:
Spring boot 2.1.2版本
org.springframework.cloud:spring-cloud-sleuth:2.1.0.RELEASE
发布于 2019-02-14 22:54:26
在聊天(https://chat.stackoverflow.com/rooms/188411/discussion-between-yk-47-and-marcin-grzejszczak)中,我们已经分析了当前的设置。它缺少bean定义,最重要的是缺少open feign的spring-cloud starter。
https://stackoverflow.com/questions/54688265
复制相似问题