[erlang-questions] Include seq_trace token in logger crash_report?

Lukas Larsson lukas@REDACTED
Mon Jul 30 11:05:00 CEST 2018


Hello!

On Sun, Jul 29, 2018 at 10:35 PM Vince Foley <vincefoley@REDACTED> wrote:

> Hello! I'm doing some error monitoring with `logger`, and it'd be really
> nice to include the `seq_trace` token in the crash_report data structure
>

> That'd let me correlate the source of the crash since by the time I get
> the crash_report message the original process is likely gone..
>
> I see that really useful stuff like the process dictionary & message queue
> is part of the report, would it be possible to add the token? If so, how
> would I make such a request?
>

You can add your own report-data to the log report by using a logger
filter. For instance the filter below will include the seq_trace token into
any logging message that fits the structure of an otp error report.

SeqTraceFilter = fun(#{msg := {report, #{ report := R } = Msg}} = L,_) ->
                      L#{ msg := {report, Msg#{ report :=
[{seq_trace,seq_trace:get_token()} | R] }}};
                    (L,_) -> L
                 end,
logger:add_primary_filter(seq_trace,{SeqTraceFilter,[]}).

Another way to achieve the same thing would be to add the seq_trace token
as a meta entry using a filter and then output that by modifying the
template of the default handler.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180730/15c7dabe/attachment.htm>


More information about the erlang-questions mailing list