Skip to content

Conversation

@josecelano
Copy link
Member

@josecelano josecelano commented Mar 11, 2025

Change HTTP core tracker events (bittorrent_http_tracker_core::statistics::event::Event) from this:

pub enum Event {
    Tcp4Announce,
    Tcp4Scrape,
    Tcp6Announce,
    Tcp6Scrape,
}

To this:

pub enum Event {
    TcpAnnounce { connection: ConnectionContext },
    TcpScrape { connection: ConnectionContext },
}

pub struct ConnectionContext {
    client: ClientConnectionContext,
    server: ServerConnectionContext,
}

pub struct ClientConnectionContext {
    ip_addr: IpAddr,
    port: Option<u16>,
}

pub struct ServerConnectionContext {
    socket_addr: SocketAddr,
}

Sub-tasks

  • Add ConnectionContext to events.
  • Merge events with the same request type (announce and scrape).
  • Add client port to ConnectionContext. ClientIpSources type and the packages/axum-http-tracker-server/src/v1/extractors/client_ip_sources.rs Axum extractor have to be changed to include also the port.

@josecelano josecelano self-assigned this Mar 11, 2025
@josecelano josecelano requested a review from da2ce7 March 11, 2025 17:34
@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat Enhancement / Feature Request Something New - Developer - Torrust Improvement Experience labels Mar 11, 2025
@codecov
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 99.26471% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.77%. Comparing base (3d3d0c7) to head (1f30f8e).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...ackages/http-tracker-core/src/services/announce.rs 98.07% 1 Missing ⚠️
packages/http-tracker-core/src/services/scrape.rs 98.78% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1374      +/-   ##
===========================================
+ Coverage    81.59%   81.77%   +0.18%     
===========================================
  Files          229      230       +1     
  Lines        16618    16806     +188     
  Branches     16618    16806     +188     
===========================================
+ Hits         13559    13743     +184     
- Misses        2818     2821       +3     
- Partials       241      242       +1     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano josecelano marked this pull request as ready for review March 17, 2025 11:36
@josecelano josecelano force-pushed the 1373-overhaul-stats-events-group-http-core-events-by-ip-version branch from 9abed69 to 0eec5b7 Compare March 17, 2025 11:48
…in HTTP tracker

Instead of only the IP. The port will be abailable in evetns so we can
build metrics also using the client's port.
To also run doctests.
@josecelano josecelano force-pushed the 1373-overhaul-stats-events-group-http-core-events-by-ip-version branch from 0eec5b7 to 1f30f8e Compare March 17, 2025 12:01
@josecelano
Copy link
Member Author

ACK 1f30f8e

@josecelano josecelano changed the title Refactor: Add connection context to HTTP core events Overhaul stats events: merge HTTP core events with a different IP version Mar 17, 2025
@josecelano josecelano merged commit 0428972 into torrust:develop Mar 17, 2025
23 checks passed
josecelano added a commit that referenced this pull request Mar 17, 2025
…erent IP version

8603f8b refactor: [#1380] refactor: [#1373] merge UDP stats events with different IP version (Jose Celano)
2be682e refactor: [#1380] refactor: [#1371] add connection context to UDP core events (Jose Celano)

Pull request description:

  Change events from this:

  `bittorrent_udp_tracker_core::statistics::event::Event`:

  ```rust
  pub enum Event {
      Udp4Connect,
      Udp4Announce,
      Udp4Scrape,
      Udp6Connect,
      Udp6Announce,
      Udp6Scrape,
  }
  ```

  To this:

  ```rust
  pub enum Event {
      UdpConnect { context: ConnectionContext },
      UdpAnnounce { context: ConnectionContext },
      UdpScrape { context: ConnectionContext },
  }

  pub struct ConnectionContext {
      client_socket_addr: SocketAddr,
      server_socket_addr: SocketAddr,
  }
  ```

  This have also be done for [HTTP core events](#1374).

  ### Sub-tasks

  - [x] Add `ConnectionContext` to events.
  - [x] Merge events with the same request type (`connect`, `announce` and `scrape`).

ACKs for top commit:
  josecelano:
    ACK 8603f8b

Tree-SHA512: dde61535ec1f6c768ae2ad4d911e4ecece9be94c2546fd7b06a0d8d45d122caa6fcbf370cfa5de61a0d10424927cef17f7faf0a351252ab28ccb17e38058269e
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 Enhancement / Feature Request Something New

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overhaul stats events: merge HTTP core events with a different IP version

1 participant