Skip to content

Commit

Permalink
Merge pull request #537 from OdyseeTeam/improve-cache-getter-retry
Browse files Browse the repository at this point in the history
Add retry success metrics
  • Loading branch information
anbsky authored Jan 22, 2025
2 parents 891f37c + 1060691 commit 5c98a2e
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 5c98a2e

Please sign in to comment.