opentracing-contrib / java-kafka-client

OpenTracing Instrumentation for Apache Kafka Client
Apache License 2.0
125 stars 64 forks source link

Consider integrating with TracerResolver #51

Closed mzbyszynski closed 5 years ago

mzbyszynski commented 5 years ago

I'm trying to use TracingConsumerInterceptor and TracingProducerInterceptor to add tracing to some Kafka connectors with a jaeger implementation under the hood. I am trying to do this via kafka connect connect configuration parameters but I'm unable to register the jaeger tracer to the global tracer in this case.

I was wondering if it would be feasible to integrate the opentracing-kafka-client with opentracing-contrib/java-traceresolver. That way the Jaeger tracer would be resolved if the jaeger tracerresolver jar was in the classpath.

I think this would be a somewhat simple change. It would just be replacing GlobalTracer.get() with TracerResolver.resolveTracer(). This function falls back to using the GlobalTracer.get() if a tracer has already been registered there, so I think it shouldn't break anything any existing implementations.

I'd be happy to submit a PR for this if that helps, or let me know if I'm missing or misunderstanding something and this change will not work.

Let me know what you think. Thanks for your help!

-Marc

malafeev commented 5 years ago

Yes, TracerResolver is one option, another is to try SpecialAgent.

mzbyszynski commented 5 years ago

Thanks @malafeev I wasn't aware of SpecialAgent. I'll give it a try today and close this issue if it works for me.

riferrei commented 5 years ago

@mzbyszynski, you may wanna take a look on this:

https://github.com/riferrei/kafka-tracing-support

I used the TracerResolver utility to resolve the tracer, in case I need to use the interceptors with Kafka Connect, REST Proxy, and KSQL.

mzbyszynski commented 5 years ago

Thanks! Special Agent worked! Also @riferrei's project looks like a great solution too.

sacoefrancis commented 3 years ago

@mzbyszynski , am too facing same issue in connect-distributed and connect-standalone add below config producer.interceptor.classes=io.opentracing.contrib.kafka.TracingProducerInterceptor consumer.interceptor.classes=io.opentracing.contrib.kafka.TracingConsumerInterceptor and added below jars on /usr/share/java/kafka path opentracing-api-0.33.0.jar opentracing-kafka-client-0.1.15.jar opentracing-kafka-streams-0.1.15.jar opentracing-noop-0.31.0.jar opentracing-specialagent-1.7.4.jar opentracing-tracerresolver-0.1.0.jar opentracing-tracerresolver-0.1.8.jar jaeger-client-1.5.0.jar jaeger-tracerresolver-0.31.0.jar

and passed JAEGER_SERVICE_NAME: jaeger as environment variable. used filesource connector used kafka connect to put record into topic, header is not automatically getting created service is not coming into JaegerUI

Can you please help me in this ?