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