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

Support consumer offset metadata from Kafka source records #5164

Open
jcrean opened this issue Nov 1, 2024 · 3 comments
Open

Support consumer offset metadata from Kafka source records #5164

jcrean opened this issue Nov 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jcrean
Copy link

jcrean commented Nov 1, 2024

Currently, the consumer code in KafkaCustomConsumer is grabbing the topic/partition/timestamp info from the source ConsumerRecord and adding them as attributes in the event metadata. It would be helpful to also have access to the offset field.

This would allow us to add calls to getMetadata("kafka_offset") in our pipelines, as we use this for internal tracking/auditing. Looking at the code, it seems like it would be relatively easy to add this.

@dlvenable
Copy link
Member

@jcrean , Are you looking to get the offset within the partition for each event?

Would you be interested in contributing this change? You can see where we do this for other metadata.

eventMetadata.setAttribute("kafka_timestamp", receivedTimeStamp);
eventMetadata.setAttribute("kafka_timestamp_type", consumerRecord.timestampType().toString());
eventMetadata.setAttribute("kafka_topic", topicName);
eventMetadata.setAttribute("kafka_partition", String.valueOf(partition));
eventMetadata.setExternalOriginationTime(Instant.ofEpochMilli(receivedTimeStamp));
event.getEventHandle().setExternalOriginationTime(Instant.ofEpochMilli(receivedTimeStamp));

@jcrean
Copy link
Author

jcrean commented Nov 21, 2024

@dlvenable Yes exactly, each ConsumerRecord contains the offset within the partition, which is data that we often use internally for tracking/investigations. I'd be happy to take a stab at a PR. Seems like a fairly straightforward change to make.

@jcrean
Copy link
Author

jcrean commented Jan 14, 2025

Hey @dlvenable sorry for the delay. Work has been a bit crazy lately. I finally got around to a PR for this:
#5331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants