Skip to content

Overhaul stats: Segregated metrics for each tracker running on a different socket address #1263

Closed
3 of 3 issues completed
@josecelano

Description

@josecelano

Relates to: #1341 (comment)
Depends on: #1385

UPDATED ON 2025-03-20: added sub-tasks

IMPORTANT!!: global metrics are not going to be removed (at least until the next major version)

While I was reviewing the tracker-core package documentation I've realized we have the tracker_usage_statistics config option in the core configuration:

[core]
tracker_usage_statistics = true

That value enables or disables the statistics.

I've recently moved the statistics out of the tracker core package. Therefore It does not make sense to have that config option there because there is nothing related to statistics tin the tracker-core package now.

That value is used in the app bootstrap:

// HTTP stats
let (http_stats_event_sender, http_stats_repository) =
    http_tracker_core::statistics::setup::factory(configuration.core.tracker_usage_statistics);
let http_stats_event_sender = Arc::new(http_stats_event_sender);
let http_stats_repository = Arc::new(http_stats_repository);

// UDP stats
let (udp_stats_event_sender, udp_stats_repository) =
    udp_tracker_core::statistics::setup::factory(configuration.core.tracker_usage_statistics);
let udp_stats_event_sender = Arc::new(udp_stats_event_sender);
let udp_stats_repository = Arc::new(udp_stats_repository);

The same config option enables stats in both the UDP and HTTP trackers.

The current config omitting irrelevant values:

[core]
tracker_usage_statistics = true

[[udp_trackers]]
bind_address = "0.0.0.0:6969"

  [udp_trackers.cookie_lifetime]
  secs = 120
  nanos = 0

[[http_trackers]]
bind_address = "0.0.0.0:7070"

[http_api]
bind_address = "0.0.0.0:1212"

  [http_api.access_tokens]
  admin = "***"

[health_check_api]
bind_address = "127.0.0.1:1313"

Maybe we should create two new values for UDP and HTTP trackers. However in the current configuration there is not a place to put generic configuration for all HTTP trackers or all UDP trackers.

We can only add a config option per instance.

NOTE: That you can run more than one HTTP and/or UDP trackers.

If we do that the config could be:

[core]
tracker_usage_statistics = true

[[udp_trackers]]
bind_address = "0.0.0.0:6969"
tracker_usage_statistics = true

  [udp_trackers.cookie_lifetime]
  secs = 120
  nanos = 0

[[http_trackers]]
bind_address = "0.0.0.0:7070"
tracker_usage_statistics = true

[http_api]
bind_address = "0.0.0.0:1212"

  [http_api.access_tokens]
  admin = "***"

[health_check_api]
bind_address = "127.0.0.1:1313"

Where you can enable/disable stats for each instance.

cc @da2ce7

Sub-tasks

My implementation plan is more or less like this:

Sub-issues

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions