From b4eb4f524d587cddeff8fd20624ef0b4d4a03289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Mon, 4 Jul 2022 12:36:34 +0200 Subject: [PATCH] Appsignal: ignore backend errors. --- changelog.md | 2 ++ config/config.exs | 1 + lib/ha_handler/drbd/watcher.ex | 5 ++++- lib/ha_handler/pgsql/watcher.ex | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 0f2e00c..62af958 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,8 @@ # 2022-07-?? - v0.4.2 * Fix eventual crash on failed DRBD backend. +* Appsignal: ignore errors on backends (failed PSQL backend currently generate + errors, and floods appsignal). # 2022-06-13 - v0.4.1 diff --git a/config/config.exs b/config/config.exs index c7812c2..f8b1b68 100644 --- a/config/config.exs +++ b/config/config.exs @@ -46,4 +46,5 @@ config :appsignal, :config, otp_app: :ha_handler, name: "ha-handler", push_api_key: "secret", + ignore_namespaces: ["pgsql", "drbd"], env: config_env() diff --git a/lib/ha_handler/drbd/watcher.ex b/lib/ha_handler/drbd/watcher.ex index 76363b4..30d8433 100644 --- a/lib/ha_handler/drbd/watcher.ex +++ b/lib/ha_handler/drbd/watcher.ex @@ -25,6 +25,9 @@ defmodule HAHandler.DRBD.Watcher do @impl true def init(opts) do + # Configures this worker's jobs to report in the "drbd" namespace + Appsignal.Span.set_namespace(Appsignal.Tracer.root_span(), "drbd") + state = %{ backend: nil, last_reconnect: nil, @@ -46,7 +49,7 @@ defmodule HAHandler.DRBD.Watcher do case connect(hostname, password) do {:ok, pid} -> {:noreply, %{state | backend: pid}} - {:error, err} -> + {:error, _err} -> # Nothing to do, as the next request will trigger the reconnect logic # (see :execute call). diff --git a/lib/ha_handler/pgsql/watcher.ex b/lib/ha_handler/pgsql/watcher.ex index 3c0bf37..f597c9b 100644 --- a/lib/ha_handler/pgsql/watcher.ex +++ b/lib/ha_handler/pgsql/watcher.ex @@ -8,6 +8,9 @@ defmodule HAHandler.PGSQL.Watcher do @impl true def init(opts) do + # Configures this worker's jobs to report in the "pgsql" namespace + Appsignal.Span.set_namespace(Appsignal.Tracer.root_span(), "pgsql") + # Starts a Postgrex child but does not means the connection was # successful. # TODO: set dbconnections backoff and connect hooks