diff --git a/lib/realtime/rpc.ex b/lib/realtime/rpc.ex index efd97be00..9e4d5b1e3 100644 --- a/lib/realtime/rpc.ex +++ b/lib/realtime/rpc.ex @@ -4,19 +4,26 @@ defmodule Realtime.Rpc do """ import Realtime.Logs alias Realtime.Telemetry + require Logger @doc """ Calls external node using :rpc.call/5 and collects telemetry """ @spec call(atom(), atom(), atom(), any(), keyword()) :: any() def call(node, mod, func, args, opts \\ []) do + Logger.debug("Rpc.call called: #{inspect({node, mod, func, args})}") timeout = Keyword.get(opts, :timeout, Application.get_env(:realtime, :rpc_timeout)) {latency, response} = :timer.tc(fn -> :rpc.call(node, mod, func, args, timeout) end) + success = case response do + {:badrpc, _} -> false + _ -> true + end + Telemetry.execute( [:realtime, :rpc], %{latency: latency}, - %{mod: mod, func: func, target_node: node, origin_node: node()} + %{mod: mod, func: func, target_node: node, origin_node: node(), success: success} ) response @@ -28,6 +35,7 @@ defmodule Realtime.Rpc do @spec enhanced_call(atom(), atom(), atom(), any(), keyword()) :: {:ok, any()} | {:error, :rpc_error, term()} | {:error, term()} def enhanced_call(node, mod, func, args \\ [], opts \\ []) do + Logger.debug("Rpc.enhanced_call called: #{inspect({node, mod, func, args})}") timeout = Keyword.get(opts, :timeout, Application.get_env(:realtime, :rpc_timeout)) with {latency, response} <-