add ENABLE_DEBUG_AGENT and don't require modules unless they are enabled

This commit is contained in:
Henry Oswald 2018-12-11 15:46:29 +00:00
parent 299f132bd7
commit c257482e15
2 changed files with 14 additions and 10 deletions

View file

@ -1,5 +1,3 @@
debugAgent = require('@google-cloud/debug-agent')
traceAgent = require('@google-cloud/trace-agent')
prom = require('prom-client')
Register = require('prom-client').register
@ -21,17 +19,23 @@ module.exports = Metrics =
initialize: (_name) ->
appname = _name
collectDefaultMetrics({ timeout: 5000, prefix: Metrics.buildPromKey()})
if process.env['ENABLE_TRACE_AGENT'] == "true"
traceAgent = require('@google-cloud/trace-agent')
traceOpts =
ignoreUrls: [/^\/status/, /^\/health_check/]
traceAgent.start(traceOpts)
debugAgent.start({
serviceContext: {
allowExpressions: true,
service: appname,
version: process.env['BUILD_VERSION']
}
})
if process.env['ENABLE_DEBUG_AGENT'] == "true"
debugAgent = require('@google-cloud/debug-agent')
debugAgent.start({
serviceContext: {
allowExpressions: true,
service: appname,
version: process.env['BUILD_VERSION']
}
})
Metrics.inc("process_startup")
registerDestructor: (func) ->

View file

@ -1,6 +1,6 @@
{
"name": "metrics-sharelatex",
"version": "2.0.10",
"version": "2.0.11",
"description": "A drop-in metrics and monitoring module for node.js apps",
"repository": {
"type": "git",