exsentry v0.7.1 ExSentry
ExSentry is an Elixir interface to the Sentry error reporting platform.
Installation
Add ExSentry to your list of dependencies in
mix.exs
:def deps do [{:exsentry, "~> 0.7.1"}] end
Ensure ExSentry is started and packaged with your application, in
mix.exs
:def application do [applications: [:exsentry]] end
Configure the default ExSentry client by specifying your Sentry DSN in
config.exs
:config :exsentry, otp_app: :my_app, dsn: "your-dsn-here"
To turn ExSentry off for a particular
MIX_ENV
, set the Sentry DSN to the empty string""
in the appropriate config file.
Typical usage
Use ExSentry.LoggerBackend
to send all :error
-level log messages
to Sentry:
defmodule MyApp do
use Application
def start(_type, _args) do
Logger.add_backend(ExSentry.LoggerBackend)
# ...
end
# ...
end
Use ExSentry.Plug
to capture all exceptions in a Plug pipeline:
# Phoenix example
defmodule MyApp.Router do
use MyApp.Web, :router
use ExSentry.Plug
pipeline :browser do
# ...
# pure Plug example
defmodule MyApp.Router do
use Plug.Router
use ExSentry.Plug
get "/" do
# ...
Use ExSentry
by itself to send exception or message data to Sentry:
ExSentry.capture_message("Hello world!")
ExSentry.capture_exception(an_exception)
ExSentry.capture_exceptions fn ->
something_that_might_raise()
end
Standalone usage
ExSentry can be used as a manually-configured standalone client.
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
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.
Pass an Erlang stacktrace as opts[:stacktrace]
to override
the default System.stacktrace
behavior.
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.