From 537d1168b5820e38993fa2c6746f29013db94989 Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Wed, 19 Jun 2024 13:41:41 +0200 Subject: [PATCH] fix: Remove scout_apm --- apps/cf/config/config.exs | 4 --- apps/cf/mix.exs | 1 - apps/cf_graphql/lib/endpoint.ex | 1 - .../cf_graphql/lib/scout_apm_absinthe_plug.ex | 32 ------------------- apps/cf_graphql/mix.exs | 1 - apps/cf_jobs/lib/job.ex | 1 - apps/cf_jobs/lib/jobs/create_notifications.ex | 2 +- apps/cf_jobs/lib/jobs/flags.ex | 2 +- apps/cf_jobs/lib/jobs/moderation.ex | 1 - apps/cf_jobs/lib/jobs/reputation.ex | 3 +- apps/cf_jobs/mix.exs | 1 - .../lib/channels/video_debate_channel.ex | 3 +- apps/cf_rest_api/lib/rest_api.ex | 1 - apps/cf_rest_api/mix.exs | 1 - apps/db/config/config.exs | 6 +--- apps/db/mix.exs | 1 - 16 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 apps/cf_graphql/lib/scout_apm_absinthe_plug.ex diff --git a/apps/cf/config/config.exs b/apps/cf/config/config.exs index 05b44a01..bed36274 100644 --- a/apps/cf/config/config.exs +++ b/apps/cf/config/config.exs @@ -34,10 +34,6 @@ config :cf, config :guardian, Guardian.DB, repo: DB.Repo -config :scout_apm, - name: "CaptainFact", - key: {:system, "CF_SCOUT_APM_KEY"} - # To send records to Algolia (search engine) config :algoliax, batch_size: 500, diff --git a/apps/cf/mix.exs b/apps/cf/mix.exs index bbe1aaa2..ba0b4420 100644 --- a/apps/cf/mix.exs +++ b/apps/cf/mix.exs @@ -58,7 +58,6 @@ defmodule CF.Mixfile do {:sweet_xml, "~> 0.6"}, {:burnex, "~> 3.1"}, {:yaml_elixir, "~> 2.9.0"}, - {:scout_apm, "~> 1.0.6"}, # ---- Internal ---- {:db, in_umbrella: true}, diff --git a/apps/cf_graphql/lib/endpoint.ex b/apps/cf_graphql/lib/endpoint.ex index 06275d45..0fbd4c6d 100644 --- a/apps/cf_graphql/lib/endpoint.ex +++ b/apps/cf_graphql/lib/endpoint.ex @@ -18,7 +18,6 @@ defmodule CF.GraphQLWeb.Endpoint do json_decoder: Poison ) - plug(ScoutApm.Absinthe.Plug) plug(Plug.MethodOverride) plug(Plug.Head) plug(CF.GraphQLWeb.Router) diff --git a/apps/cf_graphql/lib/scout_apm_absinthe_plug.ex b/apps/cf_graphql/lib/scout_apm_absinthe_plug.ex deleted file mode 100644 index b5c60a71..00000000 --- a/apps/cf_graphql/lib/scout_apm_absinthe_plug.ex +++ /dev/null @@ -1,32 +0,0 @@ -defmodule ScoutApm.Absinthe.Plug do - alias ScoutApm.Internal.Layer - - def init(default), do: default - - def call(conn, _default) do - ScoutApm.TrackedRequest.start_layer("Controller", action_name(conn)) - - conn - |> Plug.Conn.register_before_send(&before_send/1) - end - - def before_send(conn) do - full_name = action_name(conn) - uri = "#{conn.request_path}" - - ScoutApm.TrackedRequest.stop_layer(fn layer -> - layer - |> Layer.update_name(full_name) - |> Layer.update_uri(uri) - end) - - conn - end - - # Takes a connection, extracts the phoenix controller & action, then manipulates & cleans it up. - # Returns a string like "PageController#index" - defp action_name(conn) do - action_name = conn.params["operationName"] - "GraphQL##{action_name}" - end -end diff --git a/apps/cf_graphql/mix.exs b/apps/cf_graphql/mix.exs index b14311ee..a9121937 100644 --- a/apps/cf_graphql/mix.exs +++ b/apps/cf_graphql/mix.exs @@ -42,7 +42,6 @@ defmodule CF.Graphql.Mixfile do {:absinthe_plug, "~> 1.4.1"}, {:kaur, "~> 1.1"}, {:poison, "~> 3.1"}, - {:scout_apm, "~> 1.0.6"}, # Internal dependencies {:db, in_umbrella: true}, diff --git a/apps/cf_jobs/lib/job.ex b/apps/cf_jobs/lib/job.ex index 76a31806..8f89c7f8 100644 --- a/apps/cf_jobs/lib/job.ex +++ b/apps/cf_jobs/lib/job.ex @@ -6,7 +6,6 @@ defmodule CF.Jobs.Job do @type t :: module use GenServer - import ScoutApm.Tracing def init(args) do {:ok, args} diff --git a/apps/cf_jobs/lib/jobs/create_notifications.ex b/apps/cf_jobs/lib/jobs/create_notifications.ex index 7fe475a9..8a55be12 100644 --- a/apps/cf_jobs/lib/jobs/create_notifications.ex +++ b/apps/cf_jobs/lib/jobs/create_notifications.ex @@ -66,7 +66,7 @@ defmodule CF.Jobs.CreateNotifications do end # --- Server callbacks --- - @transaction_opts [type: "background", name: "update_notifications"] + def handle_call({:update, force}, _from, _state) do last_action_id = ReportManager.get_last_action_id(@analyser_id) diff --git a/apps/cf_jobs/lib/jobs/flags.ex b/apps/cf_jobs/lib/jobs/flags.ex index cc322030..1b2c74ce 100644 --- a/apps/cf_jobs/lib/jobs/flags.ex +++ b/apps/cf_jobs/lib/jobs/flags.ex @@ -42,7 +42,7 @@ defmodule CF.Jobs.Flags do end # --- Server callbacks --- - @transaction_opts [type: "background", name: "update_flags"] + def handle_call(:update_flags, _from, _state) do last_action_id = ReportManager.get_last_action_id(@analyser_id) diff --git a/apps/cf_jobs/lib/jobs/moderation.ex b/apps/cf_jobs/lib/jobs/moderation.ex index 359868bb..8d47ca81 100644 --- a/apps/cf_jobs/lib/jobs/moderation.ex +++ b/apps/cf_jobs/lib/jobs/moderation.ex @@ -79,7 +79,6 @@ defmodule CF.Jobs.Moderation do # --- Internal API --- - @transaction_opts [type: "background", name: "update_moderation"] def handle_call(:update, _, _) do UserAction |> join(:inner, [a], uf in ModerationUserFeedback, on: uf.action_id == a.id) diff --git a/apps/cf_jobs/lib/jobs/reputation.ex b/apps/cf_jobs/lib/jobs/reputation.ex index d21d1cb4..68a00210 100644 --- a/apps/cf_jobs/lib/jobs/reputation.ex +++ b/apps/cf_jobs/lib/jobs/reputation.ex @@ -100,7 +100,7 @@ defmodule CF.Jobs.Reputation do do: max(change, @daily_loss_limit - today_change) # --- Server callbacks --- - @transaction_opts [type: "background", name: "update_reputation"] + def handle_call(:update_reputations, _from, _state) do last_action_id = ReportManager.get_last_action_id(@analyser_id) @@ -115,7 +115,6 @@ defmodule CF.Jobs.Reputation do {:reply, :ok, :ok} end - @transaction_opts [type: "background", name: "reset_reputation_limits"] def handle_call(:reset_daily_limits, _from, _state) do Logger.info("[Jobs.Reputation] Reset daily limits") diff --git a/apps/cf_jobs/mix.exs b/apps/cf_jobs/mix.exs index dcbb6406..e88faa14 100644 --- a/apps/cf_jobs/mix.exs +++ b/apps/cf_jobs/mix.exs @@ -36,7 +36,6 @@ defmodule CF.Jobs.Mixfile do [ {:quantum, "~> 2.3"}, {:timex, "~> 3.0"}, - {:scout_apm, "~> 1.0.6"}, # ---- Internal ---- {:cf, in_umbrella: true}, diff --git a/apps/cf_rest_api/lib/channels/video_debate_channel.ex b/apps/cf_rest_api/lib/channels/video_debate_channel.ex index 31171478..a6228ddd 100644 --- a/apps/cf_rest_api/lib/channels/video_debate_channel.ex +++ b/apps/cf_rest_api/lib/channels/video_debate_channel.ex @@ -1,6 +1,6 @@ defmodule CF.RestApi.VideoDebateChannel do use CF.RestApi, :channel - import ScoutApm.Tracing + alias CF.RestApi.Presence import CF.Actions.ActionCreator, only: [ @@ -26,7 +26,6 @@ defmodule CF.RestApi.VideoDebateChannel do alias CF.Notifications.Subscriptions alias CF.RestApi.{VideoView, SpeakerView, ChangesetView} - @transaction_opts [type: "web", name: "VideoDebateChannel.join"] def join("video_debate:" <> video_hash_id, _payload, socket) do Video |> Video.with_speakers() diff --git a/apps/cf_rest_api/lib/rest_api.ex b/apps/cf_rest_api/lib/rest_api.ex index 69cfc34b..6485fcac 100644 --- a/apps/cf_rest_api/lib/rest_api.ex +++ b/apps/cf_rest_api/lib/rest_api.ex @@ -29,7 +29,6 @@ defmodule CF.RestApi do def controller do quote do use Phoenix.Controller, namespace: CF.RestApi - use ScoutApm.Instrumentation alias DB.Repo import Ecto diff --git a/apps/cf_rest_api/mix.exs b/apps/cf_rest_api/mix.exs index aa4a58fa..1da9a4d3 100644 --- a/apps/cf_rest_api/mix.exs +++ b/apps/cf_rest_api/mix.exs @@ -44,7 +44,6 @@ defmodule CF.RestApi.Mixfile do {:phoenix_pubsub, "~> 2.0"}, {:jason, "~> 1.4"}, {:poison, "~> 3.1"}, - {:scout_apm, "~> 1.0.6"}, {:plug_cowboy, "~> 2.1"}, # ---- Internal ---- diff --git a/apps/db/config/config.exs b/apps/db/config/config.exs index 2a0ea654..0879c26d 100644 --- a/apps/db/config/config.exs +++ b/apps/db/config/config.exs @@ -8,11 +8,7 @@ config :db, # Database: use postgres config :db, DB.Repo, adapter: Ecto.Adapters.Postgres, - pool_size: 3, - loggers: [ - {Ecto.LogEntry, :log, []}, - {ScoutApm.Instruments.EctoLogger, :log, []} - ] + pool_size: 3 # Import environment specific config import_config "#{Mix.env()}.exs" diff --git a/apps/db/mix.exs b/apps/db/mix.exs index faa802cd..c95ec833 100644 --- a/apps/db/mix.exs +++ b/apps/db/mix.exs @@ -55,7 +55,6 @@ defmodule DB.Mixfile do {:kaur, "~> 1.1"}, {:mime, "~> 1.2"}, {:scrivener_ecto, "~> 2.0"}, - {:scout_apm, "~> 1.0.6"}, {:algoliax, "~> 0.7.1"}, # Dev only