Skip to content

Commit

Permalink
Merge branch 'main' into feature/94603
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored Oct 11, 2022
2 parents 67a6e1a + d3db6e7 commit 79eb184
Show file tree
Hide file tree
Showing 129 changed files with 3,496 additions and 1,059 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ kibana_vars=(
csp.report_to
data.autocomplete.valueSuggestions.terminateAfter
data.autocomplete.valueSuggestions.timeout
data.search.asyncSearch.waitForCompletion
data.search.asyncSearch.keepAlive
data.search.asyncSearch.batchedReduceSize
data.search.sessions.defaultExpiration
data.search.sessions.enabled
data.search.sessions.maxUpdateRetries
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const gaugeFunction = (): GaugeExpressionFunctionDefinition => ({
(handlers.variables?.embeddableTitle as string) ??
handlers.getExecutionContext?.()?.description,
},
canNavigateToLens: Boolean(handlers?.variables?.canNavigateToLens),
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type GaugeInput = Datatable;
export interface GaugeExpressionProps {
data: Datatable;
args: GaugeArguments;
canNavigateToLens: boolean;
}

export interface GaugeRender {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('GaugeComponent', function () {

beforeAll(async () => {
wrapperProps = {
canNavigateToLens: false,
data: createData(),
chartsThemeService,
args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export const gaugeRenderer: (
const visualizationType = extractVisualizationType(executionContext);

if (containerType && visualizationType) {
plugins.usageCollection?.reportUiCounter(containerType, METRIC_TYPE.COUNT, [
const events = [
`render_${visualizationType}_${type}`,
]);
config.canNavigateToLens ? `render_${visualizationType}_${type}_convertable` : undefined,
].filter<string>((event): event is string => Boolean(event));
plugins.usageCollection?.reportUiCounter(containerType, METRIC_TYPE.COUNT, events);
}

handlers.done();
Expand Down
40 changes: 40 additions & 0 deletions src/plugins/data/config.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import moment from 'moment/moment';
import { SearchConfigSchema, SearchSessionsConfigSchema } from './config';

export const getMockSearchConfig = ({
sessions: { enabled = true, defaultExpiration = moment.duration(7, 'd') } = {
enabled: true,
defaultExpiration: moment.duration(7, 'd'),
},
asyncSearch: {
waitForCompletion = moment.duration(100, 'ms'),
keepAlive = moment.duration(1, 'm'),
batchedReduceSize = 64,
} = {
waitForCompletion: moment.duration(100, 'ms'),
keepAlive: moment.duration(1, 'm'),
batchedReduceSize: 64,
},
}: Partial<{
sessions: Partial<SearchSessionsConfigSchema>;
asyncSearch: Partial<SearchConfigSchema['asyncSearch']>;
}>): SearchConfigSchema =>
({
asyncSearch: {
waitForCompletion,
keepAlive,
batchedReduceSize,
} as SearchConfigSchema['asyncSearch'],
sessions: {
enabled,
defaultExpiration,
} as SearchSessionsConfigSchema,
} as SearchConfigSchema);
29 changes: 19 additions & 10 deletions src/plugins/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,29 @@ export const searchSessionsConfigSchema = schema.object({
}),
});

export const configSchema = schema.object({
search: schema.object({
aggs: schema.object({
shardDelay: schema.object({
// Whether or not to register the shard_delay (which is only available in snapshot versions
// of Elasticsearch) agg type/expression function to make it available in the UI for either
// functional or manual testing
enabled: schema.boolean({ defaultValue: false }),
}),
export const searchConfigSchema = schema.object({
asyncSearch: schema.object({
waitForCompletion: schema.duration({ defaultValue: '100ms' }),
keepAlive: schema.duration({ defaultValue: '1m' }),
batchedReduceSize: schema.number({ defaultValue: 64 }),
}),
aggs: schema.object({
shardDelay: schema.object({
// Whether or not to register the shard_delay (which is only available in snapshot versions
// of Elasticsearch) agg type/expression function to make it available in the UI for either
// functional or manual testing
enabled: schema.boolean({ defaultValue: false }),
}),
sessions: searchSessionsConfigSchema,
}),
sessions: searchSessionsConfigSchema,
});

export const configSchema = schema.object({
search: searchConfigSchema,
});

export type ConfigSchema = TypeOf<typeof configSchema>;

export type SearchConfigSchema = TypeOf<typeof searchConfigSchema>;

export type SearchSessionsConfigSchema = TypeOf<typeof searchSessionsConfigSchema>;
12 changes: 10 additions & 2 deletions src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
ENHANCED_ES_SEARCH_STRATEGY,
enhancedEsSearchStrategyProvider(
this.initializerContext.config.legacy.globalConfig$,
this.initializerContext.config.get().search,
this.logger,
usage
)
Expand All @@ -189,13 +190,20 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
// for example use case
this.searchAsInternalUser = enhancedEsSearchStrategyProvider(
this.initializerContext.config.legacy.globalConfig$,
this.initializerContext.config.get().search,
this.logger,
usage,
true
);

this.registerSearchStrategy(EQL_SEARCH_STRATEGY, eqlSearchStrategyProvider(this.logger));
this.registerSearchStrategy(SQL_SEARCH_STRATEGY, sqlSearchStrategyProvider(this.logger));
this.registerSearchStrategy(
EQL_SEARCH_STRATEGY,
eqlSearchStrategyProvider(this.initializerContext.config.get().search, this.logger)
);
this.registerSearchStrategy(
SQL_SEARCH_STRATEGY,
sqlSearchStrategyProvider(this.initializerContext.config.get().search, this.logger)
);

registerBsearchRoute(
bfetch,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/search/session/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface IScopedSearchSessionsClient {
expires: Date
) => Promise<SavedObjectsUpdateResponse<SearchSessionSavedObjectAttributes>>;
status: (sessionId: string) => Promise<SearchSessionStatusResponse>;
getConfig: () => SearchSessionsConfigSchema | null;
getConfig: () => SearchSessionsConfigSchema;
}

export interface ISearchSessionService {
Expand Down
Loading

0 comments on commit 79eb184

Please sign in to comment.