sentry v1.1.1 Sentry.Plug

Provides basic funcitonality to handle Plug.ErrorHandler

Usage

Add the following to your router.ex:

use Plug.ErrorLogger
use Sentry.Plug

Sending Post Body Params

In order to send post body parameters you need to first scrub them of sensitive information. To do so we ask you to pass a scrubber key which accepts a Plug.Conn and returns a map with keys to send.

def scrub_params(conn) do
  conn.params # Make sure the params have been fetched.
  |> Map.to_list
  |> Enum.filter(fn ({key, val}) -> 
    key in ~w(password passwd secret credit_card) ||
    Regex.match?(~r/^(?:[ -]*?){13,16}$r/, val) # Matches Credit Cards
  end)
  |> Enum.into(%{})
end

Then pass it into Sentry.Plug

use Sentry.Plug, scrubber: &scrub_params/1

You can also pass it in as a {module, fun} like so

use Sentry.Plug, scrubber: {MyModule, :scrub_params}

Please Note: If you are sending large files you will want to scrub them out.

Headers Scrubber

By default we will scrub Authorization and Authentication headers from all requests before sending them.

Including Request Identifiers

If you’re using Phoenix, Plug.RequestId, or another method to set a request ID response header, and would like to include that information with errors reported by Sentry.Plug, the :request_id_header option allows you to set which header key Sentry should check. It will default to “x-request-id”, which Plug.RequestId (and therefore Phoenix) also default to.

use Sentry.Plug, request_id_header: "application-request-id"

Summary

Functions

build_request_interface_data(conn, opts)
remote_address(address)
remote_port(arg)