Skip to content

Overhaul stats: add more metrics to the torrent-repository package #1521

Description

@josecelano

Context

I've added basic metrics to the torrent-repository:

  • torrent_repository_torrents_total: The total number of torrents.
  • torrent_repository_torrents_downloads_total: The total number of torrent downloads (since the tracker process started).
  • torrent_repository_peer_connections_total: The total number of peer connections (one connection per torrent).

My goal is to add new labeled metrics to the metrics API endpoint to include all the metrics we have in the stats API endpoint:

stats endpoint (omitting non-relevant metrics for this issue):

{
  "torrents": 0,
  "completed": 0,
  "seeders": 0,
  "leechers": 0
  ...  
}
  • The old all torrents field in the new torrent_repository_torrents_total.
  • The fields seeders and leechers were merged into a single metric torrent_repository_peer_connections_total with a peer_role label. The peer_role values are: seeder and leecher
  • The old field completed is the number of downloads. That is a special one because I'm making some changes. I added the new metric torrent_repository_torrents_downloads_total, but it only counts downloads since the tracker was started. I will add the same metric in the tracker-core package, but the historical value. The reason is that metric requires persistence, and the torrent-repository package only has in-memory data structures. Persistence is handled in the tracker-core. I will implement it by allowing persistent metrics whose initial values are loaded when the tracker starts.

Add more metrics

I want to add more metrics not existing in the current stats endpoint.

  • Events metrics: metrics to count how many times an event has happened. For example, how many times has a peer been added, removed, or updated.
  • Peer inactivity metrics: a new metric to count how many peers are inactive.

I will open subissues for each of them.

cc @da2ce7

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions