...
|
...
|
@@ -5,7 +5,6 @@ const MysqlSender = require('../lib/mysql-sender'); |
|
|
const _ = require('lodash');
|
|
|
const logger = global.yoho.logger;
|
|
|
const config = global.yoho.config;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const msg2row = require('./msg2row');
|
|
|
|
|
|
const durationType = {
|
...
|
...
|
@@ -14,7 +13,9 @@ const durationType = { |
|
|
fs: 'firstscreen'
|
|
|
};
|
|
|
|
|
|
const influxSender = new Sender(config.report);
|
|
|
const apiInfluxSender = new Sender(config.reportApi);
|
|
|
const routeInfluxSender = new Sender(config.reportRoute);
|
|
|
|
|
|
const slowRouterSender = new MysqlSender(config.table.slow);
|
|
|
const errorRouterSender = new MysqlSender(config.table.error);
|
|
|
|
...
|
...
|
@@ -43,23 +44,11 @@ module.exports = (req, res, next) => { |
|
|
reqID: item.rid,
|
|
|
uid: item.u,
|
|
|
udid: item.ud,
|
|
|
route: item.r,
|
|
|
path: item.pt
|
|
|
}
|
|
|
route: item.pt
|
|
|
},
|
|
|
time: new Date().getTime() * 1000000
|
|
|
};
|
|
|
|
|
|
if (item.r) {
|
|
|
try {
|
|
|
_.merge(data, {
|
|
|
tags: {
|
|
|
route: crypto.decrypt(item.r)
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
logger.warn('parse message wrong ', item.r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sourceMapParse.parse({
|
|
|
fileUrl: item.sc,
|
|
|
line: parseInt(item.ln || 0, 10),
|
...
|
...
|
@@ -104,29 +93,29 @@ module.exports = (req, res, next) => { |
|
|
reqID: item.rid,
|
|
|
uid: item.u,
|
|
|
udid: item.ud,
|
|
|
route: item.r,
|
|
|
path: item.path
|
|
|
}
|
|
|
route: item.pt
|
|
|
},
|
|
|
time: new Date().getTime() * 1000000
|
|
|
};
|
|
|
|
|
|
if (item.r) {
|
|
|
try {
|
|
|
_.merge(data, {
|
|
|
tags: {
|
|
|
route: crypto.decrypt(item.r)
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
logger.warn('parse message wrong ', item.r);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (durationType[item.tp]) {
|
|
|
if (item.type === 'api') {
|
|
|
apiInfluxSender({
|
|
|
measurement: 'api-info',
|
|
|
tags: {
|
|
|
app: item.app,
|
|
|
host: item.hostname,
|
|
|
api: item.api
|
|
|
},
|
|
|
field: {
|
|
|
duration: item.duration
|
|
|
}
|
|
|
});
|
|
|
} else if (item.type === 'route') {
|
|
|
const duration = _.parseInt(item.t);
|
|
|
|
|
|
if (duration < 1000 * 60 * 10) {
|
|
|
_.merge(data, {
|
|
|
measurement: 'web-client-duration',
|
|
|
measurement: 'route-info',
|
|
|
tags: {
|
|
|
type: durationType[item.tp]
|
|
|
},
|
...
|
...
|
@@ -136,7 +125,17 @@ module.exports = (req, res, next) => { |
|
|
}
|
|
|
});
|
|
|
|
|
|
influxSender.addMessage(data);
|
|
|
routeInfluxSender.addMessage({
|
|
|
measurement: 'route-info',
|
|
|
tags: {
|
|
|
app: item.app,
|
|
|
host: item.hostname,
|
|
|
route: item.path
|
|
|
},
|
|
|
field: {
|
|
|
duration: item.duration
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (duration > config.slowRoute.min || duration < config.slowRoute.max) {
|
|
|
slowRouterSender.addMessage(msg2row.slowRouter(data));
|
...
|
...
|
|