Skip to content

Commit e695f44

Browse files
committed
sentry docs
1 parent 9b8ec9c commit e695f44

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

docs/config.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ Optional settings
5252
Set this to true if you want to capture all exceptions that occur even outside of a request cycle. This
5353
defaults to false.
5454

55+
.. describe:: filter
56+
57+
Set this to a module that implements the ``Sentry.EventFilter`` behaviour if you would like to prevent
58+
certain exceptions from being sent. See below for further documentation.
59+
5560
Testing Your Configuration
5661
--------------------------
5762

docs/index.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ new process and it fails you might lose your context. That said using the contex
107107
# adds an breadcrumb to the request to help debug
108108
Sentry.Context.add_breadcrumb(%{my: "crumb"})
109109
110+
Filtering Events
111+
--------------
112+
113+
If you would like to prevent certain exceptions, the :filter configuration option
114+
allows you to implement the ``Sentry.EventFilter`` behaviour. The first argument is the
115+
source of the event, and the second is the exception to be sent. ``Sentry.Plug``
116+
will have a source of ``:plug``, and ``Sentry.Logger`` will have a source of ``:logger``.
117+
If an exception does not come from either of those sources, the source will be nil
118+
unless the ``:event_source`` option is passed to ``Sentry.capture_exception/2``
119+
120+
A configuration like below will prevent sending ``Phoenix.Router.NoRouteError`` from ``Sentry.Plug``, but
121+
allows other exceptions to be sent.
122+
123+
.. code-block:: elixir
124+
# sentry_event_filter.exs
125+
defmodule MyApp.SentryEventFilter do
126+
@behaviour Sentry.EventFilter
127+
128+
def exclude_exception?(:plug, %Elixir.Phoenix.Router.NoRouteError{}), do: true
129+
def exclude_exception?(_, ), do: false
130+
end
131+
132+
# config.exs
133+
config :sentry, filter: MyApp.SentryEventFilter,
134+
included_environments: ~w(production staging),
135+
environment_name: System.get_env("RELEASE_LEVEL") || "development"
136+
110137
Deep Dive
111138
---------
112139

docs/usage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ With calls to ``capture_exception`` additional data can be supplied as a keyword
7171
"email" => "clever-girl"
7272
}
7373
74+
.. describe:: event_source
75+
76+
The source of the event. Used by the `Sentry.EventFilter` behaviour.
7477

7578
Breadcrumbs
7679
-----------

0 commit comments

Comments
 (0)