Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oteltest: make CheckReceivers environment more similar to the collector #43302

Merged
merged 6 commits into from
Mar 17, 2025

Conversation

mauri870
Copy link
Member

@mauri870 mauri870 commented Mar 14, 2025

The CheckReceivers function is designed to start receivers in the same process to assert conditions. This simulated environment should closely resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using the factory and only then starts each component. Previously, we were creating and starting each receiver sequentially, which is incorrect and masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the collector logger. This core includes certain fields—specifically data_type, kind, and name. In the tests, these fields were previously missing, so this PR ensures they are included.

Last but not least, replace Eventually with EventuallyWithT so we aggregate assertions properly.

Proposed commit message

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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

Sorry, something went wrong.

The CheckReceivers function is designed to start receivers in the same
process to assert conditions. This simulated environment should closely
resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using
the factory and only then starts each component. Previously, we were
creating and starting each receiver sequentially, which is incorrect and
masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the
collector logger. This core includes certain fields—specifically
data_type, kind, and name. In the tests, these fields were previously
missing, so this PR ensures they are included.
@mauri870 mauri870 added cleanup Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Mar 14, 2025
@mauri870 mauri870 self-assigned this Mar 14, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 14, 2025
Copy link
Contributor

mergify bot commented Mar 14, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @mauri870? 🙏.
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.

@mauri870 mauri870 marked this pull request as ready for review March 14, 2025 15:27
@mauri870 mauri870 requested a review from a team as a code owner March 14, 2025 15:27
@elasticmachine
Copy link
Collaborator

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

@mauri870 mauri870 force-pushed the oteltest-fix-logger-fields branch from 9222265 to bacd8b8 Compare March 14, 2025 16:06
@mauri870 mauri870 added backport-8.x Automated backport to the 8.x branch with mergify backport-9.0 Automated backport to the 9.0 branch labels Mar 17, 2025
@mauri870 mauri870 merged commit 8d31036 into elastic:main Mar 17, 2025
147 checks passed
mergify bot pushed a commit that referenced this pull request Mar 17, 2025
…or (#43302)

* oteltest: make CheckReceivers environment more similar to the collector

The CheckReceivers function is designed to start receivers in the same
process to assert conditions. This simulated environment should closely
resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using
the factory and only then starts each component. Previously, we were
creating and starting each receiver sequentially, which is incorrect and
masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the
collector logger. This core includes certain fields—specifically
data_type, kind, and name. In the tests, these fields were previously
missing, so this PR ensures they are included.

* remove i++

* use EventuallyWithT for assertions

* fix imports

* specify factory per receiver

(cherry picked from commit 8d31036)
mergify bot pushed a commit that referenced this pull request Mar 17, 2025
…or (#43302)

* oteltest: make CheckReceivers environment more similar to the collector

The CheckReceivers function is designed to start receivers in the same
process to assert conditions. This simulated environment should closely
resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using
the factory and only then starts each component. Previously, we were
creating and starting each receiver sequentially, which is incorrect and
masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the
collector logger. This core includes certain fields—specifically
data_type, kind, and name. In the tests, these fields were previously
missing, so this PR ensures they are included.

* remove i++

* use EventuallyWithT for assertions

* fix imports

* specify factory per receiver

(cherry picked from commit 8d31036)
mauri870 added a commit that referenced this pull request Mar 18, 2025
…or (#43302) (#43319)

* oteltest: make CheckReceivers environment more similar to the collector

The CheckReceivers function is designed to start receivers in the same
process to assert conditions. This simulated environment should closely
resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using
the factory and only then starts each component. Previously, we were
creating and starting each receiver sequentially, which is incorrect and
masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the
collector logger. This core includes certain fields—specifically
data_type, kind, and name. In the tests, these fields were previously
missing, so this PR ensures they are included.

* remove i++

* use EventuallyWithT for assertions

* fix imports

* specify factory per receiver

(cherry picked from commit 8d31036)

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
mauri870 added a commit that referenced this pull request Mar 18, 2025
…or (#43302) (#43318)

* oteltest: make CheckReceivers environment more similar to the collector

The CheckReceivers function is designed to start receivers in the same
process to assert conditions. This simulated environment should closely
resemble the real OTel collector startup.

This PR fixes some inconsistencies in the test environment.

First, when instantiating receivers, the collector first creates them using
the factory and only then starts each component. Previously, we were
creating and starting each receiver sequentially, which is incorrect and
masked issues with global state when multiple receivers were present.

Second, a Beats receiver logger inherits from the zap.Core of the
collector logger. This core includes certain fields—specifically
data_type, kind, and name. In the tests, these fields were previously
missing, so this PR ensures they are included.

* remove i++

* use EventuallyWithT for assertions

* fix imports

* specify factory per receiver

(cherry picked from commit 8d31036)

Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-9.0 Automated backport to the 9.0 branch cleanup Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants