mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(portal): Attach Sentry in each umbrella app (#8749)
- Attaches the Sentry Logging hook in each of [api, web, domain] - Removes errant Sentry logging configuration in config/config.exs - Fixes the exception logger to default to logging exceptions, use `skip_sentry: true` to skip Tested successfully in dev. Hopefully the cluster behaves the same way. Fixes #8639
This commit is contained in:
@@ -6,6 +6,15 @@ defmodule API.Application do
|
||||
_ = :opentelemetry_cowboy.setup()
|
||||
_ = OpentelemetryPhoenix.setup(adapter: :cowboy2)
|
||||
|
||||
# Configure Sentry to capture Logger messages
|
||||
:logger.add_handler(:sentry, Sentry.LoggerHandler, %{
|
||||
config: %{
|
||||
level: :warning,
|
||||
metadata: :all,
|
||||
capture_log_messages: true
|
||||
}
|
||||
})
|
||||
|
||||
children = [
|
||||
API.Endpoint,
|
||||
API.RateLimit
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule Domain.Telemetry.Sentry do
|
||||
def before_send(%{original_exception: %{report_to_sentry: report_to_sentry}} = event) do
|
||||
if report_to_sentry do
|
||||
event
|
||||
else
|
||||
def before_send(%{original_exception: %{skip_sentry: skip_sentry}} = event) do
|
||||
if skip_sentry do
|
||||
nil
|
||||
else
|
||||
event
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,6 +7,15 @@ defmodule Web.Application do
|
||||
_ = :opentelemetry_cowboy.setup()
|
||||
_ = OpentelemetryPhoenix.setup(adapter: :cowboy2)
|
||||
|
||||
# Configure Sentry to capture Logger messages
|
||||
:logger.add_handler(:sentry, Sentry.LoggerHandler, %{
|
||||
config: %{
|
||||
level: :warning,
|
||||
metadata: :all,
|
||||
capture_log_messages: true
|
||||
}
|
||||
})
|
||||
|
||||
children = [
|
||||
Web.Endpoint
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ defmodule Web.SignIn do
|
||||
{:ok, socket}
|
||||
else
|
||||
_other ->
|
||||
raise Web.LiveErrors.NotFoundError, report_to_sentry: false
|
||||
raise Web.LiveErrors.NotFoundError, skip_sentry: true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
defmodule Web.LiveErrors do
|
||||
defmodule NotFoundError do
|
||||
defexception message: "Not Found", report_to_sentry: true
|
||||
defexception message: "Not Found", skip_sentry: false
|
||||
|
||||
defimpl Plug.Exception do
|
||||
def status(_exception), do: 404
|
||||
|
||||
@@ -168,17 +168,6 @@ config :web, api_url_override: "ws://localhost:13001/"
|
||||
##### API #####################
|
||||
###############################
|
||||
|
||||
config :api, :logger, [
|
||||
{:handler, :api, Sentry.LoggerHandler,
|
||||
%{
|
||||
config: %{
|
||||
level: :warning,
|
||||
metadata: :all,
|
||||
capture_log_messages: true
|
||||
}
|
||||
}}
|
||||
]
|
||||
|
||||
config :api, ecto_repos: [Domain.Repo]
|
||||
config :api, generators: [binary_id: true, context_app: :domain]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user