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

Surfacing deprecations with rich context from ES warning header #120044

Merged
merged 23 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fe0b13a
First stab at surfacing deprecations from warning header
rudolf Nov 30, 2021
38afb23
Log deprecations with error level but disable logger context by default
rudolf Dec 1, 2021
a8bdd08
Don't filter out error logs from ProcRunner
rudolf Dec 2, 2021
d9f0d61
Another try at not having messages ignored on CI
rudolf Dec 2, 2021
4a5efc1
Log deprecation logs with warn not info
rudolf Dec 2, 2021
41966de
Tests
rudolf Dec 3, 2021
fb198cf
Let write() do it's writing
rudolf Dec 3, 2021
0c33294
Commit pre-built @kbn/pm package
rudolf Dec 3, 2021
e85c007
Second try to commit pre-built @kbn/pm package
rudolf Dec 3, 2021
a8b0aef
Enable deprecation logger for jest_integration even though logs aren'…
rudolf Dec 3, 2021
91b0e26
Apply suggestions from code review
rudolf Dec 3, 2021
52ef440
Merge branch 'es-log-deprecations' of https://github.com/rudolf/kiban…
rudolf Dec 3, 2021
8c40b54
deprecations logger: warn for kibana and debug for users
rudolf Dec 7, 2021
02ea4aa
Merge branch 'main' into es-log-deprecations
kibanamachine Dec 7, 2021
6298e55
Refactor split query and deprecation logger out of configure_client
rudolf Dec 7, 2021
75499c5
Unit test for tooling_log_text_writer
rudolf Dec 7, 2021
bf49c56
Fix TS
rudolf Dec 7, 2021
b8863f1
Use event.meta.request.params.headers to include Client constructor h…
rudolf Dec 7, 2021
fd78fd7
Fix tests
rudolf Dec 7, 2021
d619c99
Ignore deprecation warnings not from Elasticsearch
rudolf Dec 7, 2021
26c3437
Log on info level
rudolf Dec 7, 2021
946fb68
Log in JSON so that entire deprecation message is on one line
rudolf Dec 8, 2021
22f9274
commit built kbn-pm package
rudolf Dec 8, 2021
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 (!/\[deprecation\]\[elasticsearch\]/.test(txt)) {
return false;
}
} else {
return false;
}
}

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