msg2row.js
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const _ = require('lodash');
function slowRouter(m) {
return {
app: _.get(m, 'tags.app', ''),
type: _.get(m, 'tags.type', ''),
hostname: _.get(m, 'tags.hostname', ''),
preqid: _.get(m, 'fields.preqid', ''),
reqid: _.get(m, 'fields.reqID', ''),
uid: _.get(m, 'fields.uid', ''),
udid: _.get(m, 'fields.udid', ''),
api: _.get(m, 'tags.api', ''),
route: _.get(m, 'tags.route', ''),
duration: _.get(m, 'fields.duration', ''),
create_time: _.get(m, 'time') ? _.get(m, 'time') / 1000000 : 0
};
}
function errorRouter(m) {
return {
app: _.get(m, 'tags.app', ''),
type: _.get(m, 'tags.type', ''),
hostname: _.get(m, 'tags.hostname', ''),
preqid: _.get(m, 'tags.preqid', ''),
reqid: _.get(m, 'tags.reqID', ''),
uid: _.get(m, 'tags.uid', ''),
route: _.get(m, 'tags.route', ''),
udid: _.get(m, 'tags.udid', ''),
code: _.get(m, 'tags.code', ''),
line: _.get(m, 'fields.line', ''),
column: _.get(m, 'fields.column', ''),
script: _.get(m, 'fields.script', ''),
message: _.get(m, 'fields.message', ''),
stack: _.get(m, 'fields.stack', ''),
create_time: _.get(m, 'time') ? _.get(m, 'time') / 1000000 : 0
};
}
module.exports = {
slowRouter,
errorRouter
};