Skip to content

Commit fc18241

Browse files
committed
Merge branch 'master' of github.com:elastic/kibana into apm-transaction-per-min
2 parents 9ee6554 + 8fe5d15 commit fc18241

569 files changed

Lines changed: 14557 additions & 14986 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
/x-pack/plugins/infra/ @elastic/logs-metrics-ui
8585
/x-pack/plugins/ingest_manager/ @elastic/ingest-management
8686
/x-pack/legacy/plugins/ingest_manager/ @elastic/ingest-management
87-
/x-pack/plugins/observability/ @elastic/logs-metrics-ui @elastic/apm-ui @elastic/uptime @elastic/ingest-management
87+
/x-pack/plugins/observability/ @elastic/observability-ui
8888
/x-pack/legacy/plugins/monitoring/ @elastic/stack-monitoring-ui
8989
/x-pack/plugins/monitoring/ @elastic/stack-monitoring-ui
9090
/x-pack/plugins/uptime @elastic/uptime

packages/eslint-config-kibana/typescript.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ module.exports = {
124124
}],
125125
'@typescript-eslint/no-var-requires': 'error',
126126
'@typescript-eslint/unified-signatures': 'error',
127-
'@typescript-eslint/prefer-ts-expect-error': 'warn',
128127
'constructor-super': 'error',
129128
'dot-notation': 'error',
130129
'eqeqeq': ['error', 'always', {'null': 'ignore'}],

packages/kbn-ui-shared-deps/entry.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,8 @@ if (window.__kbnThemeVersion__ === 'v7') {
6161
ElasticEuiDarkTheme = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
6262
}
6363

64+
import * as Theme from './theme.ts';
65+
export { Theme };
66+
6467
// massive deps that we should really get rid of or reduce in size substantially
6568
export const ElasticsearchBrowser = require('elasticsearch-browser/elasticsearch.js');

packages/kbn-ui-shared-deps/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ exports.externals = {
4444
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
4545
'styled-components': '__kbnSharedDeps__.StyledComponents',
4646
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
47+
'@kbn/ui-shared-deps/theme': '__kbnSharedDeps__.Theme',
4748
// this is how plugins/consumers from npm load monaco
4849
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',
4950

@@ -59,8 +60,8 @@ exports.externals = {
5960
'@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices',
6061
'@elastic/eui/lib/services/format': '__kbnSharedDeps__.ElasticEuiLibServicesFormat',
6162
'@elastic/eui/dist/eui_charts_theme': '__kbnSharedDeps__.ElasticEuiChartsTheme',
62-
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.ElasticEuiLightTheme',
63-
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.ElasticEuiDarkTheme',
63+
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.Theme.euiLightVars',
64+
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.Theme.euiDarkVars',
6465

6566
/**
6667
* massive deps that we should really get rid of or reduce in size substantially

test/plugin_functional/plugins/core_logging/server/index.ts renamed to packages/kbn-ui-shared-deps/theme.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,28 @@
1717
* under the License.
1818
*/
1919

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

23-
export const plugin = (init: PluginInitializerContext) => new CoreLoggingPlugin(init);
22+
const globals: any = typeof window === 'undefined' ? {} : window;
23+
24+
export type Theme = typeof LightTheme;
25+
26+
export let euiLightVars: Theme;
27+
export let euiDarkVars: Theme;
28+
if (globals.__kbnThemeVersion__ === 'v7') {
29+
euiLightVars = require('@elastic/eui/dist/eui_theme_light.json');
30+
euiDarkVars = require('@elastic/eui/dist/eui_theme_dark.json');
31+
} else {
32+
euiLightVars = require('@elastic/eui/dist/eui_theme_amsterdam_light.json');
33+
euiDarkVars = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
34+
}
35+
36+
/**
37+
* EUI Theme vars that automatically adjust to light/dark theme
38+
*/
39+
export let euiThemeVars: Theme;
40+
if (globals.__kbnDarkTheme__) {
41+
euiThemeVars = euiDarkVars;
42+
} else {
43+
euiThemeVars = euiLightVars;
44+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["index.d.ts", "./monaco"]
3+
"include": [
4+
"index.d.ts",
5+
"theme.ts"
6+
]
47
}

packages/kbn-ui-shared-deps/webpack.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
7878
test: /\.css$/,
7979
use: [MiniCssExtractPlugin.loader, 'css-loader'],
8080
},
81+
{
82+
include: [require.resolve('./theme.ts')],
83+
use: [
84+
{
85+
loader: 'babel-loader',
86+
options: {
87+
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
88+
},
89+
},
90+
],
91+
},
8192
],
8293
},
8394

src/core/public/chrome/chrome_service.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,27 @@ export class ChromeService {
185185
/>
186186
),
187187
});
188+
}
188189

189-
if (isIE()) {
190-
notifications.toasts.addWarning({
191-
title: mountReactNode(
192-
<FormattedMessage
193-
id="core.chrome.browserDeprecationWarning"
194-
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
195-
values={{
196-
link: (
197-
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
198-
<FormattedMessage
199-
id="core.chrome.browserDeprecationLink"
200-
defaultMessage="the support matrix on our website"
201-
/>
202-
</EuiLink>
203-
),
204-
}}
205-
/>
206-
),
207-
});
208-
}
190+
if (isIE()) {
191+
notifications.toasts.addWarning({
192+
title: mountReactNode(
193+
<FormattedMessage
194+
id="core.chrome.browserDeprecationWarning"
195+
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
196+
values={{
197+
link: (
198+
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
199+
<FormattedMessage
200+
id="core.chrome.browserDeprecationLink"
201+
defaultMessage="the support matrix on our website"
202+
/>
203+
</EuiLink>
204+
),
205+
}}
206+
/>
207+
),
208+
});
209209
}
210210

211211
return {

src/core/server/logging/integration_tests/logging.test.ts

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919

2020
import * as kbnTestServer from '../../../../test_utils/kbn_server';
21+
import { InternalCoreSetup } from '../../internal_types';
22+
import { LoggerContextConfigInput } from '../logging_config';
23+
import { Subject } from 'rxjs';
2124

2225
function createRoot() {
2326
return kbnTestServer.createRoot({
@@ -111,4 +114,162 @@ describe('logging service', () => {
111114
expect(mockConsoleLog).toHaveBeenCalledTimes(0);
112115
});
113116
});
117+
118+
describe('custom context configuration', () => {
119+
const CUSTOM_LOGGING_CONFIG: LoggerContextConfigInput = {
120+
appenders: {
121+
customJsonConsole: {
122+
kind: 'console',
123+
layout: {
124+
kind: 'json',
125+
},
126+
},
127+
customPatternConsole: {
128+
kind: 'console',
129+
layout: {
130+
kind: 'pattern',
131+
pattern: 'CUSTOM - PATTERN [%logger][%level] %message',
132+
},
133+
},
134+
},
135+
136+
loggers: [
137+
{ context: 'debug_json', appenders: ['customJsonConsole'], level: 'debug' },
138+
{ context: 'debug_pattern', appenders: ['customPatternConsole'], level: 'debug' },
139+
{ context: 'info_json', appenders: ['customJsonConsole'], level: 'info' },
140+
{ context: 'info_pattern', appenders: ['customPatternConsole'], level: 'info' },
141+
{
142+
context: 'all',
143+
appenders: ['customJsonConsole', 'customPatternConsole'],
144+
level: 'debug',
145+
},
146+
],
147+
};
148+
149+
let root: ReturnType<typeof createRoot>;
150+
let setup: InternalCoreSetup;
151+
let mockConsoleLog: jest.SpyInstance;
152+
const loggingConfig$ = new Subject<LoggerContextConfigInput>();
153+
const setContextConfig = (enable: boolean) =>
154+
enable ? loggingConfig$.next(CUSTOM_LOGGING_CONFIG) : loggingConfig$.next({});
155+
beforeAll(async () => {
156+
mockConsoleLog = jest.spyOn(global.console, 'log');
157+
root = kbnTestServer.createRoot();
158+
159+
setup = await root.setup();
160+
setup.logging.configure(['plugins', 'myplugin'], loggingConfig$);
161+
}, 30000);
162+
163+
beforeEach(() => {
164+
mockConsoleLog.mockClear();
165+
});
166+
167+
afterAll(async () => {
168+
mockConsoleLog.mockRestore();
169+
await root.shutdown();
170+
});
171+
172+
it('does not write to custom appenders when not configured', async () => {
173+
const logger = root.logger.get('plugins.myplugin.debug_pattern');
174+
setContextConfig(false);
175+
logger.info('log1');
176+
setContextConfig(true);
177+
logger.debug('log2');
178+
logger.info('log3');
179+
setContextConfig(false);
180+
logger.info('log4');
181+
expect(mockConsoleLog).toHaveBeenCalledTimes(2);
182+
expect(mockConsoleLog).toHaveBeenCalledWith(
183+
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][DEBUG] log2'
184+
);
185+
expect(mockConsoleLog).toHaveBeenCalledWith(
186+
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][INFO ] log3'
187+
);
188+
});
189+
190+
it('writes debug_json context to custom JSON appender', async () => {
191+
setContextConfig(true);
192+
const logger = root.logger.get('plugins.myplugin.debug_json');
193+
logger.debug('log1');
194+
logger.info('log2');
195+
expect(mockConsoleLog).toHaveBeenCalledTimes(2);
196+
197+
const [firstCall, secondCall] = mockConsoleLog.mock.calls.map(([jsonString]) =>
198+
JSON.parse(jsonString)
199+
);
200+
expect(firstCall).toMatchObject({
201+
level: 'DEBUG',
202+
context: 'plugins.myplugin.debug_json',
203+
message: 'log1',
204+
});
205+
expect(secondCall).toMatchObject({
206+
level: 'INFO',
207+
context: 'plugins.myplugin.debug_json',
208+
message: 'log2',
209+
});
210+
});
211+
212+
it('writes info_json context to custom JSON appender', async () => {
213+
setContextConfig(true);
214+
const logger = root.logger.get('plugins.myplugin.info_json');
215+
logger.debug('i should not be logged!');
216+
logger.info('log2');
217+
218+
expect(mockConsoleLog).toHaveBeenCalledTimes(1);
219+
expect(JSON.parse(mockConsoleLog.mock.calls[0][0])).toMatchObject({
220+
level: 'INFO',
221+
context: 'plugins.myplugin.info_json',
222+
message: 'log2',
223+
});
224+
});
225+
226+
it('writes debug_pattern context to custom pattern appender', async () => {
227+
setContextConfig(true);
228+
const logger = root.logger.get('plugins.myplugin.debug_pattern');
229+
logger.debug('log1');
230+
logger.info('log2');
231+
232+
expect(mockConsoleLog).toHaveBeenCalledTimes(2);
233+
expect(mockConsoleLog).toHaveBeenCalledWith(
234+
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][DEBUG] log1'
235+
);
236+
expect(mockConsoleLog).toHaveBeenCalledWith(
237+
'CUSTOM - PATTERN [plugins.myplugin.debug_pattern][INFO ] log2'
238+
);
239+
});
240+
241+
it('writes info_pattern context to custom pattern appender', async () => {
242+
setContextConfig(true);
243+
const logger = root.logger.get('plugins.myplugin.info_pattern');
244+
logger.debug('i should not be logged!');
245+
logger.info('log2');
246+
expect(mockConsoleLog).toHaveBeenCalledTimes(1);
247+
expect(mockConsoleLog).toHaveBeenCalledWith(
248+
'CUSTOM - PATTERN [plugins.myplugin.info_pattern][INFO ] log2'
249+
);
250+
});
251+
252+
it('writes all context to both appenders', async () => {
253+
setContextConfig(true);
254+
const logger = root.logger.get('plugins.myplugin.all');
255+
logger.debug('log1');
256+
logger.info('log2');
257+
258+
expect(mockConsoleLog).toHaveBeenCalledTimes(4);
259+
const logs = mockConsoleLog.mock.calls.map(([jsonString]) => jsonString);
260+
261+
expect(JSON.parse(logs[0])).toMatchObject({
262+
level: 'DEBUG',
263+
context: 'plugins.myplugin.all',
264+
message: 'log1',
265+
});
266+
expect(logs[1]).toEqual('CUSTOM - PATTERN [plugins.myplugin.all][DEBUG] log1');
267+
expect(JSON.parse(logs[2])).toMatchObject({
268+
level: 'INFO',
269+
context: 'plugins.myplugin.all',
270+
message: 'log2',
271+
});
272+
expect(logs[3]).toEqual('CUSTOM - PATTERN [plugins.myplugin.all][INFO ] log2');
273+
});
274+
});
114275
});

src/core/server/plugins/plugins_service.test.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const logger = loggingSystemMock.create();
5151

5252
expect.addSnapshotSerializer(createAbsolutePathSerializer());
5353

54-
['path-1', 'path-2', 'path-3', 'path-4', 'path-5'].forEach((path) => {
54+
['path-1', 'path-2', 'path-3', 'path-4', 'path-5', 'path-6', 'path-7', 'path-8'].forEach((path) => {
5555
jest.doMock(join(path, 'server'), () => ({}), {
5656
virtual: true,
5757
});
@@ -227,14 +227,34 @@ describe('PluginsService', () => {
227227
path: 'path-4',
228228
configPath: 'path-4-disabled',
229229
}),
230+
createPlugin('plugin-with-disabled-optional-dep', {
231+
path: 'path-5',
232+
configPath: 'path-5',
233+
optionalPlugins: ['explicitly-disabled-plugin'],
234+
}),
235+
createPlugin('plugin-with-missing-optional-dep', {
236+
path: 'path-6',
237+
configPath: 'path-6',
238+
optionalPlugins: ['missing-plugin'],
239+
}),
240+
createPlugin('plugin-with-disabled-nested-transitive-dep', {
241+
path: 'path-7',
242+
configPath: 'path-7',
243+
requiredPlugins: ['plugin-with-disabled-transitive-dep'],
244+
}),
245+
createPlugin('plugin-with-missing-nested-dep', {
246+
path: 'path-8',
247+
configPath: 'path-8',
248+
requiredPlugins: ['plugin-with-missing-required-deps'],
249+
}),
230250
]),
231251
});
232252

233253
await pluginsService.discover();
234254
const setup = await pluginsService.setup(setupDeps);
235255

236256
expect(setup.contracts).toBeInstanceOf(Map);
237-
expect(mockPluginSystem.addPlugin).not.toHaveBeenCalled();
257+
expect(mockPluginSystem.addPlugin).toHaveBeenCalledTimes(2);
238258
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledTimes(1);
239259
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledWith(setupDeps);
240260

@@ -244,14 +264,20 @@ describe('PluginsService', () => {
244264
"Plugin \\"explicitly-disabled-plugin\\" is disabled.",
245265
],
246266
Array [
247-
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
267+
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [missing-plugin]",
248268
],
249269
Array [
250-
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
270+
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [another-explicitly-disabled-plugin]",
251271
],
252272
Array [
253273
"Plugin \\"another-explicitly-disabled-plugin\\" is disabled.",
254274
],
275+
Array [
276+
"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]",
277+
],
278+
Array [
279+
"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]",
280+
],
255281
]
256282
`);
257283
});

0 commit comments

Comments
 (0)