Mercurial > prosody-modules
comparison mod_measure_lua/mod_measure_lua.lua @ 4578:d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
In the spirit of separate collectors found in other Prometheus
packages, this is a separate module to collect metrics related to
the lua stack itself.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Sat, 29 May 2021 12:12:17 +0200 |
parents | |
children | 3c3f45241317 |
comparison
equal
deleted
inserted
replaced
4577:253df0798996 | 4578:d95fcde6e39d |
---|---|
1 module:set_global() | |
2 | |
3 local custom_metric = require "core.statsmanager".metric | |
4 local gc_bytes = custom_metric( | |
5 "gauge", "lua_heap", "bytes", | |
6 "Memory used by objects under control of the Lua garbage collector" | |
7 ):with_labels() | |
8 | |
9 module:hook("stats-update", function () | |
10 local kbytes = collectgarbage("count"); | |
11 gc_bytes:set(kbytes * 1024); | |
12 end); | |
13 |