Skip to content

feat(agent): enable service.profilesSupport feature gate by default - #2274

Open
royrajan13 wants to merge 2 commits into
aws:mainfrom
royrajan13:feat/enable-profiles-support-gate
Open

feat(agent): enable service.profilesSupport feature gate by default#2274
royrajan13 wants to merge 2 commits into
aws:mainfrom
royrajan13:feat/enable-profiles-support-gate

Conversation

@royrajan13

@royrajan13 royrajan13 commented Sep 4, 2026

Copy link
Copy Markdown

Description of the issue

Issue: #2273

Configuring a profiles pipeline makes the agent fail to start, because the
collector's profiles signal is gated behind service.profilesSupport (alpha, off
by default in collector v0.124.0):

pipeline "profiles": profiling signal support is at alpha level, gated under the "service.profilesSupport" feature gate

The agent builds the collector's arguments itself and only ever passes
--config=, so an operator has no supported way to enable the gate.

Description of changes

The agent now appends --feature-gates=+service.profilesSupport to the arguments
it builds for the collector command, so profiles pipelines start without the
operator needing to know the gate exists.

The flag is only appended after checking the collector's feature-gate registry
for an enableable gate with that ID. featuregate.Registry.Set returns an error
for an unknown gate ID, which surfaces as a flag-parse failure and a fatal
startup error. Without the guard, the moment the gate graduates and is deleted
upstream, a routine collector dependency bump would produce an agent that
refuses to start. With it, graduation is a no-op.

The guard also treats StageDeprecated as not enableable, because Set rejects
enabling a deprecated gate with the same class of error, and deprecated is the
pre-deletion state of a graduating gate. A StageStable gate that is still
registered remains enableable, so the flag keeps being passed until the gate is
removed from the registry entirely.

New file cmd/amazon-cloudwatch-agent/featuregates.go holds
collectorFeatureGateArgs and the registry check. amazon-cloudwatch-agent.go
gains one line at the existing cmd.SetArgs site. featuregate moves from the
indirect to the direct require block in go.mod (no version change).

License

By submitting this pull request, I confirm that you can use, modify, copy, and
redistribute this contribution, under the terms of your choice.

Tests

New unit tests in cmd/amazon-cloudwatch-agent/featuregates_test.go cover all
four registry states: gate registered at alpha (flag passed), gate at stable
(flag still passed), gate absent (no flag, no error), and gate deprecated (no
flag, no error).

Rather than string-comparing the produced arguments, each case parses them
through a real featuregate registry flag set, and a separate test asserts the
gate actually flips to enabled -- so the tests validate the flag name and +
syntax against the library rather than against a hardcoded expectation.

  • go build ./... -- pass
  • go test ./cmd/amazon-cloudwatch-agent/ -- pass (whole package)
  • make fmt -- pass, no changes
  • make fmt-sh -- pass, no changes

Requirements

  • Commits are squashed into a logical, reviewable set (one commit for a single change)
  • Commits and PR description comply with Amazon internal guidelines
  • make passes locally (build, unit tests, lint) — go build ./... and go test ./cmd/amazon-cloudwatch-agent/ pass; make lint exits non-zero with pre-existing repo-wide findings that also fail on unmodified main, none in the new file or on either line added to amazon-cloudwatch-agent.go
  • All GitHub Actions checks on the PR are passing — PR Build / PR Test workflows require maintainer approval to run for a first-time contributor
  • Integration test evidence: N/A — no existing integration test category exercises profiles, and the JSON config translator cannot yet emit a profiles pipeline (feat(translator): add profiles section to the JSON config translator #2275 adds that). The gate-argument logic is fully unit-tested; end-to-end profiles evidence lands with a follow-up test PR against amazon-cloudwatch-agent-test.
  • New or updated integration test coverage: N/A — profiles integration coverage will be added in a follow-up amazon-cloudwatch-agent-test PR once feat(translator): add profiles section to the JSON config translator #2275 makes profiles configurable.
  • New functionality has unit tests; bug fixes have a reproducing test
  • Config translation changes include updated golden files — N/A, no translator changes
  • Breaking or customer-visible changes are called out in the PR description — configurations that already contain a profiles pipeline (via -otelconfig) previously failed at startup and now start with the gate enabled; all other configurations see no behavior change

Profiles pipelines are gated behind the collector's alpha
service.profilesSupport feature gate, so a profiles pipeline currently fails
agent startup outright:

    pipeline "profiles": profiling signal support is at alpha level, gated
    under the "service.profilesSupport" feature gate

The agent builds the collector's argv itself and only passes --config, so an
operator has no supported way to enable the gate. It now requests the gate
when building those args, which is what makes profiles usable out of the box.

The request is guarded by a lookup in the collector's feature gate registry.
featuregate.Registry.Set rejects an unknown gate ID (and rejects enabling a
deprecated one), and that error surfaces as a cobra flag parse failure, i.e.
a fatal startup error. Since this gate is on a graduation path and will
eventually be deleted upstream, passing it unconditionally would turn a
routine collector dependency bump into an agent that refuses to start.
Consulting the registry first makes graduation a no-op instead.

Key files:
- cmd/amazon-cloudwatch-agent/featuregates.go: collectorFeatureGateArgs
  builds the --feature-gates arg, skipping any gate the registry cannot
  enable.
- cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go: appends those args
  alongside the existing --config args in runAgent.

Testing:
- New unit tests cover all four registry states: gate registered (arg
  emitted), absent (nil, no error), stable (still enableable, arg emitted),
  and deprecated (treated like absent). The produced args are parsed through
  the real featuregate flag set rather than string-compared, and one test
  asserts the gate ends up enabled after parsing.
- go build ./..., CGO_ENABLED=0 go test ./cmd/amazon-cloudwatch-agent/,
  make fmt and make fmt-sh all pass.

Closes aws#2273
@OisinMcMenamin

Copy link
Copy Markdown

Contribution checklist for this PR, filled out against its current state. @royrajan13 — feel free to fold this into the # Requirements section of the description (it replaces that section's current contents; your lint note is preserved in the third item).

Requirements

  • Commits are squashed into a logical, reviewable set (one commit for a single change)
  • Commits and PR description comply with Amazon internal guidelines
  • make passes locally (build, unit tests, lint) — go build ./... and go test ./cmd/amazon-cloudwatch-agent/ pass; make lint exits non-zero with pre-existing repo-wide findings that also fail on unmodified main, none in the new file or on either line added to amazon-cloudwatch-agent.go
  • All GitHub Actions checks on the PR are passing — PR Build / PR Test workflows require maintainer approval to run for a first-time contributor
  • Integration test evidence: N/A — no existing integration test category exercises profiles, and the JSON config translator cannot yet emit a profiles pipeline (feat(translator): add profiles section to the JSON config translator #2275 adds that). The gate-argument logic is fully unit-tested; end-to-end profiles evidence lands with a follow-up test PR against amazon-cloudwatch-agent-test.
  • New or updated integration test coverage: N/A — profiles integration coverage will be added in a follow-up amazon-cloudwatch-agent-test PR once feat(translator): add profiles section to the JSON config translator #2275 makes profiles configurable.
  • New functionality has unit tests; bug fixes have a reproducing test
  • Config translation changes include updated golden files — N/A, no translator changes
  • Breaking or customer-visible changes are called out in the PR description — configurations that already contain a profiles pipeline (via -otelconfig) previously failed at startup and now start with the gate enabled; all other configurations see no behavior change

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.

2 participants