Skip to content

refactor(emit): retire legacy backend-collector emitter — target tier never existed - #241

Merged
zzylol merged 1 commit into
mainfrom
retire-legacy-backend-emitter
May 15, 2026
Merged

zzylol merged 1 commit into
mainfrom
retire-legacy-backend-emitter

Conversation

@zzylol

@zzylol zzylol commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Retires emit/backend.rs::generate_backend_collector_config — it emitted OTel-collector YAML for a "backend-role" merge-collector tier that was never deployed in any ASAPCollector configuration. Its output keyed processors as {sketch}_merge with a {mode, group_by} body — a shape no real ASAPCollector processor accepts (real merge processors are factory type {sketch}merge with Config { MetricName string }).
  • Drops 4 OpAMP push call sites (handle_plan, handle_rollback, the /api/v1/collector-config/backend bootstrap handler, and Replanner) that all routed to AgentRole::Backend — which has zero subscribers in current deployment.
  • Sketch merging is unaffected: the typed L5 path's StageId::Backend already routes through emit_backend_streaming_config_json to asapquery-backend's precompute engine over HTTP. That's the real merge path.

What's NOT touched

Kept intentionally — these have separate consumers and warrant their own follow-up decision:

  • types::BackendCollectorConfig + CollectionPlan.backend_config — still populated by optimizer cost/rules and read by metrics_exposer for Prometheus counters.
  • AgentRole::Backend enum variant — public OpAMP role surface, cheap to leave registered.

Test plan

  • cargo check clean (only pre-existing warnings)
  • cargo test --lib: 687 passed; 0 failed
  • cargo test --tests: 27 passed; 0 failed
  • cargo test --bin control_plane: 27 passed; 0 failed

🤖 Generated with Claude Code

… never existed

`emit/backend.rs::generate_backend_collector_config` emitted OTel-
collector YAML for a "backend-role" merge-collector tier that was never
actually deployed in any ASAPCollector configuration. Its output keyed
processors as `{sketch}_merge` with a `{mode, group_by}` body — a shape
no ASAPCollector processor accepts (the real merge processors are
factory type `{sketch}merge` with `Config { MetricName string }`).
Anything that pushed this YAML via OpAMP `push_to_role(AgentRole::Backend)`
went to zero subscribers — and any future backend collector that *did*
register would receive a config it couldn't load.

The work this path nominally did — central sketch merging — has been
taken over by the typed L5: `StageId::Backend` routes through
`emit_backend_streaming_config_json`, which posts to asapquery-backend's
precompute engine over HTTP. That's the real merge path.

Removes:
- control_plane/src/emit/backend.rs (function + 3 tests)
- pub mod / re-export entry in emit/mod.rs (table updated to record retirement)
- Imports + 4 call sites:
  - main.rs::handle_plan         — per-plan OpAMP push
  - main.rs::handle_rollback     — rollback OpAMP push
  - main.rs::handle_bootstrap_backend_config + its
    /api/v1/collector-config/backend route (entire handler)
  - replan.rs::Replanner         — replan OpAMP push
- Stale doc-comment in emit/stage_config.rs referencing the retired emitter

Kept (out of scope for this PR):
- types::BackendCollectorConfig struct + CollectionPlan.backend_config
  field — still populated by the optimizer and read by metrics_exposer
  for Prometheus counters. Worth re-assessing in a follow-up.
- AgentRole::Backend enum variant — public OpAMP role surface; cheap to
  leave available.

Build clean. All 687 lib tests + 27 binary tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 371ffce into main May 15, 2026
zzylol added a commit that referenced this pull request May 15, 2026
…gentCollectorConfig (#242)

Now that the legacy backend-collector emitter is retired (#241), the
`BackendCollectorConfig { merge_sketch_type, group_by }` struct on
`CollectionPlan` has no real consumers — both fields are derivative of
`AgentCollectorConfig`:

- `merge_sketch_type` was always set to `agent_config.sketch_type.clone()`
  (literally — see the deleted `let backend_sketch = sketch_type.clone();`
  line in RulesPlanner, and the deleted `backend_config_matches_sketch_type`
  test that asserted the equality as an invariant).
- `group_by` was always `agent_config.aggregate_by.clone()` when set, else
  `vec![]`. The shadow was a true field-by-field duplicate.

Only one site read these fields: the `metrics_exposer` plan-id hash, which
already includes `agent_config.sketch_type`. Replaced `backend_config.group_by`
with `agent_config.aggregate_by` in the hash (option (b) from review) to
preserve the "plan_id changes when grouping changes" observability semantic.

Removes:
- `pub struct BackendCollectorConfig` + the `pub backend_config` field
- 8 initializer sites (store, replan, optimizer/{rules×2, cost test,
  cost/delta test, cost/mod test}, emit/asapquery_backend test,
  metrics_exposer test)
- 3 mutation sites in the optimizer's sketch-type tuning loops
  (cost/mod ×2, pareto)
- The redundant `backend_config_matches_sketch_type` test in rules/mod.rs
- One import of `BackendCollectorConfig` in emit/asapquery_backend.rs

Plan-id hash values shift on this release — they're opaque per-plan
identifiers, so anyone alerting on specific values was already on shaky
ground. The semantics (changes-on-replan, stable-on-refresh) are
preserved.

Build clean. 686 lib tests + 27 binary tests pass (1 less than before
this PR — the deleted redundant-invariant test).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol deleted the retire-legacy-backend-emitter branch July 17, 2026 20:06
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