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: Use broadcast channel for events in HTTP Core #1388

Closed
josecelano opened this issue Mar 18, 2025 · 0 comments · Fixed by #1391
Closed

Overhaul stats: Use broadcast channel for events in HTTP Core #1388

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

Comments

@josecelano
Copy link
Member

Switch from mpsc to broadcast channel. That will allow multiple event listeners.

  • mpsc: multi-producer, single-consumer channel. Many values can be sent.
  • broadcast: multi-producer, multi-consumer. Many values can be sent. Each receiver sees every value.

It will make the code a little bit more complex becuase we have to handle "Lagging" but evens with one one subscriber are not very useful. They are limited for collecting global metrics or do other stuff but in a centralized way. Multiple listeners allows decoupling logic associated to events.

cc @da2ce7

@josecelano josecelano added - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat labels Mar 18, 2025
@josecelano josecelano self-assigned this 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
…adcast

Stats events were introduced to colelct tracker metrics. WE only have
global metrics (aggregate metrics for all UDP and HTTP trackers).

This will change in the future:

- Seggregated metrics: one listeners per tracker (per socket).
- Generic events: there could be other event consumers. Events will be
  decoupled from stats.

This change allows multiple receivers in the channel.

For now, we one use one listener but with this change it will be easy to
add more.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
…adcast

Stats events were introduced to collect tracker metrics. We only have global metrics (aggregate metrics for all UDP and HTTP trackers).

This will change in the future. We will have:

- Segregated metrics: one listeners per tracker (per socket).
- Generic events: there could be other event consumers. Events will be decoupled from stats.

This change allows multiple receivers in the channel.

For now, we one use one listener but with this change will be easy to add more.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 18, 2025
…adcast

Stats events were introduced to collect tracker metrics. We only have global metrics (aggregate metrics for all UDP and HTTP trackers).

This will change in the future. We will have:

- Segregated metrics: one listeners per tracker (per socket).
- Generic events: there could be other event consumers. Events will be decoupled from stats.

This change allows multiple receivers in the channel.

For now, we one use one listener but with this change will be easy to add more.
josecelano added a commit that referenced this issue Mar 18, 2025
… Core

5f9c4d3 refactor: [#1388] change channel in HTTP core from mpsc to broadcast (Jose Celano)
64c7b21 refactor: [#1388] minor changes to HTTP core events (Jose Celano)

Pull request description:

  Stats events were introduced to collect tracker metrics. We only have global metrics (aggregate metrics for all UDP and HTTP trackers).

  This will change in the future. We will have:

  - **Segregated metrics**: one listener per tracker (per socket).
  - **Generic events**: there could be other events consumers. Events will be decoupled from stats.

  This change allows multiple receivers in the channel.

  For now, we one use one listener but with this change will be easy to add more.

ACKs for top commit:
  josecelano:
    ACK 5f9c4d3

Tree-SHA512: 9732bd79ba3515bd8aacbd7df854d8419afdf161555f96ab011278f04eb0f5c23c8a8003610e47b8adb14fe338d683b2fde142eca5ab94cd0d9afda82190249e
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 a pull request may close this issue.

1 participant