Skip to content

Expose unambiguous download counter semantics #2122

Closed

Description

@josecelano

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, and completed_persisted_enabled fields.
  • 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

Activity

  1. added
    Bug
    on Aug 31, 2026
  2. added theissue type on Aug 31, 2026
  3. added 2 commits that reference this issue on Sep 1, 2026
  4. self-assigned this
    on Sep 1, 2026
  5. added 3 commits that reference this issue on Sep 1, 2026
  6. added a commit that references this issue on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions