Skip to content

[ES|QL] Add mechanism to simulate long queries#191520

Merged
lukasolson merged 1 commit intoelastic:mainfrom
lukasolson:esql_delay
Aug 28, 2024
Merged

[ES|QL] Add mechanism to simulate long queries#191520
lukasolson merged 1 commit intoelastic:mainfrom
lukasolson:esql_delay

Conversation

@lukasolson
Copy link
Copy Markdown
Contributor

@lukasolson lukasolson commented Aug 27, 2024

Summary

Adds a mechanism to simulate a long-running query in ES|QL.

Elasticsearch provides a query type, error_query, in snapshot builds that allows passing a delay to simulate long-running queries. This PR adds a way to utilize this for testing & debugging purposes.

To use: In your browser console, simply execute the following:

window.ELASTIC_ESQL_DELAY_SECONDS = 5;

This will cause search requests to pause for 5 seconds (on each shard). This can then be used in testing & debugging.

It should be noted that this is similar in pattern to the existing window.ELASTIC_LENS_DELAY_SECONDS pattern that Lens uses.

@lukasolson lukasolson self-assigned this Aug 27, 2024
@lukasolson
Copy link
Copy Markdown
Contributor Author

/ci

@lukasolson lukasolson added release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// Team:ESQL ES|QL related features in Kibana t// Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// labels Aug 27, 2024
Comment on lines +12 to +26
import type {
IKibanaSearchRequest,
IKibanaSearchResponse,
ISearchGeneric,
} from '@kbn/search-types';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { getStartEndParams } from '@kbn/esql-utils';

import { zipObject } from 'lodash';
import { Observable, defer, throwError } from 'rxjs';
import { catchError, map, switchMap, tap } from 'rxjs';
import { buildEsQuery } from '@kbn/es-query';
import type { ISearchGeneric } from '@kbn/search-types';
import type { ESQLSearchResponse, ESQLSearchParams } from '@kbn/es-types';
import { catchError, defer, map, Observable, switchMap, tap, throwError } from 'rxjs';
import { buildEsQuery, type Filter } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchResponse } from '@kbn/es-types';
import { getEsQueryConfig } from '../../es_query';
import { getTime } from '../../query';
import { ESQL_ASYNC_SEARCH_STRATEGY, KibanaContext, ESQL_TABLE_TYPE } from '..';
import { ESQL_ASYNC_SEARCH_STRATEGY, ESQL_TABLE_TYPE, KibanaContext } from '..';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is just import optimization, the only actual change here is adding the type Filter to the import from @kbn/es-query.

@lukasolson lukasolson marked this pull request as ready for review August 27, 2024 23:20
@lukasolson lukasolson requested review from a team as code owners August 27, 2024 23:20
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 418.7KB 418.8KB +186.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @lukasolson

Copy link
Copy Markdown
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good and work well

@lukasolson lukasolson merged commit b3a56f7 into elastic:main Aug 28, 2024
@kibanamachine kibanamachine added v8.16.0 backport:skip This PR does not require backporting labels Aug 28, 2024
@stratoula
Copy link
Copy Markdown
Contributor

Awesome Lukas

lukasolson added a commit that referenced this pull request Aug 29, 2024
## Summary

Requires #191520.
Resolves #188266.

Prior to this PR, when polling on an async ES|QL request, we would log
the response to every polling request. This PR only logs when the
request is complete.

Before:


![image](https://github.com/user-attachments/assets/fe9a763d-ef43-4f46-a096-0e08e1805f47)

After:


![image](https://github.com/user-attachments/assets/5d59f016-8b0e-4a3f-b044-17b5de97739f)


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
([build](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6823))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// Team:ESQL ES|QL related features in Kibana t// Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants