Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more metrics #1176

Merged
merged 6 commits into from
Jan 9, 2025
Merged

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Jan 7, 2025

Add more metrics useful for detecting tracker errors and load level.

UDP

  • udp_requests_banned: the total number of UDP requests that have been banned.
  • udp_banned_ips_total: the total number of IPs that have been banned for sending wrong connection IDs.
  • udp_avg_connect_processing_time_ns: the average time processing a UDP connect request.
  • udp_avg_announce_processing_time_ns: the average time processing a UDP announce request.
  • udp_avg_scrape_processing_time_ns: the average time processing a UDP scrape request.

Important refactor

I needed to pass the Ban Service to the stats handler to get some values. I did not want to add the ban service to the tracker because the tracker is already to "fat". It has many responsibilities. In fact, I want to extract new services out of the tracker like whitelist, authorization, etc. My plan was to extract them and leave the tracker as the application services container. However I think it will be easier if we:

  • We pass new services like BanService directly to handlers instead of using the tracker as a facade.
  • Move other services out of the Tracker and also pass them directly to handlers.

At the end, the Tracker should have only a couple of methods like announce and scrape.

@josecelano josecelano linked an issue Jan 7, 2025 that may be closed by this pull request
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 93.75000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 76.07%. Comparing base (c9638f3) to head (08a862a).

Files with missing lines Patch % Lines
src/console/profiling.rs 0.00% 2 Missing ⚠️
src/main.rs 0.00% 2 Missing ⚠️
src/servers/udp/server/banning.rs 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1176      +/-   ##
===========================================
+ Coverage    76.00%   76.07%   +0.06%     
===========================================
  Files          174      174              
  Lines        11567    11599      +32     
  Branches     11567    11599      +32     
===========================================
+ Hits          8792     8824      +32     
  Misses        2606     2606              
  Partials       169      169              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

All UDP tracker will share the same service. In the future, the HTTP
trackers can also use it.

The service was not include inside the tracker (easy solution) becuase
the Tracker type is too big. It has became the app container. In fact,
we want to reduce it in the future by extracting the services outside of
the tracker: stats, whitelist, etc. Those services will be instantiate
independently in the future in the app bootstrap.
```json
{
  "torrents": 0,
  "seeders": 0,
  "completed": 0,
  "leechers": 0,
  "tcp4_connections_handled": 0,
  "tcp4_announces_handled": 0,
  "tcp4_scrapes_handled": 0,
  "tcp6_connections_handled": 0,
  "tcp6_announces_handled": 0,
  "tcp6_scrapes_handled": 0,
  "udp_requests_aborted": 0,
  "udp_requests_banned": 0,
  "udp_banned_ips_total": 0,
  "udp4_requests": 0,
  "udp4_connections_handled": 0,
  "udp4_announces_handled": 0,
  "udp4_scrapes_handled": 0,
  "udp4_responses": 0,
  "udp4_errors_handled": 0,
  "udp6_requests": 0,
  "udp6_connections_handled": 0,
  "udp6_announces_handled": 0,
  "udp6_scrapes_handled": 0,
  "udp6_responses": 0,
  "udp6_errors_handled": 0
}
```

The new metric: `udp_banned_ips_total`. It's the total number of IPs that have been banned for sending wrong connection IDs.
… events

- The `kind`is the type of response: connect, annouince, etc
- The req_processing_time is the time it took to process the requests on
  the backend, without including sending the response back to the client
(network latency).
```json
{
  "torrents": 1,
  "seeders": 1,
  "completed": 0,
  "leechers": 0,
  "tcp4_connections_handled": 0,
  "tcp4_announces_handled": 0,
  "tcp4_scrapes_handled": 0,
  "tcp6_connections_handled": 0,
  "tcp6_announces_handled": 0,
  "tcp6_scrapes_handled": 0,
  "udp_requests_aborted": 0,
  "udp_requests_banned": 0,
  "udp_banned_ips_total": 0,
  "udp_avg_connect_processing_time_ns": 37000,
  "udp_avg_announce_processing_time_ns": 42067,
  "udp_avg_scrape_processing_time_ns": 0,
  "udp4_requests": 60,
  "udp4_connections_handled": 30,
  "udp4_announces_handled": 30,
  "udp4_scrapes_handled": 0,
  "udp4_responses": 60,
  "udp4_errors_handled": 0,
  "udp6_requests": 0,
  "udp6_connections_handled": 0,
  "udp6_announces_handled": 0,
  "udp6_scrapes_handled": 0,
  "udp6_responses": 0,
  "udp6_errors_handled": 0
}
```

New metrcis are:

- udp_avg_connect_processing_time_ns
- udp_avg_announce_processing_time_ns
- udp_avg_scrape_processing_time_ns
@josecelano josecelano force-pushed the 1145-add-more-metrics branch from e3327db to 903d47f Compare January 9, 2025 16:59
@josecelano josecelano marked this pull request as ready for review January 9, 2025 17:00
@josecelano
Copy link
Member Author

ACK 903d47f

@josecelano josecelano merged commit f6aca40 into torrust:develop Jan 9, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more metrics
1 participant