Skip to content

Conversation

@kirrg001
Copy link
Contributor

@kirrg001 kirrg001 commented Dec 9, 2025

refs https://jsw.ibm.com/browse/INSTA-66145

Description

Added support for @confluentinc/kafka-javascript including full correlation across multiple processes.

Initially inspired by a community Otel instrumentation, but the instrumentation was not finished and lacked support of various features.

Forked into https://github.com/instana/instrumentation-confluent-kafka-javascript and added:

Tasks

Post Release

https://jsw.ibm.com/browse/INSTA-70616

@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from b494aa5 to 702163b Compare December 29, 2025 10:50
kirrg001 added a commit that referenced this pull request Dec 29, 2025
refs #2221

- we had no esm app for the Otel integration
- proofed that it works
@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch 4 times, most recently from 50edd3c to f955561 Compare December 31, 2025 10:19
@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 11640e5 to 81080d1 Compare December 31, 2025 12:53
kirrg001 added a commit that referenced this pull request Jan 2, 2026
refs #2221

- global agent defined once
- some more helpful logs
- oracledb needs sometimes longer on CI to connect to the sidecar
- better cleanup
@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 81080d1 to 00d4ab3 Compare January 2, 2026 08:39
kirrg001 added a commit that referenced this pull request Jan 2, 2026
refs https://jsw.ibm.com/browse/INSTA-66145

- added a single place to prepare the otel data
- extracted from feat: added support for @confluentinc/kafka-javascript  #2221 to improve readability on feat: added support for @confluentinc/kafka-javascript  #2221
- reordered and regrouped code
- no functional changes!
@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 00d4ab3 to af6e9ae Compare January 2, 2026 11:40
*
* Trace correlation does not work with socket.io, because they do not support
* headers or meta data, only payload.
* headers or meta data, only payload!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We did not had support yet for Exit/Entry or Entry/Exit correlation in our integration.
Will re-investigate socket.io via https://jsw.ibm.com/browse/INSTA-70626

* - manipulate the returned context of `setSpan` with our ids
* - the Otel span will be cleaned up automatically from Otel SDK
*/
module.exports.setW3CTraceContext = (api, preparedData, otelSpan, instanaSpan, originalCtx) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

setW3CTraceContext and extractW3CTraceContext can be moved to general utility as soon as we have a second case. This is general logic.

@kirrg001 kirrg001 marked this pull request as ready for review January 5, 2026 12:01
@kirrg001 kirrg001 requested a review from a team as a code owner January 5, 2026 12:01
Copy link
Contributor

@aryamohanan aryamohanan left a comment

Choose a reason for hiding this comment

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

This is really great work 🎖️
I’ve completed my first round of review and will do some testing, then come back with any further feedback.

Thanks for taking care of this Kate ❤️

@@ -0,0 +1,149 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:
It would be good to have a dedicated folder under opentelemetry, for example confluent-kafka/consumer-app.js, to better organize these files. This structure would improve clarity and maintainability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we will create a better structure via https://jsw.ibm.com/browse/INSTA-70618

let sampled = true;
const spanContext = otelSpan.spanContext();

if (spanContext?.traceFlags !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to add some unit test coverage for this file. Normally, TraceFlags should contain a value, right? so having tests would help identify the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines are auto-tested, but I will check the coverage again 👍

@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 7f407dc to 1e12ff8 Compare January 5, 2026 13:06
@instana instana deleted a comment from sonarqubecloud bot Jan 5, 2026
Copy link
Contributor

@aryamohanan aryamohanan left a comment

Choose a reason for hiding this comment

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

❤️

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jan 5, 2026

36.4% Coverage on New Code (required ≥ 80%)

That is wrong, but I understand why this happens:

We install core + collector as zips into the target otel folder. The lines are not counted.

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jan 5, 2026

Try to fix via sonar config
622a80a

Copy link
Contributor

@abhilash-sivan abhilash-sivan left a comment

Choose a reason for hiding this comment

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

Super

@kirrg001
Copy link
Contributor Author

kirrg001 commented Jan 6, 2026

Sonar is not fixed yet. Raised https://jsw.ibm.com/browse/INSTA-70905

@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 4369a71 to 32533f8 Compare January 6, 2026 09:57
@kirrg001 kirrg001 force-pushed the feat-otel-confl-kaf branch from 32533f8 to 13063f9 Compare January 7, 2026 07:54
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
36.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@kirrg001 kirrg001 merged commit 986c8e0 into main Jan 7, 2026
2 of 3 checks passed
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.

4 participants