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') prom = require('prom-client')
Register = require('prom-client').register Register = require('prom-client').register
collectDefaultMetrics = prom.collectDefaultMetrics collectDefaultMetrics = prom.collectDefaultMetrics
@ -20,6 +19,8 @@ module.exports = Metrics =
appname = _name appname = _name
collectDefaultMetrics({ timeout: 5000, prefix: Metrics.buildPromKey()}) collectDefaultMetrics({ timeout: 5000, prefix: Metrics.buildPromKey()})
logger = require("logger-sharelatex")
logger.log("ENABLE_TRACE_AGENT set to #{process.env['ENABLE_TRACE_AGENT']}") logger.log("ENABLE_TRACE_AGENT set to #{process.env['ENABLE_TRACE_AGENT']}")
if process.env['ENABLE_TRACE_AGENT'] == "true" if process.env['ENABLE_TRACE_AGENT'] == "true"
logger.log("starting google trace agent") logger.log("starting google trace agent")
@ -34,12 +35,24 @@ module.exports = Metrics =
logger.log("starting google debug agent") logger.log("starting google debug agent")
debugAgent = require('@google-cloud/debug-agent') debugAgent = require('@google-cloud/debug-agent')
debugAgent.start({ debugAgent.start({
serviceContext: {
allowExpressions: true, allowExpressions: true,
serviceContext: {
service: appname, service: appname,
version: process.env['BUILD_VERSION'] 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") Metrics.inc("process_startup")
registerDestructor: (func) -> registerDestructor: (func) ->

View file

@ -1,6 +1,6 @@
{ {
"name": "metrics-sharelatex", "name": "metrics-sharelatex",
"version": "2.0.11", "version": "2.0.12",
"description": "A drop-in metrics and monitoring module for node.js apps", "description": "A drop-in metrics and monitoring module for node.js apps",
"repository": { "repository": {
"type": "git", "type": "git",
@ -12,6 +12,7 @@
"prom-client": "^11.1.3", "prom-client": "^11.1.3",
"underscore": "~1.6.0", "underscore": "~1.6.0",
"@google-cloud/debug-agent": "^3.0.0", "@google-cloud/debug-agent": "^3.0.0",
"@google-cloud/profiler": "^0.2.3",
"@google-cloud/trace-agent": "^3.2.0" "@google-cloud/trace-agent": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {