Server Health & Uptime
The ServerTracker collects infrastructure telemetry to help developers diagnose crashes, memory leaks, and performance hitching.
Events Dispatched
Section titled “Events Dispatched”| Event Name | Category | Description |
|---|---|---|
ServerInit |
server |
Dispatched when the server starts up, recording JobId, PlaceId, and PlaceVersion. |
ServerHeartbeat |
server |
Periodic health snapshot dispatched every serverHeartbeatIntervalSeconds (default: 60s). |
ServerShutdown |
server |
Dispatched during game:BindToClose with final uptime and player stats. |
Captured Metrics
Section titled “Captured Metrics”- Uptime: Calculated accurately with
os.clock()from server startup. - Memory Consumption: Tracked in megabytes via
Stats:GetTotalMemoryUsageMb(). - Heartbeat FPS: Frame execution rate calculated over 1-second rolling windows to detect server hitching.
- Concurrent Players: Real-time player count and peak concurrent players (
peakPlayerCount).
Code Examples
Section titled “Code Examples”Querying Health Snapshot
Section titled “Querying Health Snapshot”local uptime = Analytics:GetServerUptimeSeconds()local health = Analytics:GetServerHealth()
if health then print(string.format("Server Uptime: %d seconds", uptime)) print(string.format("Memory Usage: %d MB", health.memoryUsageMb)) print(string.format("Server FPS: %d", health.averageHeartbeatFps)) print(string.format("Peak Players: %d", health.peakPlayerCount))endAlerting on Memory Spikes
Section titled “Alerting on Memory Spikes”You can register middleware to flag memory leaks:
Analytics:Use(function(event) if event.name == "ServerHeartbeat" and event.data.memoryUsageMb > 1500 then warn(string.format("[CRITICAL ALERT] Server %s memory exceeds 1500MB!", game.JobId)) end return eventend)