Mercurial > prosody-modules
annotate mod_measure_lua/mod_measure_lua.lua @ 4598:09f0911c735d
mod_ogp: Add the ability to block OGP fetching for certain domains
author | JC Brand <jc@opkode.com> |
---|---|
date | Tue, 22 Jun 2021 12:25:36 +0200 |
parents | d95fcde6e39d |
children | 3c3f45241317 |
rev | line source |
---|---|
4578
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
1 module:set_global() |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
2 |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
3 local custom_metric = require "core.statsmanager".metric |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
4 local gc_bytes = custom_metric( |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
5 "gauge", "lua_heap", "bytes", |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
6 "Memory used by objects under control of the Lua garbage collector" |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
7 ):with_labels() |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
8 |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
9 module:hook("stats-update", function () |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
10 local kbytes = collectgarbage("count"); |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
11 gc_bytes:set(kbytes * 1024); |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
12 end); |
d95fcde6e39d
mod_measure_lua: add openmetrics-spirited way to collect lua memory use
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
13 |