有没有一种方法可以在罐子中启用zipkin跟踪,以便无论在哪里使用罐子,它都会默认初始化一个单独的跨度

时间:2019-04-12 06:56:29

标签: java retrofit spring-cloud-sleuth zipkin distributed-tracing

我正在使用对服务的改造调用来创建客户端sdk,将其打包为单独的jar。我必须在此jar中包含zipkin跟踪器/跟踪,以便使用此jar与该服务进行通信的任何应用程序都会为该服务的每次调用自动创建一个单独的跨度。有没有可行的解决方案来解决我的问题?

我一直在尝试使用“ io.zipkin.brave:brave-instrumentation-okhttp3”库解决此问题。我还添加了“ org.springframework.cloud:spring-cloud-starter-sleuth”依赖项,以便在默认情况下生成tracer-id。但是,将此罐子添加到使用kafka-streams和“ io.zipkin.brave:brave-instrumentation-kafka-streams”依赖项的项目中,不会自动初始化新的跨度。

    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();

我期望的是,默认情况下,使用此jar的应用程序对通过此jar进行的每个改造调用都具有单独的跨度。

0 个答案:

没有答案