feat: add error routes and error paths info

This commit is contained in:
DIYgod
2019-08-23 00:15:13 +08:00
parent 6dc109b55c
commit f7e8682ba8
5 changed files with 50 additions and 4 deletions

View File

@@ -29,6 +29,24 @@ module.exports = async (ctx) => {
hotPathsValue += `${ctx.debug.paths[item]}&nbsp;&nbsp;${item}<br>`;
});
let hotErrorRoutesValue = '';
if (ctx.debug.errorRoutes) {
const errorRoutes = Object.keys(ctx.debug.errorRoutes).sort((a, b) => ctx.debug.errorRoutes[b] - ctx.debug.errorRoutes[a]);
const hotErrorRoutes = errorRoutes.slice(0, 30);
hotErrorRoutes.forEach((item) => {
hotErrorRoutesValue += `${ctx.debug.errorRoutes[item]}&nbsp;&nbsp;${item}<br>`;
});
}
let hotErrorPathsValue = '';
if (ctx.debug.errorPaths) {
const errorPaths = Object.keys(ctx.debug.errorPaths).sort((a, b) => ctx.debug.errorPaths[b] - ctx.debug.errorPaths[a]);
const hotErrorPaths = errorPaths.slice(0, 30);
hotErrorPaths.forEach((item) => {
hotErrorPathsValue += `${ctx.debug.errorPaths[item]}&nbsp;&nbsp;${item}<br>`;
});
}
const ips = Object.keys(ctx.debug.ips).sort((a, b) => ctx.debug.ips[b] - ctx.debug.ips[a]);
const hotIPs = ips.slice(0, 50);
let hotIPsValue = '';
@@ -97,6 +115,14 @@ module.exports = async (ctx) => {
name: '热门IP',
value: hotIPsValue,
},
{
name: '报错路由',
value: hotErrorRoutesValue,
},
{
name: '报错路径',
value: hotErrorPathsValue,
},
],
});
};