mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-23 02:55:13 -04: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
|
appName = appName || DEFAULT_APP_NAME
|
||||||
configure({ ...opts, appName })
|
configure({ ...opts, appName })
|
||||||
collectDefaultMetrics({ timeout: 5000, prefix: '' })
|
collectDefaultMetrics({ timeout: 5000, prefix: '' })
|
||||||
|
promWrapper.setupSweeping()
|
||||||
|
|
||||||
console.log(`ENABLE_TRACE_AGENT set to ${process.env.ENABLE_TRACE_AGENT}`)
|
console.log(`ENABLE_TRACE_AGENT set to ${process.env.ENABLE_TRACE_AGENT}`)
|
||||||
if (process.env.ENABLE_TRACE_AGENT === 'true') {
|
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",
|
"name": "@overleaf/metrics",
|
||||||
"version": "3.5.0",
|
"version": "3.5.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@overleaf/metrics",
|
"name": "@overleaf/metrics",
|
||||||
"version": "3.5.0",
|
"version": "3.5.1",
|
||||||
"description": "A drop-in metrics and monitoring module for node.js apps",
|
"description": "A drop-in metrics and monitoring module for node.js apps",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"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) {
|
if (process.env.DEBUG_METRICS) {
|
||||||
console.log('Registering sweep method')
|
console.log('Registering sweep method')
|
||||||
}
|
}
|
||||||
PromWrapper.sweepRegistered = true
|
sweepingInterval = setInterval(function() {
|
||||||
setInterval(function() {
|
|
||||||
if (PromWrapper.ttlInMinutes) {
|
|
||||||
if (process.env.DEBUG_METRICS) {
|
if (process.env.DEBUG_METRICS) {
|
||||||
console.log('Sweeping metrics')
|
console.log('Sweeping metrics')
|
||||||
}
|
}
|
||||||
return metrics.forEach((metric, key) => {
|
return metrics.forEach((metric, key) => {
|
||||||
return metric.sweep()
|
return metric.sweep()
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}, 60000)
|
}, 60000)
|
||||||
|
|
||||||
|
const Metrics = require('./index')
|
||||||
|
Metrics.registerDestructor(() => clearInterval(sweepingInterval))
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PromWrapper
|
module.exports = PromWrapper
|
||||||
|
|
Loading…
Reference in a new issue