diff --git a/quesma/quesma/search.go b/quesma/quesma/search.go index 531239165..8bd30379c 100644 --- a/quesma/quesma/search.go +++ b/quesma/quesma/search.go @@ -133,11 +133,16 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin startTime := time.Now() id := ctx.Value(tracing.RequestIdCtxKey).(string) - uri := ctx.Value(tracing.RequestPath).(string) + path := "" + if value := ctx.Value(tracing.RequestPath); value != nil { + if str, ok := value.(string); ok { + path = str + } + } pushSecondaryInfoToManagementConsole := func() { qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ Id: id, - Uri: ctx.Value(tracing.RequestPath).(string), + Path: path, IncomingQueryBody: body, QueryBodyTranslated: translatedQueryBody, QueryTranslatedResults: responseBody, @@ -293,11 +298,11 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin go func() { // Async search takes longer. Return partial results and wait for recovery.LogPanicWithCtx(ctx) res := <-optAsync.doneCh - q.storeAsyncSearch(qmc, id, optAsync.asyncRequestIdStr, optAsync.startTime, uri, body, res, true) + q.storeAsyncSearch(qmc, id, optAsync.asyncRequestIdStr, optAsync.startTime, path, body, res, true) }() return q.handlePartialAsyncSearch(ctx, optAsync.asyncRequestIdStr) case res := <-optAsync.doneCh: - responseBody, err = q.storeAsyncSearch(qmc, id, optAsync.asyncRequestIdStr, optAsync.startTime, uri, body, res, + responseBody, err = q.storeAsyncSearch(qmc, id, optAsync.asyncRequestIdStr, optAsync.startTime, path, body, res, optAsync.keepOnCompletion) return responseBody, err @@ -306,7 +311,7 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin } func (q *QueryRunner) storeAsyncSearch(qmc *ui.QuesmaManagementConsole, id, asyncRequestIdStr string, - startTime time.Time, uri string, body []byte, result AsyncSearchWithError, keep bool) (responseBody []byte, err error) { + startTime time.Time, path string, body []byte, result AsyncSearchWithError, keep bool) (responseBody []byte, err error) { took := time.Since(startTime) if result.err != nil { if keep { @@ -317,7 +322,7 @@ func (q *QueryRunner) storeAsyncSearch(qmc *ui.QuesmaManagementConsole, id, asyn err = result.err qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ Id: id, - Uri: uri, + Path: path, IncomingQueryBody: body, QueryBodyTranslated: result.translatedQueryBody, QueryTranslatedResults: responseBody, @@ -329,7 +334,7 @@ func (q *QueryRunner) storeAsyncSearch(qmc *ui.QuesmaManagementConsole, id, asyn responseBody, err = asyncResponse.Marshal() qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ Id: id, - Uri: uri, + Path: path, IncomingQueryBody: body, QueryBodyTranslated: result.translatedQueryBody, QueryTranslatedResults: responseBody, diff --git a/quesma/quesma/termsenum/terms_enum.go b/quesma/quesma/termsenum/terms_enum.go index eb868fc3a..55a685364 100644 --- a/quesma/quesma/termsenum/terms_enum.go +++ b/quesma/quesma/termsenum/terms_enum.go @@ -43,10 +43,15 @@ func handleTermsEnumRequest(ctx context.Context, table string, reqBody []byte, q } else { result, err = json.Marshal(makeTermsEnumResponse(rows)) } - + path := "" + if value := ctx.Value(tracing.RequestPath); value != nil { + if str, ok := value.(string); ok { + path = str + } + } qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ Id: ctx.Value(tracing.RequestIdCtxKey).(string), - Uri: ctx.Value(tracing.RequestPath).(string), + Path: path, IncomingQueryBody: reqBody, QueryBodyTranslated: []byte(selectQuery.String()), QueryTranslatedResults: result, diff --git a/quesma/quesma/ui/html_pages_test.go b/quesma/quesma/ui/html_pages_test.go index ccc5a3657..5fa08ee8a 100644 --- a/quesma/quesma/ui/html_pages_test.go +++ b/quesma/quesma/ui/html_pages_test.go @@ -21,7 +21,7 @@ func TestHtmlPages(t *testing.T) { qmc := NewQuesmaManagementConsole(config.QuesmaConfiguration{}, nil, nil, logChan, telemetry.NewPhoneHomeEmptyAgent()) qmc.PushPrimaryInfo(&QueryDebugPrimarySource{Id: id, QueryResp: xssBytes}) qmc.PushSecondaryInfo(&QueryDebugSecondarySource{Id: id, - Uri: xss, + Path: xss, IncomingQueryBody: xssBytes, QueryBodyTranslated: xssBytes, QueryTranslatedResults: xssBytes, diff --git a/quesma/quesma/ui/html_panels.go b/quesma/quesma/ui/html_panels.go index 5c482dfb8..c12674c6d 100644 --- a/quesma/quesma/ui/html_panels.go +++ b/quesma/quesma/ui/html_panels.go @@ -27,7 +27,7 @@ func generateQueries(debugKeyValueSlice []DebugKeyValue, withLinks bool) []byte if withLinks { buffer.Html(``) } - buffer.Html("

RequestID:").Text(v.Key).Html(" URI: ").Text(v.Value.Uri).Html("

\n") + buffer.Html("

RequestID:").Text(v.Key).Html(" Path: ").Text(v.Value.Path).Html("

\n") buffer.Html(`
`)
 		buffer.Text(string(v.Value.IncomingQueryBody))
 		buffer.Html("\n
") diff --git a/quesma/quesma/ui/management_console.go b/quesma/quesma/ui/management_console.go index df186e9a7..79ce6aa1f 100644 --- a/quesma/quesma/ui/management_console.go +++ b/quesma/quesma/ui/management_console.go @@ -47,7 +47,7 @@ type QueryDebugPrimarySource struct { type QueryDebugSecondarySource struct { Id string - Uri string + Path string IncomingQueryBody []byte QueryBodyTranslated []byte @@ -239,7 +239,7 @@ func (qmc *QuesmaManagementConsole) processChannelMessage() { logger.Debug().Msg("Received debug info from secondary source: " + msg.Id) secondaryDebugInfo := QueryDebugSecondarySource{ msg.Id, - msg.Uri, + msg.Path, []byte(util.JsonPrettify(string(msg.IncomingQueryBody), true)), msg.QueryBodyTranslated, []byte(util.JsonPrettify(string(msg.QueryTranslatedResults), true)),