diff --git a/src/plugins/data/common/search/expressions/esql.ts b/src/plugins/data/common/search/expressions/esql.ts index 34ac9a1ccffc5..cc5bb94131a60 100644 --- a/src/plugins/data/common/search/expressions/esql.ts +++ b/src/plugins/data/common/search/expressions/esql.ts @@ -23,7 +23,12 @@ 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, ESQL_TABLE_TYPE, KibanaContext } from '..'; +import { + ESQL_ASYNC_SEARCH_STRATEGY, + ESQL_TABLE_TYPE, + isRunningResponse, + type KibanaContext, +} from '..'; import { UiSettingsCommon } from '../..'; declare global { @@ -251,7 +256,9 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => { return throwError(() => error); }), tap({ - next({ rawResponse, requestParams }) { + next(response) { + if (isRunningResponse(response)) return; + const { rawResponse, requestParams } = response; logInspectorRequest() .stats({ hits: { diff --git a/src/plugins/inspector/public/views/requests/components/request_selector.tsx b/src/plugins/inspector/public/views/requests/components/request_selector.tsx index 0a3a113f07664..84aa916c2fe9f 100644 --- a/src/plugins/inspector/public/views/requests/components/request_selector.tsx +++ b/src/plugins/inspector/public/views/requests/components/request_selector.tsx @@ -114,6 +114,7 @@ export class RequestSelector extends Component { } > diff --git a/test/functional/apps/discover/esql/_esql_view.ts b/test/functional/apps/discover/esql/_esql_view.ts index 11ea6a9ac4b22..7bdcb1bfe17fb 100644 --- a/test/functional/apps/discover/esql/_esql_view.ts +++ b/test/functional/apps/discover/esql/_esql_view.ts @@ -325,6 +325,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(requestNames).to.contain('Visualization'); }); }); + + describe('with slow queries', () => { + it('should show only one entry in inspector for table/visualization', async function () { + await PageObjects.discover.selectTextBaseLang(); + const testQuery = `from kibana_sample_data_flights | limit 10`; + await monacoEditor.setCodeEditorValue(testQuery); + + await browser.execute(() => { + window.ELASTIC_ESQL_DELAY_SECONDS = 5; + }); + await testSubjects.click('querySubmitButton'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.execute(() => { + window.ELASTIC_ESQL_DELAY_SECONDS = undefined; + }); + + await inspector.open(); + const requestNames = (await inspector.getRequestNames()).split(','); + const requestTotalTime = await inspector.getRequestTotalTime(); + expect(requestTotalTime).to.be.greaterThan(5000); + expect(requestNames.length).to.be(2); + expect(requestNames).to.contain('Table'); + expect(requestNames).to.contain('Visualization'); + }); + }); }); describe('query history', () => { diff --git a/test/functional/services/inspector.ts b/test/functional/services/inspector.ts index 348f37281156e..af695ad0a308a 100644 --- a/test/functional/services/inspector.ts +++ b/test/functional/services/inspector.ts @@ -328,4 +328,9 @@ export class InspectorService extends FtrService { return value === comboBoxOptions; } + + public async getRequestTotalTime() { + const [ms] = (await this.testSubjects.getVisibleText('inspectorRequestTotalTime')).split('ms'); + return parseFloat(ms); + } }