aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2021-06-14 11:19:42 +0100
committerMatthew Wild <mwild1@gmail.com>2021-06-14 11:19:42 +0100
commit2562f23efcde00bb21f9dae9c389d05eaa797ab9 (patch)
treef2c6355308ab8a95fba2236947a74beb69df62c6
parentf36c48ffb0f7cfc18da8ab32c9f5dc61be9ff3f5 (diff)
downloadprosody-2562f23efcde00bb21f9dae9c389d05eaa797ab9.tar.gz
prosody-2562f23efcde00bb21f9dae9c389d05eaa797ab9.zip
util.openmetrics: Use pack from util.table, detect appropriate unpack for Lua 5.1 (thanks sups)
-rw-r--r--util/openmetrics.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/openmetrics.lua b/util/openmetrics.lua
index 90d3fdc2..a3ef827b 100644
--- a/util/openmetrics.lua
+++ b/util/openmetrics.lua
@@ -25,6 +25,7 @@ local array = require "util.array";
local log = require "util.logger".init("util.openmetrics");
local new_multitable = require "util.multitable".new;
local iter_multitable = require "util.multitable".iter;
+local t_pack, t_unpack = require "util.table".pack, table.unpack or unpack; --luacheck: ignore 113/unpack
-- BEGIN of Utility: "metric proxy"
-- This allows to wrap a MetricFamily in a proxy which only provides the
@@ -129,10 +130,10 @@ function metric_family_mt:with_labels(...)
end
local metric = self.data:get(...)
if not metric then
- local values = table.pack(...)
+ local values = t_pack(...)
metric = self:new_metric(values)
values[values.n+1] = metric
- self.data:set(table.unpack(values, 1, values.n+1))
+ self.data:set(t_unpack(values, 1, values.n+1))
end
return metric
end
@@ -159,9 +160,9 @@ function metric_family_mt:iter_metrics()
for i=1,nlabels do
searchkeys[i] = nil;
end
- local it, state = iter_multitable(self.data, table.unpack(searchkeys, 1, nlabels))
+ local it, state = iter_multitable(self.data, t_unpack(searchkeys, 1, nlabels))
return function(_s)
- local label_values = table.pack(it(_s))
+ local label_values = t_pack(it(_s))
if label_values.n == 0 then
return nil, nil
end