Skip to content

@opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called during KafkaJs transaction (e.g. producer.transaction().sendBatch()) #2741

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

Open
tabomors opened this issue Feb 28, 2025 · 1 comment
Assignees
Labels
bug Something isn't working pkg:instrumentation-kafkajs priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@tabomors
Copy link

tabomors commented Feb 28, 2025

What version of OpenTelemetry are you using?

"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-node": "^0.56.1",
"@opentelemetry/sdk-node": "^0.57.2",

What version of Node are you using?

v22.13.1

What did you do?

I have code that sends batch messages during the kafkajs' transaction, e.g:

// producer is KafkajsProducer

const transaction = await producer.transaction();

transaction.sendBatch(batch)

await transaction.commit()

What did you expect to see?

I expected to see span are emitted for each sendBatch call that happens during kafkajs' transaction and each message in kafka to have traceparent header if it is possible

What did you see instead?

I didn't see any spans were emitted or traceparent header was set

Additional context

I can confirm that if I run it without transaction I see spans are emitted and traceparent header is set

My best guess is producer.transaction().sendBatch() is not wrapped currently, only send methods of producer are wrapped (e.g producer.sendBatch())

https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/instrumentation-kafkajs/src/instrumentation.ts#L133
https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/instrumentation-kafkajs/src/instrumentation.ts#L142

@tabomors tabomors added the bug Something isn't working label Feb 28, 2025
@tabomors tabomors changed the title @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called by KafkaJs transaction (e.g. producer.transaction().sendBatch()) @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called inside of KafkaJs transaction (e.g. producer.transaction().sendBatch()) Feb 28, 2025
@tabomors tabomors changed the title @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called inside of KafkaJs transaction (e.g. producer.transaction().sendBatch()) @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called during KafkaJs' transaction (e.g. producer.transaction().sendBatch()) Feb 28, 2025
@tabomors tabomors changed the title @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called during KafkaJs' transaction (e.g. producer.transaction().sendBatch()) @opentelemetry/instrumentation-kafkajs does not instrument sendBatch or send methods if they are being called during KafkaJs transaction (e.g. producer.transaction().sendBatch()) Feb 28, 2025
@dyladan dyladan added the priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect label Mar 5, 2025
@dyladan
Copy link
Member

dyladan commented Mar 5, 2025

@seemk can you look into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-kafkajs priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

No branches or pull requests

3 participants