Skip to content

Conversation

@blakerouse
Copy link
Contributor

What does this PR do?

Adds a new OTEL_COMPONENT flag that allows building the Elastic Agent with a seperate OTEL EDOT collector binary, instead of it being compiled into the Elastic Agent binary. The OTEL_COMPONENT flag is only temporary and will become the default with no way to turn it off in the future.

The binary is currently named otelcol-component to allow it to live next to the otelcol scripts. Because the OTEL_COMPONENT flag is optional and the packages.yml doesn't really allow that optionality this provides a way for both to exist at the same time.

Once this becomes the only way to build then it will just be otelcol and the scripts will either just be replaced with that actual binary or a symlink if the script is not in the correct place.

NOTE: This does not yet include the agentbeat into the single binary, that will happen in the next PR. This just confirms that building in this mode does work and runs correctly.

Why is it important?

Part of the journey to separate the control plane and data plane components into separate binaries.

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

Disruptive User Impact

None

How to test this PR locally

Run packaging as you normally would on your system to build an Elastic Agent but add the OTEL_COMPONENT="true" option before the mage package. Example below for building on my system is as follows:

PLATFORMS="darwin/arm64" SNAPSHOT="true" EXTERNAL="true" OTEL_COMPONENT="true" PACKAGES="targz" mage package

Once built running elastic-agent otel will spawn the seperate binary and running with elastic-agent run and a configuration that will use the OTEL runtime will also work.

@blakerouse blakerouse self-assigned this Nov 18, 2025
@blakerouse blakerouse requested a review from a team as a code owner November 18, 2025 21:54
@blakerouse blakerouse added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Nov 18, 2025
@blakerouse blakerouse requested a review from pchila November 18, 2025 21:54
@blakerouse blakerouse added skip-changelog opentelemetry Related to the Elastic Distribution of the OpenTelemetry Collector backport-active-all Automated backport with mergify to all the active branches labels Nov 18, 2025
@elasticmachine
Copy link
Contributor

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

@blakerouse
Copy link
Contributor Author

Failing only because it cannot install junit2html. Fixes for that is here - #11238

Once merged I will rebase and then should go green.

@blakerouse
Copy link
Contributor Author

@pchila Thanks for the review. I have updated all your the suggestions.

@cmacknz
Copy link
Member

cmacknz commented Nov 20, 2025

The binary is currently named otelcol-component to allow it to live next to the otelcol scripts.

The binary should probably be called elastic-otel-collector to follow the convention of our Docker image. This is similar to what other vendors name their collectors e.g. https://github.com/aws-observability/aws-otel-collector or https://github.com/observIQ/bindplane-otel-collector

@blakerouse
Copy link
Contributor Author

@cmacknz I updated the binary name to elastic-otel-collector.

@swiatekm
Copy link
Contributor

When I try to build this locally, I get an error about VCS stamping:

elastic-agent git:(edot-binary-buildtag) ✗ OTEL_COMPONENT=true EXTERNAL=true SNAPSHOT=true PACKAGES="tar.gz" PLATFORMS="linux/amd64" mage package
(...)
--- CrossBuild elastic-otel-collector
--- CrossBuild Elastic-Agent
>> otel:golangCrossBuild: Building for linux/amd64
>> golangCrossBuild: Building for linux/amd64
>> Building using: cmd='build/mage-linux-amd64 golangCrossBuild', env=[CC=gcc, CXX=g++, GOARCH=amd64, GOARM=, GOOS=linux, GOTOOLCHAIN=local, PLATFORM_ID=linux-amd64]
>> Building using: cmd='build/mage-linux-amd64 otel:golangCrossBuild', env=[CC=gcc, CXX=g++, GOARCH=amd64, GOARM=, GOOS=linux, GOTOOLCHAIN=local, PLATFORM_ID=linux-amd64]
error obtaining VCS status: exit status 128
        Use -buildvcs=false to disable VCS stamping.
Error: finding repository root: running "go list -f {{.Root}}" failed with exit code 1
Error: failed building for linux/amd64: exit status 1
failed building for linux/amd64: exit status 1
package ran for 30.323247319s
Error: multiple failures: running "docker run --ulimit nofile=262144:262144 --env EXEC_UID=1000 --env EXEC_GID=1001 -v /home/mikolaj/go/pkg/mod:/go/pkg/mod:ro -v elastic-agent-crossbuild-build-cache:/tmp/.cache/go-build --rm --env GOFLAGS=-mod=readonly --env GOCACHE=/tmp/.cache/go-build --env MAGEFILE_VERBOSE= --env MAGEFILE_TIMEOUT= --env SNAPSHOT=true --env DEV=false --env EXTERNAL=true --env FIPS=false --env OTEL_COMPONENT=true -v /home/mikolaj/Projects/elastic-agent:/go/src/github.com/elastic/elastic-agent -w /go/src/github.com/elastic/elastic-agent docker.elastic.co/beats-dev/golang-crossbuild:1.24.10-main-debian11 --build-cmd build/mage-linux-amd64 otel:golangCrossBuild --platforms linux/amd64" failed with exit code 1

@cmacknz
Copy link
Member

cmacknz commented Nov 20, 2025

The two related issues for vcs stamping issue are but that error doesn't immediately look like either of these two:

@cmacknz
Copy link
Member

cmacknz commented Nov 20, 2025

We likely need a temporary CI step to build this way to make sure it doesn't accidentally break in a future PR.

@blakerouse blakerouse requested a review from a team as a code owner November 24, 2025 20:23
@blakerouse
Copy link
Contributor Author

I fixed the VCS issue and I added the packaging steps in the CI to ensure that the build keeps working as this feature is iterated on before it comes the default.

Its ready for another review. Thanks.

@cmacknz @swiatekm @pchila

v1v
v1v previously approved these changes Nov 25, 2025
Copy link
Member

@v1v v1v left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes in the BK pipeline - LGTM, although I wonder if using a buildkite matrix could help here. FIPS was enabled in the past and duplicated the code, so I should avoid duplicating steps and use a dynamic approach instead?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

cc @blakerouse

@blakerouse blakerouse merged commit 9f1c464 into elastic:main Nov 25, 2025
21 checks passed
@github-actions
Copy link
Contributor

@Mergifyio backport 8.19 9.1 9.2

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2025

mergify bot pushed a commit that referenced this pull request Nov 25, 2025
…TEL EDOT binary (#11237)

* Add ability to build seperate edot binary. Add build flag to change build.

* Get this working.

* Fix crossBuild log.

* Fix imports.

* fixes from code review.

* Revert the change for packageAgent.

* Update binary name.

* Fix docker container. Add CI steps for build.

* Change to serial deps.

* Try not using go list.

* Revert "Change to serial deps."

This reverts commit 329de79.

* Fix BK to build windows OTEL_COMPONENT.

(cherry picked from commit 9f1c464)

# Conflicts:
#	internal/pkg/agent/cmd/common.go
#	magefile.go
mergify bot pushed a commit that referenced this pull request Nov 25, 2025
…TEL EDOT binary (#11237)

* Add ability to build seperate edot binary. Add build flag to change build.

* Get this working.

* Fix crossBuild log.

* Fix imports.

* fixes from code review.

* Revert the change for packageAgent.

* Update binary name.

* Fix docker container. Add CI steps for build.

* Change to serial deps.

* Try not using go list.

* Revert "Change to serial deps."

This reverts commit 329de79.

* Fix BK to build windows OTEL_COMPONENT.

(cherry picked from commit 9f1c464)
mergify bot pushed a commit that referenced this pull request Nov 25, 2025
…TEL EDOT binary (#11237)

* Add ability to build seperate edot binary. Add build flag to change build.

* Get this working.

* Fix crossBuild log.

* Fix imports.

* fixes from code review.

* Revert the change for packageAgent.

* Update binary name.

* Fix docker container. Add CI steps for build.

* Change to serial deps.

* Try not using go list.

* Revert "Change to serial deps."

This reverts commit 329de79.

* Fix BK to build windows OTEL_COMPONENT.

(cherry picked from commit 9f1c464)

# Conflicts:
#	internal/edot/cmd/otel.go
#	internal/pkg/agent/cmd/validate.go
#	internal/pkg/agent/main.go
#	magefile.go
blakerouse added a commit that referenced this pull request Nov 25, 2025
…low building a seperate OTEL EDOT binary (#11415)

* Add `OTEL_COMPONENT=true` to packaging to allow building a seperate OTEL EDOT binary (#11237)

* Add ability to build seperate edot binary. Add build flag to change build.

* Get this working.

* Fix crossBuild log.

* Fix imports.

* fixes from code review.

* Revert the change for packageAgent.

* Update binary name.

* Fix docker container. Add CI steps for build.

* Change to serial deps.

* Try not using go list.

* Revert "Change to serial deps."

This reverts commit 329de79.

* Fix BK to build windows OTEL_COMPONENT.

(cherry picked from commit 9f1c464)

# Conflicts:
#	internal/pkg/agent/cmd/common.go
#	magefile.go

* Fix conflicts.

* No windows/arm64 in 8.18.

---------

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
blakerouse added a commit that referenced this pull request Nov 26, 2025
…ow building a seperate OTEL EDOT binary (#11417)

* Add `OTEL_COMPONENT=true` to packaging to allow building a seperate OTEL EDOT binary (#11237)

* Add ability to build seperate edot binary. Add build flag to change build.

* Get this working.

* Fix crossBuild log.

* Fix imports.

* fixes from code review.

* Revert the change for packageAgent.

* Update binary name.

* Fix docker container. Add CI steps for build.

* Change to serial deps.

* Try not using go list.

* Revert "Change to serial deps."

This reverts commit 329de79.

* Fix BK to build windows OTEL_COMPONENT.

(cherry picked from commit 9f1c464)

* Change to SerialDeps.

---------

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches opentelemetry Related to the Elastic Distribution of the OpenTelemetry Collector 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.

6 participants