laminar icon indicating copy to clipboard operation
laminar copied to clipboard

Implement support for laminar metrics.

Open TimonPost opened this issue 6 years ago • 3 comments

Task Description

Laminar currently does not provide much internal information to the outside. To solve this we need to have metrics, and a way to integrate this easily.

Task TODO

  • [ ] Think of metrics we can collect
  • [ ] Are there crates that can help us with this
  • [ ] Think of design to move metrics into our current API without too many changes.

TimonPost avatar Mar 10 '19 14:03 TimonPost

My idea to implement this is the following:

  1. We can make SocketEvent have an entry for Metrics:
pub enum SocketEvent {
    /// A packet has been received from a client.
    Packet(Packet),
    /// A new client connects. Clients are uniquely identified by the ip:port combination at this layer.
    Connect(SocketAddr),
    /// A client disconnects. This is generated from the server-side intentionally disconnecting a client,
    /// or it could be from the client disconnecting.
    Disconnect(SocketAddr),
    /// This is generated if the server has not seen traffic from a client after a configurable amount of time.
    Timeout(SocketAddr),
    
    /// Metrics of lamianar
    Metrics(Metrics)
}
  1. Example of metrics we can gather: source
pub struct Metrics {
    counters: [u64; DataPoint::Length as usize],
    packet_loss: f32,
    sent_bandwidth_kbps: f32,
    received_bandwidth_kbps: f32,
    acked_bandwidth_kbps: f32,

    // Config values to tweak the calculated fields
    bandwidth_smoothing_factor: f32,
}
  1. Send metrics back to the user Because we created a Metrics entry for the SocketEvent we can send it on the EventChannel

  2. Add a config entry

  • Metrics Enabled; whether we should calculate metrics or not.
  • Metrics send interval; send on event channel.

TimonPost avatar Jul 06 '19 16:07 TimonPost

It seems like this could potentially be combined with:

  • Expose active connections (https://github.com/amethyst/laminar/issues/271)
  • Expose RTT information (https://github.com/amethyst/laminar/issues/268)

I might try and roll all of those into a single interface and PR.

Should metrics be on an event, or on an on-demand poll?

ncallaway avatar Aug 30 '20 23:08 ncallaway

Thats a good question. I tended to see them as an event like my comment above shows.

TimonPost avatar Aug 31 '20 19:08 TimonPost