Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: Add some extra logging to pubsub systems #1308

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions internal/peer/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ func (p *MockPeers) Start() error {
func (p *MockPeers) Ready() error {
return nil
}

func (p *MockPeers) stop() {}
1 change: 1 addition & 0 deletions internal/peer/pubsub_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (p *RedisPubsubPeers) Start() error {

p.peers = generics.NewSetWithTTL[string](PeerEntryTimeout)
p.callbacks = make([]func(), 0)
p.Logger.Info().Logf("subscribing to pubsub peers channel")
p.sub = p.PubSub.Subscribe(context.Background(), "peers", p.listen)

p.Metrics.Register("num_peers", "gauge")
Expand Down
5 changes: 5 additions & 0 deletions pubsub/pubsub_goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (ps *GoRedisPubSub) Start() error {
hosts := []string{redisCfg.Host}
// if we have a cluster host, use that instead of the regular host
if len(redisCfg.ClusterHosts) > 0 {
ps.Logger.Info().Logf("ClusterHosts was specified, setting up Redis Cluster")
hosts = redisCfg.ClusterHosts
clusterModeEnabled = true
}
Expand All @@ -72,6 +73,7 @@ func (ps *GoRedisPubSub) Start() error {
options.DB = redisCfg.Database

if redisCfg.UseTLS {
ps.Logger.Info().WithField("TLSInsecure", redisCfg.UseTLSInsecure).Logf("Using TLS with Redis")
options.TLSConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
InsecureSkipVerify: redisCfg.UseTLSInsecure,
Expand All @@ -81,13 +83,16 @@ func (ps *GoRedisPubSub) Start() error {

var client redis.UniversalClient
if clusterModeEnabled {
ps.Logger.Info().WithField("hosts", options.Addrs).Logf("Using Redis Cluster Client")
client = redis.NewClusterClient(options.Cluster())
} else {
ps.Logger.Info().WithField("hosts", options.Addrs).Logf("Using Redis Universal client")
client = redis.NewUniversalClient(options)
}

// if an authcode was provided, use it to authenticate the connection
if authcode != "" {
ps.Logger.Info().Logf("Using Redis AuthCode to authenticate connection")
pipe := client.Pipeline()
pipe.Auth(context.Background(), authcode)
if _, err := pipe.Exec(context.Background()); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/honeycombio/refinery/logger"
"github.com/honeycombio/refinery/metrics"
"github.com/honeycombio/refinery/pubsub"
"github.com/stretchr/testify/assert"
Expand All @@ -30,6 +31,7 @@ func newPubSub(typ string) pubsub.PubSub {
ps = &pubsub.GoRedisPubSub{
Metrics: m,
Tracer: tracer,
Logger: &logger.NullLogger{},
}
case "local":
ps = &pubsub.LocalPubSub{
Expand Down
Loading