Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Elixir versions before 1.11 #953

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/appsignal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ defmodule Appsignal do
helper functions for sending metrics to AppSignal.
"""

require Mix.Appsignal.Utils

@os Mix.Appsignal.Utils.compile_env(:appsignal, :os_internal, :os)
@os Application.compile_env(:appsignal, :os_internal, :os)

use Application
alias Appsignal.Config
require Logger
import Appsignal.Utils, only: [info: 1, warning: 1]

@doc false
def start(_type, _args) do
Expand Down Expand Up @@ -87,7 +84,7 @@ defmodule Appsignal do
def initialize do
case {Config.initialize(), Config.configured_as_active?()} do
{_, false} ->
info("AppSignal disabled.")
Logger.info("AppSignal disabled.")

{:ok, true} ->
Appsignal.IntegrationLogger.debug("AppSignal starting.")
Expand All @@ -101,7 +98,7 @@ defmodule Appsignal do
end

{{:error, :invalid_config}, true} ->
warning(
Logger.warning(
"Warning: No valid AppSignal configuration found, continuing with " <>
"AppSignal metrics disabled."
)
Expand Down
12 changes: 6 additions & 6 deletions lib/appsignal/absinthe.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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

import Appsignal.Utils, only: [warning: 1]

def attach do
handlers = %{
[:absinthe, :execute, :operation, :start] => &__MODULE__.absinthe_execute_operation_start/4,
Expand All @@ -34,7 +32,9 @@ defmodule Appsignal.Absinthe do
:ok

{_, {:error, _} = error} ->
warning("Appsignal.Absinthe not attached to #{inspect(event)}: #{inspect(error)}")
Logger.warning(
"Appsignal.Absinthe not attached to #{inspect(event)}: #{inspect(error)}"
)

error
end
Expand Down
7 changes: 4 additions & 3 deletions lib/appsignal/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ defmodule Appsignal.Config do
@moduledoc false
alias Appsignal.Nif
alias Appsignal.Utils.FileSystem
import Appsignal.Utils, only: [warning: 1]

require Logger

@default_config %{
active: false,
Expand Down Expand Up @@ -64,7 +65,7 @@ defmodule Appsignal.Config do
config = Map.merge(config, sources[:override])

if !empty?(config[:working_dir_path]) do
warning(fn ->
Logger.warning(fn ->
"'working_dir_path' is deprecated, please use " <>
"'working_directory_path' instead and specify the " <>
"full path to the working directory"
Expand Down Expand Up @@ -234,7 +235,7 @@ defmodule Appsignal.Config do
"all"

unknown ->
warning(
Logger.warning(
"Unknown value #{inspect(unknown)} for report_oban_errors config " <>
~s(option. Valid values are "discard", "none", "all". ) <>
~s(Defaulting to "all".)
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/demo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/diagnose/agent.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions lib/appsignal/diagnose/host.ex
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/diagnose/library.ex
Original file line number Diff line number Diff line change
@@ -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
%{
Expand Down
10 changes: 5 additions & 5 deletions lib/appsignal/ecto.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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)
import Appsignal.Utils, only: [module_name: 1, warning: 1]
@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 """
Attaches `Appsignal.Ecto` to the Ecto telemetry channel configured in the
Expand Down Expand Up @@ -34,7 +34,7 @@ defmodule Appsignal.Ecto do
:ok

{:error, _} = error ->
warning("Appsignal.Ecto not attached to #{inspect(event)}: #{inspect(error)}")
Logger.warning("Appsignal.Ecto not attached to #{inspect(event)}: #{inspect(error)}")

error
end
Expand Down
3 changes: 1 addition & 2 deletions lib/appsignal/ecto_repo.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 4 additions & 6 deletions lib/appsignal/error/backend.ex
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
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

import Appsignal.Utils, only: [warning: 1]

def init(opts), do: {:ok, opts}

def attach do
case Logger.add_backend(Appsignal.Error.Backend) do
{:error, error} ->
warning("Appsignal.Error.Backend not attached to Logger: #{error}")
Logger.warning("Appsignal.Error.Backend not attached to Logger: #{error}")
:error

_ ->
Expand Down
10 changes: 4 additions & 6 deletions lib/appsignal/finch.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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

import Appsignal.Utils, only: [warning: 1]

def attach do
handlers = %{
[:finch, :request, :start] => &__MODULE__.finch_request_start/4,
Expand All @@ -23,7 +21,7 @@ defmodule Appsignal.Finch do
:ok

{:error, _} = error ->
warning("Appsignal.Finch not attached to #{inspect(event)}: #{inspect(error)}")
Logger.warning("Appsignal.Finch not attached to #{inspect(event)}: #{inspect(error)}")

error
end
Expand Down
3 changes: 1 addition & 2 deletions lib/appsignal/heartbeat.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions lib/appsignal/instrumentation.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/instrumentation/decorators.ex
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 2 additions & 4 deletions lib/appsignal/integration_logger.ex
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/logger.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions lib/appsignal/monitor.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 5 additions & 7 deletions lib/appsignal/oban.ex
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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

import Appsignal.Utils, only: [warning: 1]

def attach do
exception_handler =
case Appsignal.Config.report_oban_errors() do
Expand Down Expand Up @@ -42,7 +40,7 @@ defmodule Appsignal.Oban do
:ok

{_, {:error, _} = error} ->
warning("Appsignal.Oban not attached to #{inspect(event)}: #{inspect(error)}")
Logger.warning("Appsignal.Oban not attached to #{inspect(event)}: #{inspect(error)}")

error
end
Expand Down
1 change: 0 additions & 1 deletion lib/appsignal/probes/erlang_probe.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule Appsignal.Probes.ErlangProbe do
@moduledoc false
require Appsignal.Utils

def call(sample \\ nil) do
next_sample = sample_schedulers()
Expand Down
3 changes: 1 addition & 2 deletions lib/appsignal/probes/probes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/span.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 4 additions & 6 deletions lib/appsignal/tesla.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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

import Appsignal.Utils, only: [warning: 1]

def attach do
handlers = %{
[:tesla, :request, :start] => &__MODULE__.tesla_request_start/4,
Expand All @@ -23,7 +21,7 @@ defmodule Appsignal.Tesla do
:ok

{:error, _} = error ->
warning("Appsignal.Tesla not attached to #{inspect(event)}: #{inspect(error)}")
Logger.warning("Appsignal.Tesla not attached to #{inspect(event)}: #{inspect(error)}")

error
end
Expand Down
4 changes: 1 addition & 3 deletions lib/appsignal/tracer.ex
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions lib/appsignal/transmitter.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Appsignal.Transmitter do
@moduledoc false

import Appsignal.Utils, only: [warning: 1]
require Logger

def request(method, url, headers \\ [], body \\ "") do
http_client = Application.get_env(:appsignal, :http_client, :hackney)
Expand Down Expand Up @@ -62,7 +62,7 @@ defmodule Appsignal.Transmitter do

{:error, message} ->
unless ca_file_path == packaged_ca_file_path() do
warning(
Logger.warning(
"Ignoring non-existing or unreadable ca_file_path (#{ca_file_path}): #{inspect(message)}"
)
end
Expand Down
Loading
Loading