mod_measure_lua/mod_measure_lua.lua
changeset 4582 d95fcde6e39d
child 4605 3c3f45241317
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_measure_lua/mod_measure_lua.lua	Sat May 29 12:12:17 2021 +0200
@@ -0,0 +1,13 @@
+module:set_global()
+
+local custom_metric = require "core.statsmanager".metric
+local gc_bytes = custom_metric(
+	"gauge", "lua_heap", "bytes",
+	"Memory used by objects under control of the Lua garbage collector"
+):with_labels()
+
+module:hook("stats-update", function ()
+	local kbytes = collectgarbage("count");
+  gc_bytes:set(kbytes * 1024);
+end);
+