Skip to content

[EDOT] - add header setter extension#9903

Merged
VihasMakwana merged 14 commits intoelastic:mainfrom
VihasMakwana:add-header-setter
Sep 19, 2025
Merged

[EDOT] - add header setter extension#9903
VihasMakwana merged 14 commits intoelastic:mainfrom
VihasMakwana:add-header-setter

Conversation

@VihasMakwana
Copy link
Copy Markdown
Contributor

@VihasMakwana VihasMakwana commented Sep 12, 2025

What does this PR do?

This PR adds headersettetextension to EDOT.

Why is it important?

This extension is pretty useful to set headers based on request context/based on the configurations and can be helpful to route requests to various backends. We recently got an issue for same.

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

  1. Build elastic-agent from this branch.
  2. Run the following config:
receivers:
  filelog:
    include: [ /var/log/system.log ]
    start_at: beginning
    storage: file_storage/filelogreceiver

exporters:
  debug:
    verbosity: detailed
    sampling_initial: 10000
    sampling_thereafter: 10000

extensions:
  headers_setter:
    headers:
    - action: upsert
      key: User-ID
      value: user_id

service:
  extensions: [headers_setter]
  pipelines:
    logs:
      receivers: [filelog]
      exporters:
        - debug

Related issues

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Sep 12, 2025

This pull request does not have a backport label. Could you fix it @VihasMakwana? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@VihasMakwana VihasMakwana marked this pull request as ready for review September 12, 2025 13:17
@VihasMakwana VihasMakwana requested a review from a team as a code owner September 12, 2025 13:17
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Sep 12, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

swiatekm
swiatekm previously approved these changes Sep 12, 2025
@swiatekm swiatekm self-requested a review September 12, 2025 15:44
Copy link
Copy Markdown
Member

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

Can you add the extension to tests which ensure the components we ship actually start correctly? https://github.com/elastic/elastic-agent/blob/main/internal/pkg/otel/testdata/all-components.yml for example.

swiatekm
swiatekm previously approved these changes Sep 15, 2025
@swiatekm
Copy link
Copy Markdown
Member

Do we need to backport this?

@VihasMakwana VihasMakwana added the backport-9.1 Automated backport to the 9.1 branch label Sep 16, 2025
Comment thread internal/pkg/otel/README.md Outdated
@swiatekm
Copy link
Copy Markdown
Member

I'm seeing the same test failures here as in #9952, which suggests broader breakage.

@swiatekm
Copy link
Copy Markdown
Member

@VihasMakwana can you rebase on main? This should fix the test failures.

Comment thread changelog/fragments/1757668211-add-headersetter-extension-to-EDOT.yaml Outdated
@elasticmachine
Copy link
Copy Markdown
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

History

cc @VihasMakwana

@elastic-sonarqube
Copy link
Copy Markdown

@VihasMakwana VihasMakwana merged commit 593a8b9 into elastic:main Sep 19, 2025
23 checks passed
@swiatekm swiatekm added the backport-8.19 Automated backport to the 8.19 branch label Sep 19, 2025
mergify Bot pushed a commit that referenced this pull request Sep 19, 2025
* add header setter extensions

* go.mod and notice

* revert otel.yml

* add header setter to test config

* spelling

* go.mod

* doc

(cherry picked from commit 593a8b9)

# Conflicts:
#	go.mod
#	internal/pkg/otel/components.go
mergify Bot pushed a commit that referenced this pull request Sep 19, 2025
* add header setter extensions

* go.mod and notice

* revert otel.yml

* add header setter to test config

* spelling

* go.mod

* doc

(cherry picked from commit 593a8b9)

# Conflicts:
#	go.mod
#	internal/pkg/otel/components.go
"go.opentelemetry.io/collector/receiver"

// Receivers:
headersetterextension "github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension"
Copy link
Copy Markdown
Contributor

@mykola-elastic mykola-elastic Sep 19, 2025

Choose a reason for hiding this comment

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

It is not a receiver, extension section is below (lines 63 and down) @swiatekm @VihasMakwana

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.

noticed because it caused some merge conflicts in #9858

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.

Added a small fix in the PR: #10079

VihasMakwana added a commit that referenced this pull request Sep 22, 2025
* [EDOT] - add header setter extension (#9903)

* add header setter extensions

* go.mod and notice

* revert otel.yml

* add header setter to test config

* spelling

* go.mod

* doc

(cherry picked from commit 593a8b9)

# Conflicts:
#	go.mod
#	internal/pkg/otel/components.go

* notice and conflicts

---------

Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com>
Co-authored-by: Vihas <vihas.makwana@elastic.co>
VihasMakwana added a commit that referenced this pull request Sep 22, 2025
* [EDOT] - add header setter extension (#9903)

* add header setter extensions

* go.mod and notice

* revert otel.yml

* add header setter to test config

* spelling

* go.mod

* doc

(cherry picked from commit 593a8b9)

# Conflicts:
#	go.mod
#	internal/pkg/otel/components.go

* notice and conflicts

---------

Co-authored-by: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com>
Co-authored-by: Vihas <vihas.makwana@elastic.co>
@swiatekm swiatekm removed backport-8.19 Automated backport to the 8.19 branch backport-9.1 Automated backport to the 9.1 branch labels Sep 22, 2025
intxgo pushed a commit to intxgo/elastic-agent that referenced this pull request Sep 24, 2025
* add header setter extensions

* go.mod and notice

* revert otel.yml

* add header setter to test config

* spelling

* go.mod

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

Labels

Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OTel Collector Contrib headerssetterextension to EDOT

8 participants