I'm building some monitoring for an Elixir app and want to be tracking the total length of process' message queues - if they go over any reasonable value it would mean the system isn't keeping up.
How would one query in a real-life system? :erlang.system_info/1 doesn't seem to be providing it, and you can only get per-process information from :erlang.process_info/1. I don't like the idea of using the latter and manually aggregating the message queue lengths, since there's potentially thousands of relevant GenServer processes and instrumenting them feels like unnecessary overhead.
I seem to remember Wombat OAM having this functionality which makes me think it's possible, but I might be mistaken.
In Erlang:
All info: :erlang.process_info(self())
Just the message queue length: :erlang.process_info(self(), :message_queue_len) # => {:message_queue_len, 2}
Just the messages: :erlang.process_info(self(), :messages) #=> {:messages, [:hello, :world]}
In Elixir:
All the info: Process.info(self())
Just the message queue length: Process.info(self(), :message_queue_len)
Just the messages: Process.info(self(), :messages)
Both give the same output which includes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With