View Source bugsnag (bugsnag_erlang v3.0.0-rc1)

BugSnag Erlang client.

Configuration

It can be configured using application environment variables or by passing a map to the start_link/1 function.

If using application environment variables, the config looks like the following:

{bugsnag_erlang, [
    {enabled, true},
    {api_key, "BUGSNAG_API_KEY"},
    {release_stage, "production"},
    {handler_name, bugsnag_logger_handler},
    {pool_size, 10}
]}

If enabled is set to other than true, the rest of the configuration won't be read and no handler will be registered. For the rest of the keys, see config/0.

If a new handler wants to be added, the handler_name key can be set to a new atom.

Summary

Types

Configuration options for the Bugsnag client.

Event to notify to BugSnag.

Metadata about the event.

A printable string

Functions

Add a new logger handler.

Add a new logger handler.

Notify of a bugsnag event.

Notify a global worker about an exception.

Notify a global worker about an exception.

Remove a new logger handler.

Add a new global bugsnag_logger_handler handler.

Types

config()

-type config() ::
          #{api_key := binary(),
            release_stage := binary(),
            name := logger_handler:id(),
            pool_size := pos_integer(),
            endpoint => binary(),
            events_limit => pos_integer()}.

Configuration options for the Bugsnag client.

It takes the following configuration options:

  • api_key: the Bugsnag API key, mandatory to provide.
  • release_stage: the release stage of the application, defaults to production
  • name: defaults to bugsnag_logger_handler, but allows to create more logger handlers with different configurations.
  • pool_size: defaults to the number of schedulers, increases the number of workers in the pool in case of high load.
  • endpoint: allows you to configure a custom config, including testing endpoints.
  • events_limit: allows you to configure the maximum number of events to be sent to Bugsnag at once. If event queues fill too fast, older non-sent events will be dropped. The default is 1000, as an average big event including stacktraces is no bigger than 1KB, therefore 1000 events should keep the payload below 1MB.

event()

-type event() ::
          #{what => text(),
            message => text(),
            class => exit | error | throw,
            reason => term(),
            stacktrace => [{module(), atom(), non_neg_integer() | [term()], [{atom(), _}]}],
            atom() => text()}.

Event to notify to BugSnag.

  1. Events that contain #{class := _, reason := _, stacktrace := _}, following the naming convention as exemplified by erlang:raise/3, will be treated as exceptions to BugSnag.
  2. Event structure will have all their printable key-value pairs as key-value pairs in metaData.
  3. breadcrumbs will always contain the timestamp of the event.

metadata()

-type metadata() ::
          #{mfa := {module(), atom(), non_neg_integer()},
            line := non_neg_integer(),
            level => logger:level(),
            time => integer(),
            atom => term()}.

Metadata about the event.

The default severity level is warning. The default mfa is {undefined, undefined, 0} and line is also 0.

text()

-type text() :: atom() | string() | binary().

A printable string

Functions

add_handler(Config)

-spec add_handler(config()) -> supervisor:startchild_ret().

Add a new logger handler.

add_handler(Config, LoggerConfig)

Add a new logger handler.

notify(BugSnagConfig, Report, Meta)

-spec notify(config(), event(), metadata()) -> term().

Notify of a bugsnag event.

  1. Events that contain #{class := _, reason := _, stacktrace := _}, following the naming convention as exemplified by erlang:raise/3, will be treated as exceptions to BugSnag.
  2. Event structure will have all their printable key-value pairs as key-value pairs in metaData

notify(Type, Reason, Message, Module, Line)

This function is deprecated. bugsnag:notify/5 is deprecated; will be removed in the next major release. See the documentation for details.
-spec notify(atom(), atom() | string(), string() | binary(), module(), non_neg_integer()) -> ok.

Notify a global worker about an exception.

notify(Type, Reason, Message, Module, Line, Trace, Request)

This function is deprecated. bugsnag:notify/7 is deprecated; will be removed in the next major release. See the documentation for details.
-spec notify(atom(),
             atom() | string(),
             string() | binary(),
             module(),
             non_neg_integer(),
             [term()],
             term()) ->
                ok.

Notify a global worker about an exception.

remove_handler/1

-spec remove_handler(logger_handler:id() | config()) -> ok | {error, term()}.

Remove a new logger handler.

start_link(ApiKey, ReleaseStage)

This function is deprecated. bugsnag:start_link/2 is deprecated; will be removed in the next major release. See the documentation for details.
-spec start_link(binary(), binary()) -> gen_server:start_ret().

Add a new global bugsnag_logger_handler handler.

This is deprecated, add_handler/1 is preferred.