Skip to content

Commit e6514f4

Browse files
author
Lakshay Kalbhor
committed
chore: add debug logs to healthcheck
1 parent 7bf29b9 commit e6514f4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/relay/source_pool.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (sp *SourcePool) Close() {
229229

230230
// newConn initializes a new consumer group config.
231231
func (sp *SourcePool) newConn(ctx context.Context, s Server) (*kgo.Client, error) {
232-
sp.log.Debug("running TCP health check", "id", s.ID, "server", s.Config.BootstrapBrokers)
232+
sp.log.Debug("running TCP health check", "id", s.ID, "server", s.Config.BootstrapBrokers, "session_timeout", s.Config.SessionTimeout)
233233
if ok := checkTCP(ctx, s.Config.BootstrapBrokers, s.Config.SessionTimeout); !ok {
234234
return nil, ErrorNoHealthy
235235
}
@@ -297,12 +297,14 @@ func (sp *SourcePool) healthcheck(ctx context.Context, signal chan struct{}) err
297297

298298
// For the first ever check, clients will be nil.
299299
if clients[i] == nil {
300+
sp.log.Debug("initializing admin client for background check", "id", s.ID, "server", s.Config.BootstrapBrokers)
300301
cl, err := sp.initConsumerClient(s.Config)
301302
if err != nil {
302303
sp.log.Error("error initializing admin client in background healthcheck", "id", s.ID, "server", s.Config.BootstrapBrokers, "error", err)
303304
continue
304305
}
305306

307+
sp.log.Debug("initialized admin client for background check", "id", s.ID, "server", s.Config.BootstrapBrokers)
306308
clients[i] = cl
307309
}
308310

@@ -314,6 +316,7 @@ func (sp *SourcePool) healthcheck(ctx context.Context, signal chan struct{}) err
314316

315317
// Get the highest offset of all the topics on the source server and sum them up
316318
// to derive the weight of the server.
319+
sp.log.Debug("getting high watermark via admin client for background check", "id", idx)
317320
offsets, err := sp.GetHighWatermark(ctx, clients[idx])
318321
if err != nil && offsets == nil {
319322
sp.log.Error("error fetching offset in background healthcheck", "id", s.ID, "server", s.Config.BootstrapBrokers, "error", err)
@@ -506,6 +509,7 @@ func (sp *SourcePool) setWeight(id int, weight int64) {
506509
sp.curCandidate = s
507510
}
508511

512+
sp.log.Debug("setting candidate weight", "id", id, "weight", weight, "curr", sp.curCandidate)
509513
sp.servers[id] = s
510514
break
511515
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func main() {
2222
// Initialize CLI flags.
2323
initFlags(ko)
2424

25+
fmt.Println(buildString)
2526
if ko.Bool("version") {
26-
fmt.Println(buildString)
2727
os.Exit(0)
2828
}
2929

0 commit comments

Comments
 (0)