mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #11758 from overleaf/jpa-metric-max-access-checks-hit
[web] add metric for hitting limit on new compile domain access checks GitOrigin-RevId: 58df0911a411dd77698932e13d212cf15b4c8931
This commit is contained in:
parent
c52799798d
commit
e525c4c58d
3 changed files with 24 additions and 0 deletions
|
@ -15,7 +15,13 @@ function recordFallbackUsage(_req, res) {
|
|||
res.sendStatus(204)
|
||||
}
|
||||
|
||||
function recordMaxAccessChecksHit(_req, res) {
|
||||
Metrics.inc('user_content_domain_max_access_checks_hit')
|
||||
res.sendStatus(204)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
recordCheckResult,
|
||||
recordFallbackUsage,
|
||||
recordMaxAccessChecksHit,
|
||||
}
|
||||
|
|
|
@ -214,6 +214,10 @@ const rateLimiters = {
|
|||
points: 15,
|
||||
duration: 60,
|
||||
}),
|
||||
userContentDomainMaxAccessChecksHit: new RateLimiter('user-content-mach', {
|
||||
points: 15,
|
||||
duration: 60,
|
||||
}),
|
||||
}
|
||||
|
||||
function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
||||
|
@ -1358,6 +1362,13 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|||
),
|
||||
UserContentDomainController.recordFallbackUsage
|
||||
)
|
||||
webRouter.post(
|
||||
'/record-user-content-domain-max-access-checks-hit',
|
||||
RateLimiterMiddleware.rateLimit(
|
||||
rateLimiters.userContentDomainMaxAccessChecksHit
|
||||
),
|
||||
UserContentDomainController.recordMaxAccessChecksHit
|
||||
)
|
||||
|
||||
webRouter.get(
|
||||
`/read/:token(${TokenAccessController.READ_ONLY_TOKEN_PATTERN})`,
|
||||
|
|
|
@ -278,6 +278,9 @@ export function scheduleUserContentDomainAccessCheck() {
|
|||
return scheduleUserContentDomainAccessCheck()
|
||||
}
|
||||
if (accessCheckPassed) return
|
||||
if (remainingChecks === 0) {
|
||||
recordMaxAccessChecksHit()
|
||||
}
|
||||
if (remainingChecks-- <= 0) return
|
||||
checkUserContentDomainAccess()
|
||||
.then(ok => {
|
||||
|
@ -288,3 +291,7 @@ export function scheduleUserContentDomainAccessCheck() {
|
|||
})
|
||||
}, INITIAL_DELAY_MS)
|
||||
}
|
||||
|
||||
function recordMaxAccessChecksHit() {
|
||||
postJSON('/record-user-content-domain-max-access-checks-hit').catch(() => {})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue