1 defmodule Pleroma.Telemetry.Logger do
2 @moduledoc "Transforms Pleroma telemetry events to logs"
7 [:pleroma, :connection_pool, :reclaim, :start],
8 [:pleroma, :connection_pool, :reclaim, :stop],
9 [:pleroma, :connection_pool, :provision_failure],
10 [:pleroma, :connection_pool, :client, :dead],
11 [:pleroma, :connection_pool, :client, :add]
14 :telemetry.attach_many("pleroma-logger", @events, &handle_event/4, [])
17 # Passing anonymous functions instead of strings to logger is intentional,
18 # that way strings won't be concatenated if the message is going to be thrown
19 # out anyway due to higher log level configured
22 [:pleroma, :connection_pool, :reclaim, :start],
24 %{max_connections: max_connections, reclaim_max: reclaim_max},
28 "Connection pool is exhausted (reached #{max_connections} connections). Starting idle connection cleanup to reclaim as much as #{
35 [:pleroma, :connection_pool, :reclaim, :stop],
36 %{reclaimed_count: 0},
41 "Connection pool failed to reclaim any connections due to all of them being in use. It will have to drop requests for opening connections to new hosts"
46 [:pleroma, :connection_pool, :reclaim, :stop],
47 %{reclaimed_count: reclaimed_count},
51 Logger.debug(fn -> "Connection pool cleaned up #{reclaimed_count} idle connections" end)
55 [:pleroma, :connection_pool, :provision_failure],
61 "Connection pool had to refuse opening a connection to #{key} due to connection limit exhaustion"
66 [:pleroma, :connection_pool, :client, :dead],
67 %{client_pid: client_pid, reason: reason},
72 "Pool worker for #{key}: Client #{inspect(client_pid)} died before releasing the connection with #{
79 [:pleroma, :connection_pool, :client, :add],
80 %{clients: [_, _ | _] = clients},
81 %{key: key, protocol: :http},
85 "Pool worker for #{key}: #{length(clients)} clients are using an HTTP1 connection at the same time, head-of-line blocking might occur."
89 def handle_event([:pleroma, :connection_pool, :client, :add], _, _, _), do: :ok