Get data statistics from websocket client #7572
-
Hi, I would like to collect usage statistics from a websocket client connection. i.e. number of bytes sent and number of bytes received. Ideally the number of bytes on the wire, but uncompressed would also work. What is the easiest way to collect these stats? I don't see a public interface. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I don't see an easy option with the current code. It could maybe be possible by using a custom response class, though the actual sending is handled by the writer class (passed into the response class), which is hardcoded: Line 890 in 6755796 I think there has been requests to introduce tracing to websockets, so if you wanted to try and expand the current tracing stuff to websockets, maybe that would be worth looking at (I've not personally done anything with the tracing API before, so not sure how well it matches up). By the way, your Pygame book was a big influence on me learning to program ~15 years ago. |
Beta Was this translation helpful? Give feedback.
I don't see an easy option with the current code. It could maybe be possible by using a custom response class, though the actual sending is handled by the writer class (passed into the response class), which is hardcoded:
aiohttp/aiohttp/client.py
Line 890 in 6755796
I think there has been requests to introduce tracing to websockets, so if you wanted to try and expand the current tracing stuff to websockets, maybe that would be worth looking at (I've not personally done anything with the tracing API before, so not sure how well it matches up).
By the way, your Pyg…