Closed tadlakha9 closed 2 weeks ago
Spring Boot doesn't provide any integration with Retrofit and it looks like this might be a general issue rather than a Spring Boot bug. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
I would suggest posting a question on Stack Overflow or asking in the Micrometer Slack. I'm afraid we don't really have the expertise to help you here.
Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Its not more specific to Retrofit, actually when we call an api, we get the tracer with currentSpan later currentSpan got lost in between. We have similar issue in the past as well.
This is not a Spring Boot bug IMO. You have no micrometer integration with the OKHttp3 client being used by Retrofit. I think you need something like this in your RetrofitConfig
:
@Bean
public Retrofit retrofit(ObservationRegistry registry) {
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(OkHttpObservationInterceptor.builder(registry, "test").build())
.addInterceptor(tracingInterceptor)
.build();
....
Sorry for being a bit late but we have a working Retrofit with OKHttp sample you might be able to use to create your own configuration.
We are facing an issue with spring boot 3.3.1, TraceContext is not propagated while calling one microservice with another via retrofit.
Our Observation
When we call an api in microservice 1,
tracer.currentSpan().context()
is available after calling another microservice via retrofit, TraceContext would not get propagated and a new context with new traceId would get started.Sample projects