newrelic 9.5.0 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,57 +5,73 @@
5
5
 
6
6
  'use strict'
7
7
 
8
+ const defaultConfig = module.exports
9
+ const { array, int, float, boolean, object, objectList, allowList } = require('./formatters')
10
+
8
11
  /**
12
+ * A function that returns the definition of the agent configuration
9
13
  * This file includes all of the configuration variables used by the Node.js
10
14
  * module. If there's a configurable element of the module and it's not
11
15
  * described in here, there's been a terrible mistake.
16
+ *
17
+ * This is used to set a default value, a formatter to run when assigning the value, and
18
+ * an override if the env var does not follow our standard convention. We should not have
19
+ * to add any more overrides as all new configuration values should follow the convention of
20
+ * `NEW_RELIC_PATH_TO_CONFIG_KEY`
12
21
  */
22
+ defaultConfig.definition = () => ({
23
+ newrelic_home: {
24
+ env: 'NEW_RELIC_HOME',
25
+ default: null
26
+ },
13
27
 
14
- exports.config = () => ({
15
28
  /**
16
29
  * Array of application names.
17
- *
18
- * @env NEW_RELIC_APP_NAME
19
30
  */
20
- app_name: [],
31
+ app_name: {
32
+ formatter(val) {
33
+ return val.split(/;|,/).map((k) => k.trim())
34
+ },
35
+ default: []
36
+ },
21
37
  /**
22
38
  * The user's license key. Must be set by per-app configuration file.
23
- *
24
- * @env NEW_RELIC_LICENSE_KEY
25
39
  */
26
40
  license_key: '',
27
41
  /**
28
42
  *
29
43
  * Enables/Disables security policies. Paste your security policies
30
44
  * token from the New Relic Admin below.
31
- *
32
- * @env NEW_RELIC_SECURITY_POLICIES_TOKEN
33
45
  */
34
46
  security_policies_token: '',
35
47
  /**
36
48
  * Hostname for the New Relic collector proxy.
37
49
  *
38
50
  * You shouldn't need to change this.
39
- *
40
- * @env NEW_RELIC_HOST
41
51
  */
42
52
  host: '',
43
53
  /**
44
54
  * The port on which the collector proxy will be listening.
45
55
  *
46
56
  * You shouldn't need to change this.
47
- *
48
- * @env NEW_RELIC_PORT
49
57
  */
50
- port: 443,
58
+ port: {
59
+ formatter: int,
60
+ default: 443
61
+ },
51
62
  /**
52
63
  * Whether or not to use SSL to connect to New Relic's servers.
53
64
  *
54
65
  * NOTE: This option can no longer be disabled.
55
- *
56
- * @env NEW_RELIC_USE_SSL
57
66
  */
58
- ssl: true,
67
+ ssl: {
68
+ env: 'NEW_RELIC_USE_SSL',
69
+ formatter(_, logger) {
70
+ logger.warn('SSL config key can no longer be disabled, not updating.')
71
+ return true
72
+ },
73
+ default: true
74
+ },
59
75
  /**
60
76
  * Proxy url
61
77
  *
@@ -65,38 +81,37 @@ exports.config = () => ({
65
81
  * e.g. http://user:pass@host:port/
66
82
  *
67
83
  * Setting proxy will override other proxy settings.
68
- *
69
- * @env NEW_RELIC_PROXY_URL
70
84
  */
71
- proxy: '',
85
+ proxy: {
86
+ env: 'NEW_RELIC_PROXY_URL',
87
+ default: ''
88
+ },
72
89
  /**
73
90
  * Proxy host to use to connect to the internet.
74
- *
75
- * @env NEW_RELIC_PROXY_HOST
76
91
  */
77
92
  proxy_host: '',
78
93
  /**
79
94
  * Proxy port to use to connect to the internet.
80
- *
81
- * @env NEW_RELIC_PROXY_PORT
82
95
  */
83
96
  proxy_port: '',
84
97
  /**
85
98
  * Proxy user name when required.
86
- *
87
- * @env NEW_RELIC_PROXY_USER
88
99
  */
89
100
  proxy_user: '',
90
101
  /**
91
102
  * Proxy password when required.
92
- *
93
- * @env NEW_RELIC_PROXY_PASS
94
103
  */
95
104
  proxy_pass: '',
96
105
  // Serverless DT config defaults
97
- trusted_account_key: null,
98
- primary_application_id: null,
99
- account_id: null,
106
+ trusted_account_key: {
107
+ default: null
108
+ },
109
+ primary_application_id: {
110
+ default: null
111
+ },
112
+ account_id: {
113
+ default: null
114
+ },
100
115
  /**
101
116
  * Custom SSL certificates
102
117
  *
@@ -110,13 +125,18 @@ exports.config = () => ({
110
125
  * ]
111
126
  *
112
127
  */
113
- certificates: [],
128
+ certificates: {
129
+ formatter: array,
130
+ default: []
131
+ },
114
132
  /**
115
133
  * Whether the module is enabled.
116
- *
117
- * @env NEW_RELIC_ENABLED
118
134
  */
119
- agent_enabled: true,
135
+ agent_enabled: {
136
+ env: 'NEW_RELIC_ENABLED',
137
+ formatter: boolean,
138
+ default: true
139
+ },
120
140
  /**
121
141
  * The default Apdex tolerating / threshold value for applications, in
122
142
  * seconds. The default for Node is apdexT to 100 milliseconds, which is
@@ -128,24 +148,25 @@ exports.config = () => ({
128
148
  *
129
149
  * @see https://docs.newrelic.com/docs/apm/new-relic-apm/apdex/changing-your-apdex-settings
130
150
  */
131
- apdex_t: 0.1,
132
-
151
+ apdex_t: {
152
+ formatter: float,
153
+ default: 0.1
154
+ },
133
155
  /**
134
156
  * When true, all request headers except for those listed in attributes.exclude
135
157
  * will be captured for all traces, unless otherwise specified in a destination's
136
158
  * attributes include/exclude lists.
137
- *
138
- * @env NEW_RELIC_ALLOW_ALL_HEADERS
139
159
  */
140
- allow_all_headers: false,
160
+ allow_all_headers: {
161
+ formatter: boolean,
162
+ default: false
163
+ },
141
164
 
142
165
  /**
143
166
  * If the data compression threshold is reached in the payload, the
144
167
  * agent compresses data, using gzip compression by default. The
145
168
  * config option `compressed_content_encoding` can be set to 'deflate'
146
169
  * to use deflate compression.
147
- *
148
- * @env NEW_RELIC_COMPRESSED_CONTENT_ENCODING
149
170
  */
150
171
  compressed_content_encoding: 'gzip',
151
172
 
@@ -157,45 +178,51 @@ exports.config = () => ({
157
178
  /**
158
179
  * If `true`, enables capture of attributes for all destinations.
159
180
  * If there are specific parameters you want ignored, use `attributes.exclude`.
160
- *
161
- * @env NEW_RELIC_ATTRIBUTES_ENABLED
162
181
  */
163
- enabled: true,
182
+ enabled: {
183
+ formatter: boolean,
184
+ default: true
185
+ },
164
186
 
165
187
  /**
166
188
  * Prefix of attributes to exclude from all destinations. Allows * as wildcard at end.
167
189
  *
168
190
  * NOTE: If excluding headers, they must be in camelCase form to be filtered.
169
- *
170
- * @env NEW_RELIC_ATTRIBUTES_EXCLUDE
171
191
  */
172
- exclude: [],
192
+ exclude: {
193
+ formatter: array,
194
+ default: []
195
+ },
173
196
 
174
197
  /**
175
198
  * Prefix of attributes to include in all destinations. Allows * as wildcard at end.
176
199
  *
177
200
  * NOTE: If including headers, they must be in camelCase form to be filtered.
178
- *
179
- * @env NEW_RELIC_ATTRIBUTES_INCLUDE
180
201
  */
181
- include: [],
202
+ include: {
203
+ formatter: array,
204
+ default: []
205
+ },
182
206
 
183
207
  /**
184
208
  * If `true`, patterns may be added to the `attributes.include`
185
209
  * list.
186
- *
187
- * @env NEW_RELIC_ATTRIBUTES_INCLUDE_ENABLED
188
210
  */
189
- include_enabled: true,
211
+ include_enabled: {
212
+ formatter: boolean,
213
+ default: true
214
+ },
190
215
 
191
216
  /**
192
217
  * Controls how many attribute include/exclude rule results are cached by
193
218
  * the filter. Increasing this limit will cause greater memory usage and is
194
219
  * only necessary if you have an extremely high variety of attributes.
195
220
  */
196
- filter_cache_limit: 1000
221
+ filter_cache_limit: {
222
+ formatter: int,
223
+ default: 1000
224
+ }
197
225
  },
198
-
199
226
  logging: {
200
227
  /**
201
228
  * Verbosity of the module's logging. This module uses bunyan
@@ -204,42 +231,49 @@ exports.config = () => ({
204
231
  * 'trace'. Logging at levels 'info' and higher is very terse. For support
205
232
  * requests, attaching logs captured at 'trace' level are extremely helpful
206
233
  * in chasing down bugs.
207
- *
208
- * @env NEW_RELIC_LOG_LEVEL
209
234
  */
210
- level: 'info',
235
+ level: {
236
+ default: 'info',
237
+ env: 'NEW_RELIC_LOG_LEVEL'
238
+ },
211
239
  /**
212
240
  * Where to put the log file -- by default just uses process.cwd +
213
241
  * 'newrelic_agent.log'. A special case is a filepath of 'stdout',
214
242
  * in which case all logging will go to stdout, or 'stderr', in which
215
243
  * case all logging will go to stderr.
216
- *
217
- * @env NEW_RELIC_LOG
218
244
  */
219
- filepath: require('path').join(process.cwd(), 'newrelic_agent.log'),
245
+ filepath: {
246
+ default: require('path').join(process.cwd(), 'newrelic_agent.log'),
247
+ env: 'NEW_RELIC_LOG'
248
+ },
220
249
  /**
221
250
  * Whether to write to a log file at all
222
- *
223
- * @env NEW_RELIC_LOG_ENABLED
224
251
  */
225
- enabled: true,
252
+ enabled: {
253
+ formatter: boolean,
254
+ default: true,
255
+ env: 'NEW_RELIC_LOG_ENABLED'
256
+ },
226
257
 
227
258
  /**
228
259
  * Enables extra debugging at `warn` level. No need to enable except under
229
260
  * specific debugging conditions.
230
261
  */
231
- diagnostics: false
262
+ diagnostics: {
263
+ formatter: boolean,
264
+ deafult: false
265
+ }
232
266
  },
233
-
234
267
  audit_log: {
235
268
  /**
236
269
  * Enables logging of out bound traffic from the Agent to the Collector.
237
270
  * This field is ignored if trace level logging is enabled.
238
271
  * With trace logging, all traffic is logged.
239
- *
240
- * @env NEW_RELIC_AUDIT_LOG_ENABLED
241
272
  */
242
- enabled: false,
273
+ enabled: {
274
+ formatter: boolean,
275
+ default: false
276
+ },
243
277
 
244
278
  /**
245
279
  * Specify which methods are logged. Used in conjunction with the audit_log flag
@@ -247,44 +281,49 @@ exports.config = () => ({
247
281
  * Otherwise, if the audit log is enabled, only the methods specified
248
282
  * in the filter will be logged
249
283
  * Methods include: error_data, metric_data, and analytic_event_data
250
- *
251
- * @env NEW_RELIC_AUDIT_LOG_ENDPOINTS
252
284
  */
253
- endpoints: []
285
+ endpoints: {
286
+ formatter: array,
287
+ default: []
288
+ }
254
289
  },
255
290
  /**
256
291
  * Whether to collect & submit error traces to New Relic.
257
- *
258
- * @env NEW_RELIC_ERROR_COLLECTOR_ENABLED
259
292
  */
260
293
  error_collector: {
261
294
  attributes: {
262
295
  /**
263
296
  * If `true`, the agent captures attributes from error collection.
264
- *
265
- * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_ENABLED
266
297
  */
267
- enabled: true,
298
+ enabled: {
299
+ formatter: boolean,
300
+ default: true
301
+ },
268
302
  /**
269
303
  * Prefix of attributes to exclude from error collection.
270
304
  * Allows * as wildcard at end.
271
- *
272
- * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_EXCLUDE
273
305
  */
274
- exclude: [],
306
+ exclude: {
307
+ formatter: array,
308
+ default: []
309
+ },
275
310
  /**
276
311
  * Prefix of attributes to include in error collection.
277
312
  * Allows * as wildcard at end.
278
- *
279
- * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_INCLUDE
280
313
  */
281
- include: []
314
+ include: {
315
+ formatter: array,
316
+ default: []
317
+ }
282
318
  },
283
319
  /**
284
320
  * Disabling the error tracer just means that errors aren't collected
285
321
  * and sent to New Relic -- it DOES NOT remove any instrumentation.
286
322
  */
287
- enabled: true,
323
+ enabled: {
324
+ formatter: boolean,
325
+ default: true
326
+ },
288
327
  /**
289
328
  * List of HTTP error status codes the error tracer should disregard.
290
329
  * Ignoring a status code means that the transaction is not renamed to
@@ -295,14 +334,19 @@ exports.config = () => ({
295
334
  * `noticeError()`.
296
335
  *
297
336
  * Defaults to 404 NOT FOUND.
298
- *
299
- * @env NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERROR_CODES
300
337
  */
301
- ignore_status_codes: [404],
338
+ ignore_status_codes: {
339
+ env: 'NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERROR_CODES',
340
+ formatter: array,
341
+ default: [404]
342
+ },
302
343
  /**
303
344
  * Whether error events are collected.
304
345
  */
305
- capture_events: true,
346
+ capture_events: {
347
+ formatter: boolean,
348
+ default: true
349
+ },
306
350
  /**
307
351
  * The agent will collect all error events up to this number per minute.
308
352
  * If there are more than that, a statistical sampling will be collected.
@@ -313,16 +357,35 @@ exports.config = () => ({
313
357
  * Relic servers. The memory concerns are something you should consider for
314
358
  * your own server's sake. The payload of events is compressed, but if it
315
359
  * grows too large the New Relic servers may reject it.
316
- *
317
- * @env NEW_RELIC_ERROR_COLLECTOR_MAX_EVENT_SAMPLES_STORED
318
360
  */
319
- max_event_samples_stored: 100,
361
+ max_event_samples_stored: {
362
+ formatter: int,
363
+ default: 100
364
+ },
320
365
 
321
- expected_classes: [],
322
- expected_messages: {},
323
- expected_status_codes: [],
324
- ignore_classes: [],
325
- ignore_messages: {}
366
+ expected_classes: {
367
+ formatter: array,
368
+ default: [],
369
+ env: 'NEW_RELIC_ERROR_COLLECTOR_EXPECTED_ERRORS'
370
+ },
371
+ expected_messages: {
372
+ formatter: object,
373
+ default: {}
374
+ },
375
+ expected_status_codes: {
376
+ formatter: array,
377
+ default: [],
378
+ env: 'NEW_RELIC_ERROR_COLLECTOR_EXPECTED_ERROR_CODES'
379
+ },
380
+ ignore_classes: {
381
+ formatter: array,
382
+ default: [],
383
+ env: 'NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERRORS'
384
+ },
385
+ ignore_messages: {
386
+ formatter: object,
387
+ default: {}
388
+ }
326
389
  },
327
390
  /**
328
391
  * Error message redaction
@@ -334,10 +397,11 @@ exports.config = () => ({
334
397
  /**
335
398
  * When `true`, the agent will redact the messages of captured
336
399
  * errors.
337
- *
338
- * @env NEW_RELIC_STRIP_EXCEPTION_MESSAGES_ENABLED
339
400
  */
340
- enabled: false
401
+ enabled: {
402
+ formatter: boolean,
403
+ default: false
404
+ }
341
405
  },
342
406
  /**
343
407
  * Options regarding collecting system information. Used for system
@@ -347,80 +411,104 @@ exports.config = () => ({
347
411
  /**
348
412
  * This flag dictates whether the agent attempts to reach out to AWS
349
413
  * to get info about the vm the process is running on.
350
- *
351
- * @env NEW_RELIC_UTILIZATION_DETECT_AWS
352
414
  */
353
- detect_aws: true,
415
+ detect_aws: {
416
+ formatter: boolean,
417
+ default: true
418
+ },
354
419
  /**
355
420
  * This flag dictates whether the agent attempts to detect if the
356
421
  * the process is running on Pivotal Cloud Foundry.
357
- *
358
- * @env NEW_RELIC_UTILIZATION_DETECT_PCF
359
422
  */
360
- detect_pcf: true,
423
+ detect_pcf: {
424
+ formatter: boolean,
425
+ default: true
426
+ },
361
427
  /**
362
428
  * This flag dictates whether the agent attempts to reach out to Azure to
363
429
  * get info about the vm the process is running on.
364
- *
365
- * @env NEW_RELIC_UTILIZATION_DETECT_AZURE
366
430
  */
367
- detect_azure: true,
431
+ detect_azure: {
432
+ formatter: boolean,
433
+ default: true
434
+ },
368
435
  /**
369
436
  * This flag dictates whether the agent attempts to read files
370
437
  * to get info about the container the process is running in.
371
438
  *
372
439
  * @env NEW_RELIC_UTILIZATION_DETECT_DOCKER
373
440
  */
374
- detect_docker: true,
441
+ detect_docker: {
442
+ formatter: boolean,
443
+ default: true
444
+ },
375
445
 
376
446
  /**
377
447
  * This flag dictates whether the agent attempts to reach out to GCP
378
448
  * to get info about the vm the process is running on.
379
- *
380
- * @env NEW_RELIC_UTILIZATION_DETECT_GCP
381
449
  */
382
- detect_gcp: true,
450
+ detect_gcp: {
451
+ formatter: boolean,
452
+ default: true
453
+ },
383
454
 
384
455
  /**
385
456
  * This flag dictates whether the agent attempts to reach out to
386
457
  * Kubernetes to get info about the container the process is running on.
387
- *
388
- * @env NEW_RELIC_UTILIZATION_DETECT_KUBERNETES
389
458
  */
390
- detect_kubernetes: true
459
+ detect_kubernetes: {
460
+ formatter: boolean,
461
+ default: true
462
+ },
463
+ logical_processors: {
464
+ formatter: float,
465
+ default: null
466
+ },
467
+ billing_hostname: {
468
+ default: null
469
+ },
470
+ total_ram_mib: {
471
+ formatter: int,
472
+ default: null
473
+ }
391
474
  },
392
475
  transaction_tracer: {
393
476
  attributes: {
394
477
  /**
395
478
  * If `true`, the agent captures attributes from transaction traces.
396
- *
397
- * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_ENABLED
398
479
  */
399
- enabled: true,
480
+ enabled: {
481
+ formatter: boolean,
482
+ default: true
483
+ },
400
484
  /**
401
485
  * Prefix of attributes to exclude from transaction traces.
402
486
  * Allows * as wildcard at end.
403
- *
404
- * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_EXCLUDE
405
487
  */
406
- exclude: [],
488
+ exclude: {
489
+ formatter: array,
490
+ default: []
491
+ },
407
492
  /**
408
493
  * Prefix of attributes to include in transaction traces.
409
494
  * Allows * as wildcard at end.
410
- *
411
- * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_INCLUDE
412
495
  */
413
- include: []
496
+ include: {
497
+ formatter: array,
498
+ default: []
499
+ }
414
500
  },
415
501
  /**
416
502
  * Whether to collect & submit slow transaction traces to New Relic. The
417
503
  * instrumentation is loaded regardless of this setting, as it's necessary
418
504
  * to gather metrics. Disable the agent to prevent the instrumentation from
419
505
  * loading.
420
- *
421
- * @env NEW_RELIC_TRACER_ENABLED
422
506
  */
423
- enabled: true,
507
+ enabled: {
508
+ formatter: boolean,
509
+ default: true,
510
+ env: 'NEW_RELIC_TRACER_ENABLED'
511
+ },
424
512
  /**
425
513
  * The duration at below which the slow transaction tracer should collect a
426
514
  * transaction trace. If set to 'apdex_f', the threshold will be set to
@@ -428,10 +516,12 @@ exports.config = () => ({
428
516
  * be 2 seconds.
429
517
  *
430
518
  * If a time is provided, it is set in seconds.
431
- *
432
- * @env NEW_RELIC_TRACER_THRESHOLD
433
519
  */
434
- transaction_threshold: 'apdex_f',
520
+ transaction_threshold: {
521
+ formatter: float,
522
+ default: 'apdex_f',
523
+ env: 'NEW_RELIC_TRACER_THRESHOLD'
524
+ },
435
525
  /**
436
526
  * Increase this parameter to increase the diversity of the slow
437
527
  * transaction traces recorded by your application over time. Confused?
@@ -457,7 +547,11 @@ exports.config = () => ({
457
547
  *
458
548
  * @env NEW_RELIC_TRACER_TOP_N
459
549
  */
460
- top_n: 20,
550
+ top_n: {
551
+ formatter: int,
552
+ default: 20,
553
+ env: 'NEW_RELIC_TRACER_TOP_N'
554
+ },
461
555
 
462
556
  /**
463
557
  * This option affects both slow-queries and record_sql for transaction
@@ -467,31 +561,23 @@ exports.config = () => ({
467
561
  * or 'obfuscated' and other criteria (slow_sql.enabled etc) are met
468
562
  * for a query. The raw or obfuscated sql will be included in the
469
563
  * transaction trace and a slow query sample will be collected.
470
- *
471
- * @env NEW_RELIC_RECORD_SQL
472
564
  */
473
- record_sql: 'off',
565
+ record_sql: {
566
+ formatter: allowList.bind(null, ['off', 'obfuscated', 'raw']),
567
+ default: 'off',
568
+ env: 'NEW_RELIC_RECORD_SQL'
569
+ },
474
570
 
475
571
  /**
476
572
  * This option affects both slow-queries and record_sql for transaction
477
573
  * traces. This is the minimum duration a query must take (in ms) for it
478
574
  * to be considered for for slow query and inclusion in transaction traces.
479
575
  */
480
- explain_threshold: 500,
481
-
482
- /**
483
- * This option controls the enumerability of internal properties the agent
484
- * puts on application objects such as requests and promises while tracing.
485
- * When `true`, these properties will be configured with `enumerable: false`
486
- * using `Object.defineProperty`.
487
- *
488
- * XXX: This can have a significant impact on application performance, so if
489
- * this is not necessary for your application we recommend disabling the
490
- * feature.
491
- *
492
- * @env NEW_RELIC_HIDE_INTERNALS
493
- */
494
- hide_internals: true
576
+ explain_threshold: {
577
+ formatter: int,
578
+ default: 500,
579
+ env: 'NEW_RELIC_EXPLAIN_THRESHOLD'
580
+ }
495
581
  },
496
582
  /**
497
583
  * Rules for naming or ignoring transactions.
@@ -504,10 +590,12 @@ exports.config = () => ({
504
590
  * are ignored. Patterns may have capture groups (following JavaScript
505
591
  * conventions), and names will use $1-style replacement strings. See
506
592
  * the documentation for addNamingRule for important caveats.
507
- *
508
- * @env NEW_RELIC_NAMING_RULES
509
593
  */
510
- name: [],
594
+ name: {
595
+ formatter: objectList,
596
+ default: [],
597
+ env: 'NEW_RELIC_NAMING_RULES'
598
+ },
511
599
  /**
512
600
  * A list of patterns for matching incoming request URLs to be ignored by
513
601
  * the agent. Patterns may be strings or regular expressions.
@@ -516,7 +604,11 @@ exports.config = () => ({
516
604
  *
517
605
  * @env NEW_RELIC_IGNORING_RULES
518
606
  */
519
- ignore: ['^/socket.io/.*/xhr-polling/']
607
+ ignore: {
608
+ formatter: array,
609
+ default: ['^/socket.io/.*/xhr-polling/'],
610
+ env: 'NEW_RELIC_IGNORING_RULES'
611
+ }
520
612
  },
521
613
  /**
522
614
  * By default, any transactions that are not affected by other bits of
@@ -527,10 +619,11 @@ exports.config = () => ({
527
619
  * metric grouping issues and are confident your application isn't going
528
620
  * to run afoul of them. Your application could end up getting blocked!
529
621
  * Nobody wants that.
530
- *
531
- * @env NEW_RELIC_ENFORCE_BACKSTOP
532
622
  */
533
- enforce_backstop: true,
623
+ enforce_backstop: {
624
+ formatter: boolean,
625
+ default: true
626
+ },
534
627
  /**
535
628
  * Browser Monitoring
536
629
  *
@@ -542,24 +635,27 @@ exports.config = () => ({
542
635
  attributes: {
543
636
  /**
544
637
  * If `true`, the agent captures attributes from browser monitoring.
545
- *
546
- * @env NEW_RELIC_BROWSER_MONITOR_ATTRIBUTES
547
638
  */
548
- enabled: false,
639
+ enabled: {
640
+ formatter: boolean,
641
+ default: false
642
+ },
549
643
  /**
550
644
  * Prefix of attributes to exclude from browser monitoring.
551
645
  * Allows * as wildcard at end.
552
- *
553
- * @env NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_EXCLUDE
554
646
  */
555
- exclude: [],
647
+ exclude: {
648
+ formatter: array,
649
+ default: []
650
+ },
556
651
  /**
557
652
  * Prefix of attributes to include in browser monitoring.
558
653
  * Allows * as wildcard at end.
559
- *
560
- * @env NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_INCLUDE
561
654
  */
562
- include: []
655
+ include: {
656
+ formatter: array,
657
+ default: []
658
+ }
563
659
  },
564
660
  /**
565
661
  * Enable browser monitoring header generation.
@@ -587,16 +683,20 @@ exports.config = () => ({
587
683
  * time you want to generate the headers.
588
684
  *
589
685
  * Do *not* reuse the headers between users, or even between requests.
590
- *
591
- * @env NEW_RELIC_BROWSER_MONITOR_ENABLE
592
686
  */
593
- enable: true,
687
+ enable: {
688
+ formatter: boolean,
689
+ default: true,
690
+ env: 'NEW_RELIC_BROWSER_MONITOR_ENABLE'
691
+ },
594
692
  /**
595
693
  * Request un-minified sources from the server.
596
- *
597
- * @env NEW_RELIC_BROWSER_MONITOR_DEBUG
598
694
  */
599
- debug: false
695
+ debug: {
696
+ formatter: boolean,
697
+ default: false,
698
+ env: 'NEW_RELIC_BROWSER_MONITOR_DEBUG'
699
+ }
600
700
  },
601
701
  /**
602
702
  * API Configuration
@@ -608,29 +708,35 @@ exports.config = () => ({
608
708
  api: {
609
709
  /**
610
710
  * Controls for the `API.addCustomAttribute` method.
611
- *
612
- * @env NEW_RELIC_API_CUSTOM_ATTRIBUTES
613
711
  */
614
- custom_attributes_enabled: true,
712
+ custom_attributes_enabled: {
713
+ formatter: boolean,
714
+ default: true,
715
+ env: 'NEW_RELIC_API_CUSTOM_ATTRIBUTES'
716
+ },
615
717
  /**
616
718
  * Controls for the `API.recordCustomEvent` method.
617
- *
618
- * @env NEW_RELIC_API_CUSTOM_EVENTS
619
719
  */
620
- custom_events_enabled: true,
720
+ custom_events_enabled: {
721
+ formatter: boolean,
722
+ default: true,
723
+ env: 'NEW_RELIC_API_CUSTOM_EVENTS'
724
+ },
621
725
  /**
622
726
  * Controls for the `API.noticeError` method.
623
- *
624
- * @env NEW_RELIC_API_NOTICE_ERROR
625
727
  */
626
- notice_error_enabled: true,
728
+ notice_error_enabled: {
729
+ formatter: boolean,
730
+ default: true,
731
+ env: 'NEW_RELIC_API_NOTICE_ERROR'
732
+ },
627
733
  /**
628
734
  * Sets the path to custom ESM instrumentation
629
- *
630
- * @env NEW_RELIC_API_ESM_CUSTOM_INSTRUMENTATION_ENTRYPOINT
631
735
  */
632
736
  esm: {
633
- custom_instrumentation_entrypoint: null
737
+ custom_instrumentation_entrypoint: {
738
+ default: null
739
+ }
634
740
  }
635
741
  },
636
742
  /**
@@ -645,39 +751,49 @@ exports.config = () => ({
645
751
  attributes: {
646
752
  /**
647
753
  * If `true`, the agent captures attributes from transaction events.
648
- *
649
- * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_ENABLED
650
754
  */
651
- enabled: true,
755
+ enabled: {
756
+ formatter: boolean,
757
+ default: true
758
+ },
652
759
  /**
653
760
  * Prefix of attributes to exclude in transaction events.
654
761
  * Allows * as wildcard at end.
655
762
  *
656
763
  * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_EXCLUDE
657
764
  */
658
- exclude: [],
765
+ exclude: {
766
+ formatter: array,
767
+ default: []
768
+ },
659
769
  /**
660
770
  * Prefix of attributes to include in transaction events.
661
771
  * Allows * as wildcard at end.
662
772
  *
663
773
  * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_INCLUDE
664
774
  */
665
- include: []
775
+ include: {
776
+ formatter: array,
777
+ default: []
778
+ }
666
779
  },
667
780
  /**
668
781
  * If this is disabled, the agent does not collect, nor try to send,
669
782
  * analytic data.
670
783
  */
671
- enabled: true,
784
+ enabled: {
785
+ formatter: boolean,
786
+ default: true
787
+ },
672
788
  /**
673
789
  * The agent will collect all events up to this number per minute. If
674
790
  * there are more than that, a statistical sampling will be collected.
675
- *
676
- * @env NEW_RELIC_TRANSACTION_EVENTS_MAX_SAMPLES_STORED
677
791
  */
678
- max_samples_stored: 10000
792
+ max_samples_stored: {
793
+ formatter: int,
794
+ default: 10000
795
+ }
679
796
  },
680
-
681
797
  /**
682
798
  * Custom Insights Events
683
799
  *
@@ -693,7 +809,10 @@ exports.config = () => ({
693
809
  * If this is disabled, the agent does not collect, nor try to send, custom
694
810
  * event data.
695
811
  */
696
- enabled: true,
812
+ enabled: {
813
+ formatter: boolean,
814
+ default: true
815
+ },
697
816
  /**
698
817
  * The agent will collect all events up to this number per minute. If there
699
818
  * are more than that, a statistical sampling will be collected. Currently
@@ -704,10 +823,11 @@ exports.config = () => ({
704
823
  * Relic servers. The memory concerns are something you should consider for
705
824
  * your own server's sake. The payload of events is compressed, but if it
706
825
  * grows too large the New Relic servers may reject it.
707
- *
708
- * @env NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED
709
826
  */
710
- max_samples_stored: 3000
827
+ max_samples_stored: {
828
+ formatter: int,
829
+ default: 3000
830
+ }
711
831
  },
712
832
  /**
713
833
  * This is used to configure properties about the user's host name.
@@ -715,18 +835,17 @@ exports.config = () => ({
715
835
  process_host: {
716
836
  /**
717
837
  * Configurable display name for hosts
718
- *
719
- * @env NEW_RELIC_PROCESS_HOST_DISPLAY_NAME
720
838
  */
721
839
  display_name: '',
722
840
  /**
723
841
  * ip address preference when creating hostnames
724
- *
725
- * @env NEW_RELIC_IPV_PREFERENCE
726
842
  */
727
- ipv_preference: '4'
843
+ ipv_preference: {
844
+ formatter: allowList.bind(null, ['4', '6']),
845
+ default: '4',
846
+ env: 'NEW_RELIC_IPV_PREFERENCE'
847
+ }
728
848
  },
729
-
730
849
  /**
731
850
  * High Security
732
851
  *
@@ -742,7 +861,10 @@ exports.config = () => ({
742
861
  *
743
862
  * To read more see: https://docs.newrelic.com/docs/subscriptions/high-security
744
863
  */
745
- high_security: false,
864
+ high_security: {
865
+ formatter: boolean,
866
+ default: false
867
+ },
746
868
 
747
869
  /**
748
870
  * Labels
@@ -751,8 +873,9 @@ exports.config = () => ({
751
873
  * from this agent. Both label names and label values have a maximum length of
752
874
  * 255 characters. This object should contain at most 64 labels.
753
875
  */
754
- labels: {},
755
-
876
+ labels: {
877
+ default: {}
878
+ },
756
879
  /**
757
880
  * These options control behavior for slow queries, but do not affect sql
758
881
  * nodes in transaction traces.
@@ -760,10 +883,11 @@ exports.config = () => ({
760
883
  slow_sql: {
761
884
  /**
762
885
  * Enables and disables `slow_sql` recording.
763
- *
764
- * @env NEW_RELIC_SLOW_SQL_ENABLED
765
886
  */
766
- enabled: false,
887
+ enabled: {
888
+ formatter: boolean,
889
+ default: false
890
+ },
767
891
 
768
892
  /**
769
893
  * Sets the maximum number of slow query samples that will be collected in a
@@ -771,9 +895,12 @@ exports.config = () => ({
771
895
  *
772
896
  * @env NEW_RELIC_MAX_SQL_SAMPLES
773
897
  */
774
- max_samples: 10
898
+ max_samples: {
899
+ formatter: int,
900
+ default: 10,
901
+ env: 'NEW_RELIC_MAX_SQL_SAMPLES'
902
+ }
775
903
  },
776
-
777
904
  /**
778
905
  * Controls behavior of datastore instance metrics.
779
906
  *
@@ -784,64 +911,79 @@ exports.config = () => ({
784
911
  * Enables reporting of database/schema names. Default is `true`.
785
912
  */
786
913
  datastore_tracer: {
787
- instance_reporting: { enabled: true },
788
- database_name_reporting: { enabled: true }
914
+ instance_reporting: {
915
+ enabled: {
916
+ formatter: boolean,
917
+ default: true,
918
+ env: 'NEW_RELIC_DATASTORE_INSTANCE_REPORTING_ENABLED'
919
+ }
920
+ },
921
+ database_name_reporting: {
922
+ enabled: {
923
+ formatter: boolean,
924
+ default: true,
925
+ env: 'NEW_RELIC_DATASTORE_DATABASE_NAME_REPORTING_ENABLED'
926
+ }
927
+ }
789
928
  },
790
-
791
929
  /**
792
930
  * Controls behavior of gRPC server instrumentation.
793
931
  */
794
932
  grpc: {
795
933
  /**
796
934
  * Enables recording of non-zero gRPC status codes. Default is `true`.
797
- *
798
- * @env NEW_RELIC_GRPC_RECORD_ERRORS
799
935
  */
800
- record_errors: true
936
+ record_errors: {
937
+ formatter: boolean,
938
+ default: true
939
+ }
801
940
  },
802
-
803
941
  /**
804
942
  * Controls the behavior of span events produced by the agent.
805
943
  */
806
944
  span_events: {
807
945
  /**
808
946
  * Enables/disables span event generation
809
- *
810
- * @env NEW_RELIC_SPAN_EVENTS_ENABLED
811
947
  */
812
- enabled: true,
948
+ enabled: {
949
+ formatter: boolean,
950
+ default: true
951
+ },
813
952
 
814
953
  attributes: {
815
954
  /**
816
955
  * If `true`, the agent captures attributes from span events.
817
- *
818
- * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_ENABLED
819
956
  */
820
- enabled: true,
957
+ enabled: {
958
+ formatter: boolean,
959
+ default: true
960
+ },
821
961
  /**
822
962
  * Prefix of attributes to exclude in span events.
823
963
  * Allows * as wildcard at end.
824
- *
825
- * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_EXCLUDE
826
964
  */
827
- exclude: [],
965
+ exclude: {
966
+ formatter: array,
967
+ default: []
968
+ },
828
969
  /**
829
970
  * Prefix of attributes to include in span events.
830
971
  * Allows * as wildcard at end.
831
- *
832
- * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_INCLUDE
833
972
  */
834
- include: []
973
+ include: {
974
+ formatter: array,
975
+ default: []
976
+ }
835
977
  },
836
978
  /**
837
979
  * The agent will collect all events up to this number per minute. If
838
980
  * there are more than that, a statistical sampling will be collected.
839
- *
840
- * @env NEW_RELIC_SPAN_EVENTS_MAX_SAMPLES_STORED
841
981
  */
842
- max_samples_stored: 2000
982
+ max_samples_stored: {
983
+ formatter: int,
984
+ default: 2000
985
+ }
843
986
  },
844
-
845
987
  /**
846
988
  * Controls the behavior of transaction segments produced by the agent.
847
989
  */
@@ -849,27 +991,29 @@ exports.config = () => ({
849
991
  attributes: {
850
992
  /**
851
993
  * If `true`, the agent captures attributes from transaction segments.
852
- *
853
- * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_ENABLED
854
994
  */
855
- enabled: true,
995
+ enabled: {
996
+ formatter: boolean,
997
+ default: true
998
+ },
856
999
  /**
857
1000
  * Prefix of attributes to exclude in transaction segments.
858
1001
  * Allows * as wildcard at end.
859
- *
860
- * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_EXCLUDE
861
1002
  */
862
- exclude: [],
1003
+ exclude: {
1004
+ formatter: array,
1005
+ default: []
1006
+ },
863
1007
  /**
864
1008
  * Prefix of attributes to include in transaction segments.
865
1009
  * Allows * as wildcard at end.
866
- *
867
- * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_INCLUDE
868
1010
  */
869
- include: []
1011
+ include: {
1012
+ formatter: array,
1013
+ default: []
1014
+ }
870
1015
  }
871
1016
  },
872
-
873
1017
  /**
874
1018
  * Controls the method of cross agent tracing in the agent.
875
1019
  * Distributed tracing lets you see the path that a request takes through your
@@ -881,22 +1025,23 @@ exports.config = () => ({
881
1025
  distributed_tracing: {
882
1026
  /**
883
1027
  * Enables/disables distributed tracing.
884
- *
885
- * @env NEW_RELIC_DISTRIBUTED_TRACING_ENABLED
886
1028
  */
887
- enabled: true,
1029
+ enabled: {
1030
+ formatter: boolean,
1031
+ default: true
1032
+ },
888
1033
 
889
1034
  /**
890
1035
  * Excludes New Relic format distributed tracing header (`newrelic`) on
891
1036
  * outbound requests when set to `true`. By default (when false)
892
1037
  * both W3C TraceContext (`traceparent`, `tracecontext`) and
893
1038
  * New Relic formats will be sent.
894
- *
895
- * @env NEW_RELIC_DISTRIBUTED_TRACING_EXCLUDE_NEWRELIC_HEADER
896
1039
  */
897
- exclude_newrelic_header: false
1040
+ exclude_newrelic_header: {
1041
+ formatter: boolean,
1042
+ default: false
1043
+ }
898
1044
  },
899
-
900
1045
  /**
901
1046
  * Controls the use of cross-application tracing.
902
1047
  *
@@ -905,8 +1050,12 @@ exports.config = () => ({
905
1050
  * This feature has been deprecated in favor of Distributed Tracing (DT).
906
1051
  * To fully enable this feature, you must also disable DT in your configuration.
907
1052
  */
908
- cross_application_tracer: { enabled: false },
909
-
1053
+ cross_application_tracer: {
1054
+ enabled: {
1055
+ formatter: boolean,
1056
+ default: false
1057
+ }
1058
+ },
910
1059
  /**
911
1060
  * Controls behavior of message broker tracing.
912
1061
  *
@@ -914,9 +1063,13 @@ exports.config = () => ({
914
1063
  * Enables reporting parameters on message broker segments.
915
1064
  */
916
1065
  message_tracer: {
917
- segment_parameters: { enabled: true }
1066
+ segment_parameters: {
1067
+ enabled: {
1068
+ formatter: boolean,
1069
+ default: true
1070
+ }
1071
+ }
918
1072
  },
919
-
920
1073
  /**
921
1074
  * Controls the use of infinite tracing.
922
1075
  */
@@ -924,45 +1077,49 @@ exports.config = () => ({
924
1077
  trace_observer: {
925
1078
  /**
926
1079
  * The URI HOST of the observer. Setting this enables infinite tracing.
927
- *
928
- * @env NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST
929
1080
  */
930
1081
  host: '',
931
1082
  /**
932
1083
  * The URI PORT of the observer.
933
- *
934
- * @env NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_PORT
935
1084
  */
936
- port: '443'
1085
+ port: {
1086
+ formatter: int,
1087
+ default: 443
1088
+ }
937
1089
  },
938
1090
  span_events: {
939
1091
  /**
940
1092
  * The amount of spans to hold onto before dropping them
941
- *
942
- * @env NEW_RELIC_INFINITE_TRACING_SPAN_EVENTS_QUEUE_SIZE
943
1093
  */
944
- queue_size: 10000
1094
+ queue_size: {
1095
+ formatter: int,
1096
+ default: 10000
1097
+ }
945
1098
  }
946
1099
  },
947
-
948
1100
  /**
949
1101
  * Specifies whether the agent will be used to monitor serverless functions.
950
1102
  * For example: AWS Lambda
951
- *
952
- * @env NEW_RELIC_SERVERLESS_MODE_ENABLED
953
1103
  */
954
1104
  serverless_mode: {
955
- enabled: process.env.AWS_LAMBDA_FUNCTION_NAME != null
1105
+ enabled: {
1106
+ formatter: boolean,
1107
+ default: process.env.AWS_LAMBDA_FUNCTION_NAME != null
1108
+ }
956
1109
  },
957
-
958
1110
  plugins: {
959
1111
  /**
960
1112
  * Controls usage of the native metrics module which samples VM and event
961
1113
  * loop data.
962
1114
  */
963
- native_metrics: { enabled: true }
1115
+ native_metrics: {
1116
+ enabled: {
1117
+ formatter: boolean,
1118
+ default: true,
1119
+ env: 'NEW_RELIC_NATIVE_METRICS_ENABLED'
1120
+ }
1121
+ }
964
1122
  },
965
-
966
1123
  /**
967
1124
  *
968
1125
  * Controls the behavior of Logs in Context within agent
@@ -970,42 +1127,46 @@ exports.config = () => ({
970
1127
  application_logging: {
971
1128
  /**
972
1129
  * Toggles the ability for all application logging features to be enabled.
973
- *
974
- * @env NEW_RELIC_APPLICATION_LOGGING_ENABLED
975
1130
  */
976
- enabled: true,
1131
+ enabled: {
1132
+ formatter: boolean,
1133
+ default: true
1134
+ },
977
1135
  forwarding: {
978
1136
  /**
979
1137
  * Toggles whether the agent gathers log records for sending to New Relic.
980
- *
981
- * @env NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED
982
1138
  */
983
- enabled: true,
1139
+ enabled: {
1140
+ formatter: boolean,
1141
+ default: true
1142
+ },
984
1143
  /**
985
1144
  * Number of log records to send per minute to New Relic.
986
- *
987
- * @env NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED
988
1145
  */
989
- max_samples_stored: 10000
1146
+ max_samples_stored: {
1147
+ formatter: int,
1148
+ default: 10000
1149
+ }
990
1150
  },
991
1151
  metrics: {
992
1152
  /**
993
1153
  * Toggles whether the agent gathers logging metrics.
994
- *
995
- * @env NEW_RELIC_APPLICATION_LOGGING_METRICS_ENABLED
996
1154
  */
997
- enabled: true
1155
+ enabled: {
1156
+ formatter: boolean,
1157
+ default: true
1158
+ }
998
1159
  },
999
1160
  local_decorating: {
1000
1161
  /**
1001
1162
  * Toggles whether the agent performs log decoration on standard log output.
1002
- *
1003
- * @env NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED
1004
1163
  */
1005
- enabled: false
1164
+ enabled: {
1165
+ formatter: boolean,
1166
+ default: false
1167
+ }
1006
1168
  }
1007
1169
  },
1008
-
1009
1170
  /**
1010
1171
  * You may want more control over how your agent is configured and want to
1011
1172
  * disallow the use of New Relic's server-side configuration for agents.
@@ -1013,5 +1174,85 @@ exports.config = () => ({
1013
1174
  *
1014
1175
  * @env NEW_RELIC_IGNORE_SERVER_SIDE_CONFIG
1015
1176
  */
1016
- ignore_server_configuration: false
1177
+ ignore_server_configuration: {
1178
+ formatter: boolean,
1179
+ default: false,
1180
+ env: 'NEW_RELIC_IGNORE_SERVER_SIDE_CONFIG'
1181
+ }
1017
1182
  })
1183
+
1184
+ /**
1185
+ * Creates a new default config
1186
+ */
1187
+ defaultConfig.config = () => {
1188
+ const config = Object.create(null)
1189
+ const definition = defaultConfig.definition()
1190
+ buildConfig(definition, config)
1191
+ return config
1192
+ }
1193
+
1194
+ /**
1195
+ * Iterates over the configuration definition and sets all default
1196
+ * values.
1197
+ *
1198
+ * @param {object} definition configuration definition for a given leaf node
1199
+ * @param {object} config object that is used to construct the agent config
1200
+ * @param {Array} [paths=[]] an array to capture the leaf node keys to properly assign defaults for nested objects
1201
+ * @param {int} [objectKeys=1] amount of keys in a given leaf node
1202
+ */
1203
+ function buildConfig(definition, config, paths = [], objectKeys = 1) {
1204
+ let keysSeen = 0
1205
+ Object.entries(definition).reduce((conf, [key, value]) => {
1206
+ const type = typeof value
1207
+ keysSeen++
1208
+ if (type === 'string') {
1209
+ if (paths.length) {
1210
+ setNestedKey(conf, [...paths, key], value)
1211
+ } else {
1212
+ conf[key] = value
1213
+ }
1214
+ } else if (type === 'object') {
1215
+ if (value.hasOwnProperty('default')) {
1216
+ if (paths.length) {
1217
+ setNestedKey(conf, [...paths, key], value.default)
1218
+ } else {
1219
+ conf[key] = value.default
1220
+ }
1221
+ } else {
1222
+ const { length } = Object.keys(value)
1223
+ paths.push(key)
1224
+ buildConfig(definition[key], conf, paths, length)
1225
+ }
1226
+ }
1227
+
1228
+ return conf
1229
+ }, config)
1230
+
1231
+ // we have traversed every key in current object leaf node, remove wrapping key
1232
+ // to properly derive env vars of future leaf nodes
1233
+ if (keysSeen === objectKeys) {
1234
+ paths.pop()
1235
+ }
1236
+ }
1237
+
1238
+ /**
1239
+ * Properly sets the value of a nested key by creating the shells of empty parents
1240
+ *
1241
+ * @param {object} obj object to assign value to
1242
+ * @param {Array} keys list of parent keys
1243
+ * @param {value} value to assign the nested key
1244
+ */
1245
+ function setNestedKey(obj, keys, value) {
1246
+ const len = keys.length
1247
+ for (let i = 0; i < len - 1; i++) {
1248
+ const elem = keys[i]
1249
+ if (!obj[elem]) {
1250
+ obj[elem] = {}
1251
+ }
1252
+
1253
+ obj = obj[elem]
1254
+ }
1255
+
1256
+ obj[keys[len - 1]] = value
1257
+ }
1258
+ defaultConfig.setNestedKey = setNestedKey