@@ -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
0 commit comments