I am creating a client sdk with retrofit calls to a service, packaged as a separate jar. I have to include zipkin tracer/tracing in this jar so that any application using this jar to communicate with the service, have a separate span created automatically for every call to the service. Is there a feasible solution to my problem?
I have been trying to solve the problem using the "io.zipkin.brave:brave-instrumentation-okhttp3" library. I have also added the "org.springframework.cloud:spring-cloud-starter-sleuth" dependency so that the tracer-id is by-default generated. But adding this jar to a project which uses kafka-streams and the "io.zipkin.brave:brave-instrumentation-kafka-streams" dependency, doesn't automatically initialses a new span.
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(JacksonConverterFactory.create())
.addCallAdapterFactory(UnwrappedCallAdapterFactory.create());
// Enable zipking tracing
HttpTracing httpTracing = HttpTracing.create(tracing).clientOf(client);
httpClient.dispatcher(new Dispatcher(
httpTracing.tracing().currentTraceContext()
.executorService(new Dispatcher().executorService())
)).addNetworkInterceptor(TracingInterceptor.create(httpTracing));
Retrofit retrofit = builder.build();
What I expect is that applications using this jar have by-default a separate span for every retrofit call they make through this jar.