mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Log deprecations originating from Kibana on debug level (#123660)
* Log deprecations originating from Kibana on debug level * Surface debug level deprecation logs on CI * Review feedback
This commit is contained in:
parent
2e3d5969ed
commit
c64c766444
18 changed files with 47 additions and 19 deletions
|
@ -540,14 +540,13 @@ describe('instrumentQueryAndDeprecationLogger', () => {
|
|||
});
|
||||
client.diagnostic.emit('response', new errors.ResponseError(response), response);
|
||||
|
||||
// One debug log entry from 'elasticsearch.query' context
|
||||
expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
|
||||
// Test debug[1] since theree is one log entry from 'elasticsearch.query' context
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
|
||||
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
|
||||
);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:kibana');
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
|
||||
/Query:\n.*400\n.*GET \/_path\?hello\=dolly \[illegal_argument_exception\]: request \[\/_path\] contains unrecognized parameter: \[name\]/
|
||||
);
|
||||
});
|
||||
|
@ -573,7 +572,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
|
|||
});
|
||||
client.diagnostic.emit('response', null, response);
|
||||
|
||||
expect(loggingSystemMock.collect(logger).info).toEqual([]);
|
||||
// Test debug[1] since theree is one log entry from 'elasticsearch.query' context
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
|
||||
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
|
||||
|
@ -608,14 +606,13 @@ describe('instrumentQueryAndDeprecationLogger', () => {
|
|||
});
|
||||
client.diagnostic.emit('response', null, response);
|
||||
|
||||
// One debug log entry from 'elasticsearch.query' context
|
||||
expect(loggingSystemMock.collect(logger).debug.length).toEqual(1);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
|
||||
// Test debug[1] since theree is one log entry from 'elasticsearch.query' context
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
|
||||
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
|
||||
);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
|
||||
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:kibana');
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
|
||||
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
|
||||
/Query:\n.*200\n.*GET \/_path\?hello\=dolly/
|
||||
);
|
||||
});
|
||||
|
|
|
@ -139,12 +139,9 @@ export const instrumentEsQueryAndDeprecationLogger = ({
|
|||
// Strip the first 5 stack trace lines as these are irrelavent to finding the call site
|
||||
const stackTrace = new Error().stack?.split('\n').slice(5).join('\n');
|
||||
|
||||
const deprecationMsg = `Elasticsearch deprecation: ${event.warnings}\nOrigin:${requestOrigin}\nStack trace:\n${stackTrace}\nQuery:\n${queryMsg}`;
|
||||
if (requestOrigin === 'kibana') {
|
||||
deprecationLogger.info(deprecationMsg);
|
||||
} else {
|
||||
deprecationLogger.debug(deprecationMsg);
|
||||
}
|
||||
deprecationLogger.debug(
|
||||
`Elasticsearch deprecation: ${event.warnings}\nOrigin:${requestOrigin}\nStack trace:\n${stackTrace}\nQuery:\n${queryMsg}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -63,6 +63,7 @@ describe('migration from 7.7.2-xpack with 100k objects', () => {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -128,6 +128,7 @@ function createRoot() {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -170,6 +170,7 @@ function createRoot() {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -124,6 +124,7 @@ function createRoot() {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -154,6 +154,7 @@ function createRoot(options: { maxBatchSizeBytes?: number }) {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -105,6 +105,7 @@ function createRoot(options: { maxBatchSizeBytes?: number }) {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -165,6 +165,7 @@ function createRoot() {
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -169,6 +169,7 @@ function createRoot() {
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -94,6 +94,7 @@ describe('migrating from 7.3.0-xpack which used v1 migrations', () => {
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -94,6 +94,7 @@ describe('migrating from the same Kibana version that used v1 migrations', () =>
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -83,6 +83,7 @@ function createRoot({ logFileName, hosts }: RootConfig) {
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -83,6 +83,7 @@ async function createRoot({ logFileName }: CreateRootConfig) {
|
|||
{
|
||||
name: 'root',
|
||||
appenders: ['file'],
|
||||
level: 'info',
|
||||
},
|
||||
{
|
||||
name: 'savedobjects-service',
|
||||
|
|
|
@ -109,6 +109,7 @@ function createRoot() {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -76,6 +76,7 @@ function createRoot() {
|
|||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'info',
|
||||
appenders: ['file'],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -109,6 +109,25 @@ export function createRootWithCorePlugins(settings = {}, cliArgs: Partial<CliArg
|
|||
username: kibanaServerTestUser.username,
|
||||
password: kibanaServerTestUser.password,
|
||||
},
|
||||
// Log ES deprecations to surface these in CI
|
||||
logging: {
|
||||
loggers: [
|
||||
{
|
||||
name: 'root',
|
||||
level: 'error',
|
||||
appenders: ['console'],
|
||||
},
|
||||
{
|
||||
name: 'elasticsearch.deprecation',
|
||||
level: 'all',
|
||||
appenders: ['deprecation'],
|
||||
},
|
||||
],
|
||||
appenders: {
|
||||
deprecation: { type: 'console', layout: { type: 'json' } },
|
||||
console: { type: 'console', layout: { type: 'pattern' } },
|
||||
},
|
||||
},
|
||||
// createRootWithSettings sets default value to "true", so undefined should be threatened as "true".
|
||||
...(cliArgs.oss === false
|
||||
? {
|
||||
|
|
|
@ -59,6 +59,7 @@ export default function () {
|
|||
'--logging.appenders.deprecation.type=console',
|
||||
'--logging.appenders.deprecation.layout.type=json',
|
||||
'--logging.loggers[0].name=elasticsearch.deprecation',
|
||||
'--logging.loggers[0].level=all',
|
||||
'--logging.loggers[0].appenders[0]=deprecation',
|
||||
],
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue