Skip to content

Conversation

@swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Oct 22, 2025

What does this PR do?

When running the otel collector in-process, it passes env variables via a config provider wrapper instead of using setenv. The solution is a bit hacky, but this mode isn't the default and is likely to be removed shortly.

Why is it important?

The latter is not thread-safe and leads to race conditions. In particular, we have some peculiar flaky test failures on MacOS in unit tests that do this.

Checklist

  • 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

How to test this PR locally

Running existing unit tests is enough.

Related issues

@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2025

This pull request does not have a backport label. Could you fix it @swiatekm? 🙏
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.

@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 22, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @swiatekm

@swiatekm swiatekm added backport-8.19 Automated backport to the 8.19 branch backport-9.2 Automated backport to the 9.2 branch Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Oct 22, 2025
@swiatekm swiatekm marked this pull request as ready for review October 22, 2025 15:45
@swiatekm swiatekm requested a review from a team as a code owner October 22, 2025 15:45
@elasticmachine
Copy link
Contributor

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

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

This LGTM considering we will remove this (probably once we get beats receivers enabled by default).

@swiatekm swiatekm merged commit 5546bd7 into main Oct 23, 2025
29 of 30 checks passed
@swiatekm swiatekm deleted the fix/dont-use-setenv branch October 23, 2025 10:09
mergify bot pushed a commit that referenced this pull request Oct 23, 2025
(cherry picked from commit 5546bd7)

# Conflicts:
#	internal/pkg/otel/manager/execution_embedded.go
mergify bot pushed a commit that referenced this pull request Oct 23, 2025
swiatekm added a commit that referenced this pull request Oct 23, 2025
… execution (#10732)

* Avoid using setenv in the embedded collector execution (#10711)

(cherry picked from commit 5546bd7)

# Conflicts:
#	internal/pkg/otel/manager/execution_embedded.go

* Fix conflicts

---------

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
swiatekm added a commit that referenced this pull request Oct 23, 2025
(cherry picked from commit 5546bd7)

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
hayotbisonai pushed a commit to hayotbisonai/elastic-agent that referenced this pull request Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch backport-9.2 Automated backport to the 9.2 branch skip-changelog 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.

[Flaky Test]: TestOTelManager_Ports/in-process_execution

5 participants