newrelic 13.6.6 → 13.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 (36) hide show
  1. package/NEWS.md +41 -0
  2. package/THIRD_PARTY_NOTICES.md +10 -127
  3. package/index.js +1 -1
  4. package/lib/agent.js +5 -9
  5. package/lib/attributes.js +13 -6
  6. package/lib/config/default.js +1 -2
  7. package/lib/config/index.js +17 -10
  8. package/lib/config/samplers.js +114 -59
  9. package/lib/feature_flags.js +1 -1
  10. package/lib/instrumentation/koa/router-instrumentation.js +2 -1
  11. package/lib/otel/logs/index.js +1 -1
  12. package/lib/otel/metrics/index.js +2 -2
  13. package/lib/otel/{logs/normalize-timestamp.js → normalize-timestamp.js} +32 -6
  14. package/lib/otel/setup.js +9 -9
  15. package/lib/otel/traces/segment-synthesis.js +30 -6
  16. package/lib/otel/traces/segments/index.js +1 -1
  17. package/lib/otel/traces/span-processor.js +15 -1
  18. package/lib/otel/traces/utils.js +3 -1
  19. package/lib/samplers/README.md +79 -0
  20. package/lib/samplers/adaptive-sampler.js +27 -3
  21. package/lib/samplers/always-off-sampler.js +16 -0
  22. package/lib/samplers/always-on-sampler.js +17 -0
  23. package/lib/samplers/index.js +270 -0
  24. package/lib/samplers/ratio-based-sampler.js +74 -0
  25. package/lib/samplers/sampler.js +58 -0
  26. package/lib/shimmer.js +2 -2
  27. package/lib/spans/span-event-aggregator.js +6 -2
  28. package/lib/spans/span-event.js +145 -45
  29. package/lib/spans/span-link.js +99 -0
  30. package/lib/system-info.js +1 -1
  31. package/lib/transaction/index.js +13 -109
  32. package/lib/transaction/trace/index.js +1 -1
  33. package/lib/transaction/trace/segment.js +6 -9
  34. package/lib/transaction/tracer/index.js +11 -8
  35. package/lib/utilization/index.js +46 -17
  36. package/package.json +1 -5
package/NEWS.md CHANGED
@@ -1,3 +1,44 @@
1
+ ### v13.7.0 (2025-12-08)
2
+
3
+ #### Features
4
+
5
+ * Updated `koa` instrumentation to properly wrap `Router` when using `@koa/router@15.0.0`+ ([#3550](https://github.com/newrelic/node-newrelic/pull/3550)) ([f1e08ad](https://github.com/newrelic/node-newrelic/commit/f1e08ad9fe200138ab9ed32e423517f64e41af49))
6
+ * Added ability to configure a ratio based sampler ([#3501](https://github.com/newrelic/node-newrelic/pull/3501)) ([f300bd5](https://github.com/newrelic/node-newrelic/commit/f300bd5eacf9d6509b56484e7ad36d5c0725b497))
7
+ * To assign a ratio based sampler, set `config.distributed_tracing.sampler.root`, `config.distributed_tracing.sampler.remote_parent_sampled`, or `config.distributed_tracing.sampler.remote_parent_not_sampled` to `{ trace_id_ratio_based: { ratio: <float between 0 and 1> }}`
8
+ * To assign via environment variables set `NEW_RELIC_DISTRIBUTED_TRACING_SAMPLER_<TYPE>='trace_id_ratio_based'` and `NEW_RELIC_DISTRIBUTED_TRACING_SAMPLER_<TYPE>_RATIO=<float between 0 and 1>` where `<TYPE>` is one of `ROOT`, `REMOTE_PARENT_SAMPLED`, or `REMOTE_PARENT_NOT_SAMPLED`
9
+ * Updated configuration to allow `adaptive.sampling_target` to be set for `config.distributed_tracing.sampler.root`, `config.distributed_tracing.sampler.remote_parent_sampled`, and `config.distributed_tracing.sampler.remote_parent_not_sampled` ([#3532](https://github.com/newrelic/node-newrelic/pull/3532)) ([44f51dd](https://github.com/newrelic/node-newrelic/commit/44f51dd5583e74aef1e2d0ee9483d51d5ff786c3))
10
+ * Added support for OTEL span links ([#3528](https://github.com/newrelic/node-newrelic/pull/3528)) ([e840690](https://github.com/newrelic/node-newrelic/commit/e8406903dd0c92cd003fac69770785489e1bba85))
11
+ * Replaced `default` with `adaptive` as the default for samplers ([#3543](https://github.com/newrelic/node-newrelic/pull/3543)) ([3f03162](https://github.com/newrelic/node-newrelic/commit/3f0316285fdde6d3c38ce819aa41221a71bd4fcb))
12
+ * Preliminary support for partial granularity traces (Not available for production use)
13
+ * Added `essential` type for partial granularity traces ([#3547](https://github.com/newrelic/node-newrelic/pull/3547)) ([3d85fb5](https://github.com/newrelic/node-newrelic/commit/3d85fb5fa16d411892eb4a23067e66669461ada0))
14
+ * Added `reduced` type for partial granularity traces. ([#3540](https://github.com/newrelic/node-newrelic/pull/3540)) ([cfa8f41](https://github.com/newrelic/node-newrelic/commit/cfa8f41618595cc5ffb3e3b5574673721c64580c))
15
+ * Added partial granularity samplers and assign transactions with `isPartialTrace` when partial granularity sampling decisions have been made ([#3544](https://github.com/newrelic/node-newrelic/pull/3544)) ([1535a82](https://github.com/newrelic/node-newrelic/commit/1535a82331ce40d7c96e0c6746ec70bcdbd6e4f6))
16
+ * Refactored samplers into classes and store them on `agent.sampler.*` ([#3527](https://github.com/newrelic/node-newrelic/pull/3527)) ([ad63441](https://github.com/newrelic/node-newrelic/commit/ad634411a0d91240c0c16c7a372b00b36651589f))
17
+ * Updated `Samplers` class to normalize logger messages, short circuit when applicable and remove optional chaining checks ([#3546](https://github.com/newrelic/node-newrelic/pull/3546)) ([4f7684c](https://github.com/newrelic/node-newrelic/commit/4f7684cb4c64a89545704c70c110d2fd13815197))
18
+ * Updated samplers to assign priority between 0-1 when DT is disabled or both full and partial granularity are disabled ([#3559](https://github.com/newrelic/node-newrelic/pull/3559)) ([7a1c37e](https://github.com/newrelic/node-newrelic/commit/7a1c37e3e04fef0538a8af15fa690915bce65262))
19
+ * Updated transaction to store partial granularity indicator as `.partialType` ([#3561](https://github.com/newrelic/node-newrelic/pull/3561)) ([a7f20d8](https://github.com/newrelic/node-newrelic/commit/a7f20d8e83b44556434bae90bd3924c54af9f587))
20
+ * Updated when partial granularity rules are applied ([#3553](https://github.com/newrelic/node-newrelic/pull/3553)) ([a4bdf4f](https://github.com/newrelic/node-newrelic/commit/a4bdf4fbbbdac102519020c5ca4d3dc92eeff844))
21
+ * Added `toString` and `get [Symbol.toStringTag]()` to default Sampler class ([#3562](https://github.com/newrelic/node-newrelic/pull/3562)) ([771168d](https://github.com/newrelic/node-newrelic/commit/771168dcd927240b6efc703f238046e9a7f7766b))
22
+
23
+ #### Bug fixes
24
+
25
+ * Fixed normalization of OTEL hrtime ([#3564](https://github.com/newrelic/node-newrelic/pull/3564)) ([707fe7d](https://github.com/newrelic/node-newrelic/commit/707fe7d6395f0e15b5e6c6195f93df1c27540423))
26
+
27
+ #### Documentation
28
+
29
+ * Updated compatibility report ([#3551](https://github.com/newrelic/node-newrelic/pull/3551)) ([02268a4](https://github.com/newrelic/node-newrelic/commit/02268a4e3fe7b2f2f5c2fd035bcb337fd7b2bfc2))
30
+ * Added internal doc for attributes ([#3539](https://github.com/newrelic/node-newrelic/pull/3539)) ([68543b6](https://github.com/newrelic/node-newrelic/commit/68543b606fc53e59e9a6fcb08173e423bc6437a9))
31
+
32
+ #### Miscellaneous chores
33
+
34
+ * Improved logging around `preconnect` payload
35
+ * Added more logging around assigning hostname during `preconnect` ([#3568](https://github.com/newrelic/node-newrelic/pull/3568)) ([3ee4d38](https://github.com/newrelic/node-newrelic/commit/3ee4d383cd7d9e7bf16e9da5e7f130fc2a103ca4))
36
+ * Improved GCP utilization logging ([#3552](https://github.com/newrelic/node-newrelic/pull/3552)) ([e6c4141](https://github.com/newrelic/node-newrelic/commit/e6c4141b55860b5f1fe5cd14049abb9eca9b3859))
37
+ * Utilization resolution is now done concurrently ([#3556](https://github.com/newrelic/node-newrelic/pull/3556)) ([8386360](https://github.com/newrelic/node-newrelic/commit/8386360fe7fb4b7278e001dac8c8293581654069))
38
+ * Collected OTEL instrumentation scope metadata on all OTEL spans. ([#3554](https://github.com/newrelic/node-newrelic/pull/3554)) ([75703c4](https://github.com/newrelic/node-newrelic/commit/75703c41a8db1d204a1500b8b43dff0d04a5b286))
39
+ * Improved OTEL hrtime processing ([#3557](https://github.com/newrelic/node-newrelic/pull/3557)) ([8f187b1](https://github.com/newrelic/node-newrelic/commit/8f187b11eac96f78d9743cadb2302001ed94412a))
40
+ * Renamed config `opentelemetry_bridge` to `opentelemetry` ([#3565](https://github.com/newrelic/node-newrelic/pull/3565)) ([c9d156f](https://github.com/newrelic/node-newrelic/commit/c9d156fe302ffb99b262ffd3e256d953301f08f2))
41
+
1
42
  ### v13.6.6 (2025-11-19)
2
43
 
3
44
  #### Bug fixes
@@ -42,7 +42,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
42
42
 
43
43
  * [@aws-sdk/client-s3](#aws-sdkclient-s3)
44
44
  * [@aws-sdk/s3-request-presigner](#aws-sdks3-request-presigner)
45
- * [@koa/router](#koarouter)
46
45
  * [@matteo.collina/tspl](#matteocollinatspl)
47
46
  * [@newrelic/eslint-config](#newreliceslint-config)
48
47
  * [@newrelic/newrelic-oss-cli](#newrelicnewrelic-oss-cli)
@@ -69,9 +68,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
69
68
  * [got](#got)
70
69
  * [husky](#husky)
71
70
  * [jsdoc](#jsdoc)
72
- * [koa-route](#koa-route)
73
- * [koa-router](#koa-router)
74
- * [koa](#koa)
75
71
  * [lint-staged](#lint-staged)
76
72
  * [lockfile-lint](#lockfile-lint)
77
73
  * [nock](#nock)
@@ -1190,7 +1186,7 @@ This product includes source derived from [@opentelemetry/api](https://github.co
1190
1186
 
1191
1187
  ### @opentelemetry/core
1192
1188
 
1193
- This product includes source derived from [@opentelemetry/core](https://github.com/open-telemetry/opentelemetry-js) ([v2.1.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.1.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.1.0/LICENSE):
1189
+ This product includes source derived from [@opentelemetry/core](https://github.com/open-telemetry/opentelemetry-js) ([v2.2.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.2.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.2.0/LICENSE):
1194
1190
 
1195
1191
  ```
1196
1192
  Apache License
@@ -1608,7 +1604,7 @@ This product includes source derived from [@opentelemetry/exporter-metrics-otlp-
1608
1604
 
1609
1605
  ### @opentelemetry/resources
1610
1606
 
1611
- This product includes source derived from [@opentelemetry/resources](https://github.com/open-telemetry/opentelemetry-js) ([v2.1.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.1.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.1.0/LICENSE):
1607
+ This product includes source derived from [@opentelemetry/resources](https://github.com/open-telemetry/opentelemetry-js) ([v2.2.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.2.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.2.0/LICENSE):
1612
1608
 
1613
1609
  ```
1614
1610
  Apache License
@@ -2026,7 +2022,7 @@ This product includes source derived from [@opentelemetry/sdk-logs](https://gith
2026
2022
 
2027
2023
  ### @opentelemetry/sdk-metrics
2028
2024
 
2029
- This product includes source derived from [@opentelemetry/sdk-metrics](https://github.com/open-telemetry/opentelemetry-js) ([v2.1.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.1.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.1.0/LICENSE):
2025
+ This product includes source derived from [@opentelemetry/sdk-metrics](https://github.com/open-telemetry/opentelemetry-js) ([v2.2.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.2.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.2.0/LICENSE):
2030
2026
 
2031
2027
  ```
2032
2028
  Apache License
@@ -2235,7 +2231,7 @@ This product includes source derived from [@opentelemetry/sdk-metrics](https://g
2235
2231
 
2236
2232
  ### @opentelemetry/sdk-trace-base
2237
2233
 
2238
- This product includes source derived from [@opentelemetry/sdk-trace-base](https://github.com/open-telemetry/opentelemetry-js) ([v2.1.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.1.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.1.0/LICENSE):
2234
+ This product includes source derived from [@opentelemetry/sdk-trace-base](https://github.com/open-telemetry/opentelemetry-js) ([v2.2.0](https://github.com/open-telemetry/opentelemetry-js/tree/v2.2.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.2.0/LICENSE):
2239
2235
 
2240
2236
  ```
2241
2237
  Apache License
@@ -2533,7 +2529,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2533
2529
 
2534
2530
  ### import-in-the-middle
2535
2531
 
2536
- This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.14.4](https://github.com/nodejs/import-in-the-middle/tree/v1.14.4)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.14.4/LICENSE):
2532
+ This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.15.0](https://github.com/nodejs/import-in-the-middle/tree/v1.15.0)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.15.0/LICENSE):
2537
2533
 
2538
2534
  ```
2539
2535
  Apache License
@@ -2908,7 +2904,7 @@ SOFTWARE.
2908
2904
 
2909
2905
  ### semver
2910
2906
 
2911
- This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.7.2](https://github.com/npm/node-semver/tree/v7.7.2)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.7.2/LICENSE):
2907
+ This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.7.3](https://github.com/npm/node-semver/tree/v7.7.3)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.7.3/LICENSE):
2912
2908
 
2913
2909
  ```
2914
2910
  The ISC License
@@ -2964,7 +2960,7 @@ SOFTWARE.
2964
2960
 
2965
2961
  ### @aws-sdk/client-s3
2966
2962
 
2967
- This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.896.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.896.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.896.0/LICENSE):
2963
+ This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.919.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.919.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.919.0/LICENSE):
2968
2964
 
2969
2965
  ```
2970
2966
  Apache License
@@ -3173,7 +3169,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
3173
3169
 
3174
3170
  ### @aws-sdk/s3-request-presigner
3175
3171
 
3176
- This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.896.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.896.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.896.0/LICENSE):
3172
+ This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.919.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.919.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.919.0/LICENSE):
3177
3173
 
3178
3174
  ```
3179
3175
  Apache License
@@ -3380,35 +3376,6 @@ This product includes source derived from [@aws-sdk/s3-request-presigner](https:
3380
3376
 
3381
3377
  ```
3382
3378
 
3383
- ### @koa/router
3384
-
3385
- This product includes source derived from [@koa/router](https://github.com/koajs/router) ([v12.0.2](https://github.com/koajs/router/tree/v12.0.2)), distributed under the [MIT License](https://github.com/koajs/router/blob/v12.0.2/LICENSE):
3386
-
3387
- ```
3388
- The MIT License (MIT)
3389
-
3390
- Copyright (c) 2015 Alexander C. Mingoia and @koajs contributors
3391
-
3392
- Permission is hereby granted, free of charge, to any person obtaining a copy
3393
- of this software and associated documentation files (the "Software"), to deal
3394
- in the Software without restriction, including without limitation the rights
3395
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3396
- copies of the Software, and to permit persons to whom the Software is
3397
- furnished to do so, subject to the following conditions:
3398
-
3399
- The above copyright notice and this permission notice shall be included in
3400
- all copies or substantial portions of the Software.
3401
-
3402
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3403
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3404
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3405
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3406
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3407
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3408
- THE SOFTWARE.
3409
-
3410
- ```
3411
-
3412
3379
  ### @matteo.collina/tspl
3413
3380
 
3414
3381
  This product includes source derived from [@matteo.collina/tspl](https://github.com/mcollina/tspl) ([v0.1.1](https://github.com/mcollina/tspl/tree/v0.1.1)), distributed under the [MIT License](https://github.com/mcollina/tspl/blob/v0.1.1/LICENSE):
@@ -5033,7 +5000,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5033
5000
 
5034
5001
  ### eslint
5035
5002
 
5036
- This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.36.0](https://github.com/eslint/eslint/tree/v9.36.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.36.0/LICENSE):
5003
+ This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.38.0](https://github.com/eslint/eslint/tree/v9.38.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.38.0/LICENSE):
5037
5004
 
5038
5005
  ```
5039
5006
  Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
@@ -5196,7 +5163,7 @@ SOFTWARE.
5196
5163
 
5197
5164
  ### jsdoc
5198
5165
 
5199
- This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v4.0.4](https://github.com/jsdoc/jsdoc/tree/v4.0.4)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v4.0.4/LICENSE.md):
5166
+ This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v4.0.5](https://github.com/jsdoc/jsdoc/tree/v4.0.5)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v4.0.5/LICENSE.md):
5200
5167
 
5201
5168
  ```
5202
5169
  # License
@@ -5304,90 +5271,6 @@ https://github.com/jmblog/color-themes-for-google-code-prettify
5304
5271
 
5305
5272
  ```
5306
5273
 
5307
- ### koa-route
5308
-
5309
- This product includes source derived from [koa-route](https://github.com/koajs/route) ([v4.0.1](https://github.com/koajs/route/tree/v4.0.1)), distributed under the [MIT License](https://github.com/koajs/route/blob/v4.0.1/Readme.md):
5310
-
5311
- ```
5312
- MIT License
5313
-
5314
- Copyright (c) <year> <copyright holders>
5315
-
5316
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5317
- associated documentation files (the "Software"), to deal in the Software without restriction, including
5318
- without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5319
- copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
5320
- following conditions:
5321
-
5322
- The above copyright notice and this permission notice shall be included in all copies or substantial
5323
- portions of the Software.
5324
-
5325
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
5326
- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
5327
- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
5328
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5329
- USE OR OTHER DEALINGS IN THE SOFTWARE.
5330
- ```
5331
-
5332
- ### koa-router
5333
-
5334
- This product includes source derived from [koa-router](https://github.com/koajs/router) ([v12.0.1](https://github.com/koajs/router/tree/v12.0.1)), distributed under the [MIT License](https://github.com/koajs/router/blob/v12.0.1/LICENSE):
5335
-
5336
- ```
5337
- The MIT License (MIT)
5338
-
5339
- Copyright (c) 2015 Alexander C. Mingoia and @koajs contributors
5340
-
5341
- Permission is hereby granted, free of charge, to any person obtaining a copy
5342
- of this software and associated documentation files (the "Software"), to deal
5343
- in the Software without restriction, including without limitation the rights
5344
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5345
- copies of the Software, and to permit persons to whom the Software is
5346
- furnished to do so, subject to the following conditions:
5347
-
5348
- The above copyright notice and this permission notice shall be included in
5349
- all copies or substantial portions of the Software.
5350
-
5351
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5352
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5353
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5354
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5355
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5356
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5357
- THE SOFTWARE.
5358
-
5359
- ```
5360
-
5361
- ### koa
5362
-
5363
- This product includes source derived from [koa](https://github.com/koajs/koa) ([v2.16.2](https://github.com/koajs/koa/tree/v2.16.2)), distributed under the [MIT License](https://github.com/koajs/koa/blob/v2.16.2/LICENSE):
5364
-
5365
- ```
5366
- (The MIT License)
5367
-
5368
- Copyright (c) 2019 Koa contributors
5369
-
5370
- Permission is hereby granted, free of charge, to any person obtaining
5371
- a copy of this software and associated documentation files (the
5372
- 'Software'), to deal in the Software without restriction, including
5373
- without limitation the rights to use, copy, modify, merge, publish,
5374
- distribute, sublicense, and/or sell copies of the Software, and to
5375
- permit persons to whom the Software is furnished to do so, subject to
5376
- the following conditions:
5377
-
5378
- The above copyright notice and this permission notice shall be
5379
- included in all copies or substantial portions of the Software.
5380
-
5381
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
5382
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5383
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
5384
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
5385
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
5386
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
5387
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5388
-
5389
- ```
5390
-
5391
5274
  ### lint-staged
5392
5275
 
5393
5276
  This product includes source derived from [lint-staged](https://github.com/okonet/lint-staged) ([v11.2.6](https://github.com/okonet/lint-staged/tree/v11.2.6)), distributed under the [MIT License](https://github.com/okonet/lint-staged/blob/v11.2.6/LICENSE):
package/index.js CHANGED
@@ -102,7 +102,7 @@ function initialize() {
102
102
  logger.warn(
103
103
  'New Relic for Node.js in worker_threads is not officially supported. Not starting! To bypass this, set `config.worker_threads.enabled` to true in configuration.'
104
104
  )
105
- } else if (config.opentelemetry_bridge.enabled === true && otelBridgeAvailable() === false) {
105
+ } else if (config.opentelemetry.enabled === true && otelBridgeAvailable() === false) {
106
106
  logger.warn(
107
107
  'OpenTelemetry bridge enabled, but packages are missing. Not starting!'
108
108
  )
package/lib/agent.js CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- const AdaptiveSampler = require('./samplers/adaptive-sampler')
9
8
  const CollectorAPI = require('./collector/api')
10
9
  const ServerlessCollector = require('./collector/serverless')
11
10
  const DESTINATIONS = require('./config/attribute-filter').DESTINATIONS
@@ -41,6 +40,7 @@ const synthetics = require('./synthetics')
41
40
  const Harvester = require('./harvester')
42
41
  const { createFeatureUsageMetrics } = require('./util/application-logging')
43
42
  const HealthReporter = require('./health-reporter')
43
+ const Samplers = require('./samplers')
44
44
 
45
45
  // Map of valid states to whether or not data collection is valid
46
46
  const STATES = {
@@ -287,12 +287,8 @@ function Agent(config) {
287
287
  this.collector,
288
288
  this.harvester
289
289
  )
290
- this.transactionSampler = new AdaptiveSampler({
291
- agent: this,
292
- serverless: config.serverless_mode.enabled,
293
- period: config.sampling_target_period_in_seconds * 1000,
294
- target: config.sampling_target
295
- })
290
+
291
+ this.samplers = new Samplers(this)
296
292
 
297
293
  this.queries = new QueryTraceAggregator(
298
294
  {
@@ -848,10 +844,10 @@ Agent.prototype._listenForConfigChanges = function _listenForConfigChanges() {
848
844
  self.txSegmentNormalizer.load.apply(self.txSegmentNormalizer, arguments)
849
845
  })
850
846
  this.config.on('sampling_target', function updateSamplingTarget(target) {
851
- self.transactionSampler.samplingTarget = target
847
+ self.samplers.updateAdaptiveTarget(target)
852
848
  })
853
849
  this.config.on('sampling_target_period_in_seconds', function updateSamplePeriod(period) {
854
- self.transactionSampler.samplingPeriod = period * 1000
850
+ self.samplers.updateAdaptivePeriod(period)
855
851
  })
856
852
  this.config.on('event_harvest_config', function onHarvestConfigReceived(harvestConfig) {
857
853
  if (harvestConfig) {
package/lib/attributes.js CHANGED
@@ -19,6 +19,9 @@ const MAXIMUM_ATTR_VALUE_LENGTH = 4_096
19
19
  * @private
20
20
  */
21
21
  class Attributes {
22
+ static SCOPE_TRANSACTION = 'transaction'
23
+ static SCOPE_SEGMENT = 'segment'
24
+
22
25
  /**
23
26
  * @param {object} params Constructor parameters.
24
27
  * @param {string} params.scope
@@ -125,8 +128,8 @@ class Attributes {
125
128
 
126
129
  if (!isValidType(value)) {
127
130
  return logger.debug(
128
- 'Not adding attribute %s with %s value type. This is expected for undefined' +
129
- 'attributes and only an issue if an attribute is not expected to be undefined' +
131
+ 'Not adding attribute %s with %s value type. This is expected for undefined ' +
132
+ 'attributes and only an issue if an attribute is not expected to be undefined ' +
130
133
  'or not of the type expected.',
131
134
  key,
132
135
  typeof value
@@ -181,10 +184,14 @@ class Attributes {
181
184
  */
182
185
  function makeFilter(scope) {
183
186
  const { attributeFilter } = Config.getInstance()
184
- if (scope === 'transaction') {
185
- return (d, k) => attributeFilter.filterTransaction(d, k)
186
- } else if (scope === 'segment') {
187
- return (d, k) => attributeFilter.filterSegment(d, k)
187
+ switch (scope) {
188
+ case Attributes.SCOPE_TRANSACTION: {
189
+ return (d, k) => attributeFilter.filterTransaction(d, k)
190
+ }
191
+
192
+ case Attributes.SCOPE_SEGMENT: {
193
+ return (d, k) => attributeFilter.filterSegment(d, k)
194
+ }
188
195
  }
189
196
  }
190
197
 
@@ -1173,7 +1173,6 @@ defaultConfig.definition = () => {
1173
1173
  default: true,
1174
1174
  formatter: boolean
1175
1175
  },
1176
- ...samplerConfigs
1177
1176
  },
1178
1177
  partial_granularity: {
1179
1178
  enabled: {
@@ -1707,7 +1706,7 @@ defaultConfig.definition = () => {
1707
1706
  * NOTICE: this configuration is subject to change while the OTEL
1708
1707
  * feature set is in development.
1709
1708
  */
1710
- opentelemetry_bridge: {
1709
+ opentelemetry: {
1711
1710
  /**
1712
1711
  * Global switch for the whole OpenTelemetry feature. If it is set to
1713
1712
  * `false`, any other sub-feature, e.g. `traces`, will not be enabled
@@ -25,7 +25,7 @@ const mergeServerConfig = new MergeServerConfig()
25
25
  const { boolean: isTruthular } = require('./formatters')
26
26
  const configDefinition = definition()
27
27
  const parseLabels = require('../util/label-parser')
28
- const { buildTraceIdRatioSamplers, setTraceIdRatioSamplerFromEnv } = require('./samplers')
28
+ const { buildSamplers, setSamplersFromEnv } = require('./samplers')
29
29
 
30
30
  /**
31
31
  * CONSTANTS -- we gotta lotta 'em
@@ -125,6 +125,8 @@ function Config(config) {
125
125
  this.trusted_account_ids = null
126
126
  this.trusted_account_key = null
127
127
 
128
+ // The global sampling target for AdaptiveSamplers that do not
129
+ // specify their own sampling_target
128
130
  this.sampling_target = this.distributed_tracing.sampler.adaptive_sampling_target
129
131
  this.sampling_target_period_in_seconds = 60
130
132
  this.max_payload_size_in_bytes = DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES
@@ -999,10 +1001,13 @@ function getHostnameSafe(gcpId = null) {
999
1001
  // If not applicable, use the os.hostname()
1000
1002
  if (config.heroku.use_dyno_names && process.env.DYNO) {
1001
1003
  _hostname = process.env.DYNO || os.hostname()
1004
+ logger.info('Using Heroku dyno name for host name: %s', _hostname)
1002
1005
  } else if (config.utilization.gcp_use_instance_as_host && process.env.K_SERVICE && gcpId) {
1003
1006
  _hostname = gcpId
1007
+ logger.info('Using GCP instance ID for host name: %s', _hostname)
1004
1008
  } else {
1005
1009
  _hostname = os.hostname()
1010
+ logger.info('Using OS hostname for host name: %s', _hostname)
1006
1011
  }
1007
1012
  return _hostname
1008
1013
  } catch {
@@ -1010,14 +1015,15 @@ function getHostnameSafe(gcpId = null) {
1010
1015
 
1011
1016
  if (this.process_host.ipv_preference === '6' && addresses.ipv6) {
1012
1017
  _hostname = addresses.ipv6
1018
+ logger.info('Defaulting to ipv6 address for host name: %s', _hostname)
1013
1019
  } else if (addresses.ipv4) {
1014
- logger.info('Defaulting to ipv4 address for host name')
1020
+ logger.info('Defaulting to ipv4 address for host name: %s', _hostname)
1015
1021
  _hostname = addresses.ipv4
1016
1022
  } else if (addresses.ipv6) {
1017
- logger.info('Defaulting to ipv6 address for host name')
1023
+ logger.info('Defaulting to ipv6 address for host name: %s', _hostname)
1018
1024
  _hostname = addresses.ipv6
1019
1025
  } else {
1020
- logger.info('No hostname, ipv4, or ipv6 address found for machine')
1026
+ logger.info('No hostname, ipv4, or ipv6 address found for machine using UNKNOWN_BOX')
1021
1027
  _hostname = 'UNKNOWN_BOX'
1022
1028
  }
1023
1029
 
@@ -1065,8 +1071,8 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
1065
1071
  continue
1066
1072
  }
1067
1073
 
1068
- // Handle trace_id_ratio_based for distributed tracing sampler configuration
1069
- buildTraceIdRatioSamplers({ config: external, key, incomingConfig: internal, logger })
1074
+ // Handle object-based distributed tracing sampler configurations
1075
+ buildSamplers({ config: external, key, configToUpdate: internal, logger })
1070
1076
 
1071
1077
  if (key === 'ssl' && !isTruthular(external.ssl)) {
1072
1078
  logger.warn(SSL_WARNING)
@@ -1207,10 +1213,11 @@ Config.prototype._fromEnvironment = function _fromEnvironment(
1207
1213
  setFromEnv({ config, key, paths, envVar, formatter: value.formatter })
1208
1214
 
1209
1215
  // Handle custom configuration of the sampler if it's set to trace_id_ratio_based
1210
- // since sampler was set to a string but now has to be converted to an object.
1211
- // This is called here because we need set the sampler to a value first in config before setting
1212
- // trace id ratio sampler (if the user set that)
1213
- setTraceIdRatioSamplerFromEnv({
1216
+ // or adaptive with adaptive.sampling_target defined, since sampler was set to a
1217
+ // string but now has to be converted to an object.
1218
+ // This is called here because we need to set the sampler to a value first in config
1219
+ // before setting the samplers.
1220
+ setSamplersFromEnv({
1214
1221
  key,
1215
1222
  config,
1216
1223
  paths,