sentry v1.1.1 Sentry
Provides the basic functionality to submit a Sentry.Event
to the Sentry Service.
Configuration
Add the following to your production config
config :sentry, dsn: "https://public:secret@app.getsentry.com/1"
included_environments: [:prod],
environment_name: :prod,
tags: %{
env: "production"
}
The environment_name
and included_environments
work together to determine
if and when Sentry should record exceptions. The environment_name
is the
name of the current environment. In the example above, we have explicitly set
the environment to :prod
which works well if you are inside an environment
specific configuration config/prod.exs
.
An alternative is to use Mix.env
in your general configuration file:
config :sentry, dsn: "https://public:secret@app.getsentry.com/1"
included_environments: [:prod],
environment_name: Mix.env
This will set the environment name to whatever the current Mix environment
atom is, but it will only send events if the current environment is :prod
,
since that is the only entry in the included_environments
key.
You can even rely on more custom determinations of the environment name. It’s not uncommmon for most applications to have a “staging” environment. In order to handle this without adding an additional Mix environment, you can set an environment variable that determines the release level.
config :sentry, dsn: "https://public:secret@app.getsentry.com/1"
included_environments: ~w(production staging),
environment_name: System.get_env("RELEASE_LEVEL") || "development"
In this example, we are getting the environment name from the RELEASE_LEVEL
environment variable. If that variable does not exist, we default to "development"
.
Now, on our servers, we can set the environment variable appropriately. On
our local development machines, exceptions will never be sent, because the
default value is not in the list of included_environments
.
Capturing Exceptions
Simply calling capture_exception2
will send the event.
Sentry.capture_exception(my_exception)
Configuring The <code class="inline">Logger</code> Backend
See Sentry.Logger
Summary
Functions
Parses and submits an exception to Sentry if current environment is in included_environments
Sends a Sentry.Event
Callback implementation for c:Application.start/2
Functions
Specs
capture_exception(Exception.t, Keyword.t) ::
{:ok, String.t} |
:error
Parses and submits an exception to Sentry if current environment is in included_environments.
Specs
send_event(%Sentry.Event{breadcrumbs: term, culprit: term, environment: term, event_id: term, exception: term, extra: term, level: term, message: term, platform: term, release: term, request: term, server_name: term, stacktrace: term, tags: term, timestamp: term, user: term}) ::
{:ok, String.t} |
:error
Sends a Sentry.Event