Skip to content

[issues/14372] support ListIterator for Kafka consumer client#14707

Closed
patpatpat123 wants to merge 7 commits intoopen-telemetry:mainfrom
patpatpat123:main
Closed

[issues/14372] support ListIterator for Kafka consumer client#14707
patpatpat123 wants to merge 7 commits intoopen-telemetry:mainfrom
patpatpat123:main

Conversation

@patpatpat123
Copy link
Copy Markdown
Contributor

Hello team,

This PR is to address issue #14372

Problem it is trying to solve:

As of today, Spark Structured Streaming Kafka Consumer, upon consuming a message with a valid W3C header with trace, is not continuing, nor propagating the trace on the Spark side.

Root cause analysis:

It seems Spark Structured Streaming Kafka Consumer is relying on listIterator C.f. https://github.com/apache/spark/blob/master/connector/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/consumer/KafkaDataConsumer.scala#L593

As of now, Kafka instrumentation does not support listIterator.

Proposed solution

This solution will add TracingListIterator<K, V> implements ListIterator<ConsumerRecord<K, V>> (TracingListIterator.java) which will allow the handling of listIterator (instrumentation/kafka/kafka-clients/kafka-clients-common-0.11/library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/TracingList.java )

Thanks

Many thanks Lauri, Trask, and Jay for the help provided

@patpatpat123 patpatpat123 requested a review from a team as a code owner September 18, 2025 13:24
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Sep 18, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@otelbot-java-instrumentation
Copy link
Copy Markdown
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@patpatpat123
Copy link
Copy Markdown
Contributor Author

Test strategy:

As of today, the traces are separated. There are two separate traces, one from the producer, one from the consumer, without a clear relationship.

To test, I will create the Java agent containing this new code locally.

From there, run the Spark Structured Streaming Kafka Consumer.

Expected result:

We will be able to see the producer-consumer relationship

@patpatpat123 patpatpat123 closed this by deleting the head repository Sep 23, 2025
@patpatpat123
Copy link
Copy Markdown
Contributor Author

My bad...

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.

1 participant