Using client bandwidth with Ruby net / http

I am trying to track the bandwidth usage of individual requests in ruby โ€‹โ€‹to find out how much of my network usage is shared between different API calls.

I canโ€™t find anything in the net / http or ruby โ€‹โ€‹socket classes (TCPSocket, etc.), which seem to have a decent way to do this with a lot of monkey fixes.

I found a number of useful linux tools for Linux, but none of them give me the granularity to check inside the HTTP requests in the headers (so that I can figure out which URL we are requesting). The tools I use are vnStat and ipfm - great system bandwidth or host / network monitoring.

Ideally, I would like to do something in the ruby โ€‹โ€‹code to track the sent / received data. I think that if I could just get the original header and add this length to the length of the body for transmission and reception, it would be Good Enough โ„ข.

+4
source share
2 answers

Can you use the New Relic for Ruby ? It has great visualizations / graphics for use on the web / api calls.

0
source

It seems like it would be fairly easy to write middleware to track this using Faraday .

0
source

Source: https://habr.com/ru/post/1437281/


All Articles