refactor(metrics): rename crate from torrust-tracker-metrics to torrust-metrics#1820
Conversation
Move spec from drafts to open with issue number torrust#1819 prefix. Update EPIC torrust#1669 SI-08 to reference the new GitHub issue.
…rrust-metrics` Closes torrust#1819. Subissue SI-08 of EPIC torrust#1669. - Rename `name` in `packages/metrics/Cargo.toml` to `torrust-metrics`. - Update dependency key in 7 dependent `Cargo.toml` files. - Update all Rust source `torrust_tracker_metrics::` references to `torrust_metrics::`. - Update prose in `AGENTS.md` and `packages/metrics/README.md` to remove tracker-specific framing. - Update EPIC torrust#1669 Package Inventory and Desired Package State tables; mark SI-08 DONE.
There was a problem hiding this comment.
Pull request overview
This PR renames the internal metrics crate from torrust-tracker-metrics to torrust-metrics to reflect that it is intended to be reusable beyond the tracker, and updates workspace dependencies, Rust imports, and related documentation accordingly.
Changes:
- Renamed the crate in
packages/metrics/Cargo.tomland updated dependentCargo.tomldependency keys. - Updated Rust source imports/usages from
torrust_tracker_metrics::…totorrust_metrics::…across core, servers, and tests. - Updated project documentation (README/specs/EPIC/package catalog) to reference the new crate name.
Reviewed changes
Copilot reviewed 47 out of 48 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/udp-tracker-server/src/statistics/repository.rs | Updates metrics crate imports in UDP server statistics repository + tests. |
| packages/udp-tracker-server/src/statistics/mod.rs | Switches metric description/unit imports to torrust_metrics. |
| packages/udp-tracker-server/src/statistics/metrics.rs | Switches metrics collection/aggregation imports to torrust_metrics. |
| packages/udp-tracker-server/src/statistics/event/handler/response_sent.rs | Updates metrics label/metric macro imports for response-sent handler. |
| packages/udp-tracker-server/src/statistics/event/handler/request_received.rs | Updates metrics imports for request-received handler. |
| packages/udp-tracker-server/src/statistics/event/handler/request_banned.rs | Updates metrics imports for request-banned handler. |
| packages/udp-tracker-server/src/statistics/event/handler/request_accepted.rs | Updates metrics imports for request-accepted handler. |
| packages/udp-tracker-server/src/statistics/event/handler/request_aborted.rs | Updates metrics imports for request-aborted handler. |
| packages/udp-tracker-server/src/statistics/event/handler/error.rs | Updates metrics imports for error handler. |
| packages/udp-tracker-server/src/event.rs | Updates label types import used by UDP server events. |
| packages/udp-tracker-server/src/banning/event/handler.rs | Updates metrics imports used by banning handler. |
| packages/udp-tracker-server/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/udp-tracker-core/src/statistics/repository.rs | Updates metrics crate imports in UDP core statistics repository. |
| packages/udp-tracker-core/src/statistics/mod.rs | Switches metric description/unit imports to torrust_metrics. |
| packages/udp-tracker-core/src/statistics/metrics.rs | Switches metrics collection/aggregation imports to torrust_metrics. |
| packages/udp-tracker-core/src/statistics/event/handler.rs | Updates metrics label/macro imports in UDP core stats event handler. |
| packages/udp-tracker-core/src/event.rs | Updates label types import used by UDP core events. |
| packages/udp-tracker-core/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/tracker-core/tests/common/test_env.rs | Updates metrics imports used by tracker-core tests. |
| packages/tracker-core/src/statistics/repository.rs | Updates repository metrics imports to torrust_metrics. |
| packages/tracker-core/src/statistics/persisted/mod.rs | Updates persisted metrics module imports to torrust_metrics. |
| packages/tracker-core/src/statistics/mod.rs | Switches metric description/unit imports to torrust_metrics. |
| packages/tracker-core/src/statistics/metrics.rs | Switches MetricCollection imports to torrust_metrics. |
| packages/tracker-core/src/statistics/event/handler.rs | Updates metrics imports in stats event handler. |
| packages/tracker-core/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/swarm-coordination-registry/src/statistics/repository.rs | Updates metrics crate imports in swarm coordination registry stats repo. |
| packages/swarm-coordination-registry/src/statistics/mod.rs | Switches metric description/unit imports to torrust_metrics. |
| packages/swarm-coordination-registry/src/statistics/metrics.rs | Switches MetricCollection imports to torrust_metrics. |
| packages/swarm-coordination-registry/src/statistics/event/handler.rs | Updates metrics imports and one fully-qualified error type reference. |
| packages/swarm-coordination-registry/src/statistics/activity_metrics_updater.rs | Updates metrics imports used by activity updater task. |
| packages/swarm-coordination-registry/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/rest-tracker-api-core/src/statistics/services.rs | Updates MetricCollection import to torrust_metrics. |
| packages/rest-tracker-api-core/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/http-tracker-core/src/statistics/repository.rs | Updates metrics crate imports in HTTP core statistics repository. |
| packages/http-tracker-core/src/statistics/mod.rs | Switches metric description/unit imports to torrust_metrics. |
| packages/http-tracker-core/src/statistics/metrics.rs | Switches metrics collection/aggregation imports to torrust_metrics. |
| packages/http-tracker-core/src/statistics/event/handler.rs | Updates metrics label/macro imports in HTTP core stats handler. |
| packages/http-tracker-core/src/event.rs | Updates label types import used by HTTP core events. |
| packages/http-tracker-core/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/axum-rest-tracker-api-server/src/v1/context/stats/responses.rs | Updates Prometheus serialization import to torrust_metrics. |
| packages/axum-rest-tracker-api-server/src/v1/context/stats/resources.rs | Updates MetricCollection import to torrust_metrics. |
| packages/axum-rest-tracker-api-server/Cargo.toml | Renames dependency key to torrust-metrics. |
| packages/metrics/Cargo.toml | Renames the metrics crate package name to torrust-metrics. |
| packages/metrics/README.md | Updates crate name, import paths, docs links, and coverage commands. |
| docs/issues/open/1819-1669-08-rename-torrust-tracker-metrics-to-torrust-metrics.md | Updates spec metadata and marks implementation tasks/AC as done. |
| docs/issues/open/1669-overhaul-packages/EPIC.md | Updates package inventory/state tables and marks SI-08 done with #1819. |
| AGENTS.md | Updates package catalog entry to new crate name. |
| Cargo.lock | Replaces lockfile package entry from torrust-tracker-metrics to torrust-metrics. |
Comments suppressed due to low confidence (2)
packages/metrics/README.md:35
- The usage example pulls
DurationSinceUnixEpochfromtorrust_tracker_primitives, which is a deprecated re-export (and also undermines the claim that this crate is tracker-agnostic). Prefer importingDurationSinceUnixEpochfromtorrust_tracker_clock(or usingstd::time::Durationif appropriate) in the README example.
use torrust_metrics::{
metric_collection::MetricCollection,
label::{LabelSet, LabelValue},
metric_name, label_name,
};
docs/issues/open/1819-1669-08-rename-torrust-tracker-metrics-to-torrust-metrics.md:12
last-updated-utchasn’t been updated even though this spec now includes new 2026-05-21 progress log entries and metadata changes. Please bumplast-updated-utcto reflect the latest modification timestamp.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update description field to accurately reflect Prometheus metrics purpose. - Add note that crate is not yet published on crates.io and show path dependency.
|
ACK 75e57b3 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1820 +/- ##
===========================================
+ Coverage 77.68% 77.70% +0.01%
===========================================
Files 379 379
Lines 28605 28605
Branches 28605 28605
===========================================
+ Hits 22223 22228 +5
+ Misses 6073 6066 -7
- Partials 309 311 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #1819. Subissue SI-08 of EPIC #1669.
Summary
Rename the Cargo crate
torrust-tracker-metricstotorrust-metricsto reflect that it isa generic Prometheus metrics integration reusable outside the tracker.
The crate is not published on crates.io, so no migration window is needed.
Changes
packages/metrics/Cargo.toml:namechanged totorrust-metrics.Cargo.tomlfiles: dependency key updated totorrust-metrics.torrust_tracker_metrics::references updated totorrust_metrics::.packages/metrics/README.md: title, description,usestatements, docs.rs links, and coverage commands updated.AGENTS.md: Package Catalog row updated.docs/issues/open/1669-overhaul-packages/EPIC.md: Package Inventory and Desired Package State tables updated; SI-08 marked DONE.Verification
cargo build --workspace— ✅cargo test --tests --workspace --all-targets --all-features— ✅linter all— ✅cargo test --doc --workspace— ✅