Skip to content

Instantly share code, notes, and snippets.

@arathunku
Last active March 13, 2024 06:05
Show Gist options
  • Save arathunku/b162e925fe04c4643109e3a75f66a45e to your computer and use it in GitHub Desktop.
Save arathunku/b162e925fe04c4643109e3a75f66a45e to your computer and use it in GitHub Desktop.
Custom HTTP client for Sentry
# mix.exs
# {:sentry, "~> 10.2"},
# {:req, "~> 0.4.9"},
# config.exs
config :sentry, client: MyApp.SentryReqHTTPClient,
# lib/my_app/sentry_req_http_client.ex
defmodule MyApp.SentryReqHTTPClient do
@behaviour Sentry.HTTPClient
@impl true
def post(url, headers, body) do
# https://hexdocs.pm/req/Req.Steps.html#retry/1
# optional: retry: false
case Req.post(url: url, headers: headers, body: body, decode_body: false) do
{:ok, %Req.Response{status: status, headers: headers, body: body}} ->
{:ok, status, headers, body}
{:error, error} ->
{:error, error}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment