In the context of an embedded Elixir project (with a raspberry plugged to a 4G router), I’d like my application to track HTTP upload and download traffic (and then break it down regarding of my business).
Do you folks have any idea of how I should proceed?
:hackney comes with some metrics which are disabled by default, but even then they only show request count / time spent. You might be able to wrap the http functions and read the size of request and response bodies there … but that wouldn’t account for headers.
defmodule MeteredHTTP do
use HTTPoison.Base
def process_request_body(body) do
MyRequestSizeCounter.inc(IO.iodata_length(body))
body
end
def process_response_body(body) do
MyResponseSizeCoutner.inc(IO.iodata_length(body))
body
end
# etc, maybe for headers as well
end