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" +}