Add in new metrics

This commit is contained in:
James Allen
2014-05-09 14:55:37 +01:00
parent f407c22d94
commit 20219e0f2f
3 changed files with 8 additions and 22 deletions

View File

@@ -1,23 +1,2 @@
StatsD = require('lynx')
statsd = new StatsD('localhost', 8125, {on_error:->})
buildKey = (key)-> "clsi.#{process.env.NODE_ENV or "testing"}.#{key}"
module.exports =
set : (key, value, sampleRate = 1)->
statsd.set buildKey(key), value, sampleRate
inc : (key, sampleRate = 1)->
statsd.increment buildKey(key), sampleRate
Timer : class
constructor :(key, sampleRate = 1)->
this.start = new Date()
this.key = buildKey(key)
done:->
timeSpan = new Date - this.start
statsd.timing(this.key, timeSpan, this.sampleRate)
gauge : (key, value, sampleRate = 1)->
statsd.gauge key, value, sampleRate
module.exports = require "metrics-sharelatex"