fix(agent): jason-safe error entries + correct handle_info return
Errors produced by Collectors.Host were keyword tuples {:tag, msg}, which
Jason cannot encode — metric push crashed the channel. Convert them to
plain maps with :tag and :message fields.
Reporter.handle_info/2 returned {:ok, socket}, which Slipstream rejects
(GenServer-style {:noreply, socket} is the only valid return for that
callback, unlike handle_connect/handle_join/handle_disconnect).
This commit is contained in:
parent
bfe39e71e1
commit
4f82701956
2 changed files with 2 additions and 2 deletions
|
|
@ -46,7 +46,7 @@ defmodule ProxmoxAgent.Collectors.Host do
|
||||||
try do
|
try do
|
||||||
{fun.(), nil}
|
{fun.(), nil}
|
||||||
rescue
|
rescue
|
||||||
e -> {fallback, {tag, Exception.message(e)}}
|
e -> {fallback, %{tag: Atom.to_string(tag), message: Exception.message(e)}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ defmodule ProxmoxAgent.Reporter do
|
||||||
payload = %{collected_at: DateTime.utc_now() |> DateTime.to_iso8601(), data: sample}
|
payload = %{collected_at: DateTime.utc_now() |> DateTime.to_iso8601(), data: sample}
|
||||||
:ok = push_metric(socket, "metric:fast", payload)
|
:ok = push_metric(socket, "metric:fast", payload)
|
||||||
Process.send_after(self(), :collect_fast, socket.assigns.cfg.fast_seconds * 1000)
|
Process.send_after(self(), :collect_fast, socket.assigns.cfg.fast_seconds * 1000)
|
||||||
{:ok, socket}
|
{:noreply, socket}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl Slipstream
|
@impl Slipstream
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue