sentry v7.2.0 Sentry.LoggerBackend

This module makes use of Elixir 1.7's new Logger metadata to report crashed processes. It replaces the previous Sentry.Logger sytem.

To include the backend in your application, the backend can be added in your application file:

def start(_type, _opts) do
  children = [
    supervisor(MyApp.Repo, []),
    supervisor(MyAppWeb.Endpoint, [])
  ]

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]

  {:ok, _} = Logger.add_backend(Sentry.LoggerBackend)

  Supervisor.start_link(children, opts)
end

If you are on OTP 21+ and would like to configure the backend to include metadata from Logger.metadata/0 in reported events, it can be enabled:

{:ok, _} = Logger.add_backend(Sentry.LoggerBackend)
Logger.configure_backend(Sentry.LoggerBackend, include_logger_metadata: true)

It is important to be aware of whether this will include sensitive information in Sentry events before enabling it.

Options

The supported options are:

  • :include_logger_metadata - Enabling this option will read any key/value pairs with with binary, atom or number values from Logger.metadata/0 and include that dictionary under the :logger_metadata key in an event's :extra metadata. This option defaults to false.
  • :ignore_plug - Enabling this option will ignore any events that appear to be from a Plug process crashing. This is to prevent duplicate errors being reported to Sentry alongside Sentry.Plug.

Link to this section Summary

Functions

Callback implementation for c::gen_event.code_change/3.

Callback implementation for c::gen_event.handle_call/2.

Callback implementation for c::gen_event.handle_event/2.

Callback implementation for c::gen_event.handle_info/2.

Callback implementation for c::gen_event.init/1.

Callback implementation for c::gen_event.terminate/2.

Link to this section Functions

Link to this function

code_change(old_vsn, state, extra)

Callback implementation for c::gen_event.code_change/3.

Link to this function

handle_call(arg, state)

Callback implementation for c::gen_event.handle_call/2.

Link to this function

handle_event(arg1, state)

Callback implementation for c::gen_event.handle_event/2.

Link to this function

handle_info(_, state)

Callback implementation for c::gen_event.handle_info/2.

Callback implementation for c::gen_event.init/1.

Link to this function

terminate(reason, state)

Callback implementation for c::gen_event.terminate/2.