From 90c09c0d03224454b7bcae13362829fadf01871a Mon Sep 17 00:00:00 2001 From: Jacek Migdal Date: Thu, 2 May 2024 15:18:46 +0200 Subject: [PATCH] Improve performance of debug --- quesma/quesma/ui/management_console.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/quesma/quesma/ui/management_console.go b/quesma/quesma/ui/management_console.go index 70afe7c2b..df186e9a7 100644 --- a/quesma/quesma/ui/management_console.go +++ b/quesma/quesma/ui/management_console.go @@ -91,8 +91,8 @@ type QuesmaManagementConsole struct { func NewQuesmaManagementConsole(config config.QuesmaConfiguration, logManager *clickhouse.LogManager, indexManager elasticsearch.IndexManagement, logChan <-chan tracing.LogWithLevel, phoneHomeAgent telemetry.PhoneHomeAgent) *QuesmaManagementConsole { return &QuesmaManagementConsole{ - queryDebugPrimarySource: make(chan *QueryDebugPrimarySource, 5), - queryDebugSecondarySource: make(chan *QueryDebugSecondarySource, 5), + queryDebugPrimarySource: make(chan *QueryDebugPrimarySource, 10), + queryDebugSecondarySource: make(chan *QueryDebugSecondarySource, 10), queryDebugLogs: logChan, debugInfoMessages: make(map[string]QueryDebugInfo), debugLastMessages: make([]string, 0), @@ -110,13 +110,10 @@ func NewQuesmaManagementConsole(config config.QuesmaConfiguration, logManager *c } func (qmc *QuesmaManagementConsole) PushPrimaryInfo(qdebugInfo *QueryDebugPrimarySource) { - qdebugInfo.QueryResp = []byte(util.JsonPrettify(string(qdebugInfo.QueryResp), true)) qmc.queryDebugPrimarySource <- qdebugInfo } func (qmc *QuesmaManagementConsole) PushSecondaryInfo(qdebugInfo *QueryDebugSecondarySource) { - qdebugInfo.QueryTranslatedResults = []byte(util.JsonPrettify(string(qdebugInfo.QueryTranslatedResults), true)) - qdebugInfo.IncomingQueryBody = []byte(util.JsonPrettify(string(qdebugInfo.IncomingQueryBody), true)) qmc.queryDebugSecondarySource <- qdebugInfo } @@ -220,7 +217,8 @@ func (qmc *QuesmaManagementConsole) processChannelMessage() { select { case msg := <-qmc.queryDebugPrimarySource: logger.Debug().Msg("Received debug info from primary source: " + msg.Id) - debugPrimaryInfo := QueryDebugPrimarySource{msg.Id, msg.QueryResp, msg.PrimaryTook} + debugPrimaryInfo := QueryDebugPrimarySource{msg.Id, + []byte(util.JsonPrettify(string(msg.QueryResp), true)), msg.PrimaryTook} qmc.mutex.Lock() if value, ok := qmc.debugInfoMessages[msg.Id]; !ok { qmc.debugInfoMessages[msg.Id] = QueryDebugInfo{ @@ -242,9 +240,9 @@ func (qmc *QuesmaManagementConsole) processChannelMessage() { secondaryDebugInfo := QueryDebugSecondarySource{ msg.Id, msg.Uri, - msg.IncomingQueryBody, + []byte(util.JsonPrettify(string(msg.IncomingQueryBody), true)), msg.QueryBodyTranslated, - msg.QueryTranslatedResults, + []byte(util.JsonPrettify(string(msg.QueryTranslatedResults), true)), msg.SecondaryTook, } qmc.mutex.Lock()