Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.16] Surfacing deprecations with rich context from ES warning header (#120044) #120882

Merged
merged 2 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,55 @@ it('formats %s patterns and indents multi-line messages correctly', () => {
const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
expect(output).toMatchSnapshot();
});

it('does not write messages from sources in ignoreSources', () => {
const write = jest.fn();
const writer = new ToolingLogTextWriter({
ignoreSources: ['myIgnoredSource'],
level: 'debug',
writeTo: {
write,
},
});

writer.write({
source: 'myIgnoredSource',
type: 'success',
indent: 10,
args: [
'%s\n%O\n\n%d',
'foo bar',
{ foo: { bar: { 1: [1, 2, 3] } }, bar: { bar: { 1: [1, 2, 3] } } },
Infinity,
],
});

const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
expect(output).toEqual('');
});

it('never ignores write messages from the kibana elasticsearch.deprecation logger context', () => {
const write = jest.fn();
const writer = new ToolingLogTextWriter({
ignoreSources: ['myIgnoredSource'],
level: 'debug',
writeTo: {
write,
},
});

writer.write({
source: 'myIgnoredSource',
type: 'write',
indent: 10,
args: [
'%s\n%O\n\n%d',
'[elasticsearch.deprecation]',
{ foo: { bar: { 1: [1, 2, 3] } }, bar: { bar: { 1: [1, 2, 3] } } },
Infinity,
],
});

const output = write.mock.calls.reduce((acc, chunk) => `${acc}${chunk}`, '');
expect(output).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ export class ToolingLogTextWriter implements Writer {
}

if (this.ignoreSources && msg.source && this.ignoreSources.includes(msg.source)) {
return false;
if (msg.type === 'write') {
const txt = format(msg.args[0], ...msg.args.slice(1));
// Ensure that Elasticsearch deprecation log messages from Kibana aren't ignored
if (!/elasticsearch\.deprecation/.test(txt)) {
return false;
}
} else {
return false;
}
}

const prefix = has(MSG_PREFIXES, msg.type) ? MSG_PREFIXES[msg.type] : '';
Expand Down
10 changes: 9 additions & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6639,7 +6639,15 @@ class ToolingLogTextWriter {
}

if (this.ignoreSources && msg.source && this.ignoreSources.includes(msg.source)) {
return false;
if (msg.type === 'write') {
const txt = (0, _util.format)(msg.args[0], ...msg.args.slice(1)); // Ensure that Elasticsearch deprecation log messages from Kibana aren't ignored

if (!/elasticsearch\.deprecation/.test(txt)) {
return false;
}
} else {
return false;
}
}

const prefix = has(MSG_PREFIXES, msg.type) ? MSG_PREFIXES[msg.type] : '';
Expand Down
Loading