[erlang-questions] Process message counter in process_info

Fred Hebert mononcqc@REDACTED
Thu Sep 28 15:51:49 CEST 2017


Those don't exist by default as far as I can tell, but you can work around
that for some processes using the *sys* module and gen_* debug attributes:

     sys:statistics(Pid, true | false) -> ok
     sys:statistics(Pid, get [, Timeout]) -> {ok, Stats}

It can be used interactively as:

1> sys:statistics(error_logger, true).
ok
2> sys:statistics(error_logger, get).
{ok,[{start_time,{{2017,9,28},{9,48,35}}},
     {current_time,{{2017,9,28},{9,48,37}}},
     {reductions,25},
     {messages_in,0},
     {messages_out,0}]}
3> error_logger:info_msg("test", []).
ok
4>
=INFO REPORT==== 28-Sep-2017::09:48:50 ===
5> sys:statistics(error_logger, get).
{ok,[{start_time,{{2017,9,28},{9,48,35}}},
     {current_time,{{2017,9,28},{9,48,52}}},
     {reductions,674},
     {messages_in,1},
     {messages_out,0}]}

You can also start the server as `gen_Whatever:start_link(Arg1, ...,
[{debug, [statistics]}])' to enable the gathering from start time on the
required processes.

I know of no other way to handle that kind of stuff at the moment.

On Thu, Sep 28, 2017 at 9:35 AM, Max Lapshin <max.lapshin@REDACTED> wrote:

> No.
>
> I mean:
>
> process_info(self(), total_messages_received)
> process_info(self(), total_messages_sent)
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170928/ab307622/attachment.htm>


More information about the erlang-questions mailing list