Skip to content

refactor: mv collector to subpackage - #4424

Merged
chrisgacsal merged 3 commits into
mainfrom
refactor/collector-submod
May 26, 2026
Merged

chrisgacsal merged 3 commits into
mainfrom
refactor/collector-submod

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented May 25, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Move benthos-collector to a sub-module in order to isolate its dependencies from openmeter services.
Releasing the collector as binary and container image has not changed.

Releasing the collector as a separate go module is not implemented in this PR however can be added later on if there is a need for it.

Summary by CodeRabbit

  • Chores
    • Consistent version stamping with a default VERSION for release metadata.
    • Make-time validation of target OS/ARCH and standardized per-platform release output directories and archive naming.
    • Release process now prepares/clears output directories, writes the built binary into the release folder, and includes README/LICENSE in packages.
    • Docker build updated to fetch and build dependencies for the collector module for reproducible builds.

Review Change Stack

@chrisgacsal
chrisgacsal requested review from tothandras and turip May 25, 2026 12:29
@chrisgacsal chrisgacsal self-assigned this May 25, 2026
@chrisgacsal chrisgacsal added the release-note/misc Miscellaneous changes label May 25, 2026
@chrisgacsal
chrisgacsal requested a review from a team as a code owner May 25, 2026 12:29
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Makefile centralizes collector paths (ROOT_DIR, COLLECTOR_DIR, COLLECTOR_RELEASE_OUTPUT_DIR), adds a release-output helper that validates GOOS/GOARCH, and updates build targets to run from ./collector. The Docker builder now downloads and builds using the collector module (go mod download -C ./collector; go build -C ./collector ./cmd).

Changes

Collector Build Module Independence

Layer / File(s) Summary
Makefile variables and release target
Makefile
Adds ROOT_DIR and VERSION, introduces COLLECTOR_DIR and COLLECTOR_RELEASE_OUTPUT_DIR, adds collector-release-output-dir target (validates GOOS/GOARCH and creates the dir), and rewires build-benthos-collector-release to go build -C $(COLLECTOR_DIR) and place artifacts under the computed release dir.
Release naming and archive target
Makefile
Introduces COLLECTOR_RELEASE_NAME and updates archive-benthos-collector-release to use that name and validate GOOS/GOARCH at make-time.
Makefile local build target update
Makefile
Updates build-benthos-collector to run go build -C $(COLLECTOR_DIR), target ./cmd, and output to ../build/benthos-collector.
Dockerfile builder stage
benthos-collector.Dockerfile
Copies collector/go.mod and collector/go.sum into ./collector, runs go mod download -C ./collector, and updates the build to go build -C ./collector -o /usr/local/bin/benthos ./cmd.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: moving benthos-collector to a sub-module to isolate dependencies, which is clearly demonstrated by the Makefile and Dockerfile changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/collector-submod

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread collector/go.mod

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

19 Open source vulnerabilities detected - critical severity
Aikido detected 19 vulnerabilities across 12 packages, it includes 2 critical, 6 high, 9 medium and 2 low vulnerabilities.

Details

Remediation Aikido suggests bumping the vulnerable packages to a safe version.

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment thread go.mod

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 Open source vulnerabilities detected - high severity
Aikido detected 4 vulnerabilities across 2 packages, it includes 3 high and 1 medium vulnerabilities.

Details

Remediation Aikido suggests bumping the vulnerable packages to a safe version.

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benthos-collector.Dockerfile`:
- Line 14: Remove the trailing whitespace in the Dockerfile ENV declaration;
edit the line containing ENV GOMODCACHE=/go/pkg/mod (the ENV GOMODCACHE
assignment) so it ends exactly with "/go/pkg/mod" with no extra spaces or tabs
after it to fix formatting.

In `@Makefile`:
- Around line 118-124: The outdir variable is wrong for commands run from the
repo root: change outdir="../build/release/benthos-collector_$(GOOS)_$(GOARCH)"
to a repo-root relative path (e.g.
outdir="build/release/benthos-collector_$(GOOS)_$(GOARCH)") so rm -rf
"$$outdir", mkdir -p "$$outdir" and cp README.md LICENSE "$$outdir/" operate
inside the repo; keep the go build -C ./collector -o "$$outdir/benthos"
invocation (it will correctly write the binary into the repo-relative outdir).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f2b951ab-7ec3-490b-b890-91bf92fb955d

📥 Commits

Reviewing files that changed from the base of the PR and between e1a6265 and f67b827.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (4)
  • Makefile
  • benthos-collector.Dockerfile
  • collector/cmd/main.go
  • collector/cmd/version.go

Comment thread benthos-collector.Dockerfile Resolved
Comment thread Makefile Resolved
turip
turip previously approved these changes May 25, 2026
turip
turip previously approved these changes May 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Line 130: The cleanup command is quoting the glob so the shell won't expand
the asterisk; update the rm invocation that uses COLLECTOR_RELEASE_OUTPUT_DIR so
the directory path is quoted but the wildcard is outside the quotes (e.g. change
the current "`@rm` -rf \"$(COLLECTOR_RELEASE_OUTPUT_DIR)/*\" && \" to use
"$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or an equivalent unquoted glob), ensuring
the directory contents are actually removed while still safely quoting the
variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6db12db0-e635-4ef1-bec5-147751bdab23

📥 Commits

Reviewing files that changed from the base of the PR and between f67b827 and 86bbf0a.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (4)
  • Makefile
  • benthos-collector.Dockerfile
  • collector/cmd/main.go
  • collector/cmd/version.go

Comment thread Makefile Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
Makefile (1)

130-130: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix release output cleanup: quoted glob prevents expansion

The * is inside the quotes, so the shell won't expand it—you'll just try to remove a literal file named * instead of the directory contents.

💡 Suggested fix
-	`@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" && \
+	`@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* && \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 130, The Makefile cleanup command uses a quoted glob
"$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" which prevents shell expansion; change the
command that removes release output (the rm -rf invocation referencing
COLLECTOR_RELEASE_OUTPUT_DIR) to allow globbing by moving the wildcard outside
the quotes (e.g., use "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or unquoted DIR/*) so
the directory contents are deleted correctly, and keep quoting only around the
variable itself to preserve spaces in the path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@Makefile`:
- Line 130: The Makefile cleanup command uses a quoted glob
"$(COLLECTOR_RELEASE_OUTPUT_DIR)/*" which prevents shell expansion; change the
command that removes release output (the rm -rf invocation referencing
COLLECTOR_RELEASE_OUTPUT_DIR) to allow globbing by moving the wildcard outside
the quotes (e.g., use "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* or unquoted DIR/*) so
the directory contents are deleted correctly, and keep quoting only around the
variable itself to preserve spaces in the path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b9ed760-8e8b-4c32-a9be-33aedc922757

📥 Commits

Reviewing files that changed from the base of the PR and between 86bbf0a and 2894a72.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (4)
  • Makefile
  • benthos-collector.Dockerfile
  • collector/cmd/main.go
  • collector/cmd/version.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
benthos-collector.Dockerfile (1)

22-27: ⚡ Quick win

You can drop the root-module go mod download in this image path.

Now that the build is fully collector-module based, keeping both root and collector dependency downloads adds extra build time/cache churn for little value.

💡 Suggested simplification
-COPY --link go.mod go.sum ./
-
-RUN --mount=type=cache,target=/go/pkg/mod \
-    --mount=type=cache,target=/go/cache \
-    go mod download -x
-
 COPY --link collector/go.mod collector/go.sum ./collector/

 RUN --mount=type=cache,target=/go/pkg/mod \
     --mount=type=cache,target=/go/cache \
     go mod download -C ./collector -x
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benthos-collector.Dockerfile` around lines 22 - 27, Remove the redundant
root-module dependency download and keep only the collector-module download:
delete any earlier RUN that executes "go mod download" for the root module so
the only dependency fetch is the existing "go mod download -C ./collector -x"
(the COPY --link collector/go.mod collector/go.sum ./collector/ and the RUN
mounting caches + go mod download -C ./collector -x should remain). This
eliminates extra build time and cache churn while preserving module-scoped
dependency resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Makefile`:
- Line 5: The global default VERSION ?= unknown prevents existing guards like if
[ -z "$(VERSION)" ] from detecting a missing version; remove the global VERSION
?= unknown line from the Makefile so VERSION remains unset by default (or make
it explicitly empty), and either set VERSION only in the specific
release/publish target or update the guards (the if [ -z "$(VERSION)" ] checks)
to also reject the literal "unknown" (e.g., test for -z or = "unknown") so
targets requiring an explicit version fail fast.

---

Nitpick comments:
In `@benthos-collector.Dockerfile`:
- Around line 22-27: Remove the redundant root-module dependency download and
keep only the collector-module download: delete any earlier RUN that executes
"go mod download" for the root module so the only dependency fetch is the
existing "go mod download -C ./collector -x" (the COPY --link collector/go.mod
collector/go.sum ./collector/ and the RUN mounting caches + go mod download -C
./collector -x should remain). This eliminates extra build time and cache churn
while preserving module-scoped dependency resolution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 256df2dc-2c9b-41f1-9373-0a8b8eaf419b

📥 Commits

Reviewing files that changed from the base of the PR and between 2894a72 and 1994782.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (4)
  • Makefile
  • benthos-collector.Dockerfile
  • collector/cmd/main.go
  • collector/cmd/version.go

Comment thread Makefile Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Makefile (1)

128-129: 💤 Low value

Redundant validation – the order-only prereq already checks these.

Lines 128-129 duplicate the GOOS/GOARCH validation that's already in the collector-release-output-dir prerequisite (lines 118-119). You can drop these lines safely.

♻️ Proposed cleanup
 build-benthos-collector-release: | collector-release-output-dir ## Cross-compile benthos-collector for release (set GOOS/GOARCH/VERSION)
 	$(call print-target)
-	$(if $(GOOS),,$(error GOOS is not set))
-	$(if $(GOARCH),,$(error GOARCH is not set))
 	`@rm` -rf "$(COLLECTOR_RELEASE_OUTPUT_DIR)"/* && \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 128 - 129, Remove the redundant GOOS/GOARCH checks by
deleting the two lines `$(if $(GOOS),,$(error GOOS is not set))` and `$(if
$(GOARCH),,$(error GOARCH is not set))` from the Makefile; the target
prerequisite `collector-release-output-dir` already performs these order-only
validations, so keep that prerequisite and remove these duplicate checks to
avoid repetition.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Makefile`:
- Around line 128-129: Remove the redundant GOOS/GOARCH checks by deleting the
two lines `$(if $(GOOS),,$(error GOOS is not set))` and `$(if $(GOARCH),,$(error
GOARCH is not set))` from the Makefile; the target prerequisite
`collector-release-output-dir` already performs these order-only validations, so
keep that prerequisite and remove these duplicate checks to avoid repetition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 594aebe9-c700-4d4d-b4ba-71a9203a9e17

📥 Commits

Reviewing files that changed from the base of the PR and between 1994782 and d096946.

⛔ Files ignored due to path filters (4)
  • collector/go.mod is excluded by !**/*.mod
  • collector/go.sum is excluded by !**/*.sum, !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (4)
  • Makefile
  • benthos-collector.Dockerfile
  • collector/cmd/main.go
  • collector/cmd/version.go

@chrisgacsal
chrisgacsal merged commit 0d31958 into main May 26, 2026
27 of 29 checks passed
@chrisgacsal
chrisgacsal deleted the refactor/collector-submod branch May 26, 2026 08:26

This branch was previously deployed

1 inactive deployment
dev — 25b6385f Deployed May 25, 2026 by chrisgacsal via Migration Checks #14620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants