From 65c87e163f214bba1cb194ee3d7ced8a5e7e7872 Mon Sep 17 00:00:00 2001 From: Sean Hurley Date: Tue, 31 May 2022 09:56:03 -0600 Subject: [PATCH] Remove noisy logging in favor of a metric --- proxy/connection.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/proxy/connection.go b/proxy/connection.go index af1d2a9..c997a75 100644 --- a/proxy/connection.go +++ b/proxy/connection.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "fmt" "io" + "log" "math/big" "net" "runtime/debug" @@ -198,7 +199,7 @@ func (c *connection) roundTrip(msg *mongo.Message, isMaster bool, tags []string) func (c *connection) roundTripWithDualCursor(msg *mongo.Message, primaryRes *mongo.Message, isMaster bool, tags []string) { dynamic := c.dynamic.ForAddress(c.address) if dynamic.DualReadFrom != "" { - command, _ := msg.Op.CommandAndCollection() + command, collection := msg.Op.CommandAndCollection() bigint, err := rand.Int(rand.Reader, big.NewInt(100)) if err != nil { @@ -238,11 +239,9 @@ func (c *connection) roundTripWithDualCursor(msg *mongo.Message, primaryRes *mon return } - if bytes.Equal(primSection, dualSection) { - c.log.Info("Dual reads match", zap.String("real_socket", c.address), zap.String("test_socket", dynamic.DualReadFrom)) - } else { - c.log.Info("Dual reads mismatch", zap.String("real_socket", c.address), zap.String("test_socket", dynamic.DualReadFrom)) - } + match := bytes.Equal(primSection, dualSection) + // TODO: add timing to compare primary and secondary performance + c.statsd.Incr("dual_read_result", []string{fmt.Sprintf("collection:%s,match:%t", collection, match)}, 1) } } }