From 012690f687cf9c320bacf02490cad2eee89e089e Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Wed, 22 Mar 2023 09:20:40 -0700 Subject: [PATCH] Move debug wrap to right-before the API client This way other client changes are captured in the debug logging NOTE: this does not capture changes within the last API client (e.g. time removal for min/max time) --- pkg/servergroup/servergroup.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/servergroup/servergroup.go b/pkg/servergroup/servergroup.go index 946e535c0..bde81400c 100644 --- a/pkg/servergroup/servergroup.go +++ b/pkg/servergroup/servergroup.go @@ -200,6 +200,13 @@ func (s *ServerGroup) loadTargetGroupMap(targetGroupMap map[string][]*targetgrou var apiClient promclient.API apiClient = &promclient.PromAPIV1{v1.NewAPI(client)} + // If debug logging is enabled, wrap the client with a debugAPI client + // Since these are called in the reverse order of what we add, we want + // to make sure that this is the first wrap of the client + if logrus.GetLevel() >= logrus.DebugLevel { + apiClient = &promclient.DebugAPI{apiClient, u.String()} + } + if s.Cfg.RemoteRead { u.Path = path.Join(u.Path, s.Cfg.RemoteReadPath) cfg := &remote.ClientConfig{ @@ -255,13 +262,6 @@ func (s *ServerGroup) loadTargetGroupMap(targetGroupMap map[string][]*targetgrou } - // If debug logging is enabled, wrap the client with a debugAPI client - // Since these are called in the reverse order of what we add, we want - // to make sure that this is the last wrap of the client - if logrus.GetLevel() >= logrus.DebugLevel { - apiClient = &promclient.DebugAPI{apiClient, u.String()} - } - // Add LabelFilter if configured if s.Cfg.LabelFilterConfig != nil { apiClient, err = promclient.NewLabelFilterClient(ctx, apiClient, s.Cfg.LabelFilterConfig)