Skip to content

Commit

Permalink
Merge branch 'master' into cases-rbac-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Jun 7, 2021
2 parents 5bd080b + 827442b commit 56e0f0d
Show file tree
Hide file tree
Showing 172 changed files with 6,197 additions and 1,627 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch Node.js rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "10f534e1c80f795cffe1f2822becd4897754d18564612510c59b3c73544ae7c6",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.0/rules_nodejs-3.5.0.tar.gz"],
sha256 = "4a5d654a4ccd4a4c24eca5d319d85a88a650edf119601550c95bf400c8cc897e",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.1/rules_nodejs-3.5.1.tar.gz"],
)

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")

# Assure we have at least a given rules_nodejs version
check_rules_nodejs_version(minimum_version_string = "3.5.0")
check_rules_nodejs_version(minimum_version_string = "3.5.1")

# Setup the Node.js toolchain for the architectures we want to support
#
Expand Down
13 changes: 7 additions & 6 deletions dev_docs/tutorials/expressions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ tags: ['kibana', 'onboarding', 'dev', 'architecture']

## Expressions service

Expression service exposes a registry of reusable functions primary used for fetching and transposing data and a registry of renderer functions that can render data into a DOM element.
Adding functions is easy and so is reusing them. An expression is a chain of functions with provided arguments, which given a single input translates to a single output.
Expression service exposes a registry of reusable functions primary used for fetching and transposing data and a registry of renderer functions that can render data into a DOM element.
Adding functions is easy and so is reusing them. An expression is a chain of functions with provided arguments, which given a single input translates to a single output.
Each expression is representable by a human friendly string which a user can type.

### creating expressions

Here is a very simple expression string:

essql 'select column1, column2 from myindex' | mapColumn name=column3 fn='{ column1 + 3 }' | table

```
essql 'select column1, column2 from myindex' | mapColumn name=column3 fn='{ column1 + 3 }' | table
```

It consists of 3 functions:

- essql which runs given sql query against elasticsearch and returns the results
- `mapColumn`, which computes a new column from existing ones;
- `table`, which prepares the data for rendering in a tabular format.

The same expression could also be constructed in the code:

```ts
Expand Down Expand Up @@ -61,7 +62,7 @@ In addition, on the browser side, there are two additional ways to run expressio
#### React expression renderer component
This is the easiest way to get expressions rendered inside your application.
This is the easiest way to get expressions rendered inside your application.
```ts
<ReactExpressionRenderer expression={expression} />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
"@babel/traverse": "^7.12.12",
"@babel/types": "^7.12.12",
"@bazel/ibazel": "^0.15.10",
"@bazel/typescript": "^3.5.0",
"@bazel/typescript": "^3.5.1",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
"@elastic/apm-rum": "^5.6.1",
Expand Down
14 changes: 10 additions & 4 deletions packages/kbn-apm-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface SpanOptions {
labels?: Record<string, string>;
}

type Span = Exclude<typeof agent.currentSpan, undefined | null>;

export function parseSpanOptions(optionsOrName: SpanOptions | string) {
const options = typeof optionsOrName === 'string' ? { name: optionsOrName } : optionsOrName;

Expand All @@ -30,7 +32,7 @@ const runInNewContext = <T extends (...args: any[]) => any>(cb: T): ReturnType<T

export async function withSpan<T>(
optionsOrName: SpanOptions | string,
cb: () => Promise<T>
cb: (span?: Span) => Promise<T>
): Promise<T> {
const options = parseSpanOptions(optionsOrName);

Expand Down Expand Up @@ -71,13 +73,17 @@ export async function withSpan<T>(
span.addLabels(labels);
}

return cb()
return cb(span)
.then((res) => {
span.outcome = 'success';
if (!span.outcome || span.outcome === 'unknown') {
span.outcome = 'success';
}
return res;
})
.catch((err) => {
span.outcome = 'failure';
if (!span.outcome || span.outcome === 'unknown') {
span.outcome = 'failure';
}
throw err;
})
.finally(() => {
Expand Down
37 changes: 20 additions & 17 deletions x-pack/build_chromium/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# Chromium build

We ship our own headless build of Chromium which is significantly smaller than
the standard binaries shipped by Google. The scripts in this folder can be used
to accept a commit hash from the Chromium repository, and initialize the build
on Ubuntu Linux.
We ship our own headless build of Chromium for Linux and Mac OS, using a
version of the source that corresponds to the requirements of the Puppeteer
node module. The scripts in this folder can be used to accept a commit hash
from the Chromium repository, and initialize the build in a workspace.

## Why do we do this

By default, Puppeteer will download a zip file containing the Chromium browser for any
OS. This creates problems on Linux, because Chromium has a dependency on X11, which
is often not installed for a server environment. We don't want to make a requirement
for Linux that you need X11 to run Kibana. To work around this, we create our own Chromium
build, using the
**Linux**: By default, Puppeteer will download a zip file containing the
Chromium browser for any OS. This creates problems on Linux, because Chromium
has a dependency on X11, which is often not installed for a server environment.
We don't want to make a requirement for Linux that you need X11 to run Kibana.
To work around this, we create our own Chromium build, using the
[`headless_shell`](https://chromium.googlesource.com/chromium/src/+/5cf4b8b13ed518472038170f8de9db2f6c258fe4/headless)
build target. There are no (trustworthy) sources of these builds available elsewhere.

Fortunately, creating the custom builds is only necessary for Linux. When you have a build
of Kibana for Linux, or if you use a Linux desktop to develop Kibana, you have a copy of
`headless_shell` bundled inside. When you have a Windows or Mac build of Kibana, or use
either of those for development, you have a copy of the full build of Chromium, which
was downloaded from the main [Chromium download
location](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html).
build target. There are no (trustworthy) sources of these builds available
elsewhere.

**Mac**: We do this on Mac because Elastic signs the Kibanna release artifact
with Apple to work with Gatekeeper on Mac OS. Having our own binary of Chromium
and bundling it with Kibana is integral to the artifact signing process.

**Windows**: No custom build is necessary for Windows. We are able to use the
full build of Chromium, downloaded from the main [Chromium download
location](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html),
using the revision that corresponds with the Puppeteer dependency.

## Build Script Usage

Expand Down
19 changes: 13 additions & 6 deletions x-pack/build_chromium/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
md5_file,
)

# This file builds Chromium headless on Linux.
# This file builds Chromium headless on Mac and Linux.

# Verify that we have an argument, and if not print instructions
if (len(sys.argv) < 2):
Expand Down Expand Up @@ -68,7 +68,6 @@
print('Running install-build-deps...')
runcmd(src_path + '/build/install-build-deps.sh')


print('Updating all modules')
runcmd('gclient sync -D')

Expand All @@ -89,7 +88,7 @@
print('Compiling... this will take a while')
runcmd('autoninja -C out/headless headless_shell')

# Optimize the output on Linux x64 by stripping inessentials from the binary
# Optimize the output on Linux x64 and Mac by stripping inessentials from the binary
# ARM must be cross-compiled from Linux and can not read the ARM binary in order to strip
if platform.system() != 'Windows' and arch_name != 'arm64':
print('Optimizing headless_shell')
Expand All @@ -112,10 +111,18 @@ def archive_file(name):
archive.write(from_path, to_path)
return to_path

# Add dependencies that must be bundled with the Chromium executable.
# Each platform has slightly different requirements for what dependencies
# must be bundled with the Chromium executable.
archive_file('headless_shell')
archive_file(path.join('swiftshader', 'libEGL.so'))
archive_file(path.join('swiftshader', 'libGLESv2.so'))
if platform.system() == 'Linux':
archive_file(path.join('swiftshader', 'libEGL.so'))
archive_file(path.join('swiftshader', 'libGLESv2.so'))

elif platform.system() == 'Darwin':
archive_file('headless_shell')
archive_file('libswiftshader_libEGL.dylib')
archive_file('libswiftshader_libGLESv2.dylib')
archive_file(path.join('Helpers', 'chrome_crashpad_handler'))

archive.close()

Expand Down
30 changes: 30 additions & 0 deletions x-pack/build_chromium/darwin/args.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Based on //build/headless.gn

# Embed resource.pak into binary to simplify deployment.
headless_use_embedded_resources = true

# In order to simplify deployment we build ICU data file
# into binary.
icu_use_data_file = false

# Use embedded data instead external files for headless in order
# to simplify deployment.
v8_use_external_startup_data = false

enable_nacl = false
enable_print_preview = false
enable_basic_printing = false
enable_remoting = false
use_alsa = false
use_cups = false
use_dbus = false
use_gio = false
# Please, consult @elastic/kibana-security before changing/removing this option.
use_kerberos = false
use_libpci = false
use_pulseaudio = false
use_udev = false

is_debug = false
symbol_level = 0
is_component_build = false
Loading

0 comments on commit 56e0f0d

Please sign in to comment.