consolodate on metrics.timing

This commit is contained in:
Henry Oswald 2018-11-20 21:42:34 +00:00
parent 7fc49d1eb5
commit 5599521c09

View file

@ -56,6 +56,14 @@ module.exports = Metrics =
timing: (key, timeSpan, sampleRate)-> timing: (key, timeSpan, sampleRate)->
statsd.timing(buildKey(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 Timer : class
constructor :(key, sampleRate = 1)-> constructor :(key, sampleRate = 1)->
@ -65,15 +73,7 @@ module.exports = Metrics =
done:-> done:->
timeSpan = new Date - this.start timeSpan = new Date - this.start
statsd.timing(buildKey(this.key), timeSpan, this.sampleRate) Metrics.timing(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)
return timeSpan return timeSpan
gauge : (key, value, sampleRate = 1)-> gauge : (key, value, sampleRate = 1)->