feat: Add unexposed otel engine and extension to codebase and change build structure#5114
feat: Add unexposed otel engine and extension to codebase and change build structure#5114
Conversation
ac90fea to
796c875
Compare
37da85e to
667ee33
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces the foundation for an Alloy Collector Distribution built using the OpenTelemetry Collector Builder (OCB). The changes restructure the build graph to support running Alloy with an OpenTelemetry Collector runtime, though the otel subcommand is not yet exposed. The PR includes a new alloyengine extension that embeds the Alloy flow engine within the OTel Collector.
Key changes:
- Refactored command structure to allow exporting and reusing the Alloy CLI components
- Created a new
alloyengineextension for the OTel Collector that runs Alloy's flow engine - Added automated generation of OTel Collector distribution using OCB with a custom builder configuration
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/alloycli/cmd_run.go | Exports RunCommand and modifies interruptContext to accept parent context |
| internal/alloycli/alloycli.go | Exports Command() function for reuse in collector |
| flowcmd/flowcmd.go | Refactors from main package to flowcmd library with exported functions |
| flowcmd/fallback_version.go | Changes from embedded file to reading manifest at runtime |
| extension/alloyengine/* | New OTel extension that wraps and runs Alloy's flow engine |
| collector/* | Generated OTel Collector distribution code and configuration |
| Makefile | Adds targets for collector generation and modifies alloy build path |
| Dockerfile* | Adds BUILD_DISTRO build arg to control distro generation |
| dependency-replacements.yaml | Adds extension and collector modules for dependency management |
🔍 Dependency ReviewBelow are the dependency upgrades and replace updates detected in go.mod changes, along with any code-impact analysis and supporting evidence.
go.opentelemetry.io/collector/confmap v1.45.0 -> v1.49.0 — ✅ SafeSummary:
Evidence from code:
Changelog highlights (module releases between 1.46.0 and 1.49.0 across OpenTelemetry Collector):
Code changes required: None. go.opentelemetry.io/collector/featuregate v1.45.0 -> v1.49.0 — ✅ SafeSummary:
Impact:
Changelog notes:
Code changes required: None. go.uber.org/zap v1.27.0 -> v1.27.1 — ✅ SafeSummary:
Changelog highlights:
Code changes required: None. github.com/hashicorp/go-version v1.7.0 -> v1.8.0 — ✅ SafeSummary:
Changelog highlights:
Code changes required: None. replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter -> github.com/grafana/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.0.0-20260108134526-9817e6c361c9 —
|
631d675 to
b0367c1
Compare
thampiotr
left a comment
There was a problem hiding this comment.
Looking good!
One thing I also wonder about: does the PR dependency review bot need some adjustments to its prompt to look into the right go.mod files?
3f4fd87 to
5a9a773
Compare
a4bf57e to
da33ecf
Compare
da33ecf to
4e94041
Compare
thampiotr
left a comment
There was a problem hiding this comment.
I think we're almost there!
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 29 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
flowcmd/flowcmd.go:39
- Debug statement left in production code. The
fmt.Println("hi")statement should be removed before merging as it serves no functional purpose and pollutes stdout.
thampiotr
left a comment
There was a problem hiding this comment.
From my POV this is ready % couple of minor comments.
Nice work!
3990c07 to
ffbf4b5
Compare
| ## Stability | ||
|
|
||
| This extension is currently marked as **Development** stability level. The API and behavior may change in future releases. | ||
|
|
There was a problem hiding this comment.
Non-blocking question: I'm guessing this is using the OTel stability definitions for upstreaming purposes. Since it lives in alloy for now should we use the alloy stability levels until it can be upstreamed?
There was a problem hiding this comment.
That's a good point actually, I was trying to make this as OTel-ey as possible but when we talk about this feature externally we should be sticking to Alloy stability levels for the time being. I will change that now
kgeckhart
left a comment
There was a problem hiding this comment.
Non-blocking general comment: I found the PR description incredibly helpful for understanding the layout of the changes. I think it could be useful to find a home for some of the content in the README.md and perhaps introducing a collector/README.md
…e collector directory
True, there is going to be a follow up PR containing more documentation - but since this PR includes changes that primarily affect developers and therefore should be referenced in the contributing guide, i've added a README here - along with a brief summary and link in the contributing.md file |
What this PR Introduces
This PR introduces the Alloy Collector Distro, which has it's components defined in an OCB file and generated using the builder tool . The beefy change here is a re-jig of the build graph of the project, which is why I would like to introduce this as a single PR to ensure that folks are on board with it. The
otelsubcommand itself is not exposed yet, this will be introduced in a follow up PR which includes documentation changes.Please bare in mind a fair bit of code here is generated. I will try to provide an overview in the following sections to make it easier to break down
OCB
The components to include in our otel distribution are all defined in our
builder-manifest.yamlOCB file. The file itself references the extensions/exporters/processors and so forth that we want to include, it also definesreplacedirectives that we want to include in our final build. This is what will generate the maingo.modfile in thecollectordirectory that will be the build root for the project. Note that this is important to keep in sync with the replace directives we have in thealloymodule, for which we use the newdependency-replacements.yamlfile and generation targets (relevant design doc)General file structure (relevant design doc)
Changed build graph

Building locally / Makefile changes
When building locally via
make alloy, the entire chain of replacement and collector generation/build will run - I found this to be the smoothest experience when developing locally so I didn't have to think about manually running commands before building in my changes. The time taken to do the generation is also relatively low. However in CI, the generation currently does not run. My reasoning for this is that we are checking in the built/generated code - what is built in CI should be a reflection of the files we are checking in. If we did generation as part of CI, then the user might check in files would not work when building locally but pass in CI or vice versaVersioning
The version of the manifest is currently being kept in sync with the alloy version (currently v1.12.1). IMO we should keep the versioning synced, as
otelis a subcommand of the alloy CLI and so our distro is embedded within alloy from a user-perspective. I feel it'd make more sense for users to see a single version when they runalloy --versionandalloy otel --versionTesting
Very minimal, since command has not been exposed yet - once this is merged, integration tests and lifecycle tests will be added
Change in Binary Size
before:
after:
So this increases the binary size by ~1Mb, due to the collector code being bundled in
relates to #4719
Edit
I've also left out versioning for the alloyextension here - from what I understand, this can be done with release-please - but I feel like this can be done in a follow up PR if we want to actually tag/release this extension for use in external OCB manifests