Enable Sentry

This commit is contained in:
Claudio Ortolina
2025-10-01 13:34:09 +03:00
parent 67341f3ceb
commit 4c33d3f0aa
8 changed files with 53 additions and 0 deletions
+4
View File
@@ -9,6 +9,10 @@ defmodule MusicLibrary.Application do
@impl true
def start(_type, _args) do
:logger.add_handler(:my_sentry_handler, Sentry.LoggerHandler, %{
config: %{metadata: [:file, :line]}
})
_ = Assets.Cache.new()
children = [
+3
View File
@@ -1,4 +1,5 @@
defmodule MusicLibraryWeb.Endpoint do
use Sentry.PlugCapture
use Phoenix.Endpoint, otp_app: :music_library
# The session will be stored in the cookie and signed,
@@ -55,6 +56,8 @@ defmodule MusicLibraryWeb.Endpoint do
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Sentry.PlugContext
plug Plug.MethodOverride
plug Plug.Head
plug Plug.Session, @session_options
+25
View File
@@ -0,0 +1,25 @@
defmodule Sentry.FinchClient do
@moduledoc """
Defines a small shim to use `Finch` as a `Sentry.HTTPClient`.
"""
@behaviour Sentry.HTTPClient
@impl true
def child_spec do
Finch.child_spec(name: Sentry.Finch)
end
@impl true
def post(url, headers, body) do
request = Finch.build(:post, url, headers, body)
case Finch.request(request, Sentry.Finch) do
{:ok, response} ->
{:ok, response.status, response.headers, response.body}
error ->
error
end
end
end