...
|
...
|
@@ -141,65 +141,107 @@ async function handleClientTiming(scope, item) { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
const data = {
|
|
|
app: scope.app,
|
|
|
reqid: item.rid,
|
|
|
uid: item.u,
|
|
|
udid: item.ud,
|
|
|
route: item.r,
|
|
|
create_time: new Date().getTime(),
|
|
|
domType: 'html',
|
|
|
mineType: 'html',
|
|
|
url: item.pt,
|
|
|
dnsTime: _.parseInt(item.dt || '0'),
|
|
|
tcpTime: _.parseInt(item.tt || '0'),
|
|
|
responseTime: _.parseInt(item.rt || '0'),
|
|
|
domParseTime: _.parseInt(item.domt || '0'),
|
|
|
pageRenderTime: _.parseInt(item.et || '0'),
|
|
|
pageInteractTime: _.parseInt(item.ot || '0'),
|
|
|
pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
screenWidth: _.parseInt(item.sw || '0'),
|
|
|
screenHeight: _.parseInt(item.sh || '0'),
|
|
|
useragent: scope.useragent || '',
|
|
|
os: item.pf || '',
|
|
|
ip: scope.ip || '0.0.0.0',
|
|
|
browserName: agent.family || 'unknown',
|
|
|
browserVersion: agent.toVersion() || 'unknown',
|
|
|
osName: agent.os.family || 'unknown',
|
|
|
osVersion: agent.os.toVersion() || 'unknown'
|
|
|
};
|
|
|
let responseTime = _.parseInt(item.rt || '0');
|
|
|
|
|
|
if (!(data.responseTime >= 0 && data.responseTime <= 10000)) {
|
|
|
if (!(responseTime >= 0 && responseTime <= 10000)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const ipInfo = ipService.getIsp(scope.ip);
|
|
|
|
|
|
_.merge(data, ipInfo);
|
|
|
|
|
|
logger.debug('[client] perf info [%s]', JSON.stringify(data));
|
|
|
routeInfluxSender.addMessage({
|
|
|
measurement: 'html-timing-info',
|
|
|
tags: {
|
|
|
app: scope.app,
|
|
|
host: item.hostname,
|
|
|
route: item.r
|
|
|
},
|
|
|
fields: {
|
|
|
dnsTime: _.parseInt(item.dt || '0'),
|
|
|
tcpTime: _.parseInt(item.tt || '0'),
|
|
|
responseTime: _.parseInt(item.rt || '0'),
|
|
|
domParseTime: _.parseInt(item.domt || '0'),
|
|
|
pageRenderTime: _.parseInt(item.et || '0'),
|
|
|
pageInteractTime: _.parseInt(item.ot || '0'),
|
|
|
pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
screenWidth: _.parseInt(item.sw || '0'),
|
|
|
screenHeight: _.parseInt(item.sh || '0'),
|
|
|
}
|
|
|
});
|
|
|
|
|
|
perfReportSqlSender.addMessage(data);
|
|
|
// const data = {
|
|
|
// app: scope.app,
|
|
|
// reqid: item.rid,
|
|
|
// uid: item.u,
|
|
|
// udid: item.ud,
|
|
|
// route: item.r,
|
|
|
// create_time: new Date().getTime(),
|
|
|
// domType: 'html',
|
|
|
// mineType: 'html',
|
|
|
// url: item.pt,
|
|
|
// dnsTime: _.parseInt(item.dt || '0'),
|
|
|
// tcpTime: _.parseInt(item.tt || '0'),
|
|
|
// responseTime: _.parseInt(item.rt || '0'),
|
|
|
// domParseTime: _.parseInt(item.domt || '0'),
|
|
|
// pageRenderTime: _.parseInt(item.et || '0'),
|
|
|
// pageInteractTime: _.parseInt(item.ot || '0'),
|
|
|
// pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
// screenWidth: _.parseInt(item.sw || '0'),
|
|
|
// screenHeight: _.parseInt(item.sh || '0'),
|
|
|
// useragent: scope.useragent || '',
|
|
|
// os: item.pf || '',
|
|
|
// ip: scope.ip || '0.0.0.0',
|
|
|
// browserName: agent.family || 'unknown',
|
|
|
// browserVersion: agent.toVersion() || 'unknown',
|
|
|
// osName: agent.os.family || 'unknown',
|
|
|
// osVersion: agent.os.toVersion() || 'unknown'
|
|
|
// };
|
|
|
|
|
|
// if (!(data.responseTime >= 0 && data.responseTime <= 10000)) {
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
// const ipInfo = ipService.getIsp(scope.ip);
|
|
|
|
|
|
// _.merge(data, ipInfo);
|
|
|
|
|
|
// logger.debug('[client] perf info [%s]', JSON.stringify(data));
|
|
|
|
|
|
// perfReportSqlSender.addMessage(data);
|
|
|
}
|
|
|
|
|
|
function handleClientResource(scope, item) {
|
|
|
const data = {
|
|
|
app: scope.app,
|
|
|
reqid: item.rid,
|
|
|
uid: item.u,
|
|
|
udid: item.ud,
|
|
|
route: item.r,
|
|
|
create_time: new Date().getTime(),
|
|
|
domType: 'resource',
|
|
|
mineType: item.mtp,
|
|
|
dnsTime: _.parseInt(item.dt || '0'),
|
|
|
tcpTime: _.parseInt(item.tt || '0'),
|
|
|
responseTime: _.parseInt(item.rt || '0'),
|
|
|
pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
};
|
|
|
routeInfluxSender.addMessage({
|
|
|
measurement: 'resource-timing-info',
|
|
|
tags: {
|
|
|
app: scope.app,
|
|
|
host: item.hostname,
|
|
|
route: item.r,
|
|
|
type: item.mtp
|
|
|
},
|
|
|
fields: {
|
|
|
dnsTime: _.parseInt(item.dt || '0'),
|
|
|
tcpTime: _.parseInt(item.tt || '0'),
|
|
|
responseTime: _.parseInt(item.rt || '0'),
|
|
|
pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
}
|
|
|
});
|
|
|
|
|
|
logger.debug('[client] resource perf info [%s]', JSON.stringify(data));
|
|
|
perfReportSqlSender.addMessage(data);
|
|
|
// const data = {
|
|
|
// app: scope.app,
|
|
|
// reqid: item.rid,
|
|
|
// uid: item.u,
|
|
|
// udid: item.ud,
|
|
|
// route: item.r,
|
|
|
// create_time: new Date().getTime(),
|
|
|
// domType: 'resource',
|
|
|
// mineType: item.mtp,
|
|
|
// dnsTime: _.parseInt(item.dt || '0'),
|
|
|
// tcpTime: _.parseInt(item.tt || '0'),
|
|
|
// responseTime: _.parseInt(item.rt || '0'),
|
|
|
// pageLoadTime: _.parseInt(item.rrt || '0'),
|
|
|
// };
|
|
|
|
|
|
// logger.debug('[client] resource perf info [%s]', JSON.stringify(data));
|
|
|
// perfReportSqlSender.addMessage(data);
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|