Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search] Remove long-running query pop-up #75385

Merged
merged 115 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
9ce2275
[Search] Remove long-running query pop-up
lukasolson Aug 19, 2020
b647c34
Merge branch 'master' into search-remove-popup
lukasolson Aug 20, 2020
c1217b0
Don't timeout if requestTimeout isn't configured
lukasolson Aug 20, 2020
3299406
Merge branch 'master' into search-remove-popup
lukasolson Aug 20, 2020
b9aa07d
Remove unused kibanaUtils
lukasolson Aug 20, 2020
c2c0237
Remove unused kibanaReact
lukasolson Aug 21, 2020
7927af6
Re-add reference to kibanaUtils
lukasolson Aug 21, 2020
0f69bac
Remove unused translations and update documentation
lukasolson Aug 21, 2020
c29ab1b
Add new x-pack advanced setting searchTimeout and use it in the Enhan…
Aug 23, 2020
4f603ce
docs
Aug 23, 2020
13ea90e
Merge branch 'master' into search-remove-popup
lukasolson Aug 24, 2020
2df19ac
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 25, 2020
25aae3a
Re-add toast when queries time out
lukasolson Aug 25, 2020
849ef85
Fix types
lukasolson Aug 25, 2020
de8107d
Update error message with capabilities
lukasolson Aug 25, 2020
d54b09a
Update docs
lukasolson Aug 25, 2020
20ea649
Update docs
lukasolson Aug 25, 2020
356281a
Move search server routes into a directory.
lukeelmers Aug 20, 2020
84ad62f
Add internal/_msearch route.
lukeelmers Aug 26, 2020
9a8de03
Remove legacy search API, rewrite default search strategy to use inte…
lukeelmers Aug 26, 2020
371a4df
Remove legacy es_client code.
lukeelmers Aug 26, 2020
2475467
Handle msearch options on server.
lukeelmers Aug 26, 2020
775586a
Remove elasticsearch-browser dependency.
lukeelmers Aug 26, 2020
d7df81e
Update generated docs.
lukeelmers Aug 26, 2020
e02a9dc
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 26, 2020
2cb19ec
Merge remote-tracking branch 'lukeelmers/fix/remove-es-client' into s…
Aug 26, 2020
c07d923
Rely on server timeout in OSS (?)
Aug 26, 2020
1086b9c
Merge branch 'master' into search/search-timeout-setting
elasticmachine Aug 26, 2020
184a3e6
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 26, 2020
8c75c64
Rename function
Aug 26, 2020
5b1af34
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 26, 2020
17fd210
Merge branch 'search/search-timeout-setting' of github.com:lizozom/ki…
Aug 26, 2020
39605fe
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 26, 2020
742f3ba
Add features to dependencies
lukasolson Aug 26, 2020
4056f40
Undefined check
lukasolson Aug 26, 2020
791a92f
Merge branch 'master' into fix/remove-es-client
elasticmachine Aug 26, 2020
82915ab
Merge branch 'master' into search/search-timeout-setting
elasticmachine Aug 27, 2020
059706e
doc
Aug 27, 2020
260d23c
Code review fixes
Aug 27, 2020
9540e4c
code review
Aug 27, 2020
6de4205
doc
Aug 27, 2020
5049b35
loading count
Aug 27, 2020
002c13c
simplify code review and fix jest tets
Aug 27, 2020
3c07a71
Merge branch 'master' of github.com:elastic/kibana into pr/75943
Aug 27, 2020
1dded0a
type check
Aug 27, 2020
75c1eb6
Merge branch 'master' of github.com:elastic/kibana into search/search…
Aug 27, 2020
a6a128f
Merge remote-tracking branch 'lukeelmers/fix/remove-es-client' into s…
Aug 27, 2020
05e9bdf
Remove esShard from client
Aug 27, 2020
8dd8f95
Merge branch 'master' into fix/remove-es-client
elasticmachine Aug 31, 2020
1dab018
Merge remote-tracking branch 'lukeelmers/fix/remove-es-client' into s…
Aug 31, 2020
dc19863
cleanup request parameters from FE
Aug 31, 2020
0499b21
doc
Aug 31, 2020
05c51b8
doc
Aug 31, 2020
39fc3fe
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 1, 2020
735ac5c
Align request parameters on server,
Sep 1, 2020
0edd897
docs
Sep 1, 2020
34a008f
add management docs
Sep 1, 2020
f9fab22
docs
Sep 1, 2020
eaa9c77
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 1, 2020
a601601
Remove import
Sep 1, 2020
cb1951e
Break circular dep + fix msearch test
Sep 1, 2020
78ea8a1
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 1, 2020
4921152
Remove deleted type
Sep 1, 2020
0b954df
Fix jest
Sep 1, 2020
5e2417d
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 2, 2020
3f8b19a
Bring toSnakeCase back
Sep 2, 2020
b000274
docs
Sep 2, 2020
504814d
fix jest
Sep 2, 2020
e520695
Merge branch 'search-timeout-setting' into search-remove-popup
lukasolson Sep 3, 2020
5e0959a
Add new x-pack advanced setting searchTimeout and use it in the Enhan…
Aug 23, 2020
a682fb7
docs
Aug 23, 2020
f2c4c16
Rely on server timeout in OSS (?)
Aug 26, 2020
2497e00
Rename function
Aug 26, 2020
a65596f
doc
Aug 27, 2020
1e9e9a0
Remove esShard from client
Aug 27, 2020
6d718c5
cleanup request parameters from FE
Aug 31, 2020
060ce08
doc
Aug 31, 2020
0310fb1
doc
Aug 31, 2020
1b4770a
Align request parameters on server,
Sep 1, 2020
70b5809
docs
Sep 1, 2020
f8aba5d
add management docs
Sep 1, 2020
f4d0064
docs
Sep 1, 2020
9c5c0ec
Remove import
Sep 1, 2020
befdf10
Break circular dep + fix msearch test
Sep 1, 2020
098a9ad
Remove deleted type
Sep 1, 2020
dac9d7a
Fix jest
Sep 1, 2020
f9273d6
Bring toSnakeCase back
Sep 2, 2020
3dc393e
docs
Sep 2, 2020
59f5cc1
fix jest
Sep 2, 2020
2841d57
Fix merge
Sep 3, 2020
313bbd7
Fix types
lukasolson Sep 5, 2020
ae3f8b6
Merge branch 'search/search-timeout-setting' into search-remove-popup
lukasolson Sep 5, 2020
2dea1e3
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 6, 2020
68c2604
Merge branch 'search/search-timeout-setting' into pr/75385
Sep 6, 2020
6111ac7
Allow timeout to be undefined
Sep 6, 2020
b1b466c
Fix jest test
Sep 6, 2020
5a7c9e0
Upldate docs
Sep 6, 2020
882c4fd
Fix msearch jest
Sep 6, 2020
6e91b8f
Merge branch 'search/search-timeout-setting' into pr/75385
Sep 6, 2020
95f0e9b
Merge correction
Sep 6, 2020
b9306c0
Merge branch 'master' into search/search-timeout-setting
elasticmachine Sep 7, 2020
bec86a5
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 7, 2020
887b3ea
docs
Sep 7, 2020
b9c7dfc
Merge branch 'search/search-timeout-setting' of github.com:lizozom/ki…
Sep 8, 2020
4bdbcc6
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
f6d4b5b
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
4405680
Fix rollup search merge
Sep 8, 2020
61d1f76
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
790f2b0
Merge branch 'search/search-timeout-setting' into pr/75385
Sep 8, 2020
069390b
Merge branch 'master' of github.com:elastic/kibana into pr/75385
Sep 9, 2020
25d5e37
Fix merge
Sep 9, 2020
bc6eaae
Merge branch 'master' into search-remove-popup
elasticmachine Sep 9, 2020
c6508b0
Use i18n
lukasolson Sep 10, 2020
4ed7d31
Merge remote-tracking branch 'origin/search-remove-popup' into search…
lukasolson Sep 10, 2020
66dac98
Merge branch 'master' into search-remove-popup
lukasolson Sep 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export declare class SearchInterceptor
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [deps](./kibana-plugin-plugins-data-public.searchinterceptor.deps.md) | | <code>SearchInterceptorDeps</code> | |
| [showTimeoutError](./kibana-plugin-plugins-data-public.searchinterceptor.showtimeouterror.md) | | <code>((e: Error) =&gt; void) &amp; import(&quot;lodash&quot;).Cancelable</code> | |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [getPendingCount$()](./kibana-plugin-plugins-data-public.searchinterceptor.getpendingcount_.md) | | Returns an <code>Observable</code> over the current number of pending searches. This could mean that one of the search requests is still in flight, or that it has only received partial responses. |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates <code>pendingCount$</code> when the request is started/finalized. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [SearchInterceptor](./kibana-plugin-plugins-data-public.searchinterceptor.md) &gt; [showTimeoutError](./kibana-plugin-plugins-data-public.searchinterceptor.showtimeouterror.md)

## SearchInterceptor.showTimeoutError property

<b>Signature:</b>

```typescript
protected showTimeoutError: ((e: Error) => void) & import("lodash").Cancelable;
```
10 changes: 2 additions & 8 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import { Search } from '@elastic/elasticsearch/api/requestParams';
import { SearchResponse } from 'elasticsearch';
import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/common';
import { Subscription } from 'rxjs';
import { Toast } from 'kibana/public';
import { ToastInputFields } from 'src/core/public/notifications';
import { ToastsSetup } from 'kibana/public';
import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport';
Expand Down Expand Up @@ -1939,11 +1938,6 @@ export class SearchInterceptor {
protected application: CoreStart['application'];
// (undocumented)
protected readonly deps: SearchInterceptorDeps;
getPendingCount$(): Observable<number>;
// @internal (undocumented)
protected hideToast: () => void;
// @internal
protected longRunningToast?: Toast;
// @internal
protected pendingCount$: BehaviorSubject<number>;
// @internal (undocumented)
Expand All @@ -1957,8 +1951,8 @@ export class SearchInterceptor {
combinedSignal: AbortSignal;
cleanup: () => void;
};
// @internal (undocumented)
protected showToast: () => void;
// (undocumented)
protected showTimeoutError: ((e: Error) => void) & import("lodash").Cancelable;
// @internal
protected timeoutSubscriptions: Subscription;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,4 @@ describe('Search Usage Collector', () => {
SEARCH_EVENT_TYPE.QUERIES_CANCELLED
);
});

test('tracks long popups', async () => {
await usageCollector.trackLongQueryPopupShown();
expect(mockUsageCollectionSetup.reportUiStats).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][1]).toBe(METRIC_TYPE.LOADED);
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.LONG_QUERY_POPUP_SHOWN
);
});

test('tracks long popups dismissed', async () => {
await usageCollector.trackLongQueryDialogDismissed();
expect(mockUsageCollectionSetup.reportUiStats).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.LONG_QUERY_DIALOG_DISMISSED
);
});

test('tracks run query beyond timeout', async () => {
await usageCollector.trackLongQueryRunBeyondTimeout();
expect(mockUsageCollectionSetup.reportUiStats).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiStats.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.LONG_QUERY_RUN_BEYOND_TIMEOUT
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,5 @@ export const createUsageCollector = (
SEARCH_EVENT_TYPE.QUERIES_CANCELLED
);
},
trackLongQueryPopupShown: async () => {
const currentApp = await getCurrentApp();
return usageCollection?.reportUiStats(
currentApp!,
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.LONG_QUERY_POPUP_SHOWN
);
},
trackLongQueryDialogDismissed: async () => {
const currentApp = await getCurrentApp();
return usageCollection?.reportUiStats(
currentApp!,
METRIC_TYPE.CLICK,
SEARCH_EVENT_TYPE.LONG_QUERY_DIALOG_DISMISSED
);
},
trackLongQueryRunBeyondTimeout: async () => {
lizozom marked this conversation as resolved.
Show resolved Hide resolved
const currentApp = await getCurrentApp();
return usageCollection?.reportUiStats(
currentApp!,
METRIC_TYPE.CLICK,
SEARCH_EVENT_TYPE.LONG_QUERY_RUN_BEYOND_TIMEOUT
);
},
};
};
6 changes: 0 additions & 6 deletions src/plugins/data/public/search/collectors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@
export enum SEARCH_EVENT_TYPE {
QUERY_TIMED_OUT = 'queryTimedOut',
QUERIES_CANCELLED = 'queriesCancelled',
LONG_QUERY_POPUP_SHOWN = 'longQueryPopupShown',
LONG_QUERY_DIALOG_DISMISSED = 'longQueryDialogDismissed',
LONG_QUERY_RUN_BEYOND_TIMEOUT = 'longQueryRunBeyondTimeout',
}

export interface SearchUsageCollector {
trackQueryTimedOut: () => Promise<void>;
trackQueriesCancelled: () => Promise<void>;
trackLongQueryPopupShown: () => Promise<void>;
trackLongQueryDialogDismissed: () => Promise<void>;
trackLongQueryRunBeyondTimeout: () => Promise<void>;
}
59 changes: 0 additions & 59 deletions src/plugins/data/public/search/long_query_notification.tsx

This file was deleted.

75 changes: 34 additions & 41 deletions src/plugins/data/public/search/search_interceptor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,39 @@ describe('SearchInterceptor', () => {
await flushPromises();
});

test('Should not timeout if requestTimeout is undefined', async () => {
searchInterceptor = new SearchInterceptor({
startServices: mockCoreSetup.getStartServices(),
uiSettings: mockCoreSetup.uiSettings,
http: mockCoreSetup.http,
toasts: mockCoreSetup.notifications.toasts,
});
mockCoreSetup.http.fetch.mockImplementationOnce((options: any) => {
return new Promise((resolve, reject) => {
options.signal.addEventListener('abort', () => {
reject(new AbortError());
});

setTimeout(resolve, 5000);
});
});
const mockRequest: IEsSearchRequest = {
params: {},
};
const response = searchInterceptor.search(mockRequest);

expect.assertions(1);
const next = jest.fn();
const complete = () => {
expect(next).toBeCalled();
};
response.subscribe({ next, complete });

jest.advanceTimersByTime(5000);

await flushPromises();
});

test('Observable should fail if user aborts (test merged signal)', async () => {
const abortController = new AbortController();
mockCoreSetup.http.fetch.mockImplementationOnce((options: any) => {
Expand Down Expand Up @@ -125,7 +158,7 @@ describe('SearchInterceptor', () => {
await flushPromises();
});

test('Immediatelly aborts if passed an aborted abort signal', async (done) => {
test('Immediately aborts if passed an aborted abort signal', async (done) => {
const abort = new AbortController();
const mockRequest: IEsSearchRequest = {
params: {},
Expand All @@ -141,44 +174,4 @@ describe('SearchInterceptor', () => {
response.subscribe({ error });
});
});

describe('getPendingCount$', () => {
test('should observe the number of pending requests', () => {
const pendingCount$ = searchInterceptor.getPendingCount$();
const pendingNext = jest.fn();
pendingCount$.subscribe(pendingNext);

const mockResponse: any = { result: 200 };
mockCoreSetup.http.fetch.mockResolvedValue(mockResponse);
const mockRequest: IEsSearchRequest = {
params: {},
};
const response = searchInterceptor.search(mockRequest);

response.subscribe({
complete: () => {
expect(pendingNext.mock.calls).toEqual([[0], [1], [0]]);
},
});
});

test('should observe the number of pending requests on error', () => {
const pendingCount$ = searchInterceptor.getPendingCount$();
const pendingNext = jest.fn();
pendingCount$.subscribe(pendingNext);

const mockResponse: any = { result: 500 };
mockCoreSetup.http.fetch.mockRejectedValue(mockResponse);
const mockRequest: IEsSearchRequest = {
params: {},
};
const response = searchInterceptor.search(mockRequest);

response.subscribe({
complete: () => {
expect(pendingNext.mock.calls).toEqual([[0], [1], [0]]);
},
});
});
});
});
Loading