mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Get default Prometheus metrics working
This commit is contained in:
parent
31e97f92d5
commit
f604fb92e5
1 changed files with 11 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
||||||
StatsD = require('lynx')
|
StatsD = require('lynx')
|
||||||
statsd = new StatsD(process.env["STATSD_HOST"] or "localhost", 8125, {on_error:->})
|
statsd = new StatsD(process.env["STATSD_HOST"] or "localhost", 8125, {on_error:->})
|
||||||
|
|
||||||
|
prom = require('prom-client')
|
||||||
|
Register = require('prom-client').register
|
||||||
|
collectDefaultMetrics = prom.collectDefaultMetrics
|
||||||
|
|
||||||
name = "unknown"
|
name = "unknown"
|
||||||
hostname = require('os').hostname()
|
hostname = require('os').hostname()
|
||||||
|
|
||||||
|
@ -14,10 +18,17 @@ require "./uv_threadpool_size"
|
||||||
module.exports = Metrics =
|
module.exports = Metrics =
|
||||||
initialize: (_name) ->
|
initialize: (_name) ->
|
||||||
name = _name
|
name = _name
|
||||||
|
collectDefaultMetrics({ timeout: 5000, prefix: name })
|
||||||
|
|
||||||
registerDestructor: (func) ->
|
registerDestructor: (func) ->
|
||||||
destructors.push func
|
destructors.push func
|
||||||
|
|
||||||
|
injectMetricsRoute: (app) ->
|
||||||
|
app.get('/metrics', (req, res) ->
|
||||||
|
res.set('Content-Type', Register.contentType)
|
||||||
|
res.end(Register.metrics())
|
||||||
|
)
|
||||||
|
|
||||||
set : (key, value, sampleRate = 1)->
|
set : (key, value, sampleRate = 1)->
|
||||||
statsd.set buildKey(key), value, sampleRate
|
statsd.set buildKey(key), value, sampleRate
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue