From 628bba8dbf9ceda55bd5896d5e735d7b3c3c0042 Mon Sep 17 00:00:00 2001 From: Matt Robenolt Date: Sun, 11 Feb 2024 16:02:33 -0800 Subject: [PATCH] Add missing logging for other query paths (#18) --- handler.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/handler.go b/handler.go index bb4022e..3f90c3d 100644 --- a/handler.go +++ b/handler.go @@ -126,6 +126,7 @@ func (h *handler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes. slog.String("addr", c.GetRawConn().LocalAddr().String()), slog.Int("mysql_id", int(c.ConnectionID)), slog.String("query", query), + slog.Bool("olap", data.IsOLAP()), ) if data.IsOLAP() { @@ -157,6 +158,15 @@ func (h *handler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes. func (h *handler) ComPrepare(c *mysql.Conn, query string, bindVars map[string]*vitessquerypb.BindVariable) ([]*vitessquerypb.Field, error) { data := h.clientData(c) + defer h.logger.LogAttrs( + context.Background(), + slog.LevelDebug, + "prepare", + slog.String("addr", c.GetRawConn().LocalAddr().String()), + slog.Int("mysql_id", int(c.ConnectionID)), + slog.String("query", query), + ) + resp, err := h.client.Prepare(context.Background(), connect.NewRequest(&psdbpb.PrepareRequest{ Session: data.Session, Query: query, @@ -180,6 +190,16 @@ func (h *handler) ComPrepare(c *mysql.Conn, query string, bindVars map[string]*v func (h *handler) ComStmtExecute(c *mysql.Conn, prepare *mysql.PrepareData, callback func(*sqltypes.Result) error) error { data := h.clientData(c) + defer h.logger.LogAttrs( + context.Background(), + slog.LevelDebug, + "stmt_execute", + slog.String("addr", c.GetRawConn().LocalAddr().String()), + slog.Int("mysql_id", int(c.ConnectionID)), + slog.String("query", prepare.PrepareStmt), + slog.Bool("olap", data.IsOLAP()), + ) + if data.IsOLAP() { return h.streamExecute(c, data, prepare.PrepareStmt, castBindVars(prepare.BindVars), callback) }