Skip to content

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

Merged
andrzej-stencel merged 9 commits into
open-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 into
open-telemetry:mainfrom
singhvibhanshu:fix/47193

Conversation

@singhvibhanshu

Copy link
Copy Markdown
Member

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

axw commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

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

@axw axw left a comment

Copy link
Copy Markdown
Contributor

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
Member Author

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

@axw axw left a comment

Copy link
Copy Markdown
Contributor

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
Member Author

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

@paulojmdias paulojmdias left a comment

Copy link
Copy Markdown
Member

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
Member 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

otelbot Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

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.

AndrewCharlesHay pushed a commit to AndrewCharlesHay/opentelemetry-collector-contrib that referenced this pull request Apr 23, 2026
…utgoing records (open-telemetry#47201)

## Description

Resolves open-telemetry#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

- [x] added `TestMakeFranzMessages_RecordHeaders`
- [x] all 147 tests passed locally

---------

Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
gracewehner pushed a commit to gracewehner/opentelemetry-collector-contrib that referenced this pull request Apr 29, 2026
…utgoing records (open-telemetry#47201)

## Description

Resolves open-telemetry#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

- [x] added `TestMakeFranzMessages_RecordHeaders`
- [x] all 147 tests passed locally

---------

Signed-off-by: singhvibhanshu <singhvibhanshu@hotmail.com>
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