vorce / bugsnag-elixir

An Elixir interface to the Bugsnag API

Home Page:https://hex.pm/packages/bugsnag

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bugsnag Elixir Build Status

Capture exceptions and send them to the Bugsnag API!

Installation

# Add it to your deps in your projects mix.exs
defp deps do
  [{:bugsnag, "~> 1.3.2"}]
end

# Now, list the :bugsnag application as your application dependency:
def application do
  [applications: [:bugsnag]]
end

# Open up your config/config.exs (or appropriate project config)
config :bugsnag, api_key: "bbf085fc54ff99498ebd18ab49a832dd"

# Set the release stage in your environment configs (e.g. config/prod.exs)
config :bugsnag, release_stage: "prod"

Usage

Manual reporting

# Report an exception.
try do
  :foo = :bar
rescue
  exception -> Bugsnag.report(exception)
end

Options

These are optional fields to fill the bugsnag report with more information, depending on your specific usage scenario. They can be passed into the Bugsnag.report/2 function like so:

# ...an exception occured
  Bugsnag.report(exception, severity: "warn", user: %{name: "Jane Doe"})
  • stacktrace - Allows explicitly passing in a stacktrace used to generate the stacktrace object that is sent to bugsnag
  • severity - Sets the severity explicitly to "error", "warning" or "info"
  • release_stage - Explicitly sets an arbitrary release stage e.g. "development", "test" or "production"
  • context - Allows passing in context information, like e.g. the name of the file the crash occured in
  • user - Allows passing in user information, needs to be a map with one or more of the following fields (which are then searchable):
    • id - Any binary identifier for the user
    • name - Full name of the user
    • email - Full email of the user
  • os_version and hostname - Will be aggregated within Bugsnag's device field and can be used as a filter
  • metadata - Arbitrary metadata (See Bugsnag docs for more information)

Logger

Set the use_logger option to true in your application's config.exs. Then run Bugsnag.start and any SASL compliant processes that crash will send an error report to the Bugsnag.Logger. The logger will take care of sending the error to Bugsnag.

About

An Elixir interface to the Bugsnag API

https://hex.pm/packages/bugsnag

License:MIT License


Languages

Language:Elixir 100.0%