Skip to content

Commit

Permalink
Rename to path
Browse files Browse the repository at this point in the history
  • Loading branch information
jakozaur committed May 2, 2024
1 parent 90c09c0 commit 7c2734a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
19 changes: 12 additions & 7 deletions quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions quesma/quesma/termsenum/terms_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/html_pages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/html_panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func generateQueries(debugKeyValueSlice []DebugKeyValue, withLinks bool) []byte
if withLinks {
buffer.Html(`<a href="/request-Id/`).Text(v.Key).Html(`">`)
}
buffer.Html("<p>RequestID:").Text(v.Key).Html(" URI: ").Text(v.Value.Uri).Html("</p>\n")
buffer.Html("<p>RequestID:").Text(v.Key).Html(" Path: ").Text(v.Value.Path).Html("</p>\n")
buffer.Html(`<pre Id="query`).Text(v.Key).Html(`">`)
buffer.Text(string(v.Value.IncomingQueryBody))
buffer.Html("\n</pre>")
Expand Down
4 changes: 2 additions & 2 deletions quesma/quesma/ui/management_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type QueryDebugPrimarySource struct {
type QueryDebugSecondarySource struct {
Id string

Uri string
Path string
IncomingQueryBody []byte

QueryBodyTranslated []byte
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit 7c2734a

Please sign in to comment.