From 80e9afe42c221064220848b4adf85cb3c3a3cab2 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 12 Feb 2020 11:25:46 +0000 Subject: [PATCH] Merge pull request #2586 from overleaf/bg-simplify-rate-limit-metrics simplify metric for rate limits GitOrigin-RevId: bba98c7e38846aedcfcf0781003f755e302f7759 --- services/web/app/src/infrastructure/RateLimiter.js | 2 +- .../web/test/unit/src/infrastructure/RateLimterTests.js | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/services/web/app/src/infrastructure/RateLimiter.js b/services/web/app/src/infrastructure/RateLimiter.js index 00b36a5cb9..c39e835d68 100644 --- a/services/web/app/src/infrastructure/RateLimiter.js +++ b/services/web/app/src/infrastructure/RateLimiter.js @@ -27,7 +27,7 @@ const RateLimiter = { } const allowed = timeLeft === 0 if (!allowed) { - Metrics.inc(`rate-limit-hit.${opts.endpointName}`, 1, { + Metrics.inc('rate-limit-hit', 1, { path: opts.endpointName }) } diff --git a/services/web/test/unit/src/infrastructure/RateLimterTests.js b/services/web/test/unit/src/infrastructure/RateLimterTests.js index 9f3d8beaff..40dcc8aaad 100644 --- a/services/web/test/unit/src/infrastructure/RateLimterTests.js +++ b/services/web/test/unit/src/infrastructure/RateLimterTests.js @@ -132,12 +132,9 @@ describe('RateLimiter', function() { return this.limiter.addCount( { endpointName: this.endpointName }, (err, should) => { - sinon.assert.calledWith( - this.Metrics.inc, - `rate-limit-hit.${this.endpointName}`, - 1, - { path: this.endpointName } - ) + sinon.assert.calledWith(this.Metrics.inc, `rate-limit-hit`, 1, { + path: this.endpointName + }) return done() } )