exsentry v0.3.0 ExSentry
ExSentry is an Elixir interface to the Sentry error reporting platform.
ExSentry may be used as an OTP application with a client configured by
config.exs
, or as a standalone client configured manually.
ExSentry.Plug can be used to intercept and report exceptions encountered
by a Plug-based web application.
Installation
Add ExSentry to your list of dependencies in
mix.exs
:def deps do [{:exsentry, "~> 0.3.0"}] end
Ensure ExSentry is started and packaged with your application, in
mix.exs
:def application do [applications: [:exsentry]] end
Optional: To configure the default ExSentry client, specify your Sentry DSN in
config.exs
:config :exsentry, dsn: "your-dsn-here"
Usage
ExSentry can be used as a manually-configured standalone client,
as a config.exs
-configured OTP application,
or as a Plug in your webapp’s plug stack (e.g., Phoenix router).
Standalone
Create a client process like this:
client = ExSentry.new("your-dsn-here")
And capture messages or exceptions like this:
client |> ExSentry.capture_message("Hello world!")
client |> ExSentry.capture_exception(an_exception)
client |> ExSentry.capture_exceptions fn ->
something_that_might_raise()
end
OTP Application
If you’ve configured config.exs
as described in the README:
config :exsentry, dsn: "your-dsn-here"
You can invoke ExSentry without explicitly creating a client:
ExSentry.capture_message("Hello world!")
ExSentry.capture_exception(an_exception)
ExSentry.capture_exceptions fn ->
something_that_might_raise()
end
Plug
ExSentry can be used as a Plug error handler, to automatically inform Sentry of any exceptions encountered within your web application.
To use ExSentry as a Plug error handler, follow all configuration
instructions, then put use ExSentry.Plug
wherever your Plug stack is
defined, for instance in web/router.ex
in a Phoenix application:
defmodule MyApp.Router do
use MyApp.Web, :router
use ExSentry.Plug
pipeline :browser do
...
Authorship and License
ExSentry is copyright 2015-2016 Appcues, Inc.
ExSentry is released under the MIT License.
Summary
Functions
Sends an exception to Sentry, using the default client
Sends an exception to Sentry, using the given client
Sends an exception to Sentry, using the given client and options
Using the default client, runs the given function, sending any exception to Sentry. Does not rescue the exception
Using the given client, runs the given function, sending any exception to Sentry. Does not rescue the exception
Using the given client and options, runs the given function, sending any exception to Sentry. Does not rescue the exception
Sends a message to Sentry, using the default client
Sends a message to Sentry, using the given client
Sends a message to Sentry, using the given client and options
Starts a Sentry client, and returns the PID of the client process
Callback implementation for c::application.start/2
Functions
Specs
capture_exception(Exception.t) :: :ok
Sends an exception to Sentry, using the default client.
Specs
capture_exception(GenServer.server, Exception.t) :: :ok
capture_exception(Exception.t, [{:atom, any}]) :: :ok
Sends an exception to Sentry, using the given client.
Specs
capture_exception(GenServer.server, Exception.t, [{:atom, any}]) :: :ok
Sends an exception to Sentry, using the given client and options.
Specs
capture_exceptions((() -> any)) :: any
Using the default client, runs the given function, sending any exception to Sentry. Does not rescue the exception.
Specs
capture_exceptions(GenServer.server, (() -> any)) :: any
capture_exceptions([{:atom, any}], (() -> any)) :: any
Using the given client, runs the given function, sending any exception to Sentry. Does not rescue the exception.
Specs
capture_exceptions(GenServer.server, [{:atom, any}], (() -> any)) :: any
Using the given client and options, runs the given function, sending any exception to Sentry. Does not rescue the exception.
Specs
capture_message(String.t) :: :ok
Sends a message to Sentry, using the default client.
Specs
capture_message(GenServer.server, String.t) :: :ok
capture_message(String.t, [{:atom, any}]) :: :ok
Sends a message to Sentry, using the given client.
Specs
capture_message(GenServer.server, String.t, [{:atom, any}]) :: :ok
Sends a message to Sentry, using the given client and options.
Specs
new(String.t, [{:atom, any}]) :: GenServer.server
Starts a Sentry client, and returns the PID of the client process.