From 0da0283fb96661f19e2518435d8f76bd50069c6d Mon Sep 17 00:00:00 2001 From: Mumble <171087428+frutescens@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:37:26 -0800 Subject: [PATCH] [Feature] Two Separate Counters for Endless and Classic Starter Choice (#2) * Revert "Remove Daily from starter tracking" This reverts commit ce4aea88de78696c76046c862cdcae2f5d6d871f. * Added separate starter counter for Endless/Endless Spliced * Added daily conditional * Changed starterCounter to also hold information about the game mode. --------- Co-authored-by: frutescens --- api/savedata/prometheus.go | 2 +- api/savedata/update.go | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/api/savedata/prometheus.go b/api/savedata/prometheus.go index 749241b..06ee199 100644 --- a/api/savedata/prometheus.go +++ b/api/savedata/prometheus.go @@ -19,6 +19,6 @@ var ( Name: "rogueserver_starter_count", Help: "The total number of times a specific starter was selected", }, - []string{"starterKey"}, + []string{"starterKey", "gameMode"}, ) ) diff --git a/api/savedata/update.go b/api/savedata/update.go index 6f99553..f14b813 100644 --- a/api/savedata/update.go +++ b/api/savedata/update.go @@ -71,18 +71,7 @@ func ProcessSessionMetrics(save defs.SessionSaveData, username string) { return } else { log.Printf("increased game mode counter for %s", username) - switch save.GameMode { - case 0: - gameModeCounter.WithLabelValues("classic").Inc() - case 1: - gameModeCounter.WithLabelValues("endless").Inc() - case 2: - gameModeCounter.WithLabelValues("spliced-endless").Inc() - case 3: - gameModeCounter.WithLabelValues("daily").Inc() - case 4: - gameModeCounter.WithLabelValues("challenge").Inc() - } + gameModeCounter.WithLabelValues(getGameModeKey(save.GameMode)).Inc() } if save.WaveIndex == 1 && save.GameMode != 3 { @@ -108,8 +97,25 @@ func ProcessSessionMetrics(save defs.SessionSaveData, username string) { key := fmt.Sprintf("%d%s", species, formIndex) party += key + "," - starterCounter.WithLabelValues(key).Inc() + starterCounter.WithLabelValues(key, getGameModeKey(save.GameMode)).Inc() + } log.Printf("Incremented starters %s count for %s", party, username) } } + +func getGameModeKey(gameMode defs.GameMode) string { + switch gameMode { + case 0: + return "classic" + case 1: + return "endless" + case 2: + return "spliced-endless" + case 3: + return "daily" + case 4: + return "challenge" + } + return "none" +}