Skip to content

Commit

Permalink
Remove logging on info level from kafka service
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed Jun 4, 2022
1 parent f97e56e commit 9d17857
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion e2e/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e
import (
"context"
"fmt"
"strings"
"time"

"github.com/cloudhut/kminion/v2/kafka"
Expand Down Expand Up @@ -73,6 +74,8 @@ func NewService(ctx context.Context, cfg Config, logger *zap.Logger, kafkaSvc *k
kgoOpts = append(kgoOpts, kgo.RecordPartitioner(kgo.ManualPartitioner()))

// Create kafka service and check if client can successfully connect to Kafka cluster
logger.Info("connecting to Kafka seed brokers, trying to fetch cluster metadata",
zap.String("seed_brokers", strings.Join(kafkaSvc.Brokers(), ",")))
client, err := kafkaSvc.CreateAndTestClient(ctx, logger, kgoOpts)
if err != nil {
return nil, fmt.Errorf("failed to create kafka client for e2e: %w", err)
Expand Down Expand Up @@ -144,7 +147,6 @@ func NewService(ctx context.Context, cfg Config, logger *zap.Logger, kafkaSvc *k

// Start starts the service (wow)
func (s *Service) Start(ctx context.Context) error {

// Ensure topic exists and is configured correctly
if err := s.validateManagementTopic(ctx); err != nil {
return fmt.Errorf("could not validate end-to-end topic: %w", err)
Expand Down
8 changes: 5 additions & 3 deletions kafka/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ func (s *Service) CreateAndTestClient(ctx context.Context, l *zap.Logger, opts [
return client, nil
}

// Brokers returns list of brokers this service is connecting to
func (s *Service) Brokers() []string {
return s.cfg.Brokers
}

// testConnection tries to fetch Broker metadata and prints some information if connection succeeds. An error will be
// returned if connecting fails.
func (s *Service) testConnection(client *kgo.Client, ctx context.Context) error {
s.logger.Info("connecting to Kafka seed brokers, trying to fetch cluster metadata",
zap.String("seed_brokers", strings.Join(s.cfg.Brokers, ",")))

req := kmsg.MetadataRequest{
Topics: nil,
}
Expand Down
4 changes: 4 additions & 0 deletions minion/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"regexp"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -52,6 +53,9 @@ func NewService(cfg Config, logger *zap.Logger, kafkaSvc *kafka.Service, metrics
kgo.ConsumeTopics("__consumer_offsets"))
}

logger.Info("connecting to Kafka seed brokers, trying to fetch cluster metadata",
zap.String("seed_brokers", strings.Join(kafkaSvc.Brokers(), ",")))

client, err := kafkaSvc.CreateAndTestClient(ctx, logger, kgoOpts)
if err != nil {
return nil, fmt.Errorf("failed to create kafka client: %w", err)
Expand Down

0 comments on commit 9d17857

Please sign in to comment.