Skip to content

Commit

Permalink
balancer/rls: Fix RLS Cache metrics (#7511)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq authored Aug 14, 2024
1 parent 6d7f07c commit 7ec3fd2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions balancer/rls/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ type dataCache struct {
}

func newDataCache(size int64, logger *internalgrpclog.PrefixLogger, metricsRecorder estats.MetricsRecorder, grpcTarget string) *dataCache {
dc := &dataCache{
return &dataCache{
maxSize: size,
keys: newLRU(),
entries: make(map[cacheKey]*cacheEntry),
Expand All @@ -190,9 +190,6 @@ func newDataCache(size int64, logger *internalgrpclog.PrefixLogger, metricsRecor
uuid: uuid.New().String(),
metricsRecorder: metricsRecorder,
}
cacheSizeMetric.Record(dc.metricsRecorder, 0, grpcTarget, "", dc.uuid)
cacheEntriesMetric.Record(dc.metricsRecorder, 0, grpcTarget, "", dc.uuid)
return dc
}

// updateRLSServerTarget updates the RLS Server Target the RLS Balancer is
Expand Down Expand Up @@ -330,6 +327,8 @@ func (dc *dataCache) addEntry(key cacheKey, entry *cacheEntry) (backoffCancelled
if dc.currentSize > dc.maxSize {
backoffCancelled = dc.resize(dc.maxSize)
}
cacheSizeMetric.Record(dc.metricsRecorder, dc.currentSize, dc.grpcTarget, dc.rlsServerTarget, dc.uuid)
cacheEntriesMetric.Record(dc.metricsRecorder, int64(len(dc.entries)), dc.grpcTarget, dc.rlsServerTarget, dc.uuid)
return backoffCancelled, true
}

Expand Down

0 comments on commit 7ec3fd2

Please sign in to comment.