Last active
March 13, 2024 06:05
-
-
Save arathunku/b162e925fe04c4643109e3a75f66a45e to your computer and use it in GitHub Desktop.
Custom HTTP client for Sentry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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