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

Open
@tabomors

Description

@tabomors

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpkg:instrumentation-kafkajspriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions