From 4080d1982bf2aba2dfe84d04d99aaee03d1ecee0 Mon Sep 17 00:00:00 2001 From: Emiel Date: Wed, 20 Nov 2024 15:06:14 +0100 Subject: [PATCH 1/4] Added support for AppSignal --- CHANGELOG.md | 4 ++++ core/config/runtime.exs | 9 +++++++++ core/mix.exs | 1 + core/mix.lock | 4 ++++ core/systems/assignment/crew_page.ex | 1 + core/systems/storage/delivery.ex | 2 +- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3143267..378f23781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ ## \#7 unreleased +## \#6.2 unreleased + +* Added: AppSignal support + ## \#6.1 2024-11-19 * Fixed: Memory issues by temporary removing Sentry support diff --git a/core/config/runtime.exs b/core/config/runtime.exs index 3bd2debda..8c226de7d 100644 --- a/core/config/runtime.exs +++ b/core/config/runtime.exs @@ -117,6 +117,15 @@ if config_env() == :prod do access_key: System.get_env("UNSPLASH_ACCESS_KEY"), app_name: System.get_env("UNSPLASH_APP_NAME") + if push_api_key = System.get_env("APPSIGNAL_PUSH_API_KEY") do + config :appsignal, :config, + otp_app: :core, + name: "Next", + env: app_domain, + push_api_key: push_api_key, + active: true + end + config :core, :storage, services: System.get_env("STORAGE_SERVICES", "builtin, yoda") diff --git a/core/mix.exs b/core/mix.exs index b2091c3c2..2d4ea5ab7 100644 --- a/core/mix.exs +++ b/core/mix.exs @@ -67,6 +67,7 @@ defmodule Core.MixProject do # Workaround for conflicting versions in ex_aws & ex_phone_number {:sweet_xml, "~> 0.7", override: true}, # Deps + {:appsignal_phoenix, "~> 2.3.9"}, {:assent, "~> 0.2.3"}, {:bamboo_phoenix, git: "https://github.com/populimited/bamboo_phoenix.git", ref: "bf3e320"}, {:bamboo_ses, "~> 0.3.0"}, diff --git a/core/mix.lock b/core/mix.lock index f5242de54..7facac9da 100644 --- a/core/mix.lock +++ b/core/mix.lock @@ -1,4 +1,7 @@ %{ + "appsignal": {:hex, :appsignal, "2.13.2", "d21f885882de31e24219f6c0fbb9bdf64b009ce3f53ec32d60789d9875e372dc", [:make, :mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:decorator, "~> 1.2.3 or ~> 1.3", [hex: :decorator, repo: "hexpm", optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0debf8717d612146d21cd21f9798b8b1f6a07ac4b1feb3d52eb01c4508ecf5cd"}, + "appsignal_phoenix": {:hex, :appsignal_phoenix, "2.3.9", "7e3a5f47f833aa499ec1a5d114f5797c7ac4bcd0ad908e6da1e2197aea53baf9", [:mix], [{:appsignal, ">= 2.11.0 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:appsignal_plug, ">= 2.0.15 and < 3.0.0", [hex: :appsignal_plug, repo: "hexpm", optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.9", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "bd0f8acef5e0b7f5344f2299b01f5740f51a1a5279889b93ae676b0a2b1cf631"}, + "appsignal_plug": {:hex, :appsignal_plug, "2.0.15", "758a8a78944878e8461bbc77ca86219121a56f4299c6d79940ab083cf9afea00", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:plug, ">= 1.1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1c6059049e2081e808aaef04e2b9917e06277f61a35a0e103db860d08cbc41f1"}, "assent": {:hex, :assent, "0.2.3", "414d77ea27349dacc980b612e9edeed06c4d64a3df99a0fa8e42e6940ed20c16", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:ssl_verify_fun, ">= 0.0.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: true]}], "hexpm", "a39bc5b57920632b003bd175fd58fcb355c10efbe614bba03682ce2a76d4133f"}, "azurex": {:hex, :azurex, "0.1.5", "59a8ba34320a38c2d7ee1e4fd4477b59da7ef95b719f47362b5021f9643e8bd4", [:mix], [{:httpoison, "~> 1.6", [hex: :httpoison, repo: "hexpm", optional: false]}, {:timex, "~> 3.7", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm", "fb5e2b47b15713f2ce9db8ac7641b604482fb70d3559b95182bb2950ec7c44b3"}, "bamboo": {:hex, :bamboo, "2.3.0", "d2392a2cabe91edf488553d3c70638b532e8db7b76b84b0a39e3dfe492ffd6fc", [:mix], [{:hackney, ">= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.4 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "dd0037e68e108fd04d0e8773921512c940e35d981e097b5793543e3b2f9cd3f6"}, @@ -23,6 +26,7 @@ "currency_formatter": {:hex, :currency_formatter, "0.8.1", "ab410d520713ba3a5b56eaf4ef944471df67c870dd0e5cd5a9f7e22f9b634777", [:mix], [{:phoenix_html, ">= 0.0.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:poison, "~> 3.1.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "e1aafb0c2eba8d63d0d1055e118a674f8b60bd1095d86a701a9732803e410214"}, "db_connection": {:hex, :db_connection, "2.4.3", "3b9aac9f27347ec65b271847e6baeb4443d8474289bd18c1d6f4de655b70c94d", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c127c15b0fa6cfb32eed07465e05da6c815b032508d4ed7c116122871df73c12"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, + "decorator": {:hex, :decorator, "1.4.0", "a57ac32c823ea7e4e67f5af56412d12b33274661bb7640ec7fc882f8d23ac419", [:mix], [], "hexpm", "0a07cedd9083da875c7418dea95b78361197cf2bf3211d743f6f7ce39656597f"}, "dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"}, "digital_token": {:hex, :digital_token, "0.4.0", "2ad6894d4a40be8b2890aad286ecd5745fa473fa5699d80361a8c94428edcd1f", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a178edf61d1fee5bb3c34e14b0f4ee21809ee87cade8738f87337e59e5e66e26"}, "dns": {:hex, :dns, "2.2.0", "4721a79c2bccc25481930dffbfd06f40851321c3d679986af307111214bf124c", [:mix], [{:socket, "~> 0.3.13", [hex: :socket, repo: "hexpm", optional: false]}], "hexpm", "13ed1ef36ce896211ec6ce5e02709dbfb12aa61d6255bda8d531577a0a5a56e0"}, diff --git a/core/systems/assignment/crew_page.ex b/core/systems/assignment/crew_page.ex index b60424d02..0ed8e3327 100644 --- a/core/systems/assignment/crew_page.ex +++ b/core/systems/assignment/crew_page.ex @@ -181,6 +181,7 @@ defmodule Systems.Assignment.CrewPage do @impl true def handle_event(name, event, socket) do + Logger.debug("[CrewPage] Forwarding event to flow: #{name}") { :noreply, socket |> send_event(:flow, name, event) diff --git a/core/systems/storage/delivery.ex b/core/systems/storage/delivery.ex index 41369053c..7eef1579d 100644 --- a/core/systems/storage/delivery.ex +++ b/core/systems/storage/delivery.ex @@ -28,7 +28,7 @@ defmodule Systems.Storage.Delivery do end def deliver(backend, endpoint, data, meta_data) do - Logger.debug("[Storage.Delivery] delivery started", + Logger.notice("[Storage.Delivery] delivery started, #{byte_size(data)} bytes", ansi_color: :light_magenta ) From 3e0178d98f3a275773c058b03a9f2edcfdb72274 Mon Sep 17 00:00:00 2001 From: mellelieuwes Date: Wed, 20 Nov 2024 14:07:17 +0000 Subject: [PATCH 2/4] Formatted code --- core/systems/assignment/crew_page.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/core/systems/assignment/crew_page.ex b/core/systems/assignment/crew_page.ex index 0ed8e3327..ebb8e8a41 100644 --- a/core/systems/assignment/crew_page.ex +++ b/core/systems/assignment/crew_page.ex @@ -182,6 +182,7 @@ defmodule Systems.Assignment.CrewPage do @impl true def handle_event(name, event, socket) do Logger.debug("[CrewPage] Forwarding event to flow: #{name}") + { :noreply, socket |> send_event(:flow, name, event) From e0cf5f161df74ccc14da0322d39ca58edd6bc4ee Mon Sep 17 00:00:00 2001 From: Emiel Date: Wed, 20 Nov 2024 15:09:27 +0100 Subject: [PATCH 3/4] Removed Sentry completely --- core/lib/core/sentry/gen.ex | 75 ------------------------------------- core/lib/core/sentry/mix.ex | 16 -------- core/mix.exs | 1 - 3 files changed, 92 deletions(-) delete mode 100644 core/lib/core/sentry/gen.ex delete mode 100644 core/lib/core/sentry/mix.ex diff --git a/core/lib/core/sentry/gen.ex b/core/lib/core/sentry/gen.ex deleted file mode 100644 index 19e029748..000000000 --- a/core/lib/core/sentry/gen.ex +++ /dev/null @@ -1,75 +0,0 @@ -defmodule Core.Sentry.Gen do - alias Sentry.Config - require Logger - - defp print(message) do - Logger.notice(message) - end - - @moduledoc """ - Sends a test event to Sentry to check if your Sentry configuration is correct. - - This task reports a `RuntimeError` exception like this one: - - %RuntimeError{message: "Testing sending Sentry event"} - - ## Options - - * `compile` - boolean, use to does not compile, even if files require compilation. - * `type` - `exception` or `message`. Defaults to `exception`. *Available since v10.1.0.*. - * `stacktrace` - does not include a stacktrace in the reported event. *Available since - v10.1.0.*. - - """ - - def test_event() do - {:ok, _} = Application.ensure_all_started(:sentry) - - print_environment_info() - - if Config.dsn() do - send_event() - else - print("Event not sent because the :dsn option is not set (or set to nil)") - end - end - - defp print_environment_info do - print("Client configuration:") - - if dsn = Config.dsn() do - print("server: #{dsn.endpoint_uri}") - print("public_key: #{dsn.public_key}") - print("secret_key: #{dsn.secret_key}") - end - - print("current environment_name: #{inspect(to_string(Config.environment_name()))}") - print("hackney_opts: #{inspect(Config.hackney_opts())}\n") - end - - defp send_event() do - {:current_stacktrace, stacktrace} = Process.info(self(), :current_stacktrace) - - print("Sending test event...") - - exception = %RuntimeError{message: "Testing sending Sentry event"} - result = Sentry.capture_exception(exception, result: :sync, stacktrace: stacktrace) - - case result do - {:ok, id} -> - print("Test event sent, event ID: #{id}") - - {:error, reason} -> - print("Error sending event:\n\n#{inspect(reason)}") - - :excluded -> - print("No test event was sent because the event was excluded by a filter") - - :unsampled -> - print(""" - No test event was sent because the event was excluded according to the :sample_rate \ - configuration option. - """) - end - end -end diff --git a/core/lib/core/sentry/mix.ex b/core/lib/core/sentry/mix.ex deleted file mode 100644 index b5b89282a..000000000 --- a/core/lib/core/sentry/mix.ex +++ /dev/null @@ -1,16 +0,0 @@ -defmodule Mix.Tasks.Core.Sentry.Gen.TestEvent do - @moduledoc """ - Generates a Sentry Test Event. - - Usage: - $ mix core.sentry.gen.testevent - """ - - use Mix.Task - - @shortdoc "Generate Sentry Test Event" - def run(_args) do - Mix.Task.run("app.start") - Core.Sentry.Gen.test_event() - end -end diff --git a/core/mix.exs b/core/mix.exs index 2d4ea5ab7..b1139fa7d 100644 --- a/core/mix.exs +++ b/core/mix.exs @@ -101,7 +101,6 @@ defmodule Core.MixProject do {:plug_cowboy, "~> 2.5"}, {:postgrex, ">= 0.15.13"}, {:remote_ip, "~> 1.1"}, - {:sentry, "~> 10.7"}, {:slugify, "~> 1.3"}, {:statistics, "~> 0.6.2"}, {:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev}, From 34321682f356f4c4fea39014ce9e2d14672ee039 Mon Sep 17 00:00:00 2001 From: Emiel Date: Thu, 21 Nov 2024 21:00:20 +0100 Subject: [PATCH 4/4] Added Admin debug button to raise a test exception --- core/systems/admin/actions_view.ex | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/core/systems/admin/actions_view.ex b/core/systems/admin/actions_view.ex index afc017346..42dc7f035 100644 --- a/core/systems/admin/actions_view.ex +++ b/core/systems/admin/actions_view.ex @@ -53,11 +53,24 @@ defmodule Systems.Admin.ActionsView do } } + crash_button = %{ + action: %{ + type: :send, + event: "crash" + }, + face: %{ + type: :primary, + bg_color: "bg-delete", + label: "Raise a test exception" + } + } + socket |> assign( rollback_expired_deposits_button: rollback_expired_deposits_button, expire_button: expire_button, - expire_force_button: expire_force_button + expire_force_button: expire_force_button, + crash_button: crash_button ) end @@ -85,6 +98,12 @@ defmodule Systems.Admin.ActionsView do {:noreply, socket} end + @impl true + def handle_event("crash", _, socket) do + raise "Test exception" + {:noreply, socket} + end + @impl true def render(assigns) do ~H""" @@ -106,6 +125,14 @@ defmodule Systems.Admin.ActionsView do <.spacing value="S" /> + <.spacing value="XL" /> + Monitoring + <.spacing value="S" /> + <.wrap> + + <.spacing value="S" /> + + <%= if feature_enabled?(:debug_expire_force) do %> <.wrap>