mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
24 lines
592 B
CoffeeScript
24 lines
592 B
CoffeeScript
|
StatsD = require('node-statsd').StatsD
|
||
|
statsd = new StatsD('localhost',8125)
|
||
|
|
||
|
buildKey = (key)-> "spelling.#{process.env.NODE_ENV}.#{key}"
|
||
|
|
||
|
module.exports =
|
||
|
inc : (key, sampleRate)->
|
||
|
statsd.increment buildKey(key, sampleRate)
|
||
|
|
||
|
Timer : class
|
||
|
constructor :(key)->
|
||
|
this.start = new Date()
|
||
|
this.key = buildKey(key)
|
||
|
done:->
|
||
|
timeSpan = new Date - this.start
|
||
|
statsd.timing("#{this.key}-time", timeSpan)
|
||
|
statsd.increment "#{this.key}-count"
|
||
|
|
||
|
gauge : (key, value, sampleRate)->
|
||
|
stats = {};
|
||
|
stat = buildKey(key)
|
||
|
stats[stat] = value+"|g";
|
||
|
statsd.send(stats, sampleRate);
|