Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana into step-list-duration
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Dec 3, 2021
2 parents 485cfa0 + ded75bd commit b107a0a
Show file tree
Hide file tree
Showing 149 changed files with 1,706 additions and 1,275 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
"@types/kbn__apm-utils": "link:bazel-bin/packages/kbn-apm-utils/npm_module_types",
"@types/kbn__cli-dev-mode": "link:bazel-bin/packages/kbn-cli-dev-mode/npm_module_types",
"@types/kbn__config": "link:bazel-bin/packages/kbn-config/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
"@types/license-checker": "15.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ filegroup(
"//packages/kbn-apm-utils:build_types",
"//packages/kbn-cli-dev-mode:build_types",
"//packages/kbn-config:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
],
Expand Down
26 changes: 22 additions & 4 deletions packages/kbn-crypto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-crypto"
PKG_REQUIRE_NAME = "@kbn/crypto"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__crypto"

SOURCE_FILES = glob(
[
Expand Down Expand Up @@ -72,7 +73,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -91,3 +92,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
3 changes: 1 addition & 2 deletions packages/kbn-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts"
"main": "./target_node/index.js"
}
2 changes: 1 addition & 1 deletion packages/kbn-server-http-tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config-schema",
"//packages/kbn-crypto",
"//packages/kbn-crypto:npm_module_types",
"@npm//@hapi/hapi",
"@npm//@hapi/hoek",
"@npm//joi",
Expand Down
13 changes: 10 additions & 3 deletions packages/kbn-utils/src/path/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
*/

import { accessSync, constants } from 'fs';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';
import { getConfigPath, getDataPath, getLogsPath, getConfigDirectory } from './';

expect.addSnapshotSerializer(createAbsolutePathSerializer());
import { REPO_ROOT } from '../repo_root';

expect.addSnapshotSerializer(
((rootPath: string = REPO_ROOT, replacement = '<absolute path>') => {
return {
test: (value: any) => typeof value === 'string' && value.startsWith(rootPath),
serialize: (value: string) => value.replace(rootPath, replacement).replace(/\\/g, '/'),
};
})()
);

describe('Default path finder', () => {
it('should expose a path to the config directory', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/expression_reveal_image/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"ui": true,
"requiredPlugins": ["expressions", "presentationUtil"],
"optionalPlugins": [],
"requiredBundles": []
"requiredBundles": ["kibanaReact"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { storiesOf } from '@storybook/react';
import { revealImageRenderer } from '../';
import { getRevealImageRenderer } from '../';
import { getElasticOutline, getElasticLogo } from '../../../../presentation_util/public';
import { Render, waitFor } from '../../../../presentation_util/public/__stories__';
import { Origin } from '../../../common/types/expression_functions';
Expand All @@ -26,7 +26,7 @@ const Renderer = ({
origin: Origin.LEFT,
percent: 0.45,
};
return <Render renderer={revealImageRenderer} config={config} />;
return <Render renderer={getRevealImageRenderer()} config={config} />;
};

storiesOf('renderers/revealImage', module).add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@
* Side Public License, v 1.
*/

import { revealImageRenderer } from './reveal_image_renderer';

export const renderers = [revealImageRenderer];

export { revealImageRenderer };
export { revealImageRendererFactory, getRevealImageRenderer } from './reveal_image_renderer';
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
*/
import React, { lazy } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Observable } from 'rxjs';
import { CoreTheme } from 'kibana/public';
import { I18nProvider } from '@kbn/i18n-react';
import { ExpressionRenderDefinition, IInterpreterRenderHandlers } from 'src/plugins/expressions';
import { i18n } from '@kbn/i18n';
import { withSuspense } from '../../../presentation_util/public';
import { CoreSetup } from '../../../../core/public';
import { KibanaThemeProvider } from '../../../kibana_react/public';
import { withSuspense, defaultTheme$ } from '../../../presentation_util/public';
import { RevealImageRendererConfig } from '../../common/types';

export const strings = {
Expand All @@ -27,25 +31,32 @@ export const strings = {
const LazyRevealImageComponent = lazy(() => import('../components/reveal_image_component'));
const RevealImageComponent = withSuspense(LazyRevealImageComponent, null);

export const revealImageRenderer = (): ExpressionRenderDefinition<RevealImageRendererConfig> => ({
name: 'revealImage',
displayName: strings.getDisplayName(),
help: strings.getHelpDescription(),
reuseDomNode: true,
render: (
domNode: HTMLElement,
config: RevealImageRendererConfig,
handlers: IInterpreterRenderHandlers
) => {
handlers.onDestroy(() => {
unmountComponentAtNode(domNode);
});
export const getRevealImageRenderer =
(theme$: Observable<CoreTheme> = defaultTheme$) =>
(): ExpressionRenderDefinition<RevealImageRendererConfig> => ({
name: 'revealImage',
displayName: strings.getDisplayName(),
help: strings.getHelpDescription(),
reuseDomNode: true,
render: (
domNode: HTMLElement,
config: RevealImageRendererConfig,
handlers: IInterpreterRenderHandlers
) => {
handlers.onDestroy(() => {
unmountComponentAtNode(domNode);
});

render(
<I18nProvider>
<RevealImageComponent onLoaded={handlers.done} {...config} parentNode={domNode} />
</I18nProvider>,
domNode
);
},
});
render(
<KibanaThemeProvider theme$={theme$}>
<I18nProvider>
<RevealImageComponent onLoaded={handlers.done} {...config} parentNode={domNode} />
</I18nProvider>
</KibanaThemeProvider>,
domNode
);
},
});

export const revealImageRendererFactory = (core: CoreSetup) =>
getRevealImageRenderer(core.theme.theme$);
5 changes: 1 addition & 4 deletions src/plugins/expression_reveal_image/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
* Side Public License, v 1.
*/

// TODO: https://github.com/elastic/kibana/issues/110893
/* eslint-disable @kbn/eslint/no_export_all */

import { ExpressionRevealImagePlugin } from './plugin';

export type { ExpressionRevealImagePluginSetup, ExpressionRevealImagePluginStart } from './plugin';
Expand All @@ -17,4 +14,4 @@ export function plugin() {
return new ExpressionRevealImagePlugin();
}

export * from './expression_renderers';
export { revealImageRendererFactory, getRevealImageRenderer } from './expression_renderers';
4 changes: 2 additions & 2 deletions src/plugins/expression_reveal_image/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { ExpressionsStart, ExpressionsSetup } from '../../expressions/public';
import { revealImageRenderer } from './expression_renderers';
import { revealImageRendererFactory } from './expression_renderers';
import { revealImageFunction } from '../common/expression_functions';

interface SetupDeps {
Expand All @@ -33,7 +33,7 @@ export class ExpressionRevealImagePlugin
{
public setup(core: CoreSetup, { expressions }: SetupDeps): ExpressionRevealImagePluginSetup {
expressions.registerFunction(revealImageFunction);
expressions.registerRenderer(revealImageRenderer);
expressions.registerRenderer(revealImageRendererFactory(core));
}

public start(core: CoreStart): ExpressionRevealImagePluginStart {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const mockLayerList = [
maxZoom: 24,
alpha: 0.75,
visible: true,
type: 'VECTOR',
type: 'GEOJSON_VECTOR',
},
{
joins: [
Expand Down Expand Up @@ -148,6 +148,6 @@ export const mockLayerList = [
maxZoom: 24,
alpha: 0.75,
visible: true,
type: 'VECTOR',
type: 'GEOJSON_VECTOR',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function useLayerList() {
maxZoom: 24,
alpha: 0.75,
visible: true,
type: LAYER_TYPE.VECTOR,
type: LAYER_TYPE.GEOJSON_VECTOR,
};

ES_TERM_SOURCE_REGION.whereQuery = getWhereQuery(serviceName!);
Expand All @@ -179,7 +179,7 @@ export function useLayerList() {
maxZoom: 24,
alpha: 0.75,
visible: true,
type: LAYER_TYPE.VECTOR,
type: LAYER_TYPE.GEOJSON_VECTOR,
};

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
getFailedTransactionRateTimeSeries,
} from '../helpers/transaction_error_rate';

export async function getErrorRate({
export async function getFailedTransactionRate({
environment,
kuery,
serviceName,
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function getErrorRate({
return { timeseries, average };
}

export async function getErrorRatePeriods({
export async function getFailedTransactionRatePeriods({
environment,
kuery,
serviceName,
Expand Down Expand Up @@ -157,11 +157,15 @@ export async function getErrorRatePeriods({
searchAggregatedTransactions,
};

const currentPeriodPromise = getErrorRate({ ...commonProps, start, end });
const currentPeriodPromise = getFailedTransactionRate({
...commonProps,
start,
end,
});

const previousPeriodPromise =
comparisonStart && comparisonEnd
? getErrorRate({
? getFailedTransactionRate({
...commonProps,
start: comparisonStart,
end: comparisonEnd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
getDurationFieldForTransactions,
getProcessorEventForTransactions,
} from '../../lib/helpers/transactions';
import { getErrorRate } from '../../lib/transaction_groups/get_error_rate';
import { getFailedTransactionRate } from '../../lib/transaction_groups/get_failed_transaction_rate';
import { withApmSpan } from '../../utils/with_apm_span';
import {
percentCgroupMemoryUsedScript,
Expand Down Expand Up @@ -123,7 +123,7 @@ async function getFailedTransactionsRateStats({
numBuckets,
}: TaskParameters): Promise<NodeStats['failedTransactionsRate']> {
return withApmSpan('get_error_rate_for_service_map_node', async () => {
const { average, timeseries } = await getErrorRate({
const { average, timeseries } = await getFailedTransactionRate({
environment,
setup,
serviceName,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/server/routes/transactions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getServiceTransactionGroupDetailedStatisticsPeriods } from '../services
import { getTransactionBreakdown } from './breakdown';
import { getTransactionTraceSamples } from './trace_samples';
import { getLatencyPeriods } from './get_latency_charts';
import { getErrorRatePeriods } from '../../lib/transaction_groups/get_error_rate';
import { getFailedTransactionRatePeriods } from '../../lib/transaction_groups/get_failed_transaction_rate';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository';
import {
Expand Down Expand Up @@ -349,7 +349,7 @@ const transactionChartsErrorRateRoute = createApmServerRoute({
end,
});

return getErrorRatePeriods({
return getFailedTransactionRatePeriods({
environment,
kuery,
serviceName,
Expand Down
10 changes: 3 additions & 7 deletions x-pack/plugins/canvas/canvas_plugin_src/renderers/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ import {
errorRendererFactory,
debugRendererFactory,
} from '../../../../../src/plugins/expression_error/public';
import { revealImageRendererFactory } from '../../../../../src/plugins/expression_reveal_image/public';
import { repeatImageRendererFactory } from '../../../../../src/plugins/expression_repeat_image/public';
import { revealImageRenderer } from '../../../../../src/plugins/expression_reveal_image/public';
import {
shapeRenderer,
progressRenderer,
} from '../../../../../src/plugins/expression_shape/public';

export const renderFunctions = [
imageRenderer,
revealImageRenderer,
shapeRenderer,
progressRenderer,
];
export const renderFunctions = [imageRenderer, shapeRenderer, progressRenderer];

export const renderFunctionFactories = [
debugRendererFactory,
errorRendererFactory,
revealImageRendererFactory,
repeatImageRendererFactory,
metricRendererFactory,
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
getErrorRenderer,
getDebugRenderer,
} from '../../../../src/plugins/expression_error/public';
import { getRevealImageRenderer } from '../../../../src/plugins/expression_reveal_image/public';
import { getRepeatImageRenderer } from '../../../../src/plugins/expression_repeat_image/public';
import { revealImageRenderer as revealImage } from '../../../../src/plugins/expression_reveal_image/public';
import {
shapeRenderer as shape,
progressRenderer as progress,
Expand All @@ -31,6 +31,7 @@ const renderFunctionsFactories = [
getTableRenderer,
getErrorRenderer,
getDebugRenderer,
getRevealImageRenderer,
getRepeatImageRenderer,
getMetricRenderer,
];
Expand All @@ -42,7 +43,6 @@ const renderFunctionsFactories = [
*/
export const renderFunctions = [
image,
revealImage,
pie,
plot,
progress,
Expand Down
Loading

0 comments on commit b107a0a

Please sign in to comment.