From 5599521c098ee4707386513fc7fb02f5a01503aa Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 20 Nov 2018 21:42:34 +0000 Subject: [PATCH] consolodate on metrics.timing --- libraries/metrics/metrics.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/metrics/metrics.coffee b/libraries/metrics/metrics.coffee index fdc45cf4f1..0e54936429 100644 --- a/libraries/metrics/metrics.coffee +++ b/libraries/metrics/metrics.coffee @@ -56,6 +56,14 @@ module.exports = Metrics = timing: (key, timeSpan, sampleRate)-> statsd.timing(buildKey(key), timeSpan, sampleRate) + if !promMetrics[this.key] + promMetrics[this.key] = new prom.Summary({ + name: "#{name}_timer_#{this.key}".replace(/\./g,"_"), + help: key, + maxAgeSeconds: 600, + ageBuckets: 10 + }) + promMetrics[this.key].observe(timeSpan) Timer : class constructor :(key, sampleRate = 1)-> @@ -65,15 +73,7 @@ module.exports = Metrics = done:-> timeSpan = new Date - this.start - statsd.timing(buildKey(this.key), timeSpan, this.sampleRate) - if !promMetrics[this.key] - promMetrics[this.key] = new prom.Summary({ - name: "#{name}_timer_#{this.key}".replace(/\./g,"_"), - help: this.key, - maxAgeSeconds: 600, - ageBuckets: 10 - }) - promMetrics[this.key].observe(timeSpan) + Metrics.timing(this.key, timeSpan, this.sampleRate) return timeSpan gauge : (key, value, sampleRate = 1)->