Skip to content

Commit

Permalink
Updates keyFleetName to keyName for Counters and Lists
Browse files Browse the repository at this point in the history
To be consistent with the tag used by fleets/replica_count
  • Loading branch information
igooch committed Dec 8, 2023
1 parent db07946 commit f34a9dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/metrics/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand All @@ -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)},
Expand Down
4 changes: 2 additions & 2 deletions pkg/metrics/controller_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions pkg/metrics/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
})
}

Expand Down

0 comments on commit f34a9dd

Please sign in to comment.