Bellwether.Crash (bellwether v0.1.0)

Copy Markdown

Turning a BEAM crash into an Event payload.

Everything here is a pure function of the crash reason and stacktrace, so the awkward shapes — an exit inside an exit, a stacktrace carrying live arguments, a :nocatch throw — are testable without crashing anything.

Line numbers are kept in the payload and kept out of the Fingerprint. They are what a human wants to see and the surest way to split one Issue into many, so they belong in exactly one of those two places.

Exception messages

A structured exception reports well: a KeyError carries the key it could not find, a FunctionClauseError the module and function that had no clause, and all of those are code. A RuntimeError carries nothing but a message, and a message is where developers put data: an interpolated address or serial is exactly what redaction exists to stop. So by default the message becomes binary(n) and the report is the exception type plus the stacktrace, which still names the line that raised.

Where that is too coarse — and for RuntimeError it usually is — an application that knows its own messages can name the exceptions whose messages may travel:

config :bellwether, keep_messages_for: [RuntimeError, MyApp.ConfigError]

Only the application can know this. Bellwether cannot, so its default is the one that cannot leak.

Summary

Functions

Build a payload from Logger metadata's :crash_reason, which is {reason, stacktrace} for every process crash the BEAM reports.

Types

kind()

@type kind() :: :error | :exit | :throw

Functions

build(reason, stacktrace, opts \\ [])

@spec build(term(), Exception.stacktrace(), keyword()) :: map()

Build a payload from Logger metadata's :crash_reason, which is {reason, stacktrace} for every process crash the BEAM reports.