Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Also try to detect serviceContext from Flex environment variables (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots committed Jan 20, 2017
1 parent a00ce2a commit f1faef6
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 278 deletions.
21 changes: 9 additions & 12 deletions src/agent/debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,21 @@ function Debuglet(debug, config) {
util.inherits(Debuglet, EventEmitter);

Debuglet.prototype.normalizeConfig_ = function(config) {
config = extend({}, defaultConfig, config);
var envConfig = {
logLevel: process.env.GCLOUD_DEBUG_LOGLEVEL,
serviceContext: {
service: process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME,
version: process.env.GAE_VERSION || process.env.GAE_MODULE_VERSION
}
};

config = extend({}, defaultConfig, config, envConfig);

if (config.keyFilename || config.credentials || config.projectId) {
throw new Error('keyFilename, projectId or credentials should be provided' +
' to the Debug module constructor rather than startAgent');
}

if (process.env.hasOwnProperty('GCLOUD_DEBUG_LOGLEVEL')) {
config.logLevel = process.env.GCLOUD_DEBUG_LOGLEVEL;
}
if (process.env.hasOwnProperty('GAE_MODULE_NAME')) {
config.serviceContext = config.serviceContext || {};
config.serviceContext.service = process.env.GAE_MODULE_NAME;
}
if (process.env.hasOwnProperty('GAE_MODULE_VERSION')) {
config.serviceContext = config.serviceContext || {};
config.serviceContext.version = process.env.GAE_MODULE_VERSION;
}
return config;
};

Expand Down

0 comments on commit f1faef6

Please sign in to comment.