diff --git a/lib/appsignal/absinthe.ex b/lib/appsignal/absinthe.ex index 2db149850..3c99133ca 100644 --- a/lib/appsignal/absinthe.ex +++ b/lib/appsignal/absinthe.ex @@ -1,9 +1,8 @@ defmodule Appsignal.Absinthe do - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) @moduledoc false diff --git a/lib/appsignal/demo.ex b/lib/appsignal/demo.ex index 053c9262c..7653d8f26 100644 --- a/lib/appsignal/demo.ex +++ b/lib/appsignal/demo.ex @@ -7,9 +7,7 @@ defmodule Appsignal.Demo do @moduledoc false import Appsignal.Instrumentation, only: [instrument: 2, instrument: 3] - require Appsignal.Utils - - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) def send_performance_sample do instrument("DemoController#hello", "call.phoenix", fn span -> diff --git a/lib/appsignal/diagnose/agent.ex b/lib/appsignal/diagnose/agent.ex index e4cd042aa..debcdf272 100644 --- a/lib/appsignal/diagnose/agent.ex +++ b/lib/appsignal/diagnose/agent.ex @@ -1,9 +1,7 @@ defmodule Appsignal.Diagnose.Agent do @moduledoc false - require Appsignal.Utils - - @nif Appsignal.Utils.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) + @nif Application.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) def report do if @nif.loaded?() do diff --git a/lib/appsignal/diagnose/host.ex b/lib/appsignal/diagnose/host.ex index ff22f79f8..10c093016 100644 --- a/lib/appsignal/diagnose/host.ex +++ b/lib/appsignal/diagnose/host.ex @@ -1,10 +1,8 @@ defmodule Appsignal.Diagnose.Host do @moduledoc false - require Appsignal.Utils - - @system Appsignal.Utils.compile_env(:appsignal, :appsignal_system, Appsignal.System) - @nif Appsignal.Utils.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) + @system Application.compile_env(:appsignal, :appsignal_system, Appsignal.System) + @nif Application.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) def info do {_, os} = :os.type() diff --git a/lib/appsignal/diagnose/library.ex b/lib/appsignal/diagnose/library.ex index 7143a0c4c..e1a8f9c85 100644 --- a/lib/appsignal/diagnose/library.ex +++ b/lib/appsignal/diagnose/library.ex @@ -1,11 +1,9 @@ defmodule Appsignal.Diagnose.Library do @moduledoc false - require Appsignal.Utils - @appsignal_version Mix.Project.config()[:version] @agent_version Appsignal.Agent.version() - @nif Appsignal.Utils.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) + @nif Application.compile_env(:appsignal, :appsignal_nif, Appsignal.Nif) def info do %{ diff --git a/lib/appsignal/ecto.ex b/lib/appsignal/ecto.ex index 692185f0f..d655f22fa 100644 --- a/lib/appsignal/ecto.ex +++ b/lib/appsignal/ecto.ex @@ -1,9 +1,8 @@ defmodule Appsignal.Ecto do - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) import Appsignal.Utils, only: [module_name: 1] @doc """ diff --git a/lib/appsignal/ecto_repo.ex b/lib/appsignal/ecto_repo.ex index e78d6819c..ba0fc14c3 100644 --- a/lib/appsignal/ecto_repo.ex +++ b/lib/appsignal/ecto_repo.ex @@ -1,6 +1,5 @@ defmodule Appsignal.Ecto.Repo do - require Appsignal.Utils - @ecto_repo Appsignal.Utils.compile_env(:appsignal, :ecto_repo, Ecto.Repo) + @ecto_repo Application.compile_env(:appsignal, :ecto_repo, Ecto.Repo) defmacro __using__(opts) do quote do diff --git a/lib/appsignal/error/backend.ex b/lib/appsignal/error/backend.ex index f37d62836..69e5e61a5 100644 --- a/lib/appsignal/error/backend.ex +++ b/lib/appsignal/error/backend.ex @@ -1,11 +1,10 @@ defmodule Appsignal.Error.Backend do @moduledoc false - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) @behaviour :gen_event diff --git a/lib/appsignal/finch.ex b/lib/appsignal/finch.ex index 07165058a..a4f190a30 100644 --- a/lib/appsignal/finch.ex +++ b/lib/appsignal/finch.ex @@ -1,9 +1,8 @@ defmodule Appsignal.Finch do - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) @moduledoc false diff --git a/lib/appsignal/heartbeat.ex b/lib/appsignal/heartbeat.ex index 89f2cecf4..ffe02055a 100644 --- a/lib/appsignal/heartbeat.ex +++ b/lib/appsignal/heartbeat.ex @@ -1,9 +1,8 @@ defmodule Appsignal.Heartbeat do alias __MODULE__ alias Appsignal.Heartbeat.Event - require Appsignal.Utils - @transmitter Appsignal.Utils.compile_env( + @transmitter Application.compile_env( :appsignal, :appsignal_transmitter, Appsignal.Transmitter diff --git a/lib/appsignal/instrumentation.ex b/lib/appsignal/instrumentation.ex index cb1127829..ac05665f2 100644 --- a/lib/appsignal/instrumentation.ex +++ b/lib/appsignal/instrumentation.ex @@ -1,8 +1,6 @@ defmodule Appsignal.Instrumentation do - require Appsignal.Utils - - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) @spec instrument(function()) :: any() @doc false diff --git a/lib/appsignal/instrumentation/decorators.ex b/lib/appsignal/instrumentation/decorators.ex index 58c291cbe..40b294dd0 100644 --- a/lib/appsignal/instrumentation/decorators.ex +++ b/lib/appsignal/instrumentation/decorators.ex @@ -1,9 +1,7 @@ defmodule Appsignal.Instrumentation.Decorators do @moduledoc false - require Appsignal.Utils - - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) use Decorator.Define, instrument: 0, diff --git a/lib/appsignal/integration_logger.ex b/lib/appsignal/integration_logger.ex index ec94061d4..67180b230 100644 --- a/lib/appsignal/integration_logger.ex +++ b/lib/appsignal/integration_logger.ex @@ -1,8 +1,6 @@ defmodule Appsignal.IntegrationLogger do - require Appsignal.Utils - - @io Appsignal.Utils.compile_env(:appsignal, :io, IO) - @file_module Appsignal.Utils.compile_env(:appsignal, :file, File) + @io Application.compile_env(:appsignal, :io, IO) + @file_module Application.compile_env(:appsignal, :file, File) @log_levels [:trace, :debug, :info, :warn, :error] diff --git a/lib/appsignal/logger.ex b/lib/appsignal/logger.ex index 0d027ebb2..478206e57 100644 --- a/lib/appsignal/logger.ex +++ b/lib/appsignal/logger.ex @@ -1,7 +1,5 @@ defmodule Appsignal.Logger do - require Appsignal.Utils - - @nif Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif) + @nif Application.compile_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif) @type log_level :: :debug | :info | :notice | :warning | :error | :critical | :alert | :emergency diff --git a/lib/appsignal/monitor.ex b/lib/appsignal/monitor.ex index 09e866a06..ea934adcd 100644 --- a/lib/appsignal/monitor.ex +++ b/lib/appsignal/monitor.ex @@ -1,10 +1,8 @@ defmodule Appsignal.Monitor do @moduledoc false - require Appsignal.Utils - - @deletion_delay Appsignal.Utils.compile_env(:appsignal, :deletion_delay, 5_000) - @sync_interval Appsignal.Utils.compile_env(:appsignal, :sync_interval, 60_000) + @deletion_delay Application.compile_env(:appsignal, :deletion_delay, 5_000) + @sync_interval Application.compile_env(:appsignal, :sync_interval, 60_000) use GenServer alias Appsignal.Tracer diff --git a/lib/appsignal/oban.ex b/lib/appsignal/oban.ex index 134dade19..1492b16d0 100644 --- a/lib/appsignal/oban.ex +++ b/lib/appsignal/oban.ex @@ -1,10 +1,9 @@ defmodule Appsignal.Oban do - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) - @appsignal Appsignal.Utils.compile_env(:appsignal, :appsignal, Appsignal) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @appsignal Application.compile_env(:appsignal, :appsignal, Appsignal) @moduledoc false diff --git a/lib/appsignal/probes/erlang_probe.ex b/lib/appsignal/probes/erlang_probe.ex index aadcfedcf..b87825168 100644 --- a/lib/appsignal/probes/erlang_probe.ex +++ b/lib/appsignal/probes/erlang_probe.ex @@ -1,6 +1,5 @@ defmodule Appsignal.Probes.ErlangProbe do @moduledoc false - require Appsignal.Utils def call(sample \\ nil) do next_sample = sample_schedulers() diff --git a/lib/appsignal/probes/probes.ex b/lib/appsignal/probes/probes.ex index 844e39384..b724f9edf 100644 --- a/lib/appsignal/probes/probes.ex +++ b/lib/appsignal/probes/probes.ex @@ -2,9 +2,8 @@ defmodule Appsignal.Probes do @moduledoc false use GenServer require Logger - require Appsignal.Utils - @integration_logger Appsignal.Utils.compile_env( + @integration_logger Application.compile_env( :appsignal, :appsignal_integration_logger, Appsignal.IntegrationLogger diff --git a/lib/appsignal/span.ex b/lib/appsignal/span.ex index 982d32530..fd67c1880 100644 --- a/lib/appsignal/span.ex +++ b/lib/appsignal/span.ex @@ -3,9 +3,7 @@ defmodule Appsignal.Span do defstruct [:reference, :pid] - require Appsignal.Utils - - @nif Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif) + @nif Application.compile_env(:appsignal, :appsignal_tracer_nif, Appsignal.Nif) @type t() :: %__MODULE__{ reference: reference(), diff --git a/lib/appsignal/tesla.ex b/lib/appsignal/tesla.ex index b7060eaa9..5f62ad01e 100644 --- a/lib/appsignal/tesla.ex +++ b/lib/appsignal/tesla.ex @@ -1,9 +1,8 @@ defmodule Appsignal.Tesla do - require Appsignal.Utils require Logger - @tracer Appsignal.Utils.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) - @span Appsignal.Utils.compile_env(:appsignal, :appsignal_span, Appsignal.Span) + @tracer Application.compile_env(:appsignal, :appsignal_tracer, Appsignal.Tracer) + @span Application.compile_env(:appsignal, :appsignal_span, Appsignal.Span) @moduledoc false diff --git a/lib/appsignal/tracer.ex b/lib/appsignal/tracer.ex index 44dc83df3..f5c8f5bed 100644 --- a/lib/appsignal/tracer.ex +++ b/lib/appsignal/tracer.ex @@ -1,9 +1,7 @@ defmodule Appsignal.Tracer do alias Appsignal.Span - require Appsignal.Utils - - @monitor Appsignal.Utils.compile_env(:appsignal, :appsignal_monitor, Appsignal.Monitor) + @monitor Application.compile_env(:appsignal, :appsignal_monitor, Appsignal.Monitor) @table :"$appsignal_registry" diff --git a/lib/appsignal/utils.ex b/lib/appsignal/utils.ex index 092b2f723..959c4eced 100644 --- a/lib/appsignal/utils.ex +++ b/lib/appsignal/utils.ex @@ -30,16 +30,4 @@ defmodule Appsignal.Utils do require Logger Logger.warning(message) end - - defmacro compile_env(app, key, default \\ nil) do - if Version.match?(System.version(), ">= 1.10.0") do - quote do - Application.compile_env(unquote(app), unquote(key), unquote(default)) - end - else - quote do - Application.get_env(unquote(app), unquote(key), unquote(default)) - end - end - end end diff --git a/lib/appsignal/utils/hostname.ex b/lib/appsignal/utils/hostname.ex index 0f441ae7d..afbf39e38 100644 --- a/lib/appsignal/utils/hostname.ex +++ b/lib/appsignal/utils/hostname.ex @@ -1,9 +1,7 @@ defmodule Appsignal.Utils.Hostname do @moduledoc false - require Appsignal.Utils - - @inet Appsignal.Utils.compile_env(:appsignal, :inet, :inet) + @inet Application.compile_env(:appsignal, :inet, :inet) def hostname do case Application.fetch_env(:appsignal, :config) do diff --git a/lib/mix/tasks/appsignal.diagnose.ex b/lib/mix/tasks/appsignal.diagnose.ex index d20a3154e..85149509a 100644 --- a/lib/mix/tasks/appsignal.diagnose.ex +++ b/lib/mix/tasks/appsignal.diagnose.ex @@ -3,10 +3,8 @@ defmodule Mix.Tasks.Appsignal.Diagnose do alias Appsignal.Config alias Appsignal.Diagnose - require Appsignal.Utils - - @system Appsignal.Utils.compile_env(:appsignal, :appsignal_system, Appsignal.System) - @report Appsignal.Utils.compile_env( + @system Application.compile_env(:appsignal, :appsignal_system, Appsignal.System) + @report Application.compile_env( :appsignal, :appsignal_diagnose_report, Appsignal.Diagnose.Report