@@ -6,28 +6,60 @@ defmodule Sentry do
66
77
88 @ moduledoc """
9- Provides the basic functionality to submit a `Sentry.Event` to the Sentry Service.
9+ Provides the basic functionality to submit a `Sentry.Event` to the Sentry Service.
1010
11- # ## Configuration
11+ ## Configuration
1212
13- Add the following to your production config
14- config :sentry, dsn: "https://public:[email protected] /1" 15- included_environments: [:prod],
16- environment_name: :prod,
17- tags: %{
18- env: "production"
19- }
13+ Add the following to your production config
2014
21- ### Capturing Exceptions
15+ config :sentry, dsn: "https://public:[email protected] /1" 16+ included_environments: [:prod],
17+ environment_name: :prod,
18+ tags: %{
19+ env: "production"
20+ }
2221
23- Simply calling `capture_exception\2 ` will send the event.
22+ The `environment_name` and `included_environments` work together to determine
23+ if and when Sentry should record exceptions. The `environment_name` is the
24+ name of the current environment. In the example above, we have explicitly set
25+ the environment to `:prod` which works well if you are inside an environment
26+ specific configuration `config/prod.exs`.
2427
25- Sentry.capture_exception(my_exception)
28+ An alternative is to use `Mix.env` in your general configuration file:
2629
27- ### Configuring The `Logger` Backend
2830
29- See `Sentry.Logger`
31+ config :sentry, dsn: "https://public:[email protected] /1" 32+ included_environments: [:prod],
33+ environment_name: Mix.env
3034
35+ This will set the environment name to whatever the current Mix environment
36+ atom is, but it will only send events if the current environment is `:prod`,
37+ since that is the only entry in the `included_environments` key.
38+
39+ You can even rely on more custom determinations of the environment name. It's
40+ not uncommmon for most applications to have a "staging" environment. In order
41+ to handle this without adding an additional Mix environment, you can set an
42+ environment variable that determines the release level.
43+
44+ config :sentry, dsn: "https://public:[email protected] /1" 45+ included_environments: ~w(production staging),
46+ environment_name: System.get_env("RELEASE_LEVEL") || "development"
47+
48+ In this example, we are getting the environment name from the `RELEASE_LEVEL`
49+ environment variable. If that variable does not exist, we default to `"development"`.
50+ Now, on our servers, we can set the environment variable appropriately. On
51+ our local development machines, exceptions will never be sent, because the
52+ default value is not in the list of `include_environments`.
53+
54+ ## Capturing Exceptions
55+
56+ Simply calling `capture_exception\2 ` will send the event.
57+
58+ Sentry.capture_exception(my_exception)
59+
60+ ## Configuring The `Logger` Backend
61+
62+ See `Sentry.Logger`
3163 """
3264
3365 @ client Application . get_env ( :sentry , :client , Sentry.Client )
0 commit comments