mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[misc] register the metrics sweeping interval handle for later cleanup
This commit is contained in:
parent
2e9c4a5d4f
commit
29742d6a87
2 changed files with 10 additions and 3 deletions
|
@ -30,6 +30,7 @@ function initialize(appName, opts = {}) {
|
|||
appName = appName || DEFAULT_APP_NAME
|
||||
configure({ ...opts, appName })
|
||||
collectDefaultMetrics({ timeout: 5000, prefix: '' })
|
||||
promWrapper.setupSweeping()
|
||||
|
||||
console.log(`ENABLE_TRACE_AGENT set to ${process.env.ENABLE_TRACE_AGENT}`)
|
||||
if (process.env.ENABLE_TRACE_AGENT === 'true') {
|
||||
|
|
|
@ -138,12 +138,15 @@ class MetricWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
if (!PromWrapper.sweepRegistered) {
|
||||
let sweepingInterval
|
||||
PromWrapper.setupSweeping = function() {
|
||||
if (sweepingInterval) {
|
||||
clearInterval(sweepingInterval)
|
||||
}
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Registering sweep method')
|
||||
}
|
||||
PromWrapper.sweepRegistered = true
|
||||
setInterval(function() {
|
||||
sweepingInterval = setInterval(function() {
|
||||
if (PromWrapper.ttlInMinutes) {
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Sweeping metrics')
|
||||
|
@ -153,6 +156,9 @@ if (!PromWrapper.sweepRegistered) {
|
|||
})
|
||||
}
|
||||
}, 60000)
|
||||
|
||||
const Metrics = require('./index')
|
||||
Metrics.registerDestructor(() => clearInterval(sweepingInterval))
|
||||
}
|
||||
|
||||
module.exports = PromWrapper
|
||||
|
|
Loading…
Reference in a new issue