From c958edc4c480e0ceeb246df0221074dee18a5266 Mon Sep 17 00:00:00 2001 From: Matt Loring Date: Fri, 9 Dec 2016 14:38:07 -0800 Subject: [PATCH] Remove unncessary environment variables --- index.js | 10 ----- test/standalone/test-config-json.js | 36 ----------------- test/standalone/test-config-priority.js | 42 -------------------- test/standalone/test-config-relative-path.js | 37 ----------------- test/standalone/test-env-disable.js | 36 ----------------- 5 files changed, 161 deletions(-) delete mode 100644 test/standalone/test-config-json.js delete mode 100644 test/standalone/test-config-priority.js delete mode 100644 test/standalone/test-config-relative-path.js delete mode 100644 test/standalone/test-env-disable.js diff --git a/index.js b/index.js index 4caef9dec..f1b337b9a 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,6 @@ var SpanData = require('./src/span-data.js'); var common = require('@google/cloud-diagnostics-common'); var semver = require('semver'); var constants = require('./src/constants.js'); -var path = require('path'); var util = require('./src/util.js'); var modulesLoadedBeforeTrace = []; @@ -74,18 +73,9 @@ var initConfig = function(projectConfig) { var config = {}; util._extend(config, require('./config.js').trace); util._extend(config, projectConfig); - 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; } - if (process.env.hasOwnProperty('GCLOUD_TRACE_DISABLE')) { - config.enabled = false; - } if (process.env.hasOwnProperty('GCLOUD_PROJECT')) { config.projectId = process.env.GCLOUD_PROJECT; } diff --git a/test/standalone/test-config-json.js b/test/standalone/test-config-json.js deleted file mode 100644 index f6e2e97fa..000000000 --- a/test/standalone/test-config-json.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -var path = require('path'); -var assert = require('assert'); - -// Default configuration: -// { logLevel: 1, stackTraceLimit: 0, flushDelaySeconds: 30, samplingRate: 10 }; - -// Fixtures configuration: -// { logLevel: 4, stackTraceLimit: 1 }; -process.env.GCLOUD_DIAGNOSTICS_CONFIG = - path.join('test', 'fixtures', 'test-config.json'); - -var agent = require('../..').start(); - -describe('json config', function() { - it('should load trace config from json file', function() { - var config = agent.private_().config_; - assert.equal(config.logLevel, 4); - }); -}); diff --git a/test/standalone/test-config-priority.js b/test/standalone/test-config-priority.js deleted file mode 100644 index b78d2d38f..000000000 --- a/test/standalone/test-config-priority.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -var path = require('path'); -var assert = require('assert'); - -// Default configuration: -// { logLevel: 1, stackTraceLimit: 0, flushDelaySeconds: 30, samplingRate: 10 }; - -// Fixtures configuration: -// { logLevel: 4, stackTraceLimit: 1 }; -process.env.GCLOUD_DIAGNOSTICS_CONFIG = - path.join(__dirname, '..', 'fixtures', 'test-config.js'); - -process.env.GCLOUD_TRACE_LOGLEVEL = 2; - -var agent = require('../..').start({logLevel: 3, stackTraceLimit: 2, - flushDelaySeconds: 31}); - -describe('should respect config load order', function() { - it('should order Default -> start -> env config -> env specific', function() { - var config = agent.private_().config_; - assert.equal(config.logLevel, 2); - assert.equal(config.stackTraceLimit, 1); - assert.equal(config.flushDelaySeconds, 31); - assert.equal(config.samplingRate, 10); - }); -}); diff --git a/test/standalone/test-config-relative-path.js b/test/standalone/test-config-relative-path.js deleted file mode 100644 index b9a695ae6..000000000 --- a/test/standalone/test-config-relative-path.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -var path = require('path'); -var assert = require('assert'); - -// Default configuration: -// { logLevel: 1, stackTraceLimit: 0, flushDelaySeconds: 30, samplingRate: 10 }; - -// Fixtures configuration: -// { logLevel: 4, stackTraceLimit: 1 }; -process.env.GCLOUD_DIAGNOSTICS_CONFIG = path.join('fixtures', 'test-config.js'); - -process.chdir('test'); - -var agent = require('../..').start(); - -describe('relative config', function() { - it('should load trace config from relative path', function() { - var config = agent.private_().config_; - assert.equal(config.logLevel, 4); - }); -}); diff --git a/test/standalone/test-env-disable.js b/test/standalone/test-env-disable.js deleted file mode 100644 index 36279dade..000000000 --- a/test/standalone/test-env-disable.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -process.env.GCLOUD_TRACE_DISABLE = 1; - -var assert = require('assert'); -var agent = require('../..'); - -describe('should respect environment variables', function() { - it('should respect GCLOUD_TRACE_DISABLE', function() { - agent.start(); - assert(!agent.isActive()); - agent.stop(); - }); - - it('should prefer env to config', function() { - agent.start({enabled: true}); - assert(!agent.isActive()); - agent.stop(); - }); -});