|
@@ -138,12 +138,15 @@ class MetricWrapper {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-if (!PromWrapper.sweepRegistered) {
|
|
|
|
|
|
|
+let sweepingInterval
|
|
|
|
|
+PromWrapper.setupSweeping = function() {
|
|
|
|
|
+ if (sweepingInterval) {
|
|
|
|
|
+ clearInterval(sweepingInterval)
|
|
|
|
|
+ }
|
|
|
if (process.env.DEBUG_METRICS) {
|
|
if (process.env.DEBUG_METRICS) {
|
|
|
console.log('Registering sweep method')
|
|
console.log('Registering sweep method')
|
|
|
}
|
|
}
|
|
|
- PromWrapper.sweepRegistered = true
|
|
|
|
|
- setInterval(function() {
|
|
|
|
|
|
|
+ sweepingInterval = setInterval(function() {
|
|
|
if (PromWrapper.ttlInMinutes) {
|
|
if (PromWrapper.ttlInMinutes) {
|
|
|
if (process.env.DEBUG_METRICS) {
|
|
if (process.env.DEBUG_METRICS) {
|
|
|
console.log('Sweeping metrics')
|
|
console.log('Sweeping metrics')
|
|
@@ -153,6 +156,9 @@ if (!PromWrapper.sweepRegistered) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}, 60000)
|
|
}, 60000)
|
|
|
|
|
+
|
|
|
|
|
+ const Metrics = require('./index')
|
|
|
|
|
+ Metrics.registerDestructor(() => clearInterval(sweepingInterval))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
module.exports = PromWrapper
|
|
module.exports = PromWrapper
|