Skip to content

Commit 7952dd8

Browse files
committed
feat(configReader): add HTTP_PROXY
1 parent 397bdf5 commit 7952dd8

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

lib/utils/configReader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ConfigReader.prototype._getEnvVarConfig = function () {
6363
disableInstrumentations: process.env.TRACE_DISABLE_INSTRUMENTATIONS
6464
? process.env.TRACE_DISABLE_INSTRUMENTATIONS.split(',')
6565
: undefined,
66-
proxy: process.env.TRACE_PROXY
66+
proxy: process.env.TRACE_PROXY || process.env.HTTP_PROXY
6767
}
6868

6969
var ignoreHeaders

lib/utils/configReader.spec.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ describe('Config Reader module', function () {
331331
var configReader = ConfigReader.create({
332332
apiKey: 'test',
333333
reporter: 'dummy',
334-
configPath: 'test'
334+
serviceName: 'test'
335335
})
336336

337337
try {
@@ -345,6 +345,39 @@ describe('Config Reader module', function () {
345345
})
346346

347347
describe('config variable', function () {
348+
describe('traceProxy', function () {
349+
it('should be configurable with the HTTP_PROXY env var', function () {
350+
this.sandbox.stub(process, 'env', {
351+
HTTP_PROXY: 'http://proxy.com'
352+
})
353+
354+
var configReader = ConfigReader.create({
355+
apiKey: testApiToken,
356+
reporter: 'dummy',
357+
serviceName: 'test'
358+
})
359+
360+
var config = configReader.getConfig()
361+
362+
expect(config.proxy).to.equal('http://proxy.com')
363+
})
364+
it('TRACE_PROXY env var takes precedence over HTTP_PROXY', function () {
365+
this.sandbox.stub(process, 'env', {
366+
TRACE_PROXY: 'http://trace-proxy.com',
367+
HTTP_PROXY: 'http://proxy.com'
368+
})
369+
370+
var configReader = ConfigReader.create({
371+
apiKey: testApiToken,
372+
reporter: 'dummy',
373+
serviceName: 'test'
374+
})
375+
376+
var config = configReader.getConfig()
377+
378+
expect(config.proxy).to.equal('http://trace-proxy.com')
379+
})
380+
})
348381
describe('disableInstrumentations', function () {
349382
it('defaults to []', function () {
350383
var configReader = ConfigReader.create({

0 commit comments

Comments
 (0)