Skip to content

Commit

Permalink
dalamud track metric
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Jun 13, 2023
1 parent 80b62e7 commit 1ba5b85
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions XLWebServices/Controllers/Dalamud/ReleaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ReleaseController : ControllerBase
private readonly ILogger<ReleaseController> _logger;

private static readonly Counter DownloadsOverTime =
Metrics.CreateCounter("xl_dalamud_startups", "Dalamud Unique Startups", "AppID");
Metrics.CreateCounter("xl_dalamud_startups", "Dalamud Unique Startups", "AppID", "Track");

private static bool isUseCanary = false;

Expand All @@ -44,6 +44,9 @@ public IActionResult VersionInfo([FromQuery] string? track = "", [FromQuery] str
if (string.IsNullOrEmpty(track))
track = "release";

if (track == "staging")
track = "stg";

if (string.IsNullOrEmpty(appId))
appId = "goat";

Expand All @@ -54,22 +57,20 @@ public IActionResult VersionInfo([FromQuery] string? track = "", [FromQuery] str
{
case "release":
{
DownloadsOverTime.WithLabels(appId).Inc();
DownloadsOverTime.WithLabels(appId, bucket == "Canary" ? "Canary" : "Control").Inc();

if (bucket == "Canary" && this.releaseCache.Get()!.DalamudVersions.ContainsKey("canary") && isUseCanary)
return new JsonResult(this.releaseCache.Get()!.DalamudVersions["canary"]);

return new JsonResult(this.releaseCache.Get()!.DalamudVersions["release"]);
}

case "staging":
return new JsonResult(this.releaseCache.Get()!.DalamudVersions["stg"]);

default:
{
if (!this.releaseCache.Get()!.DalamudVersions.TryGetValue(track, out var release))
return new JsonResult(this.releaseCache.Get()!.DalamudVersions["release"]);

DownloadsOverTime.WithLabels(appId, track).Inc();
return new JsonResult(release);
}
}
Expand Down

0 comments on commit 1ba5b85

Please sign in to comment.