msg2row.js
1.68 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
43
44
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', '').replace(/"/g, ''),
reqid: _.get(m, 'fields.reqID', '').replace(/"/g, ''),
uid: parseInt(_.get(m, 'fields.uid', '0').replace(/"/g, '') || '0'),
udid: _.get(m, 'fields.udid', '').replace(/"/g, ''),
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', ''),
api: _.get(m, 'tags.api', ''),
type: _.get(m, 'tags.type', ''),
hostname: _.get(m, 'tags.hostname', ''),
preqid: _.get(m, 'fields.preqid', '').replace(/"/g, ''),
reqid: _.get(m, 'fields.reqID', '').replace(/"/g, ''),
uid: parseInt(_.get(m, 'fields.uid', '0').replace(/"/g, '') || '0'),
udid: _.get(m, 'fields.udid', '').replace(/"/g, ''),
route: _.get(m, 'tags.route', ''),
code: _.get(m, 'tags.code', ''),
line: parseInt(_.get(m, 'fields.line', '0').replace(/"/g, '') || '0'),
column: parseInt(_.get(m, 'fields.column', '0').replace(/"/g, '') || '0'),
script: _.get(m, 'fields.script', ''),
message: _.get(m, 'fields.message', ''),
stack: _.get(m, 'fields.stack', ''),
useragent: _.get(m, 'fields.useragent', ''),
create_time: _.get(m, 'time') ? _.get(m, 'time') / 1000000 : 0
};
}
module.exports = {
slowRouter,
errorRouter
};