Skip to content

Commit

Permalink
Add retry success metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Jan 22, 2025
1 parent a66a68d commit 1060691
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/query/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ var (
},
[]string{"kind", "method"},
)
QueryCacheRetrySuccesses = promauto.NewSummary(
prometheus.SummaryOpts{
Namespace: "query_cache",
Name: "retry_successes",
Help: "Successful counts of cache retrieval retries",
},
)
QueryCacheErrorCount = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: "query_cache",
Expand Down
7 changes: 7 additions & 0 deletions app/query/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,13 @@ func preflightCacheHook(caller *Caller, ctx context.Context) (*jsonrpc.RPCRespon
duration := time.Since(start).Seconds()
switch {
case err == nil && resp.Error == nil:
if attempt > 0 {
log.Infof(
"cache retriever %s attempt #%d succeeded",
query.Method(), attempt,
)
QueryCacheRetrySuccesses.Observe(float64(attempt))
}
return resp, err
case err != nil:
QueryCacheRetrievalFailures.WithLabelValues(CacheRetrievalErrorNet, query.Method()).Inc()
Expand Down

0 comments on commit 1060691

Please sign in to comment.