newrelic 12.23.0 → 12.24.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.
package/NEWS.md CHANGED
@@ -1,3 +1,17 @@
1
+ ### v12.24.0 (2025-07-07)
2
+
3
+ #### Features
4
+
5
+ * Implemented configurable attribute value size limit ([#3206](https://github.com/newrelic/node-newrelic/pull/3206)) ([08a6eca](https://github.com/newrelic/node-newrelic/commit/08a6eca7cd35811f5bcb4e6c13264eac156b302f))
6
+
7
+ #### Documentation
8
+
9
+ * Updated compatibility report ([#3190](https://github.com/newrelic/node-newrelic/pull/3190)) ([72c492c](https://github.com/newrelic/node-newrelic/commit/72c492cf78b6cc52791604ac354e34718c8ae926))
10
+
11
+ #### Miscellaneous chores
12
+
13
+ * Rename GCP ID config flag ([#3205](https://github.com/newrelic/node-newrelic/pull/3205)) ([8446f29](https://github.com/newrelic/node-newrelic/commit/8446f29fc6ed469d663e5634540a4afe4932765b))
14
+
1
15
  ### v12.23.0 (2025-06-30)
2
16
 
3
17
  #### Features
package/lib/attributes.js CHANGED
@@ -12,6 +12,7 @@ const byteUtils = require('./util/byte-limit')
12
12
  const properties = require('./util/properties')
13
13
 
14
14
  const MAXIMUM_CUSTOM_ATTRIBUTES = 64
15
+ const MAXIMUM_ATTR_VALUE_LENGTH = 4_096
15
16
 
16
17
  /**
17
18
  * @class
@@ -19,17 +20,25 @@ const MAXIMUM_CUSTOM_ATTRIBUTES = 64
19
20
  */
20
21
  class Attributes {
21
22
  /**
22
- * @param {string} scope
23
+ * @param {object} params Constructor parameters.
24
+ * @param {string} params.scope
23
25
  * The scope of the attributes this will collect. Must be `transaction` or
24
26
  * `segment`.
25
- * @param {number} [limit]
27
+ * @param {number} [params.limit]
26
28
  * The maximum number of attributes to retrieve for each destination.
29
+ * @param {number} [params.valueLengthLimit] The maximum length allowed for
30
+ * attribute values.
27
31
  */
28
- constructor(scope, limit = Infinity) {
32
+ constructor({ scope, limit = Infinity, valueLengthLimit = 256 } = {}) {
29
33
  this.filter = makeFilter(scope)
30
34
  this.limit = limit
31
35
  this.attributes = Object.create(null)
32
36
  this.attributeCount = 0
37
+ this.attributeValueLimit = valueLengthLimit
38
+
39
+ if (this.attributeValueLimit > MAXIMUM_ATTR_VALUE_LENGTH) {
40
+ this.attributeValueLimit = MAXIMUM_ATTR_VALUE_LENGTH
41
+ }
33
42
  }
34
43
 
35
44
  /**
@@ -73,7 +82,7 @@ class Attributes {
73
82
 
74
83
  attrs[key] =
75
84
  typeof attr.value === 'string' && !attr.truncateExempt
76
- ? byteUtils.truncate(attr.value, 255)
85
+ ? byteUtils.truncate(attr.value, this.attributeValueLimit)
77
86
  : attr.value
78
87
  }
79
88
 
@@ -233,6 +233,18 @@ defaultConfig.definition = () => ({
233
233
  default: true
234
234
  },
235
235
 
236
+ /**
237
+ * Defines the number of characters allowed for each individual attribute's
238
+ * value. The default is 256 characters, with a maximum of 4,096.
239
+ */
240
+ value_size_limit: {
241
+ formatter: int,
242
+ /**
243
+ * Maximum value is 4,096.
244
+ */
245
+ default: 256
246
+ },
247
+
236
248
  /**
237
249
  * Prefix of attributes to exclude from all destinations. Allows * as wildcard at end.
238
250
  *
@@ -538,6 +550,15 @@ defaultConfig.definition = () => ({
538
550
  total_ram_mib: {
539
551
  formatter: int,
540
552
  default: null
553
+ },
554
+
555
+ /**
556
+ * When enabled, it will use GCP metadata id
557
+ * to set the hostname of the running application.
558
+ */
559
+ gcp_use_instance_as_host: {
560
+ default: true,
561
+ formatter: boolean
541
562
  }
542
563
  },
543
564
  transaction_tracer: {
@@ -1618,17 +1639,6 @@ defaultConfig.definition = () => ({
1618
1639
  }
1619
1640
  },
1620
1641
 
1621
- /**
1622
- * When enabled, it will use GCP metadata id
1623
- * to set the hostname of the running application
1624
- */
1625
- gcp_cloud_run: {
1626
- use_instance_as_host: {
1627
- default: true,
1628
- formatter: boolean
1629
- }
1630
- },
1631
-
1632
1642
  /**
1633
1643
  * When enabled, it will allow loading of the agent
1634
1644
  * in worker threads.
@@ -989,7 +989,7 @@ function getHostnameSafe(gcpId = null) {
989
989
  // If not applicable, use the os.hostname()
990
990
  if (config.heroku.use_dyno_names && process.env.DYNO) {
991
991
  _hostname = process.env.DYNO || os.hostname()
992
- } else if (config.gcp_cloud_run.use_instance_as_host && process.env.K_SERVICE && gcpId) {
992
+ } else if (config.utilization.gcp_use_instance_as_host && process.env.K_SERVICE && gcpId) {
993
993
  _hostname = gcpId
994
994
  } else {
995
995
  _hostname = os.hostname()
@@ -44,8 +44,15 @@ function Trace(transaction) {
44
44
  this.root = this.segments.root.segment
45
45
  this.totalTimeCache = null
46
46
 
47
- this.custom = new Attributes(ATTRIBUTE_SCOPE, MAXIMUM_CUSTOM_ATTRIBUTES)
48
- this.attributes = new Attributes(ATTRIBUTE_SCOPE)
47
+ this.custom = new Attributes({
48
+ scope: ATTRIBUTE_SCOPE,
49
+ limit: MAXIMUM_CUSTOM_ATTRIBUTES,
50
+ valueLengthLimit: transaction.agent.config.attributes.value_size_limit
51
+ })
52
+ this.attributes = new Attributes({
53
+ scope: ATTRIBUTE_SCOPE,
54
+ valueLengthLimit: transaction.agent.config.attributes.value_size_limit
55
+ })
49
56
 
50
57
  // sending displayName if set by user
51
58
  const displayName = transaction.agent.config.getDisplayHost()
@@ -43,7 +43,10 @@ function TraceSegment({ id, config, name, collect, parentId, root, isRoot = fals
43
43
  this.isRoot = isRoot
44
44
  this.root = root
45
45
  this.name = name
46
- this.attributes = new Attributes(ATTRIBUTE_SCOPE)
46
+ this.attributes = new Attributes({
47
+ scope: ATTRIBUTE_SCOPE,
48
+ valueLengthLimit: config?.attributes.value_size_limit
49
+ })
47
50
  this.spansEnabled = config?.distributed_tracing?.enabled && config?.span_events?.enabled
48
51
 
49
52
  // Generate a unique id for use in span events.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "12.23.0",
3
+ "version": "12.24.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [