Include seq_trace token in logger crash_report?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Include seq_trace token in logger crash_report?

Vince Foley
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?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Include seq_trace token in logger crash_report?

Lukas Larsson-8
Hello!

On Sun, Jul 29, 2018 at 10:35 PM Vince Foley <[hidden email]> 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

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Include seq_trace token in logger crash_report?

Vince Foley
wow, that's awesome. I tried it out and that indeed will work for me!

Thanks!

On Mon, Jul 30, 2018 at 2:05 AM, Lukas Larsson <[hidden email]> wrote:
Hello!

On Sun, Jul 29, 2018 at 10:35 PM Vince Foley <[hidden email]> 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


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions