Skip to content

Commit

Permalink
log whenever ping worsens by 500ms during a spike
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Dec 26, 2024
1 parent 13147c2 commit b34689f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions monkestation/code/controllers/subsystem/ping_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SUBSYSTEM_DEF(ping_logging)
runlevels = ALL
var/last_overall_avg = 0
var/active_spike = FALSE
var/next_spike_threshold = 0

/datum/controller/subsystem/ping_logging/Initialize()
fire()
Expand All @@ -16,6 +17,7 @@ SUBSYSTEM_DEF(ping_logging)
flags |= SS_NO_INIT
last_overall_avg = SSping_logging.last_overall_avg
active_spike = SSping_logging.active_spike
next_spike_threshold = SSping_logging.next_spike_threshold

/datum/controller/subsystem/ping_logging/fire(resumed = FALSE)
var/overall_avg = 0
Expand All @@ -33,10 +35,15 @@ SUBSYSTEM_DEF(ping_logging)
if(overall_avg >= 1000)
WRITE_LOG("[GLOB.log_directory]/ping.log", "ping spike detected (avg >=1000ms): [overall_avg]ms")
active_spike = TRUE
next_spike_threshold = FLOOR(overall_avg + 750, 500)
else
if(overall_avg < 500)
WRITE_LOG("[GLOB.log_directory]/ping.log", "spike possibly ended ([overall_avg]ms)")
active_spike = FALSE
next_spike_threshold = 0
else if(overall_avg > next_spike_threshold)
WRITE_LOG("[GLOB.log_directory]/ping.log", "spike worsening ([overall_avg]ms)")
next_spike_threshold = FLOOR(overall_avg + 750, 500)
last_overall_avg = overall_avg

/datum/controller/subsystem/ping_logging/stat_entry(msg)
Expand Down

0 comments on commit b34689f

Please sign in to comment.