Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate span-context for Kafka Clients by injecting and extracting in message headers #1113

Closed
mnottheone opened this issue Aug 27, 2020 · 8 comments

Comments

@mnottheone
Copy link

Right now, auto instrumentation records spans for Kafka clients, but context propagation is missing. Let me know if I am wrong and I tried running it myself and span-ids were missing in message headers.
Context propagation for Kafka clients was supported for opentracing using java-kafka-client . This is really helpful for applications involving Kafka.

Changes involved will be implementing inject and extract in TextMapPropagator. I can see explicitly only propagator's setter and getter are implemented in InjectAdapter and extractAdapter. Any specific reasons? Didn't find any blocker in OpenTelemetery API.

Can we add context propagation for kafka clients ?

I don't know the best way to get it done. But happy to learn and make a pull request.

@iNikem
Copy link
Contributor

iNikem commented Aug 27, 2020

There is code in place to propagate trace context via kafka headers:

If that does not work, then something is broken and we should investigate it. Can you confirm it does not work?

@mnottheone
Copy link
Author

mnottheone commented Aug 27, 2020

I tried in debug mode and can see traceparent ( traceId-spanId.. ) in headers. But issue is spans from producers and consumers are not getting stitched in Jaeger. There are separate Traces/spans for producer and consumer messages. It lead me to assumption that context in not propagated.

Can see no extract here

In java-kafka-client it's done here

@trask
Copy link
Member

trask commented Aug 27, 2020

Hi @mnottheone! Kafka propagation works for me, can you provide a standalone repro so we can try it out and see what might be different for your case?

@mnottheone
Copy link
Author

Hi! I tried replicating in standalone, it was working. I simply removed some extra code for JaegerTracer (Jaeger and OpenTracing libs) and it also started working. Thanks a lot for prompt responses. Closing this issue.

@vimal3271
Copy link

@mnottheone I am facing the same issue where the producer and consumer traces are reported separately . Is there any config that I need to tune ? I am using Jaeger (1.27) as backend.

@mateuszrzeszutek
Copy link
Member

Hey @vimal3271 ,
Can you open a new issue with the details of your setup? What libraries you're using for accessing kafka, what versions etc. It would be awesome if you could provide a code example or a reproduction scenario/app too

@Samarth888
Copy link

Hi, I am experiencing a similar problem where I am getting separate traces for producer and consumer instead of a single flow. I am using auto instrumentation and using Zipkin backend. I have also checked through debug mode and ensured that the headers are present, so I am not able to analyze if this is a propagation issue or something else.

@carlos045
Copy link

carlos045 commented Mar 22, 2024

I have the same issue @Samarth888 I get my http call in one trace nd producer in other trace o dont know what happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants