Skip to content

feat(orchestrator): C3 cluster /stats collector#44

Merged
martinjms merged 1 commit intomainfrom
feat/c3-stats-collector
May 2, 2026
Merged

feat(orchestrator): C3 cluster /stats collector#44
martinjms merged 1 commit intomainfrom
feat/c3-stats-collector

Conversation

@martinjms
Copy link
Copy Markdown
Collaborator

Implements #23 — orchestrator component C3. Fills in the `unimplemented!()` bodies on the `StatsCollector` scaffold landed in PR #40 and unignores the acceptance tests.

What this does

  • `poll_once` — fetches each endpoint sequentially, stores a `StatsSample`, prunes by the sample's own `sampled_at` against the retention window so the rolling-window semantic holds even under bursty polling. Failed fetches don't store a sample and don't abort the round.
  • `current_rates` — computes `bytes_out_per_sec` by diffing oldest/newest in each per-cluster series against `sampled_at`; `egress_aggregate_gbps` is the sum across clusters in Gbps. `delta_hit_rate` is a proxy (until the cluster exposes `broadcasts_attempted` per #94).
  • `time_series_for` — returns the per-endpoint series clone.
  • `run` — simple periodic poll loop driven by `tokio::time::interval`. Never returns under normal operation; production wraps in `tokio::spawn`.

Test plan

  • `cargo test -p arcane-swarm-orchestrator` — 48 passed, 0 failed (3 new C3 + 45 prior)
  • `cargo clippy -p arcane-swarm-orchestrator --all-targets -- -D warnings` clean
  • `cargo fmt --all -- --check` clean

Acceptance tests covered

All 3 from issue #23:

  • `collector_reports_correct_rates_and_counters`
  • `polling_continues_when_cluster_unreachable`
  • `time_series_memory_bounded`

Closes #23.

🤖 Generated with Claude Code

Implements component C3 — fills in the unimplemented!() bodies on the
StatsCollector scaffold landed in PR #40 and unignores the acceptance
tests on tests/stats_collector.rs.

- poll_once: fetches each endpoint sequentially, stores a StatsSample,
  prunes by the sample's own sampled_at against the retention window so
  the rolling-window semantic holds even under bursty polling. Failed
  fetches do not store a sample and do not abort the round.
- current_rates: computes bytes_out_per_sec by diffing oldest/newest in
  each per-cluster series against sampled_at; egress_aggregate_gbps is
  the sum across clusters in Gbps. delta_hit_rate is a proxy until the
  cluster exposes broadcasts_attempted (#94).
- time_series_for: returns the per-endpoint series clone.
- run: simple periodic poll loop driven by tokio::time::interval; never
  returns under normal operation. Production wraps it in tokio::spawn.

Closes #23.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@martinjms martinjms merged commit fea2b12 into main May 2, 2026
1 check passed
@martinjms martinjms deleted the feat/c3-stats-collector branch May 2, 2026 16:18
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.

Orchestrator C3: cluster /stats collector

1 participant