You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To learn more about how to use this SDK, refer to [the documentation][docs].
80
80
81
-
## Integrations
82
-
83
-
*[Phoenix and Plug][setup-phoenix-and-plug]
84
-
85
-
## Contributing to the SDK
86
-
87
-
Please refer to [`CONTRIBUTING.md`](CONTRIBUTING.md).
88
-
89
-
## Getting Help/Support
90
-
91
-
If you need help setting up or configuring the Python SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!
Licensed under the MIT license, see [`LICENSE`](./LICENSE).
104
-
105
-
### Context and Breadcrumbs
106
-
107
-
Sentry has multiple options for including contextual information. They are organized into "Tags", "User", and "Extra", and Sentry's documentation on them is [here](https://docs.sentry.io/learn/context/). Breadcrumbs are a similar concept and Sentry's documentation covers them [here](https://docs.sentry.io/learn/breadcrumbs/).
108
-
109
-
In Elixir this can be complicated due to processes being isolated from one another. Tags context can be set globally through configuration, and all contexts can be set within a process, and on individual events. If an event is sent within a process that has some context configured it will include that context in the event. Examples of each are below, and for more information see the documentation of [Sentry.Context](https://hexdocs.pm/sentry/Sentry.Context.html).
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).
132
-
133
-
To achieve that in Sentry Elixir, one can use the `before_send` 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:
134
-
135
-
```elixir
136
-
# lib/sentry.ex
137
-
defmoduleMyApp.Sentry
138
-
def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
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.
156
-
157
-
The best way to ensure source code is up to date is to recompile Sentry itself via `mix deps.compile sentry --force`. It's possible to create a Mix Task alias in `mix.exs` to do this. The example below allows one to run `mix sentry_recompile && mix compile` which will compile any uncompiled or changed parts of the application, and then force recompilation of Sentry so it has the newest source. The second `mix compile` is required due to Mix only invoking the same task once in an alias.
For more documentation, see [Sentry.Sources](https://hexdocs.pm/sentry/Sentry.Sources.html).
167
-
168
-
## Testing Your Configuration
81
+
#### Testing Your Configuration
169
82
170
83
To ensure you've set up your configuration correctly we recommend running the
171
-
included mix task. It can be tested on different Mix environments and will tell you if it is not currently configured to send events in that environment:
84
+
included Mix task. It can be tested on different Mix environments and will tell you if it is not currently configured to send events in that environment:
172
85
173
86
```bash
174
-
$ MIX_ENV=dev mix sentry.send_test_event
175
-
Client configuration:
176
-
server: https://sentry.io/
177
-
public_key: public
178
-
secret_key: secret
179
-
current environment_name: :dev
180
-
181
-
:dev is not in [:prod] so no test event will be sent
182
-
183
-
$ MIX_ENV=prod mix sentry.send_test_event
184
-
Client configuration:
185
-
server: https://sentry.io/
186
-
public_key: public
187
-
secret_key: secret
188
-
current environment_name: :prod
189
-
190
-
Sending test event!
87
+
MIX_ENV=dev mix sentry.send_test_event
191
88
```
192
89
193
-
## Testing with Sentry
90
+
###Testing with Sentry
194
91
195
-
In some cases, users may want to test that certain actions in their application cause a report to be sent to Sentry. Sentry itself does this by using [Bypass](https://github.com/PSPDFKit-labs/bypass). It is important to note that when modifying the environment configuration the test case should not be run asynchronously. Not returning the environment configuration to its original state could also affect other tests depending on how the Sentry configuration interacts with them.
92
+
In some cases, you may want to _test_ that certain actions in your application cause a report to be sent to Sentry. Sentry itself does this by using [Bypass]. It is important to note that when modifying the environment configuration the test case should not be run asynchronously, since you are modifying **global configuration**. Not returning the environment configuration to its original state could also affect other tests depending on how the Sentry configuration interacts with them. A good way to make sure to revert the environment is to use the [`on_exit/2`][exunit-on-exit] callback that ships with ExUnit.
196
93
197
94
For example:
198
95
@@ -207,18 +104,47 @@ test "add/2 does not raise but sends an event to Sentry when given bad input" do
When testing, you will also want to set the `:send_result` type to `:sync`, so that sending Sentry events blocks until the event is sent.
218
118
119
+
## Integrations
120
+
121
+
*[Phoenix and Plug][setup-phoenix-and-plug]
122
+
123
+
## Contributing to the SDK
124
+
125
+
Please refer to [`CONTRIBUTING.md`](CONTRIBUTING.md).
126
+
127
+
## Getting Help/Support
128
+
129
+
If you need help setting up or configuring the Python SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!
0 commit comments