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

Overhaul stats events: merge UDP server events with a different IP version #1382

Closed
josecelano opened this issue Mar 17, 2025 · 0 comments · Fixed by #1383
Closed

Overhaul stats events: merge UDP server events with a different IP version #1382

josecelano opened this issue Mar 17, 2025 · 0 comments · Fixed by #1383
Assignees
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Comments

@josecelano
Copy link
Member

josecelano commented Mar 17, 2025

Change events in torrust_udp_tracker_server::statistics::event::Event from this:

pub enum Event {
    UdpRequestAborted,
    UdpRequestBanned,

    // UDP4
    Udp4IncomingRequest,
    Udp4Request {
        kind: UdpResponseKind,
    },
    Udp4Response {
        kind: UdpResponseKind,
        req_processing_time: Duration,
    },
    Udp4Error,

    // UDP6
    Udp6IncomingRequest,
    Udp6Request {
        kind: UdpResponseKind,
    },
    Udp6Response {
        kind: UdpResponseKind,
        req_processing_time: Duration,
    },
    Udp6Error,
}

To this:

pub enum Event {
    UdpRequestAborted { context: ConnectionContext },
    UdpRequestBanned { context: ConnectionContext },
    UdpIncomingRequest { context: ConnectionContext },
    UdpRequest {
        context: ConnectionContext,
        kind: UdpResponseKind,
    },
    UdpResponse {
        context: ConnectionContext,
        kind: UdpResponseKind,
        req_processing_time: Duration,
    },
    UdpError { context: ConnectionContext },
}

pub struct ConnectionContext {
    client_socket_addr: SocketAddr,
    server_socket_addr: SocketAddr,
}
@josecelano josecelano added - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat labels Mar 17, 2025
@josecelano josecelano self-assigned this Mar 17, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 17, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
…s known

It could be unkown if the request couldb be parsed succesfully.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
…s known

It could be unkown if the request couldb be parsed succesfully.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
josecelano added a commit that referenced this issue Mar 18, 2025
…fferent IP version

9a8a0dc refactor: [#1382] rename UDP server event enum variants (Jose Celano)
27e2db4 refactor: [#1382] include req kin in UDP error response if it's known (Jose Celano)
625d20a refactor: [#1382] rename torrust_udp_tracker_server::statistics::event::Event::UdpRequest (Jose Celano)
203a1b4 refactor: [#1382] merge UDP server stats events with different IP version (Jose Celano)
e4c6000 refactor: [#1382] add connection context to UDP server events (Jose Celano)
74ffa4c refactor: [#1382] error request kind in UDP req does not make sense (Jose Celano)

Pull request description:

  Change events in `torrust_udp_tracker_server::statistics::event::Event` from this:

  ```rust
  pub enum Event {
      UdpRequestAborted,
      UdpRequestBanned,

      // UDP4
      Udp4IncomingRequest,
      Udp4Request {
          kind: UdpResponseKind,
      },
      Udp4Response {
          kind: UdpResponseKind,
          req_processing_time: Duration,
      },
      Udp4Error,

      // UDP6
      Udp6IncomingRequest,
      Udp6Request {
          kind: UdpResponseKind,
      },
      Udp6Response {
          kind: UdpResponseKind,
          req_processing_time: Duration,
      },
      Udp6Error,
  }

  pub enum UdpRequestKind {
      Connect,
      Announce,
      Scrape,
      Error,
  }
  ```

  To this:

  ```rust
  pub enum Event {
      UdpRequestReceived {
          context: ConnectionContext,
      },
      UdpRequestAborted {
          context: ConnectionContext,
      },
      UdpRequestBanned {
          context: ConnectionContext,
      },
      UdpRequestAccepted {
          context: ConnectionContext,
          kind: UdpRequestKind,
      },
      UdpResponseSent {
          context: ConnectionContext,
          kind: UdpResponseKind,
          req_processing_time: Duration,
      },
      UdpError {
          context: ConnectionContext,
      },
  }

  pub enum UdpRequestKind {
      Connect,
      Announce,
      Scrape,
  }

  pub enum UdpResponseKind {
      Ok { req_kind: UdpRequestKind },
      Error { opt_req_kind: Option<UdpRequestKind> },
  }

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

  ### Sub-tasks

  - [x] Add enum `UdpResponseKind`. `UdpRequestKind::Error` variant does not make sense.
  - [x] Add `ConnectionContext` to events.
  - [x] Merge events with the same request type (`connect`, `announce` and `scrape`).

ACKs for top commit:
  josecelano:
    ACK 9a8a0dc

Tree-SHA512: 3d81ebed7e0005aacb135d801ad64043bb2dccafc07476538ed372dcc256ac60faced20ded3794f0d78ee2f7295b11e6d0d45b286c896501a097aa4371227123
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
1 participant