Skip to content

Commit de0bbb1

Browse files
committed
Clean up the README
1 parent 6281925 commit de0bbb1

File tree

1 file changed

+38
-112
lines changed

1 file changed

+38
-112
lines changed

README.md

Lines changed: 38 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defp deps do
2525
[
2626
# ...
2727

28-
{:sentry, "~> 9.0"},
28+
{:sentry, "~> 10.0"},
2929
{:jason, "~> 1.4"},
3030
{:hackney, "~> 1.19"}
3131
]
@@ -78,121 +78,18 @@ Sentry.capture_message("custom_event_name", extra: %{extra: information})
7878

7979
To learn more about how to use this SDK, refer to [the documentation][docs].
8080

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!
92-
93-
## Resources
94-
95-
* [![Documentation](https://img.shields.io/badge/documentation-hexdocs.svg)][docs]
96-
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
97-
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
98-
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
99-
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
100-
101-
## License
102-
103-
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).
110-
111-
```elixir
112-
# Global Tags context via configuration:
113-
114-
config :sentry,
115-
tags: %{my_app_version: "14.30.10"}
116-
# ...
117-
118-
# Process-based Context
119-
Sentry.Context.set_extra_context(%{day_of_week: "Friday"})
120-
Sentry.Context.set_user_context(%{id: 24, username: "user_username", has_subscription: true})
121-
Sentry.Context.set_tags_context(%{locale: "en-us"})
122-
Sentry.Context.add_breadcrumb(%{category: "web.request"})
123-
124-
# Event-based Context
125-
Sentry.capture_exception(exception, [tags: %{locale: "en-us", }, user: %{id: 34},
126-
extra: %{day_of_week: "Friday"}, breadcrumbs: [%{timestamp: 1461185753845, category: "web.request"}]]
127-
```
128-
129-
### Fingerprinting
130-
131-
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-
defmodule MyApp.Sentry
138-
def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
139-
%{event | fingerprint: ["ecto", "db_connection", "timeout"]}
140-
end
141-
142-
def before_send(event) do
143-
event
144-
end
145-
end
146-
147-
# config.exs
148-
config :sentry,
149-
before_send: {MyApp.Sentry, :before_send},
150-
# ...
151-
```
152-
153-
### Reporting Exceptions with Source Code
154-
155-
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.
158-
159-
```elixir
160-
# mix.exs
161-
defp aliases do
162-
[sentry_recompile: ["compile", "deps.compile sentry --force"]]
163-
end
164-
```
165-
166-
For more documentation, see [Sentry.Sources](https://hexdocs.pm/sentry/Sentry.Sources.html).
167-
168-
## Testing Your Configuration
81+
#### Testing Your Configuration
16982

17083
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:
17285

17386
```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
19188
```
19289

193-
## Testing with Sentry
90+
### Testing with Sentry
19491

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.
19693

19794
For example:
19895

@@ -207,18 +104,47 @@ test "add/2 does not raise but sends an event to Sentry when given bad input" do
207104

208105
Sentry.put_config(:dsn, "http://public:secret@localhost:#{bypass.port}/1")
209106
Sentry.put_config(:send_result, :sync)
107+
108+
on_exit(fn ->
109+
Sentry.put_config(:dsn, nil)
110+
Sentry.put_config(:send_result, :none)
111+
end)
112+
210113
MyModule.add(1, "a")
211-
after
212-
# Return config to the previous value
213-
# ...
214114
end
215115
```
216116

217117
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.
218118

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!
130+
131+
## Resources
132+
133+
* [![Documentation](https://img.shields.io/badge/documentation-hexdocs.svg)][docs]
134+
* [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)
135+
* [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)
136+
* [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)
137+
* [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry)
138+
139+
## License
140+
141+
Licensed under the MIT license, see [`LICENSE`](./LICENSE).
142+
219143
[Sentry]: http://sentry.io/
220144
[Jason]: https://github.com/michalmuskala/jason
221145
[Hackney]: https://github.com/benoitc/hackney
146+
[Bypass]: https://github.com/PSPDFKit-labs/bypass
222147
[docs]: https://hexdocs.pm/sentry/readme.html
223148
[logger-handlers]: https://www.erlang.org/doc/apps/kernel/logger_chapter#handlers
224149
[setup-phoenix-and-plug]: https://hexdocs.pm/sentry/setup-with-plug-and-phoenix.html
150+
[exunit-on-exit]: https://hexdocs.pm/ex_unit/ExUnit.Callbacks.html#on_exit/2

0 commit comments

Comments
 (0)