mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add summaries
This commit is contained in:
parent
5039287ee4
commit
6f708fd26a
1 changed files with 13 additions and 4 deletions
|
@ -13,6 +13,7 @@ buildGlobalKey = (key)-> "#{name}.global.#{key}"
|
|||
|
||||
counters = {}
|
||||
gauges = {}
|
||||
summaries = {}
|
||||
|
||||
destructors = []
|
||||
|
||||
|
@ -44,7 +45,7 @@ module.exports = Metrics =
|
|||
inc : (key, sampleRate = 1)->
|
||||
statsd.increment buildKey(key), sampleRate
|
||||
key = this.sanitizeKey(key)
|
||||
if !counters[key]
|
||||
if !counters[key]?
|
||||
counters[key] = new prom.Counter({
|
||||
name: "#{name}_#{key}",
|
||||
help: key,
|
||||
|
@ -66,18 +67,26 @@ module.exports = Metrics =
|
|||
done:->
|
||||
timeSpan = new Date - this.start
|
||||
statsd.timing(buildKey(this.key), timeSpan, this.sampleRate)
|
||||
if !summaries[key]?
|
||||
summary = new client.Summary({
|
||||
name: "#{name}_#{key}",
|
||||
help: key,
|
||||
maxAgeSeconds: 600,
|
||||
ageBuckets: 10
|
||||
})
|
||||
summaries[key].observe(timeSpan)
|
||||
return timeSpan
|
||||
|
||||
gauge : (key, value, sampleRate = 1)->
|
||||
statsd.gauge buildKey(key), value, sampleRate
|
||||
key = this.sanitizeKey(key)
|
||||
if !gauges[key]
|
||||
if !gauges[key]?
|
||||
gauges[key] = new prom.Gauge({
|
||||
name: "#{name}_#{key}",
|
||||
help: key,
|
||||
labelNames: ['name','host']
|
||||
})
|
||||
gauges[key].set({name: name, host: hostname},this.sanitizeValue(value))
|
||||
gauges[key].set({name: name, host: hostname}, this.sanitizeValue(value))
|
||||
|
||||
globalGauge: (key, value, sampleRate = 1)->
|
||||
statsd.gauge buildGlobalKey(key), value, sampleRate
|
||||
|
|
Loading…
Reference in a new issue