summaryrefslogtreecommitdiffstats
path: root/modules/graphite/graphite.lua
diff options
context:
space:
mode:
authorPetr Špaček <petr.spacek@nic.cz>2020-06-29 14:28:45 +0200
committerPetr Špaček <petr.spacek@nic.cz>2020-06-29 16:01:09 +0200
commitf10d0ae0cb35b75d636efb0a5c2084643a48e47e (patch)
tree6a9ea962604a95f66861c1c9d4613e32f91fb6a5 /modules/graphite/graphite.lua
parentgraphite: reconnect to the graphite server when it was unavailable (diff)
downloadknot-resolver-f10d0ae0cb35b75d636efb0a5c2084643a48e47e.tar.xz
knot-resolver-f10d0ae0cb35b75d636efb0a5c2084643a48e47e.zip
graphite: more informative socket error messages
Diffstat (limited to '')
-rw-r--r--modules/graphite/graphite.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/graphite/graphite.lua b/modules/graphite/graphite.lua
index afdd2656..ff38b4b6 100644
--- a/modules/graphite/graphite.lua
+++ b/modules/graphite/graphite.lua
@@ -6,6 +6,10 @@ if not stats then modules.load('stats') end
if worker.id > 0 then return {} end
local M = {}
local socket = require("cqueues.socket")
+local proto_txt = {
+ [socket.SOCK_DGRAM] = 'udp',
+ [socket.SOCK_STREAM] = 'tcp'
+}
local function make_socket(host, port, stype)
local s, err, status
@@ -15,9 +19,8 @@ local function make_socket(host, port, stype)
status, err = pcall(s.connect, s)
if not status then
- if verbose() then
- log('[graphite] socket error: %s', err)
- end
+ log('[graphite] connecting: %s@%d %s reason: %s',
+ host, port, proto_txt[stype], err)
return status, err
end
return s
@@ -71,8 +74,10 @@ local function publish_table(metrics, prefix, now)
if not ok then
local tcp = M.cli[i]['connect'] ~= nil
if tcp and host.seen + 2 * M.interval / 1000 <= now then
- log('[graphite] reconnecting: %s@%d reason: %s',
- host.addr, host.port, err)
+ local sock_type = (host.tcp and socket.SOCK_STREAM)
+ or socket.SOCK_DGRAM
+ log('[graphite] reconnecting: %s@%d %s reason: %s',
+ host.addr, host.port, proto_txt[sock_type], err)
s = make_tcp(host.addr, host.port)
if s then
M.cli[i] = s