mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #47 from overleaf/jpa-drop-idle-background-loop
[misc] drop idle background loop
This commit is contained in:
commit
783a4f5c79
4 changed files with 23 additions and 12 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') {
|
||||
|
|
2
libraries/metrics/package-lock.json
generated
2
libraries/metrics/package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@overleaf/metrics",
|
||||
"version": "3.5.0",
|
||||
"version": "3.5.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@overleaf/metrics",
|
||||
"version": "3.5.0",
|
||||
"version": "3.5.1",
|
||||
"description": "A drop-in metrics and monitoring module for node.js apps",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -138,21 +138,31 @@ class MetricWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
if (!PromWrapper.sweepRegistered) {
|
||||
let sweepingInterval
|
||||
PromWrapper.setupSweeping = function() {
|
||||
if (sweepingInterval) {
|
||||
clearInterval(sweepingInterval)
|
||||
}
|
||||
if (!PromWrapper.ttlInMinutes) {
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Not registering sweep method -- empty ttl')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Registering sweep method')
|
||||
}
|
||||
PromWrapper.sweepRegistered = true
|
||||
setInterval(function() {
|
||||
if (PromWrapper.ttlInMinutes) {
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Sweeping metrics')
|
||||
}
|
||||
return metrics.forEach((metric, key) => {
|
||||
return metric.sweep()
|
||||
})
|
||||
sweepingInterval = setInterval(function() {
|
||||
if (process.env.DEBUG_METRICS) {
|
||||
console.log('Sweeping metrics')
|
||||
}
|
||||
return metrics.forEach((metric, key) => {
|
||||
return metric.sweep()
|
||||
})
|
||||
}, 60000)
|
||||
|
||||
const Metrics = require('./index')
|
||||
Metrics.registerDestructor(() => clearInterval(sweepingInterval))
|
||||
}
|
||||
|
||||
module.exports = PromWrapper
|
||||
|
|
Loading…
Reference in a new issue