Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## master

* Enhancements
* Allow setting `hackney_opts`

## 2.1.0 (2016-12-17)

* Enhancements
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ config :sentry,
| `release` | False | None | |
| `server_name` | False | None | |
| `use_error_logger` | False | False | |
| hackney_opts | False | [] | |

An example production config might look like this:

Expand All @@ -77,7 +78,8 @@ config :sentry,
included_environments: [:prod],
tags: %{
env: "production"
}
},
hackney_opts: [pool: :my_pool]
```

The `environment_name` and `included_environments` work together to determine
Expand Down Expand Up @@ -111,6 +113,8 @@ Now, on our servers, we can set the environment variable appropriately. On
our local development machines, exceptions will never be sent, because the
default value is not in the list of `included_environments`.

Sentry uses the [hackney HTTP client](https://github.com/benoitc/hackney) for HTTP requests. If you need to set [hackney configurations](https://github.com/benoitc/hackney/blob/master/doc/hackney.md#request5) for things like a proxy or different pool, the `hackney_opts` configuration is passed directly to hackney.

## Testing Your Configuration

To ensure you've set up your configuration correctly we recommend running the
Expand Down
4 changes: 4 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Optional settings
Set this to a module that implements the ``Sentry.EventFilter`` behaviour if you would like to prevent
certain exceptions from being sent. See below for further documentation.

.. describe:: hackney_opts

Sentry uses `hackney <https://github.com/benoitc/hackney>`_. If you would like to set `options <https://github.com/benoitc/hackney/blob/master/doc/hackney.md#request5>`_ for hackney requests, they can be provided via this configuration.

Testing Your Configuration
--------------------------

Expand Down
4 changes: 3 additions & 1 deletion lib/mix/tasks/sentry.send_test_event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
end

environment_name = Application.get_env(:sentry, :environment_name)
hackney_opts = Application.get_env(:sentry, :hackney_opts, [])
Mix.shell.info "Client configuration:"
Mix.shell.info "server: #{endpoint}"
Mix.shell.info "public_key: #{public_key}"
Mix.shell.info "secret_key: #{secret_key}"
Mix.shell.info "included_environments: #{inspect included_environments}"
Mix.shell.info "current environment_name: #{inspect environment_name}\n"
Mix.shell.info "current environment_name: #{inspect environment_name}"
Mix.shell.info "hackney_opts: #{inspect hackney_opts}\n"

maybe_send_event(environment_name, included_environments)
end
Expand Down
8 changes: 7 additions & 1 deletion lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ defmodule Sentry.Client do
end
end

@doc """
Makes the HTTP request to Sentry using hackney.

Hackney options can be set via the `hackney_opts` configuration option.
"""
def request(method, url, headers, body) do
case :hackney.request(method, url, headers, body, []) do
hackney_opts = Application.get_env(:sentry, :hackney_opts, [])
case :hackney.request(method, url, headers, body, hackney_opts) do
{:ok, 200, _headers, client} ->
case :hackney.body(client) do
{:ok, body} ->
Expand Down