Skip to content

Overhaul stats: decouple events from stats #1395

Closed
3 of 3 issues completed
Closed

Description

@josecelano

To implement the segregated metrics for each server we need to create one event listeners and metrics repository for each service. That means the stats setup function will not work anymore. For example, the stats setup function for the HTTP core is

pub fn factory(
    tracker_usage_statistics: bool,
) -> (
    Option<Box<dyn statistics::event::sender::Sender>>,
    statistics::repository::Repository,
) {
    let mut stats_event_sender: Option<Box<dyn statistics::event::sender::Sender>> = None;

    let mut keeper = statistics::keeper::Keeper::new();

    if tracker_usage_statistics {
        let (sender, _) = broadcast::channel(CHANNEL_CAPACITY);

        let receiver = sender.subscribe();

        stats_event_sender = Some(Box::new(ChannelSender { sender }));

        keeper.run_event_listener(receiver);
    }

    (stats_event_sender, keeper.repository)
}

It creates the channel and subscriber one event listener. we need to separate the channel creation from the listeners subscriptions. My plan is to:

  • Move the event enums, sender trait and channel creation to a new "pure" events module.
  • Leave the listener subscription in the statistics module.

The new events are "generic" events that can be used for any purpose, not only generating stats.

This will allow later to create one listener and repo per server (socket address).

In this issue, I'm going to only split the modules internally, the statistics::setup::factory(...) function signature will be the same. We can removed it when we introduce the new listeners.

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. added
    - Developer -
    on Mar 19, 2025
  2. self-assigned this
    on Mar 19, 2025
  3. added theissue type on Mar 19, 2025
  4. added 2 commits that reference this issue on Mar 19, 2025
  5. added a commit that references this issue on Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Developer -

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions