From 6506c39239e5bd35a27889d92d46acca9a048c63 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 21 Jan 2021 11:57:16 +0800 Subject: [PATCH] feat: remove hot ip in debug info --- lib/app.js | 1 - lib/middleware/debug.js | 5 ----- lib/routes/index.js | 11 ----------- test/middleware/debug.js | 3 --- 4 files changed, 20 deletions(-) diff --git a/lib/app.js b/lib/app.js index 61ad7129e6..b51ca2314a 100644 --- a/lib/app.js +++ b/lib/app.js @@ -48,7 +48,6 @@ app.context.debug = { etag: 0, paths: [], routes: [], - ips: [], errorPaths: [], errorRoutes: [], }; diff --git a/lib/middleware/debug.js b/lib/middleware/debug.js index d3c41ae9dc..644795418a 100644 --- a/lib/middleware/debug.js +++ b/lib/middleware/debug.js @@ -4,11 +4,6 @@ module.exports = async (ctx, next) => { } ctx.debug.paths[ctx.request.path]++; - const ip = ctx.ips[0] || ctx.ip; - if (!ctx.debug.ips[ip]) { - ctx.debug.ips[ip] = 0; - } - ctx.debug.ips[ip]++; ctx.debug.request++; await next(); diff --git a/lib/routes/index.js b/lib/routes/index.js index 22fb4f740a..8a547b19fd 100644 --- a/lib/routes/index.js +++ b/lib/routes/index.js @@ -48,13 +48,6 @@ module.exports = async (ctx) => { }); } - 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 = ''; - hotIPs.forEach((item) => { - hotIPsValue += `${ctx.debug.ips[item]} ${item}
`; - }); - let showDebug; if (!config.debugInfo || config.debugInfo === 'false') { showDebug = false; @@ -115,10 +108,6 @@ module.exports = async (ctx) => { name: 'Hot Paths', value: hotPathsValue, }, - { - name: 'Hot IP', - value: hotIPsValue, - }, { name: 'Hot Error Routes', value: hotErrorRoutesValue, diff --git a/test/middleware/debug.js b/test/middleware/debug.js index f9d32ae3f1..79c9acd61f 100644 --- a/test/middleware/debug.js +++ b/test/middleware/debug.js @@ -52,9 +52,6 @@ describe('debug', () => { case 'Hot Paths:': expect(value).toBe('3 /test/1
2 /test/2
2 /test/empty
1 /
'); break; - case 'Hot IP:': - expect(value).toBe('5 233.233.233.233
3 233.233.233.234
'); - break; case 'Hot Error Routes:': expect(value).toBe('1 /test/:id
'); break;