diff --git a/quesma/quesma/search.go b/quesma/quesma/search.go index 655babaee..f6d7f13d4 100644 --- a/quesma/quesma/search.go +++ b/quesma/quesma/search.go @@ -141,9 +141,16 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, cfg config.QuesmaC startTime := time.Now() id := ctx.Value(tracing.RequestIdCtxKey).(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, + Path: path, IncomingQueryBody: body, QueryBodyTranslated: translatedQueryBody, QueryTranslatedResults: responseBody, @@ -299,11 +306,11 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, cfg config.QuesmaC 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, 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, body, res, + responseBody, err = q.storeAsyncSearch(qmc, id, optAsync.asyncRequestIdStr, optAsync.startTime, path, body, res, optAsync.keepOnCompletion) return responseBody, err @@ -312,15 +319,8 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, cfg config.QuesmaC } func (q *QueryRunner) storeAsyncSearch(qmc *ui.QuesmaManagementConsole, id, asyncRequestIdStr string, - startTime time.Time, 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) - defer qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ - Id: id, - IncomingQueryBody: body, - QueryBodyTranslated: result.translatedQueryBody, - QueryTranslatedResults: responseBody, - SecondaryTook: took, - }) if result.err != nil { if keep { q.AsyncRequestStorage.Store(asyncRequestIdStr, AsyncRequestResult{err: result.err, added: time.Now(), @@ -328,10 +328,26 @@ func (q *QueryRunner) storeAsyncSearch(qmc *ui.QuesmaManagementConsole, id, asyn } responseBody, _ = queryparser.EmptyAsyncSearchResponse(asyncRequestIdStr, false, 503) err = result.err + qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ + Id: id, + Path: path, + IncomingQueryBody: body, + QueryBodyTranslated: result.translatedQueryBody, + QueryTranslatedResults: responseBody, + SecondaryTook: took, + }) return } asyncResponse := queryparser.SearchToAsyncSearchResponse(result.response, asyncRequestIdStr, false, 200) responseBody, err = asyncResponse.Marshal() + qmc.PushSecondaryInfo(&ui.QueryDebugSecondarySource{ + Id: id, + Path: path, + IncomingQueryBody: body, + QueryBodyTranslated: result.translatedQueryBody, + QueryTranslatedResults: responseBody, + SecondaryTook: took, + }) if keep { compressedBody := responseBody isCompressed := false diff --git a/quesma/quesma/termsenum/terms_enum.go b/quesma/quesma/termsenum/terms_enum.go index fd82836c5..55a685364 100644 --- a/quesma/quesma/termsenum/terms_enum.go +++ b/quesma/quesma/termsenum/terms_enum.go @@ -43,9 +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), + Path: path, IncomingQueryBody: reqBody, QueryBodyTranslated: []byte(selectQuery.String()), QueryTranslatedResults: result, diff --git a/quesma/quesma/ui/html_pages.go b/quesma/quesma/ui/html_pages.go index 111a5055e..f4c67d52c 100644 --- a/quesma/quesma/ui/html_pages.go +++ b/quesma/quesma/ui/html_pages.go @@ -441,7 +441,7 @@ func (qmc *QuesmaManagementConsole) generateDatasources() []byte { buffer.Html(`
") @@ -461,7 +461,7 @@ func (qmc *QuesmaManagementConsole) generateRouterStatisticsLiveTail() []byte { buffer.Html(` ") @@ -481,7 +481,7 @@ func (qmc *QuesmaManagementConsole) generateStatisticsLiveTail() []byte { buffer.Html(` ") @@ -632,7 +632,6 @@ func (qmc *QuesmaManagementConsole) generateDashboard() []byte { buffer.Html(`