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