Make register public so we can support other servers e.g. hapi

This commit is contained in:
Christopher Hoskin 2019-01-15 15:36:35 +00:00
parent f0fd0299fe
commit 93bef54c39

View file

@ -1,5 +1,5 @@
prom = require('prom-client')
Register = require('prom-client').register
collectDefaultMetrics = prom.collectDefaultMetrics
appname = "unknown"
@ -15,6 +15,7 @@ destructors = []
require "./uv_threadpool_size"
module.exports = Metrics =
register: require('prom-client').register
initialize: (_name) ->
appname = _name
collectDefaultMetrics({ timeout: 5000, prefix: Metrics.buildPromKey()})
@ -60,8 +61,8 @@ module.exports = Metrics =
injectMetricsRoute: (app) ->
app.get('/metrics', (req, res) ->
res.set('Content-Type', Register.contentType)
res.end(Register.metrics())
res.set('Content-Type', register.contentType)
res.end(register.metrics())
)
buildPromKey: (key = "")->