If RestTemplateAutoConfiguration has backed off (and, therefore, there's no RestTemplateBuilder) any RestTemplateCustomizer beans will not be used. In that situation, the beans created by RestTemplateMetricsConfiguration won't be used by Boot. We should consider making RestTemplateMetricsConfiguration back off too.
@wilkinsona I want to work on it. Please let me know if I can start working on it ?
Thanks for the offer, Raheela. I just need to check with the rest of the team that they think what I've proposed is a good idea. If they do, then the issue's all yours and you could start working on it.
@wilkinsona From what I can tell, RestTemplateAutoConfiguration will only back off if RestTemplate is not on the classpath. RestTemplateMetricsConfiguration has the same @ConditionalOnClass(RestTemplate.class) and will back-off in the same situation as RestTemplateAutoConfiguration. Give that the @ConditionalOnClass check would be less expensive, maybe the current way of backing off is better than a @ConditionalOnBean?
I think we should keep the @ConditionalOnClass but add a bean-based check too. This would primarily be for reactive web apps where RestTemplateAutoConfiguration will now back off (#15718).
ah, I was on a different branch and didn't notice the NotReactiveWebApplicationCondition on RestTemplateAutoConfiguration. Makes sense to me in that case.
@Raheela1024 We discussed this today and decided that it is a change that we want to make. If you still have time to work on it, a pull request would be most welcome. Thanks.
@wilkinsona thanks sure i am start working on it and let you know if i need any help.
@wilkinsona I need your help As, I am understanding we need to add bean-based check on RestTemplateAutoConfiguration like
@Configuration
@AutoConfigureAfter(HttpMessageConvertersAutoConfiguration.class)
@ConditionalOnClass(RestTemplate.class)
@ConditionalOnBean(RestTemplate.class)
public class RestTemplateAutoConfiguration {
Please let me know I am in wrong direction.
It's org.springframework.boot.actuate.autoconfigure.metrics.web.client.RestTemplateMetricsConfiguration that needs to have @ConditionalOnBean added to it. The idea is that the DefaultRestTemplateExchangeTagsProvider and MetricsRestTemplateCustomizer beans will only be auto-configured if there's a RestTemplateBuilder bean available so the condition should be @ConditionalOnBean(RestTemplateBuilder.class).
Closing in favour of #15842.
Most helpful comment
@wilkinsona thanks sure i am start working on it and let you know if i need any help.