Skip to content

Commit

Permalink
balancer/rls: Fix RLS Cache metrics (grpc#7511)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq authored and infovivek2020 committed Aug 18, 2024
1 parent f429ca9 commit 5908e0c
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 5908e0c

Please sign in to comment.