Skip to content

[beatreceiver] Fix manager.Enabled() usages in OTel mode - #53348

Merged
ebeahan merged 9 commits into
elastic:mainfrom
khushijain21:manager-enabled
Oct 23, 2026
Merged

ebeahan merged 9 commits into
elastic:mainfrom
khushijain21:manager-enabled

Conversation

@khushijain21

@khushijain21 khushijain21 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Proposed commit message

OTel manager returns false when manager.Enabled() is referenced across the codebase whereas the elastic-agent manager returns true. This caused certain side effects. See issue #53106

This PR removes the Enabled() method from the v2Manager interface and the beats repo will now rely on management.UnderAgent() method to evaluate conditionals.

This PR also introduces a new method called func ConfigFromControlProtocol() bool to differentiate beats running under elastic-agent process mode vs in OTel mode. There are certain code paths that must not be invoked by the receivers but should be elastic-agent.

Checklist

  • 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. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

FIxes any bug introduced by otel manager returning false for manager.Enabled() conditions

Related issues

@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@khushijain21 khushijain21 added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Sep 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 22, 2026
@khushijain21 khushijain21 added needs_team Indicates that the issue/PR needs a Team:* label Team:Security-Service Integrations Security Service Integrations Team labels Sep 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 22, 2026
@khushijain21 khushijain21 added needs_team Indicates that the issue/PR needs a Team:* label Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Sep 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 22, 2026
@khushijain21 khushijain21 added needs_team Indicates that the issue/PR needs a Team:* label skip-changelog labels Sep 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 22, 2026
@mergify

mergify Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @khushijain21? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport 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.

Comment thread heartbeat/beater/heartbeat.go Resolved
Comment thread packetbeat/beater/packetbeat.go Resolved
@khushijain21 khushijain21 changed the title Fix manager.enabled usages [beatreceiver] Fix manager.Enabled() usages in OTel mode Sep 23, 2026
@khushijain21 khushijain21 added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Sep 23, 2026
@khushijain21
khushijain21 marked this pull request as ready for review September 23, 2026 09:01
@khushijain21
khushijain21 requested review from a team as code owners September 23, 2026 09:01
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

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

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

Comment thread libbeat/beat/beat.go Resolved
Comment thread packetbeat/beater/packetbeat.go Resolved
Comment thread libbeat/management/management.go Resolved
@khushijain21
khushijain21 marked this pull request as ready for review October 22, 2026 07:13
Comment thread x-pack/libbeat/cmd/instance/beat.go Resolved
userAgentMode and userAgentUnprivilegedMode now read the process-wide
management.UnderAgent() instead of Manager.Enabled(), so the test has to
drive management mode through that flag rather than the fake manager.

Assisted-By: Cursor
Co-authored-by: Cursor <cursoragent@cursor.com>
@khushijain21
khushijain21 requested a review from cmacknz October 22, 2026 13:30

@belimawr belimawr 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.

Just the question about the user agent.

@belimawr belimawr 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.

On a quick glance LGTM. The fact that we're just delaying when b.Info.UserAgent is ready still bugs me a bit, but it's not enough to block the PR.

@ebeahan
ebeahan merged commit 0d42775 into elastic:main Oct 23, 2026
221 of 223 checks passed
@cmacknz cmacknz added the backport-9.6 Automated backport to the 9.6 branch label Oct 26, 2026
@cmacknz

cmacknz commented Oct 26, 2026

Copy link
Copy Markdown
Member

Needs backport to 9.6 - label added

khushijain21 added a commit that referenced this pull request Nov 16, 2026
…54084)

* Fix manager.enabled usages

* fix tests

* fix tests

* fix packetbeat

* address review comments

* Set UnderAgent in TestUserAgentString

userAgentMode and userAgentUnprivilegedMode now read the process-wide
management.UnderAgent() instead of Manager.Enabled(), so the test has to
drive management mode through that flag rather than the fake manager.

Assisted-By: Cursor


* fix user-agent for hbreceiver

---------


(cherry picked from commit 0d42775)

Co-authored-by: Khushi Jain <khushi.jain@elastic.co>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.6 Automated backport to the 9.6 branch skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix uses of b.Manager.Enabled() when running inputs as receivers

6 participants