spring-cloud-square icon indicating copy to clipboard operation
spring-cloud-square copied to clipboard

Tracing Only Works for @LoadBalanced OkHttpClient.Builder Beans

Open rsteppac opened this issue 3 years ago • 0 comments

Describe the bug spring-cloud-square-okhttp version 0.4.1

Auto-configuration of the org.springframework.cloud.square.okhttp.tracing.TracingOkHttpInterceptor only works if the client builder bean has been annotated with @LoadBalanced: OkHttpBuilderBeanPostProcessor.java#L42

Tracing and load balancing should work independently of each other.

Sample

@Configuration
class SampleContext {

    @Bean
    @LoadBalanced // Drop the annotation and tracing headers will no longer be added to the request
    fun okHttpClientBuilder() : OkHttpClient.Builder = OkHttpClient.Builder()

    @Bean
    fun okHttpClient(builder: OkHttpClient.Builder): OkHttpClient = builder.build()

}

rsteppac avatar Nov 07 '22 11:11 rsteppac