Repository navigation
Labels
BugIncorrect Behavior
Description
Goal
Expose separate session and persisted completed-download totals without breaking v1 consumers, and establish in_session and persisted as the naming convention for API v2's unambiguous completed-count contract.
Background
The legacy tracker_core_persistent_torrents_downloads_total counter is process-scoped when persistence is disabled but historical across restarts when persistent completed statistics are enabled. The public metric and REST completed documentation imply an always-persisted lifetime total, while the v1 response gives clients no retention-mode signal.
Scope
- Retain the legacy REST field and metric identifier/value semantics for compatibility; correct their descriptions and document deprecation.
- Add v1
completed_in_session,completed_persisted, andcompleted_persisted_enabledfields. - Maintain distinct tracker-core in-session and persisted views; export the persisted Prometheus metric only while persistent completed statistics are enabled.
- Derive REST persistence availability from validated configuration, not from numeric values or service presence.
- Review and extend the existing REST stats contract tests; add direct metrics endpoint coverage and top-level integration coverage when necessary to prove configuration-to-endpoint behavior.
- Add regression tests for persistence-free reset, persisted restoration, enabled zero values, export omission, and v1 deserialization compatibility.
- Record an ADR defining retention names, lifecycle, deprecation, and the additive v1-to-v2 migration.
- Manually verify both configurations and record exact local commands, requests, responses, and outcomes in the issue-local evidence artifact.
Out of Scope
- Removing, renaming, or changing legacy conditional values before API v2.
- API v2 implementation, listener-topology changes, database schema or migration changes, and persistence-configuration redesign.
Acceptance Criteria
- Legacy values remain compatible but accurately documented and deprecated.
- In-session values reset per process and persisted values are seeded from, then updated after successful writes to, the database aggregate.
- REST clients distinguish disabled persistence only through
completed_persisted_enabled; Prometheus omits the persisted metric while disabled. - REST server contract tests cover the expanded stats endpoint and metrics endpoint; add a top-level integration test when needed to prove the configuration-to-endpoint contract.
- The REST composition root supplies validated persistence capability; older JSON payloads remain deserializable.
- Tests cover both lifecycle modes, zero, export presence/absence, and existing listener topology.
- A repository-wide ADR and mandatory local verification evidence are completed before closure.
References
- Prerequisite: Activate persistence-free v3 runtime composition #2107
- Earlier REST API v2 deferral refined by this additive v1 bridge: Database configuration needed even when it's not used #999
- Full specification:
docs/issues/open/2122-expose-unambiguous-download-counter-semantics/ISSUE.md
Metadata
Metadata
Assignees
Labels
BugIncorrect Behavior
Activity
docs(issues): add specifications for #2121 and #2122
Merge #2123: docs(issues): add specifications for #2121 and #2122
docs(issues): address torrust#2122 review feedback
docs(issues): refine #2122 implementation plan
docs(issues): record #2122 verification evidence
Merge torrust#2127: fix(metrics): expose completed download retention