Skip to content

build: Introduce Tool for OTel Engine Generation Instead of Generate File#5550

Closed
blewis12 wants to merge 10 commits intomainfrom
blewis12/move-collector-generation-to-tools
Closed

build: Introduce Tool for OTel Engine Generation Instead of Generate File#5550
blewis12 wants to merge 10 commits intomainfrom
blewis12/move-collector-generation-to-tools

Conversation

@blewis12
Copy link
Copy Markdown
Member

@blewis12 blewis12 commented Feb 17, 2026

Brief description of Pull Request

The original purpose of this branch was to add a step before generating the collector that will remove all generated files so that we're generating "from scratch". This is because there have been a couple times that modifications to the alloy and alloy_engine go.mod files have broken the go.mod file in the collector/ directory. Annoyingly, this collector/go.mod file has to be valid in order for the OCB generation to run to fix things - I think this is because running go commands first checks if the relevant go.mod file is valid, so we run into a chicken vs egg situation

The way to avoid this is to ensure that code generation runs with a separate go.mod file, outside of the collector directory. This way it doesn't matter if the collector go.mod file is valid or not in order to re-generate itself. This PR therefore moves the generation code into tools/generate-otel-engine-collector - which like tools/generate-module-dependencies is implemented as a CLI tool. The steps are the exact same as before but with two differences:

  1. We now have a --from-scratch option which is enabled by default, which will remove generated files before re-generating them to avoid invalid states
  2. We call the OCB tool via code instead of via go generate

TODO:

  • Do we actually need --from-scratch or is having a separate go.mod file managing the tooling enough?
  • Could we use magefiles? having a CLI feels kinda hard to read

@blewis12 blewis12 force-pushed the blewis12/run-code-generation-automatically-for-local-alloy-build branch from 6aa1917 to 6aeece4 Compare March 10, 2026 20:48
Base automatically changed from blewis12/run-code-generation-automatically-for-local-alloy-build to main March 11, 2026 08:54
@blewis12 blewis12 closed this Apr 24, 2026
@blewis12 blewis12 deleted the blewis12/move-collector-generation-to-tools branch April 24, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant