From 2f9ed3a0a7f4b237c0109ddb748b394c53e285ee Mon Sep 17 00:00:00 2001 From: Mumble <171087428+frutescens@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:32:00 -0800 Subject: [PATCH] Starter Tracking (#1) * starterCounter? * Update api/savedata/update.go --------- Co-authored-by: frutescens Co-authored-by: Frederico Santos --- api/savedata/prometheus.go | 8 ++++++++ api/savedata/update.go | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/api/savedata/prometheus.go b/api/savedata/prometheus.go index 385a4d5..749241b 100644 --- a/api/savedata/prometheus.go +++ b/api/savedata/prometheus.go @@ -13,4 +13,12 @@ var ( }, []string{"gamemode"}, ) + + starterCounter = promauto.NewCounterVec( + prometheus.CounterOpts{ + Name: "rogueserver_starter_count", + Help: "The total number of times a specific starter was selected", + }, + []string{"starterKey"}, + ) ) diff --git a/api/savedata/update.go b/api/savedata/update.go index 64f20f4..fcacddc 100644 --- a/api/savedata/update.go +++ b/api/savedata/update.go @@ -79,4 +79,15 @@ func ProcessSessionMetrics(save defs.SessionSaveData, uuid []byte) { case 4: gameModeCounter.WithLabelValues("challenge").Inc() } + if save.WaveIndex == 1 { + for i := 0; i < len(save.Party); i++ { + formIndex = "" + if save.Party[i]["formIndex"] != 0 { + formIndex = "-"+save.Party[i]["formIndex"] + } + key = save.Party[i]["Species"] + formIndex + log.Printf("incremented starter %s", key) + starterCounter.WithLabelValues(key).Inc() + } + } }