-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d7402b
commit c3a86d5
Showing
3 changed files
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local metric = monitoring.counter("entity_on_step_count", "Entity on_step call count") | ||
|
||
local metric_time = monitoring.counter("entity_on_step_time", "time usage in microseconds for on_step calls") | ||
local metric_time_max = monitoring.gauge( | ||
"entity_on_step_time_max", | ||
"max time usage in microseconds for on_step calls", | ||
{ autoflush=true } | ||
) | ||
|
||
|
||
minetest.register_on_mods_loaded(function() | ||
for _, entity in pairs(minetest.registered_entities) do | ||
if type(entity.on_step) == "function" then | ||
local old_on_step = entity.on_step | ||
entity.on_step = function(...) | ||
local t0 = minetest.get_us_time() | ||
local result = old_on_step(...) | ||
local t1 = minetest.get_us_time() | ||
|
||
local diff = t1 - t0 | ||
metric_time.inc(diff) | ||
metric_time_max.setmax(diff) | ||
metric.inc() | ||
|
||
return result | ||
end | ||
end | ||
end | ||
end) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
monitoring.prometheus_push_url (monitoring push url) string |