The Error Reports Extension, version 0.1.0.
Sends the device's exceptions, exits and explicit error reports to NervesHub, where they are grouped into issues you can resolve or mute. One direction only: nothing is ever sent back.
Off by default. To turn it on, name it in extension_modules along with the
other extensions you want, since the list replaces the defaults rather than
adding to them:
config :nerves_hub_link,
extension_modules: [
NervesHubLink.Extensions.Geo,
NervesHubLink.Extensions.Health,
NervesHubLink.Extensions.NetworkIdentity,
NervesHubLink.Extensions.ErrorReports
]Like every extension, it sends nothing until NervesHub asks the device to attach it, and NervesHub only asks if the product has the extension enabled.
What gets reported
Anything the runtime attaches a crash_reason to: a process dying with an
exception, an exit or a throw, a GenServer termination, a failed task. See
NervesHubLink.Extensions.ErrorReports.Handler for why that is the signal
rather than the log level.
Application code can also report an error it caught and handled, with context the stacktrace cannot know:
try do
charge(order)
rescue
error -> NervesHubLink.report_error(error, __STACKTRACE__, group: "payments")
endWhy it batches
A crash loop is the case this is built for. NervesHub limits how often a device may send rather than how much it may say, so a message carrying twenty-five reports costs exactly what one carrying a single report costs. Sending one report per message would lose most of a restart storm and keep an arbitrary sample of it.
Reports collect in NervesHubLink.Extensions.ErrorReports.Collector from
application start, so a crash during boot, or while the device is offline, is
still there to send once there is a connection.
Configuration
config :nerves_hub_link,
error_reports: [
max_reports: 100,
interval_seconds: 60,
context: {MyApp.Telemetry, :error_context, []}
]See NervesHubLink.Extensions.ErrorReports.Config, and in particular
NervesHubLink.Extensions.ErrorReports.Config.context/0 for attaching device
state such as reboot count or free memory to every report.