mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-27 12:10:51 +00:00
24 lines
653 B
CoffeeScript
24 lines
653 B
CoffeeScript
StatsD = require('lynx')
|
|
settings = require('settings-sharelatex')
|
|
statsd = new StatsD('localhost', 8125, {on_error:->})
|
|
|
|
buildKey = (key)-> "filestore.#{process.env.NODE_ENV}.#{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
|
|
|