Repository navigation
fix(metrics): expose completed download retention - #2127
josecelano merged 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses #2122 by making completed-download retention semantics explicit across tracker-core metrics and the REST API v1 stats response, while keeping the legacy v1 completed field and legacy Prometheus metric as deprecated compatibility views.
Changes:
- Split tracker-core completed-download counters into explicit
in_sessionandpersistedviews, and make the persisted Prometheus series capability-aware (omitted when disabled). - Extend REST API v1 stats with additive
completed_in_session,completed_persisted, andcompleted_persisted_enabledfields (including backward-compatible deserialization). - Add/extend contract and integration regressions, plus ADR + issue evidence updates documenting the retention naming/behavior.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/bootstrap/jobs/tracker_core.rs | Wires the stats repository into the persistent completed-statistics listener job. |
| packages/tracker-core/tests/integration.rs | Adds regressions proving in-session reset and persisted totals across restart scenarios. |
| packages/tracker-core/tests/common/test_env.rs | Allows persistence-free composition in the test harness and gates persisted-metric loading. |
| packages/tracker-core/src/statistics/repository.rs | Adds explicit getters and config-driven metric description for in-session vs persisted counters. |
| packages/tracker-core/src/statistics/persisted/mod.rs | Loads both legacy and persisted counters from DB on startup when enabled. |
| packages/tracker-core/src/statistics/mod.rs | Defines new metric identifiers, updates descriptions, and introduces deterministic zero initialization. |
| packages/tracker-core/src/statistics/event/listener.rs | Passes the stats repository into the persistent listener dispatch path. |
| packages/tracker-core/src/statistics/event/handler.rs | Increments in-session on in-memory completion; increments persisted only after successful DB update. |
| packages/tracker-core/src/container.rs | Constructs the stats repository with validated capability flags from config. |
| packages/rest-api-runtime-adapter/src/v1/adapters/stats.rs | Maps tracker-core counters into v1 DTO fields and injects persisted-availability boolean. |
| packages/rest-api-protocol/src/v1/context/stats/resources/stats.rs | Adds the new v1 fields with serde defaults + legacy-deserialization regression. |
| packages/rest-api-protocol/Cargo.toml | Adds serde_json dev-dependency for protocol deserialization tests. |
| packages/axum-rest-api-server/tests/server/v1/contract/context/stats.rs | Extends v1 contract tests to cover fields and Prometheus export presence/omission. |
| packages/axum-rest-api-server/src/v1/routes.rs | Derives completed_persisted_enabled from validated tracker-core config during composition. |
| packages/axum-rest-api-server/src/v1/context/stats/responses.rs | Adds the new fields to the deprecated v1 “stats-as-prometheus” text response. |
| packages/axum-rest-api-server/src/v1/context/stats/mod.rs | Updates v1 stats context docs to describe deprecation + new fields. |
| packages/axum-rest-api-server/src/testing/environment.rs | Aligns test env composition error messaging with broader “valid composition” expectation. |
| docs/issues/open/2122-expose-unambiguous-download-counter-semantics/manual-verification.md | Records local evidence runs for disabled/enabled persistence scenarios. |
| docs/issues/open/2122-expose-unambiguous-download-counter-semantics/ISSUE.md | Marks tasks/ACs as DONE and records evidence/ADR references. |
| docs/adrs/index.md | Indexes the new repository-wide ADR. |
| docs/adrs/20260901113500_define_completed_download_metric_retention_names.md | Defines the retention naming contract and the v1 additive migration bridge. |
| Cargo.lock | Locks the new serde_json dev dependency for rest-api-protocol tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2127 +/- ##
===========================================
+ Coverage 84.04% 84.15% +0.11%
===========================================
Files 349 350 +1
Lines 27376 27498 +122
Branches 27376 27498 +122
===========================================
+ Hits 23007 23140 +133
+ Misses 4022 4011 -11
Partials 347 347 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
ACK 1899d73 |
Summary
Expose explicit
in_sessionandpersistedcompleted-download counters while retaining the legacy v1 REST field and Prometheus metric as deprecated compatibility views.completed_in_session,completed_persisted, andcompleted_persisted_enabledfields with backward-compatible deserialization.Verification
Closes #2122