Skip to content

Commit 9b4a570

Browse files
authored
Merge pull request #50 from gatewayd-io/add-scan-and-keys-metrics
Add scan and keys metrics
2 parents a658707 + c7c7ef9 commit 9b4a570

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

plugin/metrics.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ var (
3232
Name: "cache_deletes_total",
3333
Help: "The total number of cache deletes",
3434
})
35+
CacheScanCounter = promauto.NewCounter(prometheus.CounterOpts{
36+
Namespace: metrics.Namespace,
37+
Name: "cache_scans_total",
38+
Help: "The total number of cache scans",
39+
})
40+
CacheScanKeysCounter = promauto.NewCounter(prometheus.CounterOpts{
41+
Namespace: metrics.Namespace,
42+
Name: "cache_scan_keys_total",
43+
Help: "The total number of cache scan keys",
44+
})
3545
)

plugin/plugin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,12 @@ func (p *Plugin) invalidateDML(ctx context.Context, query string) {
276276
p.Logger.Debug("Failed to scan keys", "error", scanResult.Err())
277277
break
278278
}
279+
CacheScanCounter.Inc()
279280

280281
// Per each key, delete the cache entry and the table cache key itself.
281282
var keys []string
282283
keys, cursor = scanResult.Val()
284+
CacheScanKeysCounter.Add(float64(len(keys)))
283285
for _, tableKey := range keys {
284286
// Invalidate the cache for the table.
285287
cachedRespnseKey := strings.TrimPrefix(tableKey, table+":")

plugin/scheduler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ func (p *Plugin) PeriodicInvalidator() {
2828
p.Logger.Error("Failed to scan keys", "error", scanResult.Err())
2929
break
3030
}
31+
CacheScanCounter.Inc()
3132

3233
var addresses []string
3334
addresses, cursor = scanResult.Val()
35+
CacheScanKeysCounter.Add(float64(len(addresses)))
3436
for _, address := range addresses {
3537
valid := false
3638

0 commit comments

Comments
 (0)