Skip to content

Commit c4a2f67

Browse files
committed
Add some documentation
1 parent 42c312a commit c4a2f67

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

lib/error_tracker.ex

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ defmodule ErrorTracker do
6060
As we had seen before, you can use `ErrorTracker.report/3` to manually report an
6161
error. The third parameter of this function is optional and allows you to include
6262
extra context that will be tracked along with the error.
63+
64+
## Breadcrumbs
65+
66+
Aside from contextual information, it is sometimes useful to know in which points
67+
of your code the code was executed in a given request / process.
68+
69+
Using breadcrumbs allows you to add that information to any error generated and
70+
stored on a given process / request. And if you are using `Ash` or `Splode`their
71+
exceptions' breadcrumbs will be automatically populated.
72+
73+
If you want to add a breadcrumb you can do so:
74+
75+
```elixir
76+
ErrorTracker.add_breadcrumb("Executed my super secret code")
77+
```
78+
79+
Breadcrumbs can be viewed in the dashboard while viewing the details of an
80+
occurrence.
6381
"""
6482

6583
@typedoc """
@@ -204,6 +222,22 @@ defmodule ErrorTracker do
204222
Process.get(:error_tracker_context, %{})
205223
end
206224

225+
@doc """
226+
Adds a breadcrumb to the current process.
227+
228+
The new breadcrumb will be added as the most recent entry of the breadcrumbs
229+
list.
230+
231+
## Breadcrumbs limit
232+
233+
Breadcrumbs are a powerful tool that allows to add an infinite number of
234+
entries. However, it is not recommended to store errors with an excessive
235+
amount of breadcrumbs.
236+
237+
As they are stored as an array of strings under the hood, storing many
238+
entries per error can lead to some delays and using extra disk space on the
239+
database.
240+
"""
207241
@spec add_breadcrumb(String.t()) :: list(String.t())
208242
def add_breadcrumb(breadcrumb) when is_binary(breadcrumb) do
209243
current_breadcrumbs = Process.get(:error_tracker_breadcrumbs, [])
@@ -215,7 +249,7 @@ defmodule ErrorTracker do
215249
end
216250

217251
@doc """
218-
Obtain the context of the current process.
252+
Obtain the breadcrumbs of the current process.
219253
"""
220254
@spec get_breadcrumbs() :: list(String.t())
221255
def get_breadcrumbs do

0 commit comments

Comments
 (0)