diff --git a/lib/thousand_island/acceptor.ex b/lib/thousand_island/acceptor.ex index ab35fcd..e6be89a 100644 --- a/lib/thousand_island/acceptor.ex +++ b/lib/thousand_island/acceptor.ex @@ -30,7 +30,11 @@ defmodule ThousandIsland.Acceptor do ThousandIsland.Telemetry.span_event(span, :spawn_error) accept(listener_socket, connection_sup_pid, server_config, span, count + 1) - {:error, reason} when reason in [:closed, :einval, :econnaborted] -> + {:error, :econnaborted} -> + ThousandIsland.Telemetry.span_event(span, :econnaborted) + accept(listener_socket, connection_sup_pid, server_config, span, count + 1) + + {:error, reason} when reason in [:closed, :einval] -> ThousandIsland.Telemetry.stop_span(span, %{connections: count}) {:error, reason} -> diff --git a/lib/thousand_island/logger.ex b/lib/thousand_island/logger.ex index 4d585b0..94894a3 100644 --- a/lib/thousand_island/logger.ex +++ b/lib/thousand_island/logger.ex @@ -21,7 +21,10 @@ defmodule ThousandIsland.Logger do """ @spec attach_logger(log_level()) :: :ok | {:error, :already_exists} def attach_logger(:error) do - events = [[:thousand_island, :acceptor, :spawn_error]] + events = [ + [:thousand_island, :acceptor, :spawn_error], + [:thousand_island, :acceptor, :econnaborted] + ] :telemetry.attach_many("#{__MODULE__}.error", events, &__MODULE__.log_error/4, nil) end diff --git a/lib/thousand_island/telemetry.ex b/lib/thousand_island/telemetry.ex index ab98791..187a3e8 100644 --- a/lib/thousand_island/telemetry.ex +++ b/lib/thousand_island/telemetry.ex @@ -97,6 +97,21 @@ defmodule ThousandIsland.Telemetry do * `telemetry_span_context`: A unique identifier for this span + * `[:thousand_island, :acceptor, :econnaborted]` + + Thousand Island was unable to spawn a process to handle a connection since the remote end + closed before we could accept it. This usually occurs when it takes too long for your server + to start processing a connection; you may want to look at tuning OS-level TCP parameters or + adding more server capacity. + + This event contains the following measurements: + + * `monotonic_time`: The time of this event, in `:native` units + + This event contains the following metadata: + + * `telemetry_span_context`: A unique identifier for this span + ## `[:thousand_island, :connection, *]` Represents Thousand Island handling a specific client request @@ -281,6 +296,7 @@ defmodule ThousandIsland.Telemetry do @type event_name :: :ready | :spawn_error + | :econnaborted | :recv_error | :send_error | :sendfile_error