Skip to content

Overhaul stats: Add persisted labeled metrics for (all) torrents downloads #1535

Closed
3 of 3 issues completed
Closed

Description

@josecelano

Add support for persisting labelled metrics.

In the torrent-repository package, we have this metric:

const TRACKER_CORE_PERSISTENT_TORRENTS_DOWNLOADS_TOTAL: &str = "tracker_core_persistent_torrents_downloads_total";

However, it's not persisted. The tracker only persists the number of downloads individually per torrent. The metric represents only the total of downloads for the torrents loaded into memory.

We will add a new persisted metric in the tracker-core

const TRCAKER_CORE_PERSISTENT_TORRENTS_DOWNLOADS_TOTAL: &str = "trcaker_core_persistent_torrents_downloads_total";

This issue will implement the mechanism to persist metrics in general:

  • Load a metric from the database
  • Save a metric into the database

In fact, it will save/load metric samples.

Metric with a collection of samples.

{
   "kind":"counter",
   "name":"udp_tracker_server_requests_accepted_total",
   "samples":[
      {
         "value":51002,
         "recorded_at":"2025-05-26T16:26:06.625776528+00:00",
         "labels":[
            {
               "name":"request_kind",
               "value":"connect"
            },
            {
               "name":"server_binding_ip",
               "value":"0.0.0.0"
            },
            {
               "name":"server_binding_port",
               "value":"6868"
            },
            {
               "name":"server_binding_protocol",
               "value":"udp"
            }
         ]
      }
   ]
}

NOTES:

  • The metric we want to persist will not have labels.
  • The package metrics contains the logic related to metrics.
  • The package tracker-core is the only one containing the persistence layer. Only logic not dependent on DB can be located in the metrics package.

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. self-assigned this
    on May 26, 2025
  2. added
    - Developer -
    on May 26, 2025
  3. added a commit that references this issue on May 26, 2025
  4. changed the title [-]Overhaul stats: Persist labeled metrics[/-] [+]Overhaul stats: Add persisted labeled metrics for (all) torrents downloads[/+] on May 26, 2025
  5. added a commit that references this issue on May 27, 2025
  6. added a commit that references this issue on May 27, 2025
  7. josecelano commented on May 27, 2025

    @josecelano
    MemberAuthor

    Completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Developer -Enhancement / Feature Request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions