newrelic 9.7.2 → 9.7.4
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 +10 -2
- package/THIRD_PARTY_NOTICES.md +199 -0
- package/api.js +10 -0
- package/lib/shim/shim.js +1 -1
- package/lib/shim/webframework-shim.js +1 -17
- package/lib/system-info.js +18 -3
- package/lib/transaction/tracer/index.js +2 -0
- package/lib/util/code-level-metrics.js +23 -2
- package/package.json +5 -3
package/NEWS.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
### v9.7.
|
|
1
|
+
### v9.7.4 (2022-12-15)
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* Fixed system info gathering to prevent unhandled promise rejection when an error occurs reading `/proc` information.
|
|
4
4
|
|
|
5
|
+
### v9.7.3 (2022-12-12)
|
|
6
|
+
|
|
7
|
+
* Added support for Code Level Metrics on API methods: `startSegment`, `startBackgroundTransaction`, and `startWebTransaction`.
|
|
8
|
+
|
|
9
|
+
### v9.7.2 (2022-12-07)
|
|
10
|
+
|
|
11
|
+
* Updated `@grpc/grpc-js` instrumentation to work with 1.8.0.
|
|
12
|
+
|
|
5
13
|
### v9.7.1 (2022-12-06)
|
|
6
14
|
|
|
7
15
|
* Reintroduced throttling during reading of instrumented application's dependency tree during startup, to prevent EMFILE issues.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -54,6 +54,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
54
54
|
* [husky](#husky)
|
|
55
55
|
* [jsdoc](#jsdoc)
|
|
56
56
|
* [lint-staged](#lint-staged)
|
|
57
|
+
* [lockfile-lint](#lockfile-lint)
|
|
57
58
|
* [memcached](#memcached)
|
|
58
59
|
* [minami](#minami)
|
|
59
60
|
* [nock](#nock)
|
|
@@ -2787,6 +2788,204 @@ SOFTWARE.
|
|
|
2787
2788
|
|
|
2788
2789
|
```
|
|
2789
2790
|
|
|
2791
|
+
### lockfile-lint
|
|
2792
|
+
|
|
2793
|
+
This product includes source derived from [lockfile-lint](https://github.com/lirantal/lockfile-lint) ([v4.9.6](https://github.com/lirantal/lockfile-lint/tree/v4.9.6)), distributed under the [Apache-2.0 License](https://github.com/lirantal/lockfile-lint/blob/v4.9.6/LICENSE):
|
|
2794
|
+
|
|
2795
|
+
```
|
|
2796
|
+
|
|
2797
|
+
Apache License
|
|
2798
|
+
Version 2.0, January 2004
|
|
2799
|
+
https://www.apache.org/licenses/
|
|
2800
|
+
|
|
2801
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
2802
|
+
|
|
2803
|
+
1. Definitions.
|
|
2804
|
+
|
|
2805
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
2806
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
2807
|
+
|
|
2808
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
2809
|
+
the copyright owner that is granting the License.
|
|
2810
|
+
|
|
2811
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
2812
|
+
other entities that control, are controlled by, or are under common
|
|
2813
|
+
control with that entity. For the purposes of this definition,
|
|
2814
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
2815
|
+
direction or management of such entity, whether by contract or
|
|
2816
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
2817
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
2818
|
+
|
|
2819
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
2820
|
+
exercising permissions granted by this License.
|
|
2821
|
+
|
|
2822
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
2823
|
+
including but not limited to software source code, documentation
|
|
2824
|
+
source, and configuration files.
|
|
2825
|
+
|
|
2826
|
+
"Object" form shall mean any form resulting from mechanical
|
|
2827
|
+
transformation or translation of a Source form, including but
|
|
2828
|
+
not limited to compiled object code, generated documentation,
|
|
2829
|
+
and conversions to other media types.
|
|
2830
|
+
|
|
2831
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
2832
|
+
Object form, made available under the License, as indicated by a
|
|
2833
|
+
copyright notice that is included in or attached to the work
|
|
2834
|
+
(an example is provided in the Appendix below).
|
|
2835
|
+
|
|
2836
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
2837
|
+
form, that is based on (or derived from) the Work and for which the
|
|
2838
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
2839
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
2840
|
+
of this License, Derivative Works shall not include works that remain
|
|
2841
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
2842
|
+
the Work and Derivative Works thereof.
|
|
2843
|
+
|
|
2844
|
+
"Contribution" shall mean any work of authorship, including
|
|
2845
|
+
the original version of the Work and any modifications or additions
|
|
2846
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
2847
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
2848
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
2849
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
2850
|
+
means any form of electronic, verbal, or written communication sent
|
|
2851
|
+
to the Licensor or its representatives, including but not limited to
|
|
2852
|
+
communication on electronic mailing lists, source code control systems,
|
|
2853
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
2854
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
2855
|
+
excluding communication that is conspicuously marked or otherwise
|
|
2856
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
2857
|
+
|
|
2858
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
2859
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
2860
|
+
subsequently incorporated within the Work.
|
|
2861
|
+
|
|
2862
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
2863
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
2864
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
2865
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
2866
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
2867
|
+
Work and such Derivative Works in Source or Object form.
|
|
2868
|
+
|
|
2869
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
2870
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
2871
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
2872
|
+
(except as stated in this section) patent license to make, have made,
|
|
2873
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
2874
|
+
where such license applies only to those patent claims licensable
|
|
2875
|
+
by such Contributor that are necessarily infringed by their
|
|
2876
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
2877
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
2878
|
+
institute patent litigation against any entity (including a
|
|
2879
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
2880
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
2881
|
+
or contributory patent infringement, then any patent licenses
|
|
2882
|
+
granted to You under this License for that Work shall terminate
|
|
2883
|
+
as of the date such litigation is filed.
|
|
2884
|
+
|
|
2885
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
2886
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
2887
|
+
modifications, and in Source or Object form, provided that You
|
|
2888
|
+
meet the following conditions:
|
|
2889
|
+
|
|
2890
|
+
(a) You must give any other recipients of the Work or
|
|
2891
|
+
Derivative Works a copy of this License; and
|
|
2892
|
+
|
|
2893
|
+
(b) You must cause any modified files to carry prominent notices
|
|
2894
|
+
stating that You changed the files; and
|
|
2895
|
+
|
|
2896
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
2897
|
+
that You distribute, all copyright, patent, trademark, and
|
|
2898
|
+
attribution notices from the Source form of the Work,
|
|
2899
|
+
excluding those notices that do not pertain to any part of
|
|
2900
|
+
the Derivative Works; and
|
|
2901
|
+
|
|
2902
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
2903
|
+
distribution, then any Derivative Works that You distribute must
|
|
2904
|
+
include a readable copy of the attribution notices contained
|
|
2905
|
+
within such NOTICE file, excluding those notices that do not
|
|
2906
|
+
pertain to any part of the Derivative Works, in at least one
|
|
2907
|
+
of the following places: within a NOTICE text file distributed
|
|
2908
|
+
as part of the Derivative Works; within the Source form or
|
|
2909
|
+
documentation, if provided along with the Derivative Works; or,
|
|
2910
|
+
within a display generated by the Derivative Works, if and
|
|
2911
|
+
wherever such third-party notices normally appear. The contents
|
|
2912
|
+
of the NOTICE file are for informational purposes only and
|
|
2913
|
+
do not modify the License. You may add Your own attribution
|
|
2914
|
+
notices within Derivative Works that You distribute, alongside
|
|
2915
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
2916
|
+
that such additional attribution notices cannot be construed
|
|
2917
|
+
as modifying the License.
|
|
2918
|
+
|
|
2919
|
+
You may add Your own copyright statement to Your modifications and
|
|
2920
|
+
may provide additional or different license terms and conditions
|
|
2921
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
2922
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
2923
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
2924
|
+
the conditions stated in this License.
|
|
2925
|
+
|
|
2926
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
2927
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
2928
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
2929
|
+
this License, without any additional terms or conditions.
|
|
2930
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
2931
|
+
the terms of any separate license agreement you may have executed
|
|
2932
|
+
with Licensor regarding such Contributions.
|
|
2933
|
+
|
|
2934
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
2935
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
2936
|
+
except as required for reasonable and customary use in describing the
|
|
2937
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
2938
|
+
|
|
2939
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
2940
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
2941
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
2942
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
2943
|
+
implied, including, without limitation, any warranties or conditions
|
|
2944
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
2945
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
2946
|
+
appropriateness of using or redistributing the Work and assume any
|
|
2947
|
+
risks associated with Your exercise of permissions under this License.
|
|
2948
|
+
|
|
2949
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
2950
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
2951
|
+
unless required by applicable law (such as deliberate and grossly
|
|
2952
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
2953
|
+
liable to You for damages, including any direct, indirect, special,
|
|
2954
|
+
incidental, or consequential damages of any character arising as a
|
|
2955
|
+
result of this License or out of the use or inability to use the
|
|
2956
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
2957
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
2958
|
+
other commercial damages or losses), even if such Contributor
|
|
2959
|
+
has been advised of the possibility of such damages.
|
|
2960
|
+
|
|
2961
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
2962
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
2963
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
2964
|
+
or other liability obligations and/or rights consistent with this
|
|
2965
|
+
License. However, in accepting such obligations, You may act only
|
|
2966
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
2967
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
2968
|
+
defend, and hold each Contributor harmless for any liability
|
|
2969
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
2970
|
+
of your accepting any such warranty or additional liability.
|
|
2971
|
+
|
|
2972
|
+
END OF TERMS AND CONDITIONS
|
|
2973
|
+
|
|
2974
|
+
Copyright 2019 Liran Tal <liran.tal@gmail.com>.
|
|
2975
|
+
|
|
2976
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
2977
|
+
you may not use this file except in compliance with the License.
|
|
2978
|
+
You may obtain a copy of the License at
|
|
2979
|
+
|
|
2980
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
2981
|
+
|
|
2982
|
+
Unless required by applicable law or agreed to in writing, software
|
|
2983
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
2984
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2985
|
+
See the License for the specific language governing permissions and
|
|
2986
|
+
limitations under the License.
|
|
2987
|
+
```
|
|
2988
|
+
|
|
2790
2989
|
### memcached
|
|
2791
2990
|
|
|
2792
2991
|
This product includes source derived from [memcached](https://github.com/3rd-Eden/node-memcached) ([v2.2.2](https://github.com/3rd-Eden/node-memcached/tree/v2.2.2)), distributed under the [MIT License](https://github.com/3rd-Eden/node-memcached/blob/v2.2.2/LICENSE):
|
package/api.js
CHANGED
|
@@ -19,10 +19,15 @@ const TransactionShim = require('./lib/shim/transaction-shim')
|
|
|
19
19
|
const TransactionHandle = require('./lib/transaction/handle')
|
|
20
20
|
const AwsLambda = require('./lib/serverless/aws-lambda')
|
|
21
21
|
const applicationLogging = require('./lib/util/application-logging')
|
|
22
|
+
const {
|
|
23
|
+
assignCLMSymbol,
|
|
24
|
+
addCLMAttributes: maybeAddCLMAttributes
|
|
25
|
+
} = require('./lib/util/code-level-metrics')
|
|
22
26
|
|
|
23
27
|
const ATTR_DEST = require('./lib/config/attribute-filter').DESTINATIONS
|
|
24
28
|
const MODULE_TYPE = require('./lib/shim/constants').MODULE_TYPE
|
|
25
29
|
const NAMES = require('./lib/metrics/names')
|
|
30
|
+
|
|
26
31
|
/*
|
|
27
32
|
*
|
|
28
33
|
* CONSTANTS
|
|
@@ -840,6 +845,7 @@ API.prototype.startSegment = function startSegment(name, record, handler, callba
|
|
|
840
845
|
return handler(callback)
|
|
841
846
|
}
|
|
842
847
|
|
|
848
|
+
assignCLMSymbol(this.shim, handler)
|
|
843
849
|
// Create the segment and call the handler.
|
|
844
850
|
const wrappedHandler = this.shim.record(handler, function handlerNamer(shim) {
|
|
845
851
|
return {
|
|
@@ -901,6 +907,7 @@ API.prototype.startWebTransaction = function startWebTransaction(url, handle) {
|
|
|
901
907
|
const tracer = this.agent.tracer
|
|
902
908
|
const parent = tracer.getTransaction()
|
|
903
909
|
|
|
910
|
+
assignCLMSymbol(shim, handle)
|
|
904
911
|
return tracer.transactionNestProxy('web', function startWebSegment() {
|
|
905
912
|
const tx = tracer.getTransaction()
|
|
906
913
|
|
|
@@ -926,6 +933,7 @@ API.prototype.startWebTransaction = function startWebTransaction(url, handle) {
|
|
|
926
933
|
tx.baseSegment.start()
|
|
927
934
|
|
|
928
935
|
const boundHandle = tracer.bindFunction(handle, tx.baseSegment)
|
|
936
|
+
maybeAddCLMAttributes(handle, tx.baseSegment)
|
|
929
937
|
let returnResult = boundHandle.call(this)
|
|
930
938
|
if (returnResult && shim.isPromise(returnResult)) {
|
|
931
939
|
returnResult = shim.interceptPromise(returnResult, tx.end.bind(tx))
|
|
@@ -999,6 +1007,7 @@ function startBackgroundTransaction(name, group, handle) {
|
|
|
999
1007
|
const txName = group + '/' + name
|
|
1000
1008
|
const parent = tracer.getTransaction()
|
|
1001
1009
|
|
|
1010
|
+
assignCLMSymbol(shim, handle)
|
|
1002
1011
|
return tracer.transactionNestProxy('bg', function startBackgroundSegment() {
|
|
1003
1012
|
const tx = tracer.getTransaction()
|
|
1004
1013
|
|
|
@@ -1025,6 +1034,7 @@ function startBackgroundTransaction(name, group, handle) {
|
|
|
1025
1034
|
tx.baseSegment.start()
|
|
1026
1035
|
|
|
1027
1036
|
const boundHandle = tracer.bindFunction(handle, tx.baseSegment)
|
|
1037
|
+
maybeAddCLMAttributes(handle, tx.baseSegment)
|
|
1028
1038
|
let returnResult = boundHandle.call(this)
|
|
1029
1039
|
if (returnResult && shim.isPromise(returnResult)) {
|
|
1030
1040
|
returnResult = shim.interceptPromise(returnResult, tx.end.bind(tx))
|
package/lib/shim/shim.js
CHANGED
|
@@ -14,7 +14,7 @@ const path = require('path')
|
|
|
14
14
|
const specs = require('./specs')
|
|
15
15
|
const util = require('util')
|
|
16
16
|
const symbols = require('../symbols')
|
|
17
|
-
const maybeAddCLMAttributes = require('../util/code-level-metrics')
|
|
17
|
+
const { addCLMAttributes: maybeAddCLMAttributes } = require('../util/code-level-metrics')
|
|
18
18
|
|
|
19
19
|
// Some modules do terrible things, like change the prototype of functions. To
|
|
20
20
|
// avoid crashing things we'll use a cached copy of apply everywhere.
|
|
@@ -16,6 +16,7 @@ const specs = require('./specs')
|
|
|
16
16
|
const urltils = require('../util/urltils')
|
|
17
17
|
const util = require('util')
|
|
18
18
|
const symbols = require('../symbols')
|
|
19
|
+
const { assignCLMSymbol } = require('../util/code-level-metrics')
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* An enumeration of well-known web frameworks so that new instrumentations can
|
|
@@ -677,23 +678,6 @@ function _defaultResponsePredicate() {
|
|
|
677
678
|
return false
|
|
678
679
|
}
|
|
679
680
|
|
|
680
|
-
/**
|
|
681
|
-
* Attaches a flag on function indicating that
|
|
682
|
-
* CLM attributes need to be associated with the middleware
|
|
683
|
-
* span during record
|
|
684
|
-
*
|
|
685
|
-
* Note: director middleware instrumentation passes in a string as the "function" so we have to check if the middleware is actually a function
|
|
686
|
-
* to avoid crashing.
|
|
687
|
-
*
|
|
688
|
-
* @param {Shim} shim instance of shim
|
|
689
|
-
* @param {Function} middleware function to apply clm symbol
|
|
690
|
-
*/
|
|
691
|
-
function assignCLMSymbol(shim, middleware) {
|
|
692
|
-
if (shim.isFunction(middleware) && shim.agent.config.code_level_metrics.enabled) {
|
|
693
|
-
middleware[symbols.clm] = true
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
681
|
/**
|
|
698
682
|
* Wraps the given function in a middleware recorder function.
|
|
699
683
|
*
|
package/lib/system-info.js
CHANGED
|
@@ -214,7 +214,7 @@ module.exports._getProcessorStats = async function getProcessorStats() {
|
|
|
214
214
|
|
|
215
215
|
return processorStats
|
|
216
216
|
} else if (platform.match(/linux/i)) {
|
|
217
|
-
const data = await
|
|
217
|
+
const data = await getProcInfo('/proc/cpuinfo')
|
|
218
218
|
|
|
219
219
|
return parseCpuInfo(data)
|
|
220
220
|
}
|
|
@@ -237,7 +237,7 @@ module.exports._getMemoryStats = async function getMemoryStats() {
|
|
|
237
237
|
const memory = await getSysctlValue(['hw.realmem'])
|
|
238
238
|
return parseInt(memory, 10) / (1024 * 1024)
|
|
239
239
|
} else if (platform.match(/linux/i)) {
|
|
240
|
-
const data = await
|
|
240
|
+
const data = await getProcInfo('/proc/meminfo')
|
|
241
241
|
return parseMemInfo(data)
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -254,7 +254,7 @@ async function getKernelVersion() {
|
|
|
254
254
|
if (platform.match(/darwin/i) || platform.match(/bsd/i)) {
|
|
255
255
|
return await getSysctlValue(['kern.version'])
|
|
256
256
|
} else if (platform.match(/linux/i)) {
|
|
257
|
-
return await
|
|
257
|
+
return await getProcInfo('/proc/version')
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
logger.debug('Unknown platform: %s; could not read kernel version', platform)
|
|
@@ -294,3 +294,18 @@ async function getSysctlValue(names = []) {
|
|
|
294
294
|
|
|
295
295
|
return returnValue
|
|
296
296
|
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Helper method for getting /proc/* file information in Linux environments
|
|
300
|
+
*
|
|
301
|
+
* @param {string} procPath - the proc file to read
|
|
302
|
+
* @returns {*} null if the lookup fails, otherwise the proc file information
|
|
303
|
+
*/
|
|
304
|
+
async function getProcInfo(procPath) {
|
|
305
|
+
try {
|
|
306
|
+
return await readProc(procPath)
|
|
307
|
+
} catch (err) {
|
|
308
|
+
// swallow the error if reading fails, logging handled in readProc()
|
|
309
|
+
return null
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -11,6 +11,7 @@ const symbols = require('../../symbols')
|
|
|
11
11
|
const INACTIVE_TRANSACTION_MESSAGE = 'Not creating segment "%s" because no transaction was active'
|
|
12
12
|
const SKIP_WRAPPING_FUNCTION_MESSAGE = 'Not wrapping "%s" because it was not a function'
|
|
13
13
|
const CREATE_SEGMENT_MESSAGE = 'Creating "%s" segment for transaction %s.'
|
|
14
|
+
const { addCLMAttributes: maybeAddCLMAttributes } = require('../../util/code-level-metrics')
|
|
14
15
|
|
|
15
16
|
module.exports = Tracer
|
|
16
17
|
|
|
@@ -85,6 +86,7 @@ function addSegment(name, recorder, parent, full, task) {
|
|
|
85
86
|
|
|
86
87
|
const segment = this.createSegment(name, recorder, parent)
|
|
87
88
|
|
|
89
|
+
maybeAddCLMAttributes(task, segment)
|
|
88
90
|
return this.bindFunction(task, segment, full)(segment)
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -7,6 +7,23 @@
|
|
|
7
7
|
const logger = require('../logger').child({ component: 'code-level-metrics' })
|
|
8
8
|
const { isValidLength } = require('./byte-limit')
|
|
9
9
|
const symbols = require('../symbols')
|
|
10
|
+
const clmUtils = module.exports
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Attaches a flag on function indicating that
|
|
14
|
+
* CLM attributes need to be associated with it.
|
|
15
|
+
*
|
|
16
|
+
* Note: director middleware instrumentation passes in a string as the "function" so we have to check if the function is actually a function
|
|
17
|
+
* to avoid crashing, abstraction not FTW
|
|
18
|
+
*
|
|
19
|
+
* @param {Shim} shim instance of shim
|
|
20
|
+
* @param {Function} fn function to apply clm symbol
|
|
21
|
+
*/
|
|
22
|
+
clmUtils.assignCLMSymbol = function assignCLMSymbol(shim, fn) {
|
|
23
|
+
if (shim.isFunction(fn) && shim.agent.config.code_level_metrics.enabled) {
|
|
24
|
+
fn[symbols.clm] = true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
10
27
|
|
|
11
28
|
/**
|
|
12
29
|
* Uses function name if truthy
|
|
@@ -29,7 +46,7 @@ function setFunctionName(name) {
|
|
|
29
46
|
* @param {Function} fn function reference
|
|
30
47
|
* @param {TraceSegment} segment active segment to attach code.* attrs
|
|
31
48
|
*/
|
|
32
|
-
|
|
49
|
+
clmUtils.addCLMAttributes = function addCLMAttributes(fn, segment) {
|
|
33
50
|
if (!fn[symbols.clm]) {
|
|
34
51
|
return
|
|
35
52
|
}
|
|
@@ -48,7 +65,11 @@ module.exports = function addCLMAttributes(fn, segment) {
|
|
|
48
65
|
segment.addAttribute('code.column', column + 1)
|
|
49
66
|
}
|
|
50
67
|
} catch (err) {
|
|
51
|
-
logger.infoOnce(
|
|
68
|
+
logger.infoOnce(
|
|
69
|
+
'clm:function-inspector',
|
|
70
|
+
{ err },
|
|
71
|
+
'Not using v8 function inspector, falling back to function name'
|
|
72
|
+
)
|
|
52
73
|
const fnName = setFunctionName(fn.name)
|
|
53
74
|
|
|
54
75
|
if (isValidLength(fnName, 255)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.4",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -151,6 +151,7 @@
|
|
|
151
151
|
"prepare-test": "npm run ssl && npm run docker-env",
|
|
152
152
|
"lint": "eslint ./*.{js,mjs} lib test bin examples",
|
|
153
153
|
"lint:fix": "eslint --fix, ./*.{js,mjs} lib test bin examples",
|
|
154
|
+
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
|
|
154
155
|
"public-docs": "jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/",
|
|
155
156
|
"publish-docs": "./bin/publish-docs.sh",
|
|
156
157
|
"services": "./bin/docker-services.sh",
|
|
@@ -192,8 +193,8 @@
|
|
|
192
193
|
"winston-transport": "^4.5.0"
|
|
193
194
|
},
|
|
194
195
|
"optionalDependencies": {
|
|
195
|
-
"@
|
|
196
|
-
"@
|
|
196
|
+
"@contrast/fn-inspect": "^3.3.0",
|
|
197
|
+
"@newrelic/native-metrics": "^9.0.0"
|
|
197
198
|
},
|
|
198
199
|
"devDependencies": {
|
|
199
200
|
"@newrelic/eslint-config": "^0.2.0",
|
|
@@ -221,6 +222,7 @@
|
|
|
221
222
|
"husky": "^6.0.0",
|
|
222
223
|
"jsdoc": "^3.6.3",
|
|
223
224
|
"lint-staged": "^11.0.0",
|
|
225
|
+
"lockfile-lint": "^4.9.6",
|
|
224
226
|
"memcached": ">=0.2.8",
|
|
225
227
|
"minami": "^1.2.3",
|
|
226
228
|
"nock": "11.8.0",
|