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:
- Testing with
Airbrake.Testin your app. - Development notes
- Migrating from
airbrake
Add airbrake_client to your dependencies:
defp deps do
[
{:airbrake_client, "~> 2.3"}
]
endSee 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.
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":api_key- (required, binary) the token needed to access the Airbrake API. You can find it in User Settings.:project_id- (required, integer or string) the id of your project at Airbrake.:host- (string) the URL of the HTTP host; defaults tohttps://api.airbrake.io.
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:context_environment- (binary or function returning binary) the deployment environment; used to setnotice.context.environment. See "Setting the Environment in the Context" for more details.- This was formerly
:environmentwhich is now deprecated and will be removed in the next major release.
- This was formerly
:production_aliases- (list of strings) a list of"production"aliases for the environment.:options- (keyword list or function returning keyword list) values that are included in all notices posted to Airbrake.io. See "Shared Options" for more information.:session- can be set to:include_logger_metadatato include Logger metadata in thesessionfield of the report; omit this option if you do not want Logger metadata. See The Session for more details.
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.JasonPayloadProcessorSee Airbrake.Utils.filter/2 for details about filtering.
:filter_parameters- (list of strings) names of keys (strings or atoms) for sensitive data such as passwords and tokens.:filter_headers- (list of strings) names of HTTP headers (strings or atoms) to filter.:payload_processor- (module, defaults toAirbrake.PoisonPayloadProcessor)- See the Payload Processor guide for more details.
- Replaces
:json_encoderwhich is now deprecated,
: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.
config :airbrake_client,
# ...
ignore: :all:ignorehas several possibilities:nil(default) - skips nothing:allto ignore all errors (useful intest)- MapSet of error modules to ignore
- A function
(type, message -> boolean)
See "Ignoring Errors". Also see Airbrake.Test which
might affect your choice for :ignore in test.
See the specific modules for more details.
Airbrake.report/1to post a notice to Airbrake.Airbrake.LoggerBackendto postLoggererror messages as notices to Airbrake.Airbrake.Plugto post a notice for an error in aplugpipeline.Airbrake.Channelto post a notice for an error on a web channel.Airbrake.monitor/1to post a notice for errors from a process.Airbrake.GenServerorAirbrake.GenServer.handle_terminate/2to post a notice when aGenServerterminates abnormally.