mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
non tested promethius counters added
This commit is contained in:
parent
31e97f92d5
commit
4b075db038
2 changed files with 17 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
StatsD = require('lynx')
|
||||
statsd = new StatsD(process.env["STATSD_HOST"] or "localhost", 8125, {on_error:->})
|
||||
|
||||
prom = require('prom-client')
|
||||
collectDefaultMetrics = client.collectDefaultMetrics
|
||||
|
||||
name = "unknown"
|
||||
hostname = require('os').hostname()
|
||||
|
||||
|
@ -14,6 +17,8 @@ require "./uv_threadpool_size"
|
|||
module.exports = Metrics =
|
||||
initialize: (_name) ->
|
||||
name = _name
|
||||
collectDefaultMetrics({ timeout: 5000, prefix: name })
|
||||
|
||||
|
||||
registerDestructor: (func) ->
|
||||
destructors.push func
|
||||
|
@ -23,9 +28,19 @@ module.exports = Metrics =
|
|||
|
||||
inc : (key, sampleRate = 1)->
|
||||
statsd.increment buildKey(key), sampleRate
|
||||
counter = new prom.Counter({
|
||||
name: key,
|
||||
help: key #https://prometheus.io/docs/instrumenting/writing_exporters/#help-strings this is probably wrong
|
||||
});
|
||||
counter.inc()
|
||||
|
||||
count : (key, count, sampleRate = 1)->
|
||||
statsd.count buildKey(key), count, sampleRate
|
||||
counter = new prom.Counter({
|
||||
name: key,
|
||||
help: key #https://prometheus.io/docs/instrumenting/writing_exporters/#help-strings this is probably wrong
|
||||
});
|
||||
counter.inc(count)
|
||||
|
||||
timing: (key, timeSpan, sampleRate)->
|
||||
statsd.timing(buildKey(key), timeSpan, sampleRate)
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
"url": "https://github.com/sharelatex/metrics-sharelatex.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"lynx": "~0.1.1",
|
||||
"coffee-script": "1.6.0",
|
||||
"lynx": "~0.1.1",
|
||||
"prom-client": "^11.1.3",
|
||||
"underscore": "~1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue