From f59338a209d77c588c4102c10188c930bfa64319 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Wed, 10 Mar 2021 11:49:27 -0700 Subject: [PATCH] Don't track restored searches --- src/plugins/data/server/search/collectors/usage.ts | 10 +++++++--- .../data/server/search/es_search/es_search_strategy.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/data/server/search/collectors/usage.ts b/src/plugins/data/server/search/collectors/usage.ts index f8063e00d34cf..f9d703900fc04 100644 --- a/src/plugins/data/server/search/collectors/usage.ts +++ b/src/plugins/data/server/search/collectors/usage.ts @@ -8,7 +8,7 @@ import { once, debounce } from 'lodash'; import type { CoreSetup, Logger } from 'kibana/server'; -import type { IEsSearchResponse } from '../../../common'; +import type { IEsSearchResponse, ISearchOptions } from '../../../common'; import { isCompleteResponse } from '../../../common'; import { CollectedUsage } from './register'; @@ -79,10 +79,14 @@ export function usageProvider(core: CoreSetup): SearchUsage { /** * Rxjs observer for easily doing `tap(searchUsageObserver(logger, usage))` in an rxjs chain. */ -export function searchUsageObserver(logger: Logger, usage?: SearchUsage) { +export function searchUsageObserver( + logger: Logger, + usage?: SearchUsage, + { isRestore }: ISearchOptions = {} +) { return { next(response: IEsSearchResponse) { - if (!isCompleteResponse(response)) return; + if (isRestore || !isCompleteResponse(response)) return; logger.debug(`trackSearchStatus:next ${response.rawResponse.took}`); usage?.trackSuccess(response.rawResponse.took); }, diff --git a/src/plugins/data/server/search/es_search/es_search_strategy.ts b/src/plugins/data/server/search/es_search/es_search_strategy.ts index 4b6f1f9786958..cc81dce94c4ec 100644 --- a/src/plugins/data/server/search/es_search/es_search_strategy.ts +++ b/src/plugins/data/server/search/es_search/es_search_strategy.ts @@ -53,6 +53,6 @@ export const esSearchStrategyProvider = ( } }; - return from(search()).pipe(tap(searchUsageObserver(logger, usage))); + return from(search()).pipe(tap(searchUsageObserver(logger, usage, options))); }, });