question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feign.Builder from FeignClientsConfiguration overrides SleuthFeignBuilder

See original GitHub issue

I am trying to get Sleuth to work correctly with feign clients constructed with Feign.builder. Based on previous posts here and looking at the code, I understand that I can rely on SleuthFeignBuilder to return a builder that wraps the client in the Trace functionality.

However, I’m not able to inject the correct builder in my Spring application - it seems that the default builder, from org.springframework.cloud.netflix.feign.FeignClientsConfiguration overrides the Sleuth builder from org.springframework.cloud.sleuth.instrument.web.client.feign.TraceFeignClientAutoConfiguration since they are both marked as ConditionalOnMissingBean and the FeignClientsConfiguration class gets loaded first.

This is the builder in FeignClientsConfiguration:

	@Bean
	@Scope("prototype")
	@ConditionalOnMissingBean
	public Feign.Builder feignBuilder(Retryer retryer) {
		return Feign.builder().retryer(retryer);
	}

And this is the builder in TraceFeignClientAutoConfiguration:

	@Bean
	@ConditionalOnMissingBean
	@Scope("prototype")
	@ConditionalOnProperty(name = "feign.hystrix.enabled", havingValue = "false", matchIfMissing = true)
	Feign.Builder feignBuilder(BeanFactory beanFactory) {
		return SleuthFeignBuilder.builder(beanFactory);
	}

How can I get the 2nd one, and not the first?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dmarkhascommented, May 9, 2018

@marcingrzejszczak your last comment helped me pinpoint the issue - there was an explicit Import of FeignClientsConfiguration in a different place in the code that caused this conflict, after removing it everything works fine!

0reactions
marcingrzejszczakcommented, May 9, 2018

The TraceFeignClientAutoConfiguration is an autoconfiguration. FeignClientsConfiguration is not an autoconfiguration. It’s Usef jn the FeignContext. FeignContext is setup in FeignAutoConfiguration. We do have @AutoConfigureBefore(FeignAutoConfiguration.class).

Read more comments on GitHub >

github_iconTop Results From Across the Web

feign.Feign.builder java code examples - Tabnine
SleuthFeignBuilder.builder(...) static Feign.Builder builder(BeanFactory beanFactory) { return Feign.builder().retryer(Retryer.
Read more >
Feign Client Custom Configuration Does Not Take Effect
So my custom OkHttpClient is overridden by this lazy client. Here is the related Feign library code that is being triggered twice: FeignBuilder....
Read more >
Spring Cloud OpenFeign
You can do this by overriding calling `inheritParentContext(false) on the Builder . 1.5. Feign Spring Cloud CircuitBreaker Support. If Spring Cloud ...
Read more >
FeignClient源码深度解析 - 分布式编程
1)单独使用Feign,没有引入 sleuth 、 hystrix : 通过加载FeignClientsConfiguration的配置创建 Feign 的静态内部类: Feign.Builder
Read more >
Feign 调用过程分析 - 简书
概述SpringCloud feign 对Netflix feign进行了包装和增强, ... 又出现了两个Builder, SleuthHystrixFeignBuilder、SleuthFeignBuilder, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found