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

Add support for Kafka consumer and producer interceptors. #4065

Merged
merged 8 commits into from
Oct 2, 2021

Conversation

alesj
Copy link
Contributor

@alesj alesj commented Sep 8, 2021

Sending a PR after a short discussion #4061

The goal is to have an equivalent interceptors implementation to this one:

The main stuff is in TracingKafkaUtils class.

I'm not 100% I got all of the things, specially scopes and contexts right,
so a more experienced eye is welcome.

Plus some suggestions on what to check in the test(s) -- currently I just print out headers.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 8, 2021

CLA Signed

The committers are authorized under a signed CLA.

@alesj
Copy link
Contributor Author

alesj commented Sep 8, 2021

This EasyCLA doesn't work ... it's generating forever ...

@trask
Copy link
Member

trask commented Sep 8, 2021

This EasyCLA doesn't work ... it's generating forever ...

hey @alesj, give it another try tomorrow, hopefully it was just having temporary problems, if not, post a screenshot and we can reach out to the EasyCLA team

@alesj
Copy link
Contributor Author

alesj commented Sep 10, 2021

@trask OK, it works now ... signed

@alesj
Copy link
Contributor Author

alesj commented Sep 13, 2021

Uh, any (better) idea what went wrong here?
As I fail to find anything relevant to my PR ...

@laurit
Copy link
Contributor

laurit commented Sep 13, 2021

@alesj try running ./gradlew :instrumentation:kafka-clients:kafka-clients-0.11:library:checkstyleMain

@alesj
Copy link
Contributor Author

alesj commented Sep 13, 2021

@laurit ah, OK, tnx ... fixed now

@alesj alesj force-pushed the kafka_lib_1 branch 2 times, most recently from c65ec26 to 08f72be Compare September 13, 2021 14:03
@trask
Copy link
Member

trask commented Sep 13, 2021

@alesj latest failure is just formatting. running ./gradlew spotlessApply locally should fix it up.

Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alesj ,
Please take a look at the our Instrumenter API (posted a link to the class and some examples in one comment) - in general we want all our instrumentations to use it to generate telemetry (although there are still some that we haven't refactored yet).

@alesj
Copy link
Contributor Author

alesj commented Sep 15, 2021

@mateuszrzeszutek OK, moved my stuff to Instrumenter API + moved the common code to library ...

@alesj
Copy link
Contributor Author

alesj commented Sep 15, 2021

Uh merge conflicts ... fixing ...

@alesj alesj force-pushed the kafka_lib_1 branch 2 times, most recently from 49c2070 to 170837c Compare September 15, 2021 22:29
@alesj
Copy link
Contributor Author

alesj commented Sep 17, 2021

@mateuszrzeszutek @trask any idea how to limit logging in the test?
Since that log4j.properties doesn't help ...

@alesj alesj force-pushed the kafka_lib_1 branch 2 times, most recently from 40dcf49 to 78c75b7 Compare September 28, 2021 12:02
@alesj alesj force-pushed the kafka_lib_1 branch 2 times, most recently from 4b56eb2 to f3574a4 Compare September 29, 2021 13:02
@alesj
Copy link
Contributor Author

alesj commented Sep 29, 2021

@mateuszrzeszutek @trask i've added producer / consumer tracing wrappers to this PR ... let me know what you think

@trask
Copy link
Member

trask commented Sep 30, 2021

thanks @alesj! can you go through and mark conversations resolved where applicable, and make a list of any open questions that were raised either by reviewers or by yourself? then we'll go ahead and merge and we can create a tracking issue for the open questions / follow-ups (if any) that anyone can take

@alesj
Copy link
Contributor Author

alesj commented Sep 30, 2021

OK, all conversations resolved.
Atm I cannot think of any open questions -- imho, the docs are in-place for interceptors, wrappers as well, and we established that config(Map) doesn't work for a more custom OpenTelemetry instance.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @alesj, kafka library instrumentation is a great addition to the project! and thanks for your patience with the reviews and merge conflicts! I will merge shortly 🎉

@trask trask merged commit ff0bf0a into open-telemetry:main Oct 2, 2021
@mateuszrzeszutek
Copy link
Member

Thanks @alesj! 🚀

@rahja
Copy link

rahja commented Oct 6, 2021

Hi folks, we were looking to add instrumentation for our kafka apps and not able to find any documentation how to do that using opentelemetry-java-instrumentation javaagent. I stumbled upon this commit, which looks like came jit for us :). Can you guys help with how do we use this feature. We have all of kafka consumer, producer and streaming clients in our code and need to instrument all of these.

@trask
Copy link
Member

trask commented Oct 6, 2021

hey @rahja!

documentation how to do that using opentelemetry-java-instrumentation javaagent

if you want to use the javaagent, you can follow the getting started instructions and it should automatically instrument kafka for you.

this PR is about using kafka instrumentation without the javaagent

@rahja
Copy link

rahja commented Oct 6, 2021

Hi @trask, thanks for your response. We did follow getting started document and started getting all the traces, though producer and consumer traces don't get connected with each other. Link between them is getting broken somewhere, looks like parent trace-ids are not being sent from producer to consumer. Any suggestions on how to make that work? it will be very helpful if you can point me to right support channel or document for this. Appreciate you response.

@mateuszrzeszutek
Copy link
Member

Hey @rahja ,
Can you create a new issue wit the details of your setup? E.g. what kafka-related libraries you're using, what versions, etc.

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

Successfully merging this pull request may close these issues.

5 participants