Skip to content

Commit 0439957

Browse files
committed
Add doc to ErrorTracker.Filter module
1 parent acaac03 commit 0439957

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

lib/error_tracker/filter.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
defmodule ErrorTracker.Filter do
22
@moduledoc """
3-
Behaviour for sanitizing & modifying the saved error context
3+
Behaviour for sanitizing & modifying the error context before it's saved.
4+
5+
defmodule MyApp.ErrorFilter do
6+
@behaviour ErrorTracker.Filter
7+
8+
@impl true
9+
def sanitize(context) do
10+
context # Modify the context object (add or remove fields as much as you need.)
11+
end
12+
end
13+
14+
Once implemented, include it in the ErrorTracker configuration:
15+
16+
config :error_tracker, filter: MyApp.Filter
17+
18+
With this configuration in place, the ErrorTracker will call `MyApp.Filter.sanitize/1` to get a context before
19+
saving error occurrence.
20+
21+
> #### A note on performance {: .warning}
22+
>
23+
> Keep in mind that the `sanitize/1` will be called in the context of the ErrorTracker itself.
24+
> Slow code will have a significant impact in the ErrorTracker performance. Buggy code can bring
25+
> the ErrorTracker process down.
26+
"""
27+
28+
@doc """
29+
This function will be given an error context to inspect/modify before it's saved.
430
"""
531
@callback sanitize(context :: map()) :: map()
632
end

0 commit comments

Comments
 (0)