Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into apm-transacti…
Browse files Browse the repository at this point in the history
…on-per-min
  • Loading branch information
cauemarcondes committed Jul 2, 2020
2 parents 9ee6554 + 8fe5d15 commit fc18241
Show file tree
Hide file tree
Showing 569 changed files with 14,557 additions and 14,986 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
/x-pack/plugins/infra/ @elastic/logs-metrics-ui
/x-pack/plugins/ingest_manager/ @elastic/ingest-management
/x-pack/legacy/plugins/ingest_manager/ @elastic/ingest-management
/x-pack/plugins/observability/ @elastic/logs-metrics-ui @elastic/apm-ui @elastic/uptime @elastic/ingest-management
/x-pack/plugins/observability/ @elastic/observability-ui
/x-pack/legacy/plugins/monitoring/ @elastic/stack-monitoring-ui
/x-pack/plugins/monitoring/ @elastic/stack-monitoring-ui
/x-pack/plugins/uptime @elastic/uptime
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ module.exports = {
}],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'constructor-super': 'error',
'dot-notation': 'error',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-ui-shared-deps/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ if (window.__kbnThemeVersion__ === 'v7') {
ElasticEuiDarkTheme = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
}

import * as Theme from './theme.ts';
export { Theme };

// massive deps that we should really get rid of or reduce in size substantially
export const ElasticsearchBrowser = require('elasticsearch-browser/elasticsearch.js');
5 changes: 3 additions & 2 deletions packages/kbn-ui-shared-deps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports.externals = {
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
'styled-components': '__kbnSharedDeps__.StyledComponents',
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
'@kbn/ui-shared-deps/theme': '__kbnSharedDeps__.Theme',
// this is how plugins/consumers from npm load monaco
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',

Expand All @@ -59,8 +60,8 @@ exports.externals = {
'@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices',
'@elastic/eui/lib/services/format': '__kbnSharedDeps__.ElasticEuiLibServicesFormat',
'@elastic/eui/dist/eui_charts_theme': '__kbnSharedDeps__.ElasticEuiChartsTheme',
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.ElasticEuiLightTheme',
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.ElasticEuiDarkTheme',
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.Theme.euiLightVars',
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.Theme.euiDarkVars',

/**
* massive deps that we should really get rid of or reduce in size substantially
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,28 @@
* under the License.
*/

import type { PluginInitializerContext } from '../../../../../src/core/server';
import { CoreLoggingPlugin } from './plugin';
import LightTheme from '@elastic/eui/dist/eui_theme_light.json';

export const plugin = (init: PluginInitializerContext) => new CoreLoggingPlugin(init);
const globals: any = typeof window === 'undefined' ? {} : window;

export type Theme = typeof LightTheme;

export let euiLightVars: Theme;
export let euiDarkVars: Theme;
if (globals.__kbnThemeVersion__ === 'v7') {
euiLightVars = require('@elastic/eui/dist/eui_theme_light.json');
euiDarkVars = require('@elastic/eui/dist/eui_theme_dark.json');
} else {
euiLightVars = require('@elastic/eui/dist/eui_theme_amsterdam_light.json');
euiDarkVars = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
}

/**
* EUI Theme vars that automatically adjust to light/dark theme
*/
export let euiThemeVars: Theme;
if (globals.__kbnDarkTheme__) {
euiThemeVars = euiDarkVars;
} else {
euiThemeVars = euiLightVars;
}
5 changes: 4 additions & 1 deletion packages/kbn-ui-shared-deps/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": ["index.d.ts", "./monaco"]
"include": [
"index.d.ts",
"theme.ts"
]
}
11 changes: 11 additions & 0 deletions packages/kbn-ui-shared-deps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
include: [require.resolve('./theme.ts')],
use: [
{
loader: 'babel-loader',
options: {
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
},
},
],
},
],
},

Expand Down
40 changes: 20 additions & 20 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,27 @@ export class ChromeService {
/>
),
});
}

if (isIE()) {
notifications.toasts.addWarning({
title: mountReactNode(
<FormattedMessage
id="core.chrome.browserDeprecationWarning"
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
values={{
link: (
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
<FormattedMessage
id="core.chrome.browserDeprecationLink"
defaultMessage="the support matrix on our website"
/>
</EuiLink>
),
}}
/>
),
});
}
if (isIE()) {
notifications.toasts.addWarning({
title: mountReactNode(
<FormattedMessage
id="core.chrome.browserDeprecationWarning"
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
values={{
link: (
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
<FormattedMessage
id="core.chrome.browserDeprecationLink"
defaultMessage="the support matrix on our website"
/>
</EuiLink>
),
}}
/>
),
});
}

return {
Expand Down
161 changes: 161 additions & 0 deletions src/core/server/logging/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/

import * as kbnTestServer from '../../../../test_utils/kbn_server';
import { InternalCoreSetup } from '../../internal_types';
import { LoggerContextConfigInput } from '../logging_config';
import { Subject } from 'rxjs';

function createRoot() {
return kbnTestServer.createRoot({
Expand Down Expand Up @@ -111,4 +114,162 @@ describe('logging service', () => {
expect(mockConsoleLog).toHaveBeenCalledTimes(0);
});
});

describe('custom context configuration', () => {
const CUSTOM_LOGGING_CONFIG: LoggerContextConfigInput = {
appenders: {
customJsonConsole: {
kind: 'console',
layout: {
kind: 'json',
},
},
customPatternConsole: {
kind: 'console',
layout: {
kind: 'pattern',
pattern: 'CUSTOM - PATTERN [%logger][%level] %message',
},
},
},

loggers: [
{ context: 'debug_json', appenders: ['customJsonConsole'], level: 'debug' },
{ context: 'debug_pattern', appenders: ['customPatternConsole'], level: 'debug' },
{ context: 'info_json', appenders: ['customJsonConsole'], level: 'info' },
{ context: 'info_pattern', appenders: ['customPatternConsole'], level: 'info' },
{
context: 'all',
appenders: ['customJsonConsole', 'customPatternConsole'],
level: 'debug',
},
],
};

let root: ReturnType<typeof createRoot>;
let setup: InternalCoreSetup;
let mockConsoleLog: jest.SpyInstance;
const loggingConfig$ = new Subject<LoggerContextConfigInput>();
const setContextConfig = (enable: boolean) =>
enable ? loggingConfig$.next(CUSTOM_LOGGING_CONFIG) : loggingConfig$.next({});
beforeAll(async () => {
mockConsoleLog = jest.spyOn(global.console, 'log');
root = kbnTestServer.createRoot();

setup = await root.setup();
setup.logging.configure(['plugins', 'myplugin'], loggingConfig$);
}, 30000);

beforeEach(() => {
mockConsoleLog.mockClear();
});

afterAll(async () => {
mockConsoleLog.mockRestore();
await root.shutdown();
});

it('does not write to custom appenders when not configured', async () => {
const logger = root.logger.get('plugins.myplugin.debug_pattern');
setContextConfig(false);
logger.info('log1');
setContextConfig(true);
logger.debug('log2');
logger.info('log3');
setContextConfig(false);
logger.info('log4');
expect(mockConsoleLog).toHaveBeenCalledTimes(2);
expect(mockConsoleLog).toHaveBeenCalledWith(
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][DEBUG] log2'
);
expect(mockConsoleLog).toHaveBeenCalledWith(
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][INFO ] log3'
);
});

it('writes debug_json context to custom JSON appender', async () => {
setContextConfig(true);
const logger = root.logger.get('plugins.myplugin.debug_json');
logger.debug('log1');
logger.info('log2');
expect(mockConsoleLog).toHaveBeenCalledTimes(2);

const [firstCall, secondCall] = mockConsoleLog.mock.calls.map(([jsonString]) =>
JSON.parse(jsonString)
);
expect(firstCall).toMatchObject({
level: 'DEBUG',
context: 'plugins.myplugin.debug_json',
message: 'log1',
});
expect(secondCall).toMatchObject({
level: 'INFO',
context: 'plugins.myplugin.debug_json',
message: 'log2',
});
});

it('writes info_json context to custom JSON appender', async () => {
setContextConfig(true);
const logger = root.logger.get('plugins.myplugin.info_json');
logger.debug('i should not be logged!');
logger.info('log2');

expect(mockConsoleLog).toHaveBeenCalledTimes(1);
expect(JSON.parse(mockConsoleLog.mock.calls[0][0])).toMatchObject({
level: 'INFO',
context: 'plugins.myplugin.info_json',
message: 'log2',
});
});

it('writes debug_pattern context to custom pattern appender', async () => {
setContextConfig(true);
const logger = root.logger.get('plugins.myplugin.debug_pattern');
logger.debug('log1');
logger.info('log2');

expect(mockConsoleLog).toHaveBeenCalledTimes(2);
expect(mockConsoleLog).toHaveBeenCalledWith(
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][DEBUG] log1'
);
expect(mockConsoleLog).toHaveBeenCalledWith(
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][INFO ] log2'
);
});

it('writes info_pattern context to custom pattern appender', async () => {
setContextConfig(true);
const logger = root.logger.get('plugins.myplugin.info_pattern');
logger.debug('i should not be logged!');
logger.info('log2');
expect(mockConsoleLog).toHaveBeenCalledTimes(1);
expect(mockConsoleLog).toHaveBeenCalledWith(
'CUSTOM - PATTERN [plugins.myplugin.info_pattern][INFO ] log2'
);
});

it('writes all context to both appenders', async () => {
setContextConfig(true);
const logger = root.logger.get('plugins.myplugin.all');
logger.debug('log1');
logger.info('log2');

expect(mockConsoleLog).toHaveBeenCalledTimes(4);
const logs = mockConsoleLog.mock.calls.map(([jsonString]) => jsonString);

expect(JSON.parse(logs[0])).toMatchObject({
level: 'DEBUG',
context: 'plugins.myplugin.all',
message: 'log1',
});
expect(logs[1]).toEqual('CUSTOM - PATTERN [plugins.myplugin.all][DEBUG] log1');
expect(JSON.parse(logs[2])).toMatchObject({
level: 'INFO',
context: 'plugins.myplugin.all',
message: 'log2',
});
expect(logs[3]).toEqual('CUSTOM - PATTERN [plugins.myplugin.all][INFO ] log2');
});
});
});
34 changes: 30 additions & 4 deletions src/core/server/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const logger = loggingSystemMock.create();

expect.addSnapshotSerializer(createAbsolutePathSerializer());

['path-1', 'path-2', 'path-3', 'path-4', 'path-5'].forEach((path) => {
['path-1', 'path-2', 'path-3', 'path-4', 'path-5', 'path-6', 'path-7', 'path-8'].forEach((path) => {
jest.doMock(join(path, 'server'), () => ({}), {
virtual: true,
});
Expand Down Expand Up @@ -227,14 +227,34 @@ describe('PluginsService', () => {
path: 'path-4',
configPath: 'path-4-disabled',
}),
createPlugin('plugin-with-disabled-optional-dep', {
path: 'path-5',
configPath: 'path-5',
optionalPlugins: ['explicitly-disabled-plugin'],
}),
createPlugin('plugin-with-missing-optional-dep', {
path: 'path-6',
configPath: 'path-6',
optionalPlugins: ['missing-plugin'],
}),
createPlugin('plugin-with-disabled-nested-transitive-dep', {
path: 'path-7',
configPath: 'path-7',
requiredPlugins: ['plugin-with-disabled-transitive-dep'],
}),
createPlugin('plugin-with-missing-nested-dep', {
path: 'path-8',
configPath: 'path-8',
requiredPlugins: ['plugin-with-missing-required-deps'],
}),
]),
});

await pluginsService.discover();
const setup = await pluginsService.setup(setupDeps);

expect(setup.contracts).toBeInstanceOf(Map);
expect(mockPluginSystem.addPlugin).not.toHaveBeenCalled();
expect(mockPluginSystem.addPlugin).toHaveBeenCalledTimes(2);
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledTimes(1);
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledWith(setupDeps);

Expand All @@ -244,14 +264,20 @@ describe('PluginsService', () => {
"Plugin \\"explicitly-disabled-plugin\\" is disabled.",
],
Array [
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [missing-plugin]",
],
Array [
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [another-explicitly-disabled-plugin]",
],
Array [
"Plugin \\"another-explicitly-disabled-plugin\\" is disabled.",
],
Array [
"Plugin \\"plugin-with-disabled-nested-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [plugin-with-disabled-transitive-dep]",
],
Array [
"Plugin \\"plugin-with-missing-nested-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [plugin-with-missing-required-deps]",
],
]
`);
});
Expand Down
Loading

0 comments on commit fc18241

Please sign in to comment.