Skip to content

Commit

Permalink
Add instance uptime to API info response
Browse files Browse the repository at this point in the history
This update includes the instance uptime in the API info response.
  • Loading branch information
Ayymoss authored and RaidMax committed Sep 7, 2024
1 parent a1a6924 commit 0a8bbf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions WebfrontCore/Controllers/API/Dtos/InfoResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class InfoResponse
public MetricSnapshot<int> TotalRecentClients { get; set; }

public MetricSnapshot<int?> MaxConcurrentClients { get; set; }
public TimeSpan Uptime { get; set; }
}

public class MetricSnapshot<T>
Expand Down
5 changes: 4 additions & 1 deletion WebfrontCore/Controllers/API/Info.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -30,6 +31,7 @@ public async Task<IActionResult> Get(int period = 24, Reference.Game? game = nul
var (totalClients, totalRecentClients) =
await _serverDataViewer.ClientCountsAsync(duration, game, token);
var (maxConcurrent, maxConcurrentTime) = await _serverDataViewer.MaxConcurrentClientsAsync(overPeriod: duration, token: token);
var uptime = DateTime.Now - Process.GetCurrentProcess().StartTime;
var response = new InfoResponse
{
TotalTrackedClients = totalClients,
Expand All @@ -46,7 +48,8 @@ public async Task<IActionResult> Get(int period = 24, Reference.Game? game = nul
Value = totalRecentClients,
EndAt = DateTime.UtcNow,
StartAt = DateTime.UtcNow - duration
}
},
Uptime = uptime,
};

return Json(response);
Expand Down

0 comments on commit 0a8bbf2

Please sign in to comment.