Skip to content

Overhaul core Tracker: refactor statistics module#1229

Merged
josecelano merged 9 commits intotorrust:developfrom
josecelano:1228-overhaul-core-tracker-refactor-statistics-module
Jan 31, 2025
Merged

Overhaul core Tracker: refactor statistics module#1229
josecelano merged 9 commits intotorrust:developfrom
josecelano:1228-overhaul-core-tracker-refactor-statistics-module

Conversation

@josecelano
Copy link
Copy Markdown
Member

@josecelano josecelano commented Jan 31, 2025

Overhaul core Tracker: refactor statistics module.

Statistics have been split into three parts:

  • HTTP stats
  • UDP stats
  • API stats: the API uses both HTTP metrics and UDP metrics.

I have created a temporary directory (src/packages/) with the new packages. We need to create crates for those packages and move them to the src/packages/ dir.

I didn't want to do that in this PR.

$ tree src/packages/
src/packages/
├── http_tracker_core
│   ├── mod.rs
│   └── statistics
│       ├── event
│       │   ├── handler.rs
│       │   ├── listener.rs
│       │   ├── mod.rs
│       │   └── sender.rs
│       ├── keeper.rs
│       ├── metrics.rs
│       ├── mod.rs
│       ├── repository.rs
│       ├── services.rs
│       └── setup.rs
├── mod.rs
├── tracker_api_core
│   ├── mod.rs
│   └── statistics
│       ├── metrics.rs
│       ├── mod.rs
│       └── services.rs
└── udp_tracker_core
    ├── mod.rs
    └── statistics
        ├── event
        │   ├── handler.rs
        │   ├── listener.rs
        │   ├── mod.rs
        │   └── sender.rs
        ├── keeper.rs
        ├── metrics.rs
        ├── mod.rs
        ├── repository.rs
        ├── services.rs
        └── setup.rs

9 directories, 27 files

The app layers are a little bit different from what I described initially in the issue:

Initial design:

                   Main Torrust Tracker
                              |
              Axum HTTP tracker server (`packages\axum-http-tracker`. This hasn't been extracted yet)
                              |
                 HTTP tracker protocol (`packages\http-protocol`)
                              |
                          Core tracker (`packages\tracker-core`)

Final design:

                   Main Torrust Tracker
                              |
              Axum HTTP tracker server (`packages\axum-http-tracker`. This hasn't been extracted yet)
                              |
                    HTTP tracker core  (`src\packages\http_tracker_core`)
                              |
                 HTTP tracker protocol (`packages\http-protocol`)
                              |
                          Core tracker (`packages\tracker-core`)

I din't want to put stats in the packages\http-protocol because they are no part of the official HTTP tracker protocols. And I didn't want to put it in the axum server because it's code that can be re-used in other server implementations (using other frameworks).

This is the frist step in a bigger refactor. We will move statistics out
of the tracker-core package into new packages. Statistics are not
related to the tracker-core or enven handled there. That logic belongs
to upper layers.
@josecelano josecelano self-assigned this Jan 31, 2025
@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience labels Jan 31, 2025
@josecelano josecelano linked an issue Jan 31, 2025 that may be closed by this pull request
@josecelano josecelano requested a review from da2ce7 January 31, 2025 09:58
…in lib

The statistics are only used at the higher levels: UDP and HTTP tracker.

We will move them to new packages.
@josecelano josecelano force-pushed the 1228-overhaul-core-tracker-refactor-statistics-module branch from 4f51ffd to 9318842 Compare January 31, 2025 10:47
Stats have been splited into HTTP and UDP stats.

Parallel change, step 1:

1. [x] Start using HTTP Tracker Core Stats
2. [ ] Start using UDP  Tracker Core Stats
3. [ ] Get metrics from HTTP and UDP Tracker Core Stats
4. [ ] Remove deprecate unified HTTP and UDP stats.
@josecelano josecelano force-pushed the 1228-overhaul-core-tracker-refactor-statistics-module branch from 39449ab to 5f08b2e Compare January 31, 2025 13:47
Parallel change, step 2:

1. [x] Start using HTTP Tracker Core Stats
2. [x] Start using UDP  Tracker Core Stats
3. [ ] Get metrics from HTTP and UDP Tracker Core Stats
4. [ ] Remove deprecate unified HTTP and UDP stats.
…tats

Stats have been splited into HTTP and UDP stats.

Parallel change, step 3:

1. [x] Start using HTTP Tracker Core Stats
2. [x] Start using UDP  Tracker Core Stats
3. [x] Get metrics from HTTP and UDP Tracker Core Stats
4. [ ] Remove deprecated unified HTTP and UDP stats.
Stats have been split into HTTP and UDP stats.

Parallel change, step 4:

1. [x] Start using HTTP Tracker Core Stats
2. [x] Start using UDP  Tracker Core Stats
3. [x] Get metrics from HTTP and UDP Tracker Core Stats
4. [x] Remove deprecated unified HTTP and UDP stats.
@josecelano josecelano marked this pull request as ready for review January 31, 2025 17:04
@josecelano
Copy link
Copy Markdown
Member Author

ACK fd8b57a

@josecelano josecelano mentioned this pull request Jan 31, 2025
@josecelano josecelano merged commit 0c6d87c into torrust:develop Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overhaul core Tracker: refactor statistics module

1 participant