Skip to content

Remove the unused UDP statistics traits and services #2521

Closed

Description

@josecelano

Subissue of EPIC #1669 (Overhaul: Packages). Found while adding tests to udp-core (#1348).

Goal

Remove the unused public statistics API from udp-core and udp-server:

  • the UdpCoreStatsRepository and UdpServerStatsRepository traits, which SI-30 added for REST API decoupling, together with the async-trait dependency they alone require; and
  • the statistics::services modules (TrackerMetrics and get_metrics()).

Nothing outside each item's own definition and tests consumes them: the REST runtime adapter reads the statistics repositories directly.

Background

SI-30 (#1924) defined three traits so the REST API could depend on narrow interfaces instead of concrete UDP types: BanningStats (udp-core), UdpCoreStatsRepository (udp-core), and UdpServerStatsRepository (udp-server).

SI-30 deferred the REST-side wiring. The contract-first migration (SI-33 #1930, then EPIC #1938 and its SI-4 #1942) decoupled the REST API differently: rest-api-application defines ports (StatsQueryPort and others), and rest-api-runtime-adapter's TrackerStatsAdapter implements them over the concrete repositories (get_stats().await.metric_collection). The traits were never wired, and all those issues are closed, so the traits are leftovers.

BanningStats is not in scope: #2505 already owns its removal.

Evidence on develop (re-checked at cbdbce9c1):

  • Outside their definitions and impls, only two udp-server repository unit tests name the traits.
  • The traits are the only async_trait uses in udp-core and udp-server, so removing them leaves async-trait unused in both packages.
  • Neither crate is published on crates.io, so there is no external semver impact.

Unused statistics services (added to the scope on 2026-10-14, reported by the #1348 agent): in both packages, statistics/services.rs is the only file naming TrackerMetrics or statistics::services::get_metrics, and its only reference is its own test. The REST adapter takes swarm metadata from tracker-core and reads the repositories directly. Removing the modules drops no workspace dependency edge.

Scope

In scope:

  • Remove both traits, their impls, their clippy::double_must_use allowances, the now-unused MetricCollection imports, and the async-trait dependency from both packages.
  • Adapt it_should_initialize_metrics_when_constructed_with_default to read through get_stats(); delete it_should_return_a_snapshot_of_the_initialized_metrics_collection, which only tests the removed method.
  • Note the removal in the EPIC Overhaul: Packages #1669 SI-30 table row.
  • Remove statistics/services.rs (TrackerMetrics, get_metrics(), and its test) and pub mod services; from both packages, moving the accurate statistics event-flow docs to statistics/mod.rs without the stale Metrics field example.

Out of scope:

Decision

Maintainer, 2026-10-14: remove the traits rather than wire rest-api-runtime-adapter through them. The rest-api-application ports already own the REST boundary.

Acceptance Criteria

  • AC1: UdpCoreStatsRepository and UdpServerStatsRepository no longer exist, and no code references them.
  • AC2: cargo machete --with-metadata reports no unused dependency in udp-core or udp-server, and neither package depends on async-trait.
  • AC3: Both REST surfaces are unchanged in JSON and Prometheus formats: /api/v1/stats (UDP server fields) and /api/v1/metrics (udp_tracker_core_requests_received_total and the udp_tracker_server_* metrics).
  • AC4: The adapted udp-server test still verifies that default construction initializes the described metrics.
  • AC5: statistics::services, TrackerMetrics, and statistics::services::get_metrics() no longer exist in either package, and no code references them.
  • AC6: Each package's statistics/mod.rs documents the statistics event flow, and cargo +nightly doc --no-deps for both packages reports no broken intra-doc link.
  • linter all passes, relevant tests pass, and the manual REST stats scenario is recorded in issue-local manual-verification-evidence.md.

Coordination

Specification

The full specification, including the implementation plan, commit points, and verification plan, is in docs/issues/open/2521-1669-remove-unused-udp-stats-traits/ISSUE.md (added by the spec-only PR).

Activity

  1. added
    Code Cleanup / Refactoring
    - Developer -
    on Oct 14, 2026
  2. added 10 commits that reference this issue on Oct 14, 2026
  3. 59 remaining items

  4. added 2 commits that reference this issue on Oct 14, 2026
  5. added 6 commits that reference this issue on Oct 14, 2026
  6. added a commit that references this issue on Oct 14, 2026
  7. added 5 commits that reference this issue on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Developer -Code Cleanup / Refactoringpackagestask

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions