This repository has been archived by the owner on May 1, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add switching station metrics * remove unneeded if * fix wrong import Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
- Loading branch information
1 parent
e9ae72b
commit ff6af94
Showing
3 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
|
||
local quarry_node = minetest.registered_nodes["technic:quarry"] | ||
if quarry_node ~= nil then | ||
print("[monitoring] wrapping quarry.technic_run") | ||
local quarry_def = minetest.registered_nodes["technic:quarry"] | ||
assert(quarry_def) | ||
|
||
quarry_node.technic_run = monitoring | ||
.counter("technic_quarry_dig_count", "number of technic quarry digs") | ||
.wrap(quarry_node.technic_run) | ||
end | ||
quarry_def.technic_run = | ||
monitoring.counter("technic_quarry_dig_count", "number of technic quarry digs") | ||
.wrap(quarry_def.technic_run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
assert(type(technic.network_run) == "function") | ||
assert(type(technic.active_networks) == "table") | ||
|
||
technic.network_run = | ||
monitoring.counter("technic_switching_stations_usage", "usage in microseconds cpu time") | ||
.wraptime(technic.network_run) | ||
|
||
local active_switching_stations_metric = monitoring.gauge( | ||
"technic_active_switching_stations", | ||
"Number of active switching stations" | ||
) | ||
|
||
local function count_stations() | ||
local count = 0 | ||
for _ in pairs(technic.active_networks) do | ||
count = count + 1 | ||
end | ||
active_switching_stations_metric.set(count) | ||
minetest.after(5, count_stations) | ||
end | ||
count_stations() |