Airbrake Client

Capture exceptions and post notices for them to Airbrake or to your Errbit installation.

This library was originally forked from the airbrake Hex package. Development and support for that library seems to have lapsed, but we (the devs at Euna Payments (formerly CityBase)) had changes and updates we wanted to make. So we decided to publish our own fork of the library.

Documentation is available on hexdocs.pm.

There are sections below for configuration and usage of this library. Some other documentation that might be interesting:

Installation

Add airbrake_client to your dependencies:

defp deps do
  [
    {:airbrake_client, "~> 2.3"}
  ]
end

Configuration

See the "Create notice v3" section in the Airbrake API docs to understand the config options.

Configure :airbrake_client in your config/*.exs files.

Only the :api_key and :project_id options are required.

Airbrake project configuration

These options configure :airbrake_client to connect to the right project on Airbrake.io (or another host).

config :airbrake_client,
  api_key: System.get_env("AIRBRAKE_API_KEY"),
  project_id: System.get_env("AIRBRAKE_PROJECT_ID"),
  host: "https://api.airbrake.io"

Data for an Airbrake notice

You can add some static data to every posted notice:

config :airbrake_client,
  # ...
  context_environment: System.get_env("KUBERNETES_CLUSTER"),
  production_aliases: ["prod"],
  options: [env: %{"namespace" => System.get_env("KUBERNETES_NAMESPACE")}],
  session: :include_logger_metadata

Processing the payload when posting a notice

Use these options to change how the payload is processed when posting a notice to Airbrake:

config :airbrake_client,
  # ...
  filter_parameters: ["password"],
  filter_headers: ["authorization"],
  payload_processor: Airbrake.JasonPayloadProcessor

See Airbrake.Utils.filter/2 for details about filtering.

:json_encoder is ignored if :payload_processor is set. If only :json_encoder is set, the :payload_processor will be set to the appropriate module. If neither :json_encoder nor :payload_processor is set, the library will use Airbrake.PoisonPayloadProcessor.

Ignoring exceptions

config :airbrake_client,
  # ...
  ignore: :all

See "Ignoring Errors". Also see Airbrake.Test which might affect your choice for :ignore in test.

Usage

See the specific modules for more details.