chore: bumps go redis client 9.17.2 (#25643)

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Patroklos Papapetrou <ppapapetrou76@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Papapetrou Patroklos
2025-12-17 09:25:04 +02:00
committed by GitHub
parent fee1c565c3
commit b2df60414c
4 changed files with 27 additions and 3 deletions

2
go.mod
View File

@@ -77,7 +77,7 @@ require (
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/client_model v0.6.2
github.com/r3labs/diff/v3 v3.0.2
github.com/redis/go-redis/v9 v9.8.0
github.com/redis/go-redis/v9 v9.17.2
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e
github.com/sirupsen/logrus v1.9.3
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966

4
go.sum
View File

@@ -823,8 +823,8 @@ github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlT
github.com/r3labs/diff/v3 v3.0.2 h1:yVuxAY1V6MeM4+HNur92xkS39kB/N+cFi2hMkY06BbA=
github.com/r3labs/diff/v3 v3.0.2/go.mod h1:Cy542hv0BAEmhDYWtGxXRQ4kqRsVIcEjG9gChUlTmkw=
github.com/redis/go-redis/v9 v9.0.0-rc.4/go.mod h1:Vo3EsyWnicKnSKCA7HhgnvnyA74wOA69Cd2Meli5mmA=
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e h1:0xChnl3lhHiXbgSJKgChye0D+DvoItkOdkGcwelDXH0=
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=

23
util/cache/redis.go vendored
View File

@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net"
"strings"
"sync"
"time"
@@ -177,6 +178,23 @@ type redisHook struct {
registry MetricsRegistry
}
// ignoredRedisCommandNames are commands that go-redis may issue during connection setup / bookkeeping
// and which we don't want to count as application-level requests in metrics.
var ignoredRedisCommandNames = map[string]struct{}{
"hello": {},
"client": {},
// Optional: we can enable if we want also want to exclude other setup/noise commands.
// "auth": {},
// "select": {},
// "ping": {},
}
func shouldIgnoreRedisCmd(cmd redis.Cmder) bool {
name := strings.ToLower(strings.TrimSpace(cmd.Name()))
_, ok := ignoredRedisCommandNames[name]
return ok
}
func (rh *redisHook) DialHook(next redis.DialHook) redis.DialHook {
return func(ctx context.Context, network, addr string) (net.Conn, error) {
conn, err := next(ctx, network, addr)
@@ -189,6 +207,11 @@ func (rh *redisHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
startTime := time.Now()
err := next(ctx, cmd)
if shouldIgnoreRedisCmd(cmd) {
return err
}
rh.registry.IncRedisRequest(err != nil && !errors.Is(err, redis.Nil))
rh.registry.ObserveRedisRequestDuration(time.Since(startTime))

View File

@@ -133,6 +133,7 @@ func TestRedisMetrics(t *testing.T) {
ms := NewMockMetricsServer()
redisClient := redis.NewClient(&redis.Options{Addr: mr.Addr()})
faultyRedisClient := redis.NewClient(&redis.Options{Addr: "invalidredishost.invalid:12345"})
CollectMetrics(redisClient, ms, nil)
CollectMetrics(faultyRedisClient, ms, nil)