websockets
websockets copied to clipboard
Provide metrics
I'm thinking of something along the lines of:
websocket.get_metrics()
{
"lifetime": 23.780,
"latency": 0.423,
"frames": {
"rcvd": {
"text": 93,
"pong": 17,
},
"rcvd": {
"text": 1,
"ping": 17,
},
},
}
I'm not sure what would be must useful to track.
Idea sparked in #919.
maybe avg_{rcvd,txd}_{compressed,uncompressed}_frame_size
? latency would be the ping/pong one i imagine, so maybe an tuple of min/avg/max/mdev ?
Nice suggestions!
Latency is now available via a dedicated API. See #1195.
One year later, I'm not sure about implementing the rest:
- Buffer sizes: I don't know how to get the TCP buffers at the OS level, which are the largest buffers in the system for the most common WebSocket use cases (small messages).
- Compression: it's not just about the size, it's also about CPU usage, so benchmarks compression is best done offline with scripts similar to
experimentation/compression/broadcast.py
- Messages sent or received: this is easy to implement outside of websockets — just count what you send or receive; I don't really want to add overhead for everyone when it isn't a common feature request.
Also I looked for prior art in other WebSocket frameworks and couldn't find anything resembling this. Typical metrics are things like "number of connections to the server".