Skip to content

[exporter/kafka] Add record_headers config to set static headers on outgoing records#47201

Merged
andrzej-stencel merged 9 commits intoopen-telemetry:mainfrom
singhvibhanshu:fix/47193
Apr 13, 2026
Merged

[exporter/kafka] Add record_headers config to set static headers on outgoing records#47201
andrzej-stencel merged 9 commits intoopen-telemetry:mainfrom
singhvibhanshu:fix/47193

Conversation

@singhvibhanshu
Copy link
Copy Markdown
Contributor

Description

Resolves #47193

This PR adds a new record_headers configuration option to the Kafka exporter

Changes made:

  • added record_headers to Config struct
  • updated makeFranzMessages in the franz-go client wrapper to iterate over the configured map and append them as kgo.RecordHeader to the outgoing messages
  • added TestMakeFranzMessages_RecordHeaders to verify headers are successfully attached, bringing test suite to 147 passing tests
  • documented the new field and provided an example in the README.md
  • added .chloggen/fix-47193.yaml

Testing

  • added TestMakeFranzMessages_RecordHeaders
  • all 147 tests passed locally

Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
@axw
Copy link
Copy Markdown
Contributor

axw commented Mar 27, 2026

The issue hasn't been discussed yet. Marking this as draft until agreement is reached.

@axw axw marked this pull request as draft March 27, 2026 00:28
@khushijain21
Copy link
Copy Markdown
Contributor

@singhvibhanshu I think what this is missing is precedence order.

I think we would want include_metadata_key to take precedence if it exists. @paulojmdias wdyt?

@paulojmdias
Copy link
Copy Markdown
Member

I think we would want include_metadata_key to take precedence if it exists. @paulojmdias wdyt?

Mixed feelings about that, but let's discuss in the issue to have a proper agreement there with other codeowners 👍

@axw axw marked this pull request as ready for review April 2, 2026 02:44
Copy link
Copy Markdown
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks @singhvibhanshu. Looks good, just a few comments.

Comment thread exporter/kafkaexporter/README.md Outdated
Comment thread exporter/kafkaexporter/config.go Outdated
Comment thread exporter/kafkaexporter/internal/kafkaclient/franzgo_test.go
@singhvibhanshu
Copy link
Copy Markdown
Contributor Author

This PR got merge conflict.
I'll fix it soon.

Copy link
Copy Markdown
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM, minus the merge conflict. Thanks!

Comment thread exporter/kafkaexporter/internal/kafkaclient/franzgo_test.go Outdated
Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
@singhvibhanshu
Copy link
Copy Markdown
Contributor Author

I've resolved the merge conflicts and modfied the test.
Kindly take a look when you get a chance.
Thank you!

Copy link
Copy Markdown
Member

@paulojmdias paulojmdias left a comment

Choose a reason for hiding this comment

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

LGTM

@singhvibhanshu
Copy link
Copy Markdown
Contributor Author

/rerun

@axw axw added the ready to merge Code review completed; ready to merge by maintainers label Apr 13, 2026
@andrzej-stencel andrzej-stencel merged commit 7f5cdac into open-telemetry:main Apr 13, 2026
209 of 211 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot bot commented Apr 13, 2026

Thank you for your contribution @singhvibhanshu! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exporter/kafka ready to merge Code review completed; ready to merge by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[exporter/kafka] Add option to set headers on outgoing records

6 participants