Skip to content

Commit

Permalink
added env var for enabling diagnostic code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Clement committed Oct 7, 2019
1 parent 8a194e5 commit adba864
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ exports.config = () => ({
filter_cache_limit: 1000
},

code_injector: {
diagnostics: {
diagnostics: {
code_injector: {
enabled: false,
internal_file_pattern: /nodejs_agent\/(?:(?!test))|\/node_modules\/(?:@)?newrelic/
}
Expand Down
6 changes: 6 additions & 0 deletions lib/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const ENV_MAPPING = {
include: 'NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_INCLUDE'
}
},
diagnostics: {
code_injector: {
enabled: 'NEW_RELIC_DIAGNOSTICS_CODE_INJECTOR_ENABLED'
}
},
transaction_tracer: {
attributes: {
enabled: 'NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_ENABLED',
Expand Down Expand Up @@ -186,6 +191,7 @@ const BOOLEAN_VARS = new Set([
'NEW_RELIC_TRACER_ENABLED',
'NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_ENABLED',
'NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_ENABLED',
'NEW_RELIC_DIAGNOSTICS_CODE_INJECTOR_ENABLED',
'NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_ENABLED',
'NEW_RELIC_DEBUG_METRICS',
'NEW_RELIC_DEBUG_TRACER',
Expand Down
7 changes: 7 additions & 0 deletions test/unit/config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ describe('the agent configuration', function() {
})
})

it('should pick up on diagnostics code injection', function() {
idempotentEnv({'NEW_RELIC_DIAGNOSTICS_CODE_INJECTOR_ENABLED': true}, function(tc) {
should.exist(tc.diagnostics.code_injector.enabled)
expect(tc.diagnostics.code_injector.enabled).to.equal(true)
})
})

it('should pick up the billing hostname', function() {
idempotentEnv({'NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS': 123}, function(tc) {
should.exist(tc.utilization.logical_processors)
Expand Down

0 comments on commit adba864

Please sign in to comment.