Ignore errors
The AppSignal configuration makes it possible to ignore errors. By providing a list of specific errors AppSignal will not send alerts when these errors are raised.Appsignal.set_error/3
If you want to rescue exceptions in your application to prevent crashes, but still want to track the occurrence you can useAppsignal.set_error/2 to add the exception to the
current AppSignal transaction:
Erlang
The AppSignal integration tries its best to convert errors raised from Erlang to Elixir exceptions. For example, a:badarg
raised from Erlang is automatically converted to an ArgumentError. However, sometimes the best it can do is wrapping the error originating from Erlang in an ErlangError.
Since these don’t give much insight into the underlying issue, we recommend adding information from within your application by catching the error, creating an Elixir exception yourself and adding that to the current span using the set_error/2 function.
On versions before 2.1.0, use catch and Appsignal.send_error/3:
send_error, but still want to report the scenario as an error, it’s also possible to initialize a custom error struct.
Appsignal.send_error/3 for sending errors
without an AppSignal transaction.
Appsignal.send_error/3
AppSignal provides a mechanism to track errors that occur in code that’s not in a web or background job context, such as Mix tasks. This is useful for instrumentation that doesn’t automatically create AppSignal transactions to profile. You can use theAppsignal.send_error/3 function to
directly send an exception to AppSignal from any place in your code without
starting an AppSignal transaction first.
send_error, but still want to report the scenario as an error, it’s also possible to initialize a custom error struct.
Additional metadata
To add metadata to the sent error, pass a function as the fourth argument toAppsignal.send_errror/4:
Function arguments in backtraces
Some lines in an Elixir backtrace include the arguments a function was called with, and those arguments can contain personal data or secrets. AppSignal for Elixir replaces argument values with placeholders before it reports an error. It keeps atoms and the shape of maps, tuples, and keyword lists, so you can still tell which function clause was called. You can’t turn this off. For example, this code raises aKeyError:
Only backtrace lines are cleaned. AppSignal for Elixir reports the error message as the exception formats it, so the message of the
KeyError above still contains the map’s values.
Other values, such as PIDs and anonymous functions, are also replaced with placeholders, like
#PID<...>. Maps, tuples, and keyword lists with more than four items, and maps and tuples nested more than two levels deep, are collapsed to %{...}, {...}, and [...].