Skip to content

Commit bef73be

Browse files
Merge pull request #288 from getsentry/fingerprint-docs
Document fingerprinting options
2 parents 89a996b + e9a79f3 commit bef73be

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,30 @@ default value is not in the list of `included_environments`.
158158

159159
Sentry uses the [hackney HTTP client](https://github.com/benoitc/hackney) for HTTP requests. Sentry starts its own hackney pool named `:sentry_pool` with a default connection pool of 50, and a connection timeout of 5000 milliseconds. The pool can be configured with the `hackney_pool_max_connections` and `hackney_pool_timeout` configuration keys. If you need to set other [hackney configurations](https://github.com/benoitc/hackney/blob/master/doc/hackney.md#request5) for things like a proxy, using your own pool or response timeouts, the `hackney_opts` configuration is passed directly to hackney for each request.
160160

161+
### Fingerprinting
162+
163+
By default, Sentry aggregates reported events according to the attributes of the event, but users may need to override this functionality via [fingerprinting](https://docs.sentry.io/learn/rollups/#customize-grouping-with-fingerprints).
164+
165+
To achieve that in Sentry Elixir, one can use the `before_send_event` configuration callback. If there are certain types of errors you would like to have grouped differently, they can be matched on in the callback, and have the fingerprint attribute changed before the event is sent. An example configuration and implementation could look like:
166+
167+
```elixir
168+
# lib/sentry.ex
169+
defmodule MyApp.Sentry
170+
def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
171+
%{event | fingerprint: ["ecto", "db_connection", "timeout"]}
172+
end
173+
174+
def before_send(event) do
175+
event
176+
end
177+
end
178+
179+
# config.exs
180+
config :sentry,
181+
before_send_event: {MyApp.Sentry, :before_send},
182+
# ...
183+
```
184+
161185
### Reporting Exceptions with Source Code
162186

163187
Sentry's server supports showing the source code that caused an error, but depending on deployment, the source code for an application is not guaranteed to be available while it is running. To work around this, the Sentry library reads and stores the source code at compile time. This has some unfortunate implications. If a file is changed, and Sentry is not recompiled, it will still report old source code.

docs/index.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,34 @@ allows other exceptions to be sent.
137137
included_environments: ~w(production staging),
138138
environment_name: System.get_env("RELEASE_LEVEL") || "development"
139139
140+
Fingerprinting
141+
----------------
142+
By default, Sentry aggregates reported events according to the attributes of the event,
143+
but users may need to override this functionality via `fingerprinting <https://docs.sentry.io/learn/rollups/#customize-grouping-with-fingerprints>`_.
144+
145+
To achieve that in Sentry Elixir, one can use the ``before_send_event`` configuration callback.
146+
If there are certain types of errors you would like to have grouped differently,
147+
they can be matched on in the callback, and have the fingerprint attribute changed before the event is sent.
148+
149+
An example configuration and implementation could look like:
150+
151+
.. code-block:: elixir
152+
# sentry.ex
153+
defmodule MyApp.Sentry
154+
def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
155+
%{event | fingerprint: ["ecto", "db_connection", "timeout"]}
156+
end
157+
158+
def before_send(event) do
159+
event
160+
end
161+
end
162+
163+
# config.exs
164+
config :sentry,
165+
before_send_event: {MyApp.Sentry, :before_send},
166+
# ...
167+
140168
Including Source Code
141169
---------------------
142170

0 commit comments

Comments
 (0)