View Source ErrorTracker.Integrations.Plug (ErrorTracker v0.4.0)
Integration with Plug applications.
How to use it
Plug applications
The way to use this integration is by adding it to either your Plug.Builder
or Plug.Router
:
defmodule MyApp.Router do
use Plug.Router
use ErrorTracker.Integrations.Plug
...
end
Phoenix applications
There is a particular use case which can be useful when running a Phoenix web application.
If you want to record exceptions that may occur in your application's endpoint before reaching your router (for example, in any plug like the ones decoding cookies of body contents) you may want to add this integration too:
defmodule MyApp.Endpoint do
use Phoenix.Endpoint
use ErrorTracker.Integrations.Plug
...
end
Default context
By default we store some context for you on errors generated during a Plug request:
request.host
: theconn.host
value.request.ip
: the IP address that initiated the request. It includes parsing proxy headersrequest.method
: the HTTP method of the request.request.path
: the path of the request.request.query
: the query string of the request.request.params
: parsed params of the request (only available if they have been fetched and parsed as part of the Plug pipeline).request.headers
: headers received on the request. All headers are included by default except for theCookie
ones, as they may include large and sensitive content like sessions.