NervesHubLink.Extensions.ErrorReports.Handler (nerves_hub_link v2.14.0)

Copy Markdown View Source

The :logger handler that feeds NervesHubLink.Extensions.ErrorReports.Collector.

What it picks up

Log events carrying crash_reason metadata, and nothing else. That is what the runtime attaches when a process dies with an exception, an exit or a throw: proc_lib crash reports, GenServer terminations, failed tasks. It is also what Logger.error(msg, crash_reason: {exception, stacktrace}) sets, so application code that wants to report by hand already has a way in.

Keying on crash_reason rather than on the level is deliberate. An error is not every line logged at :error — most of those are text, with nothing to build a stacktrace or a fingerprint from — and it is not only the ones OTP labels as crash reports either.

Runs in whichever process is doing the logging, so it does as little as it can and never logs. A handler that waits charges the application for the reporting, and a handler that logs never stops.