Skip to content

Commit

Permalink
Change config format to support multiple agents
Browse files Browse the repository at this point in the history
The environment variable name for the config file has been updated to
the more general GCLOUD_CONFIG. The config file is also now structured
to support separate configs for each of the profile, debug, and trace
agents.
  • Loading branch information
Matt Loring committed Jan 7, 2016
1 parent a160e16 commit 3e150a6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ var initConfig = function(projectConfig) {
var config = {};
util._extend(config, require('./config.js'));
util._extend(config, projectConfig);
if (process.env.hasOwnProperty('GCLOUD_TRACE_CONFIG')) {
util._extend(config, require(path.resolve(process.env.GCLOUD_TRACE_CONFIG)));
if (process.env.hasOwnProperty('GCLOUD_DIAGNOSTICS_CONFIG')) {
var c = require(path.resolve(process.env.GCLOUD_DIAGNOSTICS_CONFIG));
if (c) {
util._extend(config, c.trace);
}
}
if (process.env.hasOwnProperty('GCLOUD_TRACE_LOGLEVEL')) {
config.logLevel = process.env.GCLOUD_TRACE_LOGLEVEL;
Expand Down
11 changes: 5 additions & 6 deletions test/fixtures/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
'use strict';

module.exports = {
logLevel: 4,

stackTraceLimit: 1,

flushDelaySeconds: 31

trace: {
logLevel: 4,
stackTraceLimit: 1,
flushDelaySeconds: 31
}
};

11 changes: 5 additions & 6 deletions test/fixtures/test-config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"logLevel": 4,

"stackTraceLimit": 1,

"flushDelaySeconds": 31
"trace": {
"logLevel": 4,
"stackTraceLimit": 1,
"flushDelaySeconds": 31
}
}

3 changes: 2 additions & 1 deletion test/standalone/test-config-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var assert = require('assert');

// Fixtures configuration:
// { logLevel: 4, stackTraceLimit: 1 };
process.env.GCLOUD_TRACE_CONFIG = path.join('test', 'fixtures', 'test-config.json');
process.env.GCLOUD_DIAGNOSTICS_CONFIG =
path.join('test', 'fixtures', 'test-config.json');

var agent = require('../..').start();

Expand Down
2 changes: 1 addition & 1 deletion test/standalone/test-config-priority.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var assert = require('assert');

// Fixtures configuration:
// { logLevel: 4, stackTraceLimit: 1 };
process.env.GCLOUD_TRACE_CONFIG =
process.env.GCLOUD_DIAGNOSTICS_CONFIG =
path.join(__dirname, '..', 'fixtures', 'test-config.js');

process.env.GCLOUD_TRACE_LOGLEVEL = 2;
Expand Down
2 changes: 1 addition & 1 deletion test/standalone/test-config-relative-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var assert = require('assert');

// Fixtures configuration:
// { logLevel: 4, stackTraceLimit: 1 };
process.env.GCLOUD_TRACE_CONFIG = path.join('fixtures', 'test-config.js');
process.env.GCLOUD_DIAGNOSTICS_CONFIG = path.join('fixtures', 'test-config.js');

process.chdir('test');

Expand Down

0 comments on commit 3e150a6

Please sign in to comment.