mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Add process.uptime
to the json logger (#171873)
This commit is contained in:
parent
87213e7efe
commit
1a4ac013b1
6 changed files with 27 additions and 0 deletions
|
@ -25,6 +25,7 @@ Object {
|
|||
"message": "buffered trace message",
|
||||
"process": Object {
|
||||
"pid": Any<Number>,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -42,6 +43,7 @@ Object {
|
|||
"message": "buffered info message",
|
||||
"process": Object {
|
||||
"pid": Any<Number>,
|
||||
"uptime": 10,
|
||||
},
|
||||
"some": "value",
|
||||
}
|
||||
|
@ -60,6 +62,7 @@ Object {
|
|||
"message": "buffered fatal message",
|
||||
"process": Object {
|
||||
"pid": Any<Number>,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -77,6 +80,7 @@ Object {
|
|||
"message": "buffered info message",
|
||||
"process": Object {
|
||||
"pid": Any<Number>,
|
||||
"uptime": 10,
|
||||
},
|
||||
"some": "value",
|
||||
}
|
||||
|
@ -95,6 +99,7 @@ Object {
|
|||
"message": "some new info message",
|
||||
"process": Object {
|
||||
"pid": Any<Number>,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -15,6 +15,7 @@ Object {
|
|||
"message": "message-1",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -29,6 +30,7 @@ Object {
|
|||
"message": "message-2",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -43,6 +45,7 @@ Object {
|
|||
"message": "message-3",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -57,6 +60,7 @@ Object {
|
|||
"message": "message-4",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -71,6 +75,7 @@ Object {
|
|||
"message": "message-5",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -85,6 +90,7 @@ Object {
|
|||
"message": "message-6",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
@ -99,6 +105,7 @@ Object {
|
|||
"message": "message-6",
|
||||
"process": Object {
|
||||
"pid": 5355,
|
||||
"uptime": 10,
|
||||
},
|
||||
"span": Object {
|
||||
"id": "spanId-1",
|
||||
|
|
|
@ -10,6 +10,8 @@ import { EcsVersion } from '@kbn/ecs';
|
|||
import { LogLevel, LogRecord } from '@kbn/logging';
|
||||
import { JsonLayout } from './json_layout';
|
||||
|
||||
jest.spyOn(process, 'uptime').mockReturnValue(10);
|
||||
|
||||
const timestamp = new Date(Date.UTC(2012, 1, 1, 14, 30, 22, 11));
|
||||
const records: LogRecord[] = [
|
||||
{
|
||||
|
@ -121,6 +123,7 @@ test('`format()` correctly formats record with meta-data', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 5355,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -169,6 +172,7 @@ test('`format()` correctly formats error record with meta-data', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 5355,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -202,6 +206,7 @@ test('format() meta can merge override logs', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -232,6 +237,7 @@ test('format() meta can not override message', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -262,6 +268,7 @@ test('format() meta can not override ecs version', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -295,6 +302,7 @@ test('format() meta can not override logger or level', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -325,6 +333,7 @@ test('format() meta can not override timestamp', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -359,6 +368,7 @@ test('format() meta can not override tracing properties', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
span: { id: 'span_override' },
|
||||
trace: { id: 'trace_override' },
|
||||
|
@ -404,6 +414,7 @@ test('format() meta.toJSON() is used if own property', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
server: {
|
||||
address: 'localhost',
|
||||
|
@ -448,6 +459,7 @@ test('format() meta.toJSON() is used if present on prototype', () => {
|
|||
},
|
||||
process: {
|
||||
pid: 3,
|
||||
uptime: 10,
|
||||
},
|
||||
foo: 'bar',
|
||||
});
|
||||
|
|
|
@ -53,6 +53,7 @@ export class JsonLayout implements Layout {
|
|||
},
|
||||
process: {
|
||||
pid: record.pid,
|
||||
uptime: process.uptime(),
|
||||
},
|
||||
span: spanId ? { id: spanId } : undefined,
|
||||
trace: traceId ? { id: traceId } : undefined,
|
||||
|
|
|
@ -23,6 +23,7 @@ let system: LoggingSystem;
|
|||
beforeEach(() => {
|
||||
mockConsoleLog = jest.spyOn(global.console, 'log').mockReturnValue(undefined);
|
||||
jest.spyOn<any, any>(global, 'Date').mockImplementation(() => timestamp);
|
||||
jest.spyOn(process, 'uptime').mockReturnValue(10);
|
||||
system = new LoggingSystem();
|
||||
});
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ describe('Error logging', () => {
|
|||
name: 'ResponseError',
|
||||
process: {
|
||||
pid: expect.any(Number),
|
||||
uptime: expect.any(Number),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue