diff --git a/libraries/metrics/metrics.coffee b/libraries/metrics/metrics.coffee index 95dad3a44f..963c471294 100644 --- a/libraries/metrics/metrics.coffee +++ b/libraries/metrics/metrics.coffee @@ -1,4 +1,3 @@ - prom = require('prom-client') Register = require('prom-client').register collectDefaultMetrics = prom.collectDefaultMetrics @@ -20,6 +19,8 @@ module.exports = Metrics = appname = _name collectDefaultMetrics({ timeout: 5000, prefix: Metrics.buildPromKey()}) + logger = require("logger-sharelatex") + logger.log("ENABLE_TRACE_AGENT set to #{process.env['ENABLE_TRACE_AGENT']}") if process.env['ENABLE_TRACE_AGENT'] == "true" logger.log("starting google trace agent") @@ -34,12 +35,24 @@ module.exports = Metrics = logger.log("starting google debug agent") debugAgent = require('@google-cloud/debug-agent') debugAgent.start({ + allowExpressions: true, serviceContext: { - allowExpressions: true, service: appname, version: process.env['BUILD_VERSION'] } }) + + logger.log("ENABLE_PROFILE_AGENT set to #{process.env['ENABLE_PROFILE_AGENT']}") + if process.env['ENABLE_PROFILE_AGENT'] == "true" + logger.log("starting google profile agent") + profiler = require('@google-cloud/profiler') + profiler.start({ + serviceContext: { + service: appname, + version: process.env['BUILD_VERSION'] + } + }) + Metrics.inc("process_startup") registerDestructor: (func) -> diff --git a/libraries/metrics/package.json b/libraries/metrics/package.json index bbfcaa7f9d..5d9d068ba1 100644 --- a/libraries/metrics/package.json +++ b/libraries/metrics/package.json @@ -1,6 +1,6 @@ { "name": "metrics-sharelatex", - "version": "2.0.11", + "version": "2.0.12", "description": "A drop-in metrics and monitoring module for node.js apps", "repository": { "type": "git", @@ -12,6 +12,7 @@ "prom-client": "^11.1.3", "underscore": "~1.6.0", "@google-cloud/debug-agent": "^3.0.0", + "@google-cloud/profiler": "^0.2.3", "@google-cloud/trace-agent": "^3.2.0" }, "devDependencies": {