Repository navigation
Description
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
UdpCoreStatsRepositoryandUdpServerStatsRepositorytraits, which SI-30 added for REST API decoupling, together with theasync-traitdependency they alone require; and - the
statistics::servicesmodules (TrackerMetricsandget_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-serverrepository unit tests name the traits. - The traits are the only
async_traituses inudp-coreandudp-server, so removing them leavesasync-traitunused 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_useallowances, the now-unusedMetricCollectionimports, and theasync-traitdependency from both packages. - Adapt
it_should_initialize_metrics_when_constructed_with_defaultto read throughget_stats(); deleteit_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) andpub mod services;from both packages, moving the accurate statistics event-flow docs tostatistics/mod.rswithout the staleMetricsfield example.
Out of scope:
BanningStatsand the banned-IPs count (The UDP banned-IPs metric counts clients that are not banned #2505).- The public
statslock field on the statistics repositories (Make the statistics repositories' metrics lock private #2517). - Changing the REST API ports or the runtime adapter design.
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:
UdpCoreStatsRepositoryandUdpServerStatsRepositoryno longer exist, and no code references them. - AC2:
cargo machete --with-metadatareports no unused dependency inudp-coreorudp-server, and neither package depends onasync-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_totaland theudp_tracker_server_*metrics). - AC4: The adapted
udp-servertest still verifies that default construction initializes the described metrics. - AC5:
statistics::services,TrackerMetrics, andstatistics::services::get_metrics()no longer exist in either package, and no code references them. - AC6: Each package's
statistics/mod.rsdocuments the statistics event flow, andcargo +nightly doc --no-depsfor both packages reports no broken intra-doc link. -
linter allpasses, relevant tests pass, and the manual REST stats scenario is recorded in issue-localmanual-verification-evidence.md.
Coordination
- Overhaul Packages Testing: Add tests for
udp-tracker-corepackage #1348 (unmerged) adds audp-corerepository test that callsUdpCoreStatsRepository::get_metrics_collection(); whichever lands second adapts or deletes it. - Make the statistics repositories' metrics lock private #2517 changes the same two repository files; scopes are disjoint.
- Any Overhaul Packages Testing: Add tests for
udp-tracker-corepackage #1348 test forstatistics::services::get_metrics()is deleted with the module.
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
docs(issues): [torrust#2521] verify the stats and metrics REST surfac…
docs(issues): [torrust#2521] record the package-boundary review
docs(issues): [torrust#2521] make the test-change review gates explicit
docs(issues): [torrust#2521] restore the template's completion checkp…
docs(issues): [torrust#2521] add the documentation acceptance criterion
docs(issues): [torrust#2521] map the evidence and re-verification tas…
docs(issues): [torrust#2521] name the commit where the evidence was r…
docs(issues): [torrust#2521] use stable issue references in related a…
docs(issues): [torrust#2521] log the PR torrust#2522 review round
docs(pr-reviews): [torrust#2521] add the PR torrust#2522 review audit
59 remaining items
docs(pr-reviews): [torrust#2521] add the PR torrust#2529 review audit
docs(issues): [torrust#2517] point the Risks overlap note at torrust#…
Merge #2530: chore(issues): archive closed issue #2517 spec
chore(issues): archive closed issue torrust#2521 spec to docs/issues/…
Merge #2533: docs(pr-reviews): close the PR #2527 post-merge findings…
chore(issues): archive closed issue torrust#2521 spec to docs/issues/…
docs(issues): [torrust#2521] point the archived torrust#2517 spec at …
docs(pr-reviews): [torrust#2521] add the PR torrust#2532 review audit
Merge torrust#2529: refactor: [torrust#2521] remove the unused UDP st…
docs(pr-reviews): [torrust#2521] scope the PR torrust#2532 audit's ol…
docs(pr-reviews): [torrust#2521] record F2 in the PR torrust#2532 rev…
Merge #2532: chore(issues): archive closed issue #2521 spec
docs(udp-core): reconcile the statistics docs and records with torrus…
Merge #2538: test(udp-core): [#1348] add tests to the udp-core package