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 #1383

Conversation

josecelano
Copy link
Member

@josecelano 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,
}

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

To this:

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

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

@josecelano josecelano requested a review from da2ce7 March 17, 2025 18:31
@josecelano josecelano self-assigned this Mar 17, 2025
@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label Mar 17, 2025
@josecelano josecelano added the - Developer - Torrust Improvement Experience label Mar 17, 2025
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

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

Project coverage is 81.91%. Comparing base (df507a8) to head (9a8a0dc).
Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
...ges/udp-tracker-server/src/statistics/event/mod.rs 75.00% 3 Missing ⚠️
packages/udp-tracker-server/src/handlers/scrape.rs 92.30% 1 Missing ⚠️
...udp-tracker-server/src/statistics/event/handler.rs 99.35% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1383      +/-   ##
===========================================
- Coverage    81.91%   81.91%   -0.01%     
===========================================
  Files          231      232       +1     
  Lines        16974    17104     +130     
  Branches     16974    17104     +130     
===========================================
+ Hits         13905    14010     +105     
- Misses        2826     2842      +16     
- Partials       243      252       +9     

☔ 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.

…s known

It could be unkown if the request couldb be parsed succesfully.
@josecelano josecelano force-pushed the 1382-overhaul-stats-events-merge-udp-server-events-with-a-different-ip-version branch from b4f0fd4 to 27e2db4 Compare March 18, 2025 11:40
@josecelano
Copy link
Member Author

ACK 9a8a0dc

@josecelano josecelano marked this pull request as ready for review March 18, 2025 11:46
@josecelano josecelano merged commit 7451712 into torrust:develop Mar 18, 2025
23 checks passed
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 stats events: merge UDP server events with a different IP version
1 participant