SSmetrics - Elasticsearch powered metrics viewing

This commit is contained in:
AffectedArc07
2021-08-15 13:00:19 +01:00
parent d03fc7ea1c
commit 2ece3203c2
12 changed files with 97 additions and 0 deletions
+13
View File
@@ -2,6 +2,8 @@
/datum/controller/subsystem
// Metadata; you should define these.
name = "fire codertrain" //name of the subsystem
/// Subsystem ID. Used for when we need a technical name for the SS
var/ss_id = "fire_codertrain_again"
var/init_order = INIT_ORDER_DEFAULT //order of initialization. Higher numbers are initialized first, lower numbers later. Use defines in __DEFINES/subsystems.dm for easy understanding of order.
var/wait = 20 //time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
var/priority = FIRE_PRIORITY_DEFAULT //When mutiple subsystems need to run in the same tick, higher priority subsystems will run first and be given a higher share of the tick before MC_TICK_CHECK triggers a sleep
@@ -227,3 +229,14 @@
if("queued_priority") //editing this breaks things.
return 0
. = ..()
// Returns the metrics for the subsystem.
// This can be overriden on subtypes for variables that could affect tick usage
// Example: ATs on SSair
/datum/controller/subsystem/proc/get_metrics()
SHOULD_CALL_PARENT(TRUE)
var/list/out = list()
out["cost"] = cost
out["tick_usage"] = tick_usage
out["custom"] = list() // Override as needed on child
return out
+5
View File
@@ -66,6 +66,11 @@ SUBSYSTEM_DEF(air)
msg += "AT/MS:[round((cost ? active_turfs.len/cost : 0),0.1)]"
..(msg)
/datum/controller/subsystem/air/get_metrics()
. = ..()
var/list/cust = list()
cust["active_turfs"] = length(active_turfs)
.["custom"] = cust
/datum/controller/subsystem/air/Initialize(timeofday)
setup_overlays() // Assign icons and such for gas-turf-overlays
+30
View File
@@ -0,0 +1,30 @@
SUBSYSTEM_DEF(metrics)
name = "Metrics"
flags = SS_NO_INIT
wait = 1 MINUTES
offline_implications = "Server metrics will no longer be ingested into monitoring systems. No immediate action is needed."
runlevels = RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME // ALL THE LEVELS
/// The real time of day the server started. Used to calculate time drift
var/world_init_time = 0 // Not set in here. Set in world/New()
/datum/controller/subsystem/metrics/fire(resumed)
// AA TODO
return
/datum/controller/subsystem/metrics/proc/get_metrics_json()
var/list/out = list()
out["cpu"] = world.cpu
// out["maptick"] = world.map_cpu // TODO: 514
out["elapsed_processed"] = world.time
out["elapsed_real"] = (REALTIMEOFDAY - world_init_time)
out["client_count"] = length(GLOB.clients)
out["round_id"] = text2num(GLOB.round_id) // This is so we can filter the metrics by a single round ID
// Funnel in all SS metrics
var/list/ss_data = list()
for(var/datum/controller/subsystem/SS in Master.subsystems)
ss_data[SS.ss_id] = SS.get_metrics()
out["subsystems"] = ss_data
// And send it all
return json_encode(out)
+6
View File
@@ -12,6 +12,12 @@ SUBSYSTEM_DEF(mobs)
/// The amount of giant spiders that exist in the world. Used for mob capping.
var/giant_spiders = 0
/datum/controller/subsystem/mobs/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(GLOB.mob_living_list)
.["custom"] = cust
/datum/controller/subsystem/mobs/stat_entry()
..("P:[GLOB.mob_living_list.len]")
@@ -14,6 +14,12 @@ SUBSYSTEM_DEF(processing)
/datum/controller/subsystem/processing/stat_entry()
..("[stat_tag]:[processing.len]")
/datum/controller/subsystem/processing/get_metrics()
. = ..()
var/list/cust = list()
cust["processing"] = length(processing)
.["custom"] = cust
/datum/controller/subsystem/processing/fire(resumed = 0)
if(!resumed)
currentrun = processing.Copy()
@@ -41,6 +41,12 @@ SUBSYSTEM_DEF(tickets)
var/ticketCounter = 1
/datum/controller/subsystem/tickets/get_metrics()
. = ..()
var/list/cust = list()
cust["tickets"] = length(allTickets) // Not a perf metric but I want to see a graph where SSair usage spikes and 20 tickets come in
.["custom"] = cust
/datum/controller/subsystem/tickets/Initialize()
if(!close_messages)
close_messages = list("<font color='red' size='4'><b>- [ticket_name] Rejected! -</b></font>",
+6
View File
@@ -37,6 +37,12 @@ SUBSYSTEM_DEF(timer)
/datum/controller/subsystem/timer/stat_entry(msg)
..("B:[bucket_count] P:[length(second_queue)] H:[length(hashes)] C:[length(clienttime_timers)] S:[length(timer_id_dict)]")
/datum/controller/subsystem/timer/get_metrics()
. = ..()
var/list/cust = list()
cust["bucket_count"] = bucket_count
.["custom"] = cust
/datum/controller/subsystem/timer/fire(resumed = FALSE)
var/lit = last_invoke_tick
var/last_check = world.time - TICKS2DS(BUCKET_LEN*1.5)