Merge pull request #15 from sharelatex/ho-profiler

add google profiler
This commit is contained in:
Henry Oswald 2018-12-13 14:18:35 +00:00 committed by GitHub
commit f0fd0299fe
2 changed files with 17 additions and 3 deletions

View file

@ -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) ->

View file

@ -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": {