From 7c3b7a49e921e00ee635bfa14b1f6bef1120e20a Mon Sep 17 00:00:00 2001 From: Thomas Culotta Date: Wed, 20 Mar 2024 14:44:49 -0700 Subject: [PATCH] VmAgent endpoint to report GSDK version telemetry --- .../Controllers/SessionHostController.cs | 25 ++++++++++++++++++- .../Instrumentation/GsdkVersionInfo.cs | 8 ++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 LocalMultiplayerAgent/Instrumentation/GsdkVersionInfo.cs diff --git a/LocalMultiplayerAgent/Controllers/SessionHostController.cs b/LocalMultiplayerAgent/Controllers/SessionHostController.cs index 55e3141..ed8ed1b 100644 --- a/LocalMultiplayerAgent/Controllers/SessionHostController.cs +++ b/LocalMultiplayerAgent/Controllers/SessionHostController.cs @@ -11,7 +11,7 @@ namespace LocalMultiplayerAgent.Controllers using Microsoft.Azure.Gaming.LocalMultiplayerAgent; using Microsoft.Azure.Gaming.VmAgent.Model; using Microsoft.Extensions.Hosting; - using Newtonsoft.Json; + using Instrumentation; public class SessionHostController : Controller { @@ -96,6 +96,29 @@ public async Task ProcessHeartbeat(string sessionHostId, }); } + private static bool _wasGsdkVersionLogged = false; + [HttpPost] + [Route("v1/metrics/{sessionHostId}/gsdkinfo")] + public IActionResult ReportGsdkVersion(string sessionHostId, [FromBody] GsdkVersionInfo vi) + { + if (string.IsNullOrEmpty(vi.Version)) + { + return BadRequest($"{nameof(GsdkVersionInfo.Version)} should not be an empty string"); + } + if (string.IsNullOrEmpty(vi.Flavor)) + { + return BadRequest($"{nameof(GsdkVersionInfo.Flavor)} should not be an empty string"); + } + + if (!_wasGsdkVersionLogged) + { + Globals.MultiLogger.LogInformation($"GSDK flavor/version: {vi.Flavor}/{vi.Version} from session host {sessionHostId}"); + _wasGsdkVersionLogged = true; + } + + return Ok(); + } + [HttpPatch] [Route("v1/sessionHosts/{sessionHostId}")] public Task ProcessHeartbeatV1( diff --git a/LocalMultiplayerAgent/Instrumentation/GsdkVersionInfo.cs b/LocalMultiplayerAgent/Instrumentation/GsdkVersionInfo.cs new file mode 100644 index 0000000..ecc6273 --- /dev/null +++ b/LocalMultiplayerAgent/Instrumentation/GsdkVersionInfo.cs @@ -0,0 +1,8 @@ +namespace LocalMultiplayerAgent.Instrumentation +{ + public class GsdkVersionInfo + { + public string Flavor { get; set; } // Unreal/Unity/C#/C++ etc. + public string Version { get; set; } + } +}