Skip to content

Commit

Permalink
Move debug wrap to right-before the API client
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jacksontj committed Mar 22, 2023
1 parent 2746a79 commit 012690f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/servergroup/servergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 012690f

Please sign in to comment.