Skip to content

Commit 37ba553

Browse files
committed
update docs
1 parent 30c2bf0 commit 37ba553

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,51 @@ defp deps do
2121
end
2222
```
2323

24-
Setup the application environment in your `config/prod.exs`
24+
An example production config might look like this:
2525

2626
```elixir
2727
config :sentry,
2828
dsn: "https://public:[email protected]/1",
29+
environment_name: :prod,
30+
included_environments: [:prod],
2931
tags: %{
3032
env: "production"
3133
}
3234
```
3335

36+
The environment
37+
38+
The `environment_name` and `included_environments` work together to determine
39+
if and when Sentry should record exceptions. The `environment_name` is the
40+
name of the current environment. In the example above, we have explicitly set
41+
the environment to `:prod` which works well if you are inside an environment
42+
specific configuration like `config/prod.exs`.
43+
44+
Alternatively, you could use Mix.env in your general configuration file:
45+
46+
```elixir
47+
config :sentry, dsn: "https://public:[email protected]/1"
48+
included_environments: [:prod],
49+
environment_name: Mix.env
50+
```
51+
52+
You can even rely on more custom determinations of the environment name. It's
53+
not uncommmon for most applications to have a "staging" environment. In order
54+
to handle this without adding an additional Mix environment, you can set an
55+
environment variable that determines the release level.
56+
57+
```elixir
58+
config :sentry, dsn: "https://public:[email protected]/1"
59+
included_environments: ~w(production staging),
60+
environment_name: System.get_env("RELEASE_LEVEL") || "development"
61+
```
62+
63+
In this example, we are getting the environment name from the `RELEASE_LEVEL`
64+
environment variable. If that variable does not exist, we default to `"development"`.
65+
Now, on our servers, we can set the environment variable appropriately. On
66+
our local development machines, exceptions will never be sent, because the
67+
default value is not in the list of `included_environments`.
68+
3469
### Capture Exceptions
3570

3671
Sometimes you want to capture specific exceptions, to do so use the `Sentry.capture_exception/3`.

docs/index.rst

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,47 @@ Setup the application production environment in your ``config/prod.exs``
3636
3737
config :sentry,
3838
dsn: "https://public:[email protected]/1",
39+
environment_name: :prod
3940
tags: %{
4041
env: "production"
4142
},
42-
included_environments: ~w(prod)a
43+
included_environments: [:prod]
44+
45+
46+
The ``environment_name`` and ``included_environments`` work together to determine
47+
if and when Sentry should record exceptions. The ``environment_name`` is the
48+
name of the current environment. In the example above, we have explicitly set
49+
the environment to ``:prod`` which works well if you are inside an environment
50+
specific configuration like ``config/prod.exs``.
51+
52+
An alternative is to use ``Mix.env`` in your general configuration file:
53+
54+
.. code-block:: elixir
55+
56+
config :sentry, dsn: "https://public:[email protected]/1"
57+
included_environments: [:prod],
58+
environment_name: Mix.env
59+
60+
This will set the environment name to whatever the current Mix environment
61+
atom is, but it will only send events if the current environment is ``:prod``,
62+
since that is the only entry in the ``included_environments`` key.
63+
64+
You can even rely on more custom determinations of the environment name. It's
65+
not uncommmon for most applications to have a "staging" environment. In order
66+
to handle this without adding an additional Mix environment, you can set an
67+
environment variable that determines the release level.
68+
69+
.. code-block:: elixir
70+
71+
config :sentry, dsn: "https://public:[email protected]/1"
72+
included_environments: ~w(production staging),
73+
environment_name: System.get_env("RELEASE_LEVEL") || "development"
74+
75+
In this example, we are getting the environment name from the ``RELEASE_LEVEL``
76+
environment variable. If that variable does not exist, we default to ``"development"``.
77+
Now, on our servers, we can set the environment variable appropriately. On
78+
our local development machines, exceptions will never be sent, because the
79+
default value is not in the list of ``included_environments``.
4380

4481
If using an environment with Plug or Phoenix add the following to your router:
4582

lib/sentry.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ defmodule Sentry do
4949
environment variable. If that variable does not exist, we default to `"development"`.
5050
Now, on our servers, we can set the environment variable appropriately. On
5151
our local development machines, exceptions will never be sent, because the
52-
default value is not in the list of `include_environments`.
52+
default value is not in the list of `included_environments`.
5353
5454
## Capturing Exceptions
5555

0 commit comments

Comments
 (0)