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

Commit f1faef6

Browse files
authored
Also try to detect serviceContext from Flex environment variables (#221)
1 parent a00ce2a commit f1faef6

File tree

2 files changed

+247
-278
lines changed

2 files changed

+247
-278
lines changed

src/agent/debuglet.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,21 @@ function Debuglet(debug, config) {
140140
util.inherits(Debuglet, EventEmitter);
141141

142142
Debuglet.prototype.normalizeConfig_ = function(config) {
143-
config = extend({}, defaultConfig, config);
143+
var envConfig = {
144+
logLevel: process.env.GCLOUD_DEBUG_LOGLEVEL,
145+
serviceContext: {
146+
service: process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME,
147+
version: process.env.GAE_VERSION || process.env.GAE_MODULE_VERSION
148+
}
149+
};
150+
151+
config = extend({}, defaultConfig, config, envConfig);
144152

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

150-
if (process.env.hasOwnProperty('GCLOUD_DEBUG_LOGLEVEL')) {
151-
config.logLevel = process.env.GCLOUD_DEBUG_LOGLEVEL;
152-
}
153-
if (process.env.hasOwnProperty('GAE_MODULE_NAME')) {
154-
config.serviceContext = config.serviceContext || {};
155-
config.serviceContext.service = process.env.GAE_MODULE_NAME;
156-
}
157-
if (process.env.hasOwnProperty('GAE_MODULE_VERSION')) {
158-
config.serviceContext = config.serviceContext || {};
159-
config.serviceContext.version = process.env.GAE_MODULE_VERSION;
160-
}
161158
return config;
162159
};
163160

0 commit comments

Comments
 (0)