Skip to content

Commit f8a8258

Browse files
committed
docs(elixir): Only recommend Sentry.PlugCapture for Cowboy applications
1 parent b6f0cfe commit f8a8258

File tree

1 file changed

+21
-5
lines changed
  • docs/platforms/elixir/integrations/plug_and_phoenix

1 file changed

+21
-5
lines changed

docs/platforms/elixir/integrations/plug_and_phoenix/index.mdx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ sidebar_order: 10
66

77
You can capture errors in [Plug](https://github.com/elixir-plug/plug) and [Phoenix](https://phoenixframework.org) applications with `Sentry.PlugContext` and `Sentry.PlugCapture`.
88

9-
`Sentry.PlugContext` adds contextual metadata from the current request, which is then included in errors that are captured and reported by `Sentry.PlugCapture`.
9+
`Sentry.PlugContext` adds contextual metadata from the current request to the reported errors that happen during Plug execution. For [Cowboy](https://hex.pm/packages/cowboy) applications, an additional plug `Sentry.PlugCapture` is required to ensure this metadata propagates properly.
1010

1111
## Phoenix Configuration
1212

1313
If you are using Phoenix, follow these steps to add the Plug integration:
1414

15-
1. Add `Sentry.PlugCapture` above the `use Phoenix.Endpoint` line in your endpoint file.
1615
1. Add `Sentry.PlugContext` below `Plug.Parsers`.
1716

1817
```elixir {diff}
1918
defmodule MyAppWeb.Endpoint
20-
+ use Sentry.PlugCapture
2119
use Phoenix.Endpoint, otp_app: :my_app
2220

2321
# ...
@@ -30,6 +28,16 @@ defmodule MyAppWeb.Endpoint
3028
+ plug Sentry.PlugContext
3129
```
3230

31+
2. If you're using Cowboy, add `Sentry.PlugCapture` above the `use Phoenix.Endpoint` line in your endpoint file.
32+
33+
```elixir {diff}
34+
defmodule MyAppWeb.Endpoint
35+
+ use Sentry.PlugCapture
36+
use Phoenix.Endpoint, otp_app: :my_app
37+
38+
# ...
39+
```
40+
3341
If you're also using [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view), consider also setting up your LiveViews to use the `Sentry.LiveViewHook` hook (available in the Sentry SDK versions `10.5.0` and higher):
3442

3543
```elixir
@@ -78,18 +86,26 @@ end
7886

7987
If you have a non-Phoenix application, follow these steps to configure the Plug integration:
8088

81-
1. Add `Sentry.PlugCapture` at the top of your Plug application.
8289
1. Add `Sentry.PlugContext` below `Plug.Parsers` (if it is in your stack).
8390

8491
```elixir {diff}
8592
defmodule MyApp.Router do
8693
use Plug.Router
87-
+ use Sentry.PlugCapture
8894

8995
# ...
9096

9197
plug Plug.Parsers,
9298
parsers: [:urlencoded, :multipart]
9399

94100
+ plug Sentry.PlugContext
101+
```
102+
103+
2. If you're using Cowboy, add `Sentry.PlugCapture` at the top of your Plug application.
104+
105+
```elixir {diff}
106+
defmodule MyApp.Router do
107+
use Plug.Router
108+
+ use Sentry.PlugCapture
109+
110+
# ...
95111
```

0 commit comments

Comments
 (0)