From eeb547ddaf48e7fd5d08bb991b453efa1a99f021 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Mon, 30 Sep 2024 09:44:56 +0200 Subject: [PATCH] fixup! chore: Improve logging of jumphash server selector Signed-off-by: Christian Haudum --- pkg/util/jumphash/memcached_client_selector.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/util/jumphash/memcached_client_selector.go b/pkg/util/jumphash/memcached_client_selector.go index 8011730162c71..7eec90a3de706 100644 --- a/pkg/util/jumphash/memcached_client_selector.go +++ b/pkg/util/jumphash/memcached_client_selector.go @@ -7,6 +7,7 @@ import ( "github.com/cespare/xxhash" "github.com/facette/natsort" + "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/grafana/gomemcache/memcache" @@ -23,7 +24,7 @@ import ( // with consistent DNS names where the naturally sorted order // is predictable. type Selector struct { - name string + logger log.Logger mu sync.RWMutex addrs []net.Addr resolveUnixAddr UnixResolver @@ -36,7 +37,7 @@ type TCPResolver func(network, address string) (*net.TCPAddr, error) func NewSelector(name string, resolveUnixAddr UnixResolver, resolveTCPAddr TCPResolver) *Selector { return &Selector{ - name: name, + logger: log.With(util_log.Logger, "name", name), resolveUnixAddr: resolveUnixAddr, resolveTCPAddr: resolveTCPAddr, } @@ -44,7 +45,7 @@ func NewSelector(name string, resolveUnixAddr UnixResolver, resolveTCPAddr TCPRe func DefaultSelector(name string) *Selector { return &Selector{ - name: name, + logger: log.With(util_log.Logger, "name", name), resolveUnixAddr: net.ResolveUnixAddr, resolveTCPAddr: net.ResolveTCPAddr, } @@ -105,7 +106,7 @@ func (s *Selector) SetServers(servers ...string) error { } } - level.Debug(util_log.Logger).Log("msg", "updating servers", "name", s.name, "servers", strings.Join(addresses(naddrs), ","), "count", len(naddrs)) + level.Debug(util_log.Logger).Log("msg", "updating servers", "servers", strings.Join(addresses(naddrs), ","), "count", len(naddrs)) s.mu.Lock() defer s.mu.Unlock()