Skip to content

Commit

Permalink
Merge branch 'main' into issue_118866_observability
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiopro committed Dec 6, 2021
2 parents d7ff330 + a296f6b commit 3249543
Show file tree
Hide file tree
Showing 185 changed files with 3,059 additions and 1,672 deletions.
11 changes: 11 additions & 0 deletions .buildkite/pipelines/pull_request/osquery_cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/osquery_cypress.sh
label: 'Osquery Cypress Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1
10 changes: 10 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ const uploadPipeline = (pipelineContent) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/fleet_cypress.yml'));
}

if (
(await doAnyChangesMatch([
/^x-pack\/plugins\/osquery/,
/^x-pack\/test\/osquery_cypress/,
])) ||
process.env.GITHUB_PR_LABELS.includes('ci:all-cypress-suites')
) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/osquery_cypress.yml'));
}

if (await doAnyChangesMatch([/^x-pack\/plugins\/uptime/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime.yml'));
}
Expand Down
20 changes: 20 additions & 0 deletions .buildkite/scripts/steps/functional/osquery_cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh

export JOB=kibana-osquery-cypress

echo "--- Osquery Cypress tests"

cd "$XPACK_DIR"

checks-reporter-with-killswitch "Osquery Cypress Tests" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config test/osquery_cypress/cli_config.ts
18 changes: 16 additions & 2 deletions dev_docs/key_concepts/performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ id: kibDevPerformance
slug: /kibana-dev-docs/key-concepts/performance
title: Performance
summary: Performance tips for Kibana development.
date: 2021-09-02
date: 2021-12-03
tags: ['kibana', 'onboarding', 'dev', 'performance']
---

## Keep Kibana fast
## Client-side considerations

### Lazy load code

_tl;dr_: Load as much code lazily as possible. Everyone loves snappy
applications with a responsive UI and hates spinners. Users deserve the
Expand Down Expand Up @@ -105,3 +107,15 @@ Many OSS tools allow you to analyze the generated stats file:
Webpack authors
- [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)

## Server-side considerations

### Don't block the event loop

[Node.js is single threaded](https://nodejs.dev/learn/introduction-to-nodejs) which means a single CPU-intensive server-side, synchronous operation will block any other functionality waiting to execute on the Kibana server. The affects background tasks, like alerts, and search sessions, as well as search requests and page loads.

**When writing code that will run on the server, [don't block the event loop](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/)**. Instead consider:

- Writing async code. For example, leverage [setImmediate](https://nodejs.dev/learn/understanding-setimmediate) inside for loops.
- Executing logic on the client instead. This may not be a good option if you require a lot of data going back and forth between the server and the client, as that can also slow down the user's experience, especially over slower bandwidth internet connections.
- Worker threads are also an option if the code doesn't rely on stateful Kibana services. If you are interested in using worker threads, please reach out to a tech-lead before doing so. We will likely want to implement a worker threads pool to ensure worker threads cooperate appropriately.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"**/hoist-non-react-statics": "^3.3.2",
"**/html-minifier/uglify-js": "^3.14.3",
"**/isomorphic-fetch/node-fetch": "^2.6.1",
"**/istanbul-instrumenter-loader/schema-utils": "1.0.0",
"**/istanbul-lib-coverage": "^3.2.0",
"**/json-schema": "^0.4.0",
"**/minimist": "^1.2.5",
"**/node-jose/node-forge": "^0.10.0",
Expand Down Expand Up @@ -436,6 +436,7 @@
"@babel/types": "^7.16.0",
"@bazel/ibazel": "^0.15.10",
"@bazel/typescript": "^3.8.0",
"@cypress/code-coverage": "^3.9.11",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
"@elastic/eslint-config-kibana": "link:bazel-bin/packages/elastic-eslint-config-kibana",
Expand Down Expand Up @@ -565,6 +566,8 @@
"@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__config-schema": "link:bazel-bin/packages/kbn-config-schema/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 Expand Up @@ -694,7 +697,9 @@
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.5.0",
"cypress-pipe": "^2.0.0",
"cypress-react-selector": "^2.3.13",
"cypress-real-events": "^1.5.1",
"cypress-recurse": "^1.13.1",
"debug": "^2.6.9",
"delete-empty": "^2.0.0",
"dependency-check": "^4.1.0",
Expand Down Expand Up @@ -749,7 +754,6 @@
"http-proxy": "^1.18.1",
"is-glob": "^4.0.1",
"is-path-inside": "^3.0.2",
"istanbul-instrumenter-loader": "^3.0.1",
"jest": "^26.6.3",
"jest-canvas-mock": "^2.3.1",
"jest-circus": "^26.6.3",
Expand Down Expand Up @@ -786,7 +790,7 @@
"ncp": "^2.0.0",
"node-sass": "^6.0.1",
"null-loader": "^3.0.0",
"nyc": "^15.0.1",
"nyc": "^15.1.0",
"oboe": "^2.1.4",
"parse-link-header": "^1.0.1",
"pbf": "3.2.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ filegroup(
"//packages/kbn-apm-utils:build_types",
"//packages/kbn-cli-dev-mode:build_types",
"//packages/kbn-config:build_types",
"//packages/kbn-config-schema:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
],
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-cli-dev-mode/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-logging",
"//packages/kbn-optimizer",
Expand Down
26 changes: 22 additions & 4 deletions packages/kbn-config-schema/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
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-config-schema"
PKG_REQUIRE_NAME = "@kbn/config-schema"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__config-schema"

SOURCE_FILES = glob([
"src/**/*.ts",
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"],
)
1 change: 0 additions & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@kbn/config-schema",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
StreamType,
} from './types';

export type { TypeOf, Props, NullableProps };
export type { AnyType, ConditionalType, TypeOf, Props, NullableProps };
export { ObjectType, Type };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/elastic-safer-lodash-set",
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-std",
"//packages/kbn-utility-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-docs-utils/src/api_docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Autogenerated API documentation

[RFC](../../../rfcs/text/0014_api_documentation.md)
[RFC](https://github.com/elastic/kibana/blob/main/legacy_rfcs/text/0014_api_documentation.md))

This is an experimental api documentation system that is managed by the Kibana Tech Leads until
we determine the value of such a system and what kind of maintenance burder it will incur.
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es-query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ NPM_MODULE_EXTRA_FILES = [

RUNTIME_DEPS = [
"//packages/kbn-utility-types",
"//packages/kbn-config-schema",
"//packages/kbn-i18n",
"@npm//@elastic/elasticsearch",
"@npm//load-json-file",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-io-ts-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//tslib",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps-npm",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-server-http-tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config-schema",
"//packages/kbn-crypto",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-crypto:npm_module_types",
"@npm//@hapi/hapi",
"@npm//@hapi/hoek",
"@npm//joi",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-server-route-repository/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-io-ts-utils",
"@npm//@hapi/boom",
"@npm//fp-ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"@npm//load-json-file",
"@npm//tslib",
"@npm//@types/jest",
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Boom from '@hapi/boom';
import { ByteSizeValue } from '@kbn/config-schema';
import { CliArgs } from '@kbn/config';
import type { ClientOptions } from '@elastic/elasticsearch/lib/client';
import { ConditionalType } from '@kbn/config-schema/target_types/types';
import { ConditionalType } from '@kbn/config-schema';
import { ConfigDeprecation } from '@kbn/config';
import { ConfigDeprecationContext } from '@kbn/config';
import { ConfigDeprecationFactory } from '@kbn/config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,10 @@ ace.define(
},
// parses and returns the method
method = function () {
const [first, ...rest] = text.split(' ');
text = first.toUpperCase() + rest.join(' ');
ch = ch.toUpperCase();

switch (ch) {
case 'G':
next('G');
Expand Down
Loading

0 comments on commit 3249543

Please sign in to comment.