浏览代码

[misc] do not register a noop sweeping interval

Jakob Ackermann 6 年之前
父节点
当前提交
20223d865f
共有 1 个文件被更改,包括 11 次插入 和 7 次删除
  1. 11 7
      libraries/metrics/prom_wrapper.js

+ 11 - 7
libraries/metrics/prom_wrapper.js

@@ -143,18 +143,22 @@ 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')
   }
   sweepingInterval = setInterval(function() {
-    if (PromWrapper.ttlInMinutes) {
-      if (process.env.DEBUG_METRICS) {
-        console.log('Sweeping metrics')
-      }
-      return metrics.forEach((metric, key) => {
-        return metric.sweep()
-      })
+    if (process.env.DEBUG_METRICS) {
+      console.log('Sweeping metrics')
     }
+    return metrics.forEach((metric, key) => {
+      return metric.sweep()
+    })
   }, 60000)
 
   const Metrics = require('./index')