-- Set Prometheus namespace
http.prometheus.namespace = 'resolver_'
+You can also add custom metrics or rewrite existing metrics before they are returned to Prometheus client.
+
+.. code-block:: lua
+
+ http = {
+ host = 'localhost',
+ }
+
+ -- Add an arbitrary metric to Prometheus
+ http.prometheus.finalize = function (metrics)
+ table.insert(metrics, 'build_info{version="1.2.3"} 1')
+ end
+
Tracing requests
^^^^^^^^^^^^^^^^
-- Module implementation
local M = {
namespace = '',
+ finalize = function (_ --[[metrics]]) end,
}
local snapshots, snapshots_count = {}, 120
end
table.insert(render, string.format('%slatency_count %f', M.namespace, count))
table.insert(render, string.format('%slatency_sum %f', M.namespace, sum))
+ -- Finalize metrics table before rendering
+ if type(M.finalize) == 'function' then
+ M.finalize(render)
+ end
return table.concat(render, '\n') .. '\n'
end