diff --git a/pkg/metrics/controller.go b/pkg/metrics/controller.go index 4d54677ac4..f2ac8b4bb7 100644 --- a/pkg/metrics/controller.go +++ b/pkg/metrics/controller.go @@ -329,7 +329,7 @@ func (c *Controller) recordFleetReplicas(fleetName, fleetNamespace string, total // nolint:dupl // Linter errors on lines are duplicate of recordLists func (c *Controller) recordCounters(fleetName, fleetNamespace string, counters map[string]agonesv1.AggregatedCounterStatus) { - ctx, _ := tag.New(context.Background(), tag.Upsert(keyFleetName, fleetName), tag.Upsert(keyNamespace, fleetNamespace)) + ctx, _ := tag.New(context.Background(), tag.Upsert(keyName, fleetName), tag.Upsert(keyNamespace, fleetNamespace)) for counter, counterStatus := range counters { recordWithTags(ctx, []tag.Mutator{tag.Upsert(keyType, "allocated_count"), tag.Upsert(keyCounter, counter)}, @@ -346,7 +346,7 @@ func (c *Controller) recordCounters(fleetName, fleetNamespace string, counters m // nolint:dupl // Linter errors on lines are duplicate of recordCounters func (c *Controller) recordLists(fleetName, fleetNamespace string, lists map[string]agonesv1.AggregatedListStatus) { - ctx, _ := tag.New(context.Background(), tag.Upsert(keyFleetName, fleetName), tag.Upsert(keyNamespace, fleetNamespace)) + ctx, _ := tag.New(context.Background(), tag.Upsert(keyName, fleetName), tag.Upsert(keyNamespace, fleetNamespace)) for list, listStatus := range lists { recordWithTags(ctx, []tag.Mutator{tag.Upsert(keyType, "allocated_count"), tag.Upsert(keyList, list)}, diff --git a/pkg/metrics/controller_metrics.go b/pkg/metrics/controller_metrics.go index e3edea9f12..4aee96c741 100644 --- a/pkg/metrics/controller_metrics.go +++ b/pkg/metrics/controller_metrics.go @@ -119,14 +119,14 @@ var ( Measure: fleetCountersStats, Description: "Aggregated Counters counts and capacity across GameServers in the Fleet", Aggregation: view.LastValue(), - TagKeys: []tag.Key{keyFleetName, keyNamespace, keyType, keyCounter}, + TagKeys: []tag.Key{keyName, keyNamespace, keyType, keyCounter}, }, { Name: fleetListsName, Measure: fleetListsStats, Description: "Aggregated Lists counts and capacity across GameServers in the Fleet", Aggregation: view.LastValue(), - TagKeys: []tag.Key{keyFleetName, keyNamespace, keyType, keyList}, + TagKeys: []tag.Key{keyName, keyNamespace, keyType, keyList}, }, { Name: gameServersCountName, diff --git a/pkg/metrics/controller_test.go b/pkg/metrics/controller_test.go index 73c538614e..71a6524ee9 100644 --- a/pkg/metrics/controller_test.go +++ b/pkg/metrics/controller_test.go @@ -520,18 +520,18 @@ func TestFleetCountersAndListsMetrics(t *testing.T) { reader.ReadAndExport(exporter) assertMetricData(t, exporter, fleetCountersName, []expectedMetricData{ - // keyCounter, keyFleetName, keyNamespace, keyType + // keyCounter, keyName, keyNamespace, keyType {labels: []string{counterName, fleetName, defaultNs, "allocated_count"}, val: int64(24)}, {labels: []string{counterName, fleetName, defaultNs, "allocated_capacity"}, val: int64(30)}, {labels: []string{counterName, fleetName, defaultNs, "total_count"}, val: int64(28)}, {labels: []string{counterName, fleetName, defaultNs, "total_capacity"}, val: int64(50)}, }) assertMetricData(t, exporter, fleetListsName, []expectedMetricData{ - // keyList, keyFleetName, keyNamespace, keyType - {labels: []string{fleetName, listName, defaultNs, "allocated_count"}, val: int64(4)}, - {labels: []string{fleetName, listName, defaultNs, "allocated_capacity"}, val: int64(6)}, - {labels: []string{fleetName, listName, defaultNs, "total_count"}, val: int64(1)}, - {labels: []string{fleetName, listName, defaultNs, "total_capacity"}, val: int64(100)}, + // keyList, keyName, keyNamespace, keyType + {labels: []string{listName, fleetName, defaultNs, "allocated_count"}, val: int64(4)}, + {labels: []string{listName, fleetName, defaultNs, "allocated_capacity"}, val: int64(6)}, + {labels: []string{listName, fleetName, defaultNs, "total_count"}, val: int64(1)}, + {labels: []string{listName, fleetName, defaultNs, "total_capacity"}, val: int64(100)}, }) }