Skip to content

Commit

Permalink
Improve performance of debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jakozaur committed May 2, 2024
1 parent 4cf81fe commit 90c09c0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions quesma/quesma/ui/management_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
}

Expand Down Expand Up @@ -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{
Expand All @@ -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()
Expand Down

0 comments on commit 90c09c0

Please sign in to comment.