newrelic 9.7.1 → 9.7.2
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 +4 -0
- package/lib/instrumentation/grpc-js/grpc.js +20 -23
- package/package.json +1 -1
package/NEWS.md
CHANGED
|
@@ -12,11 +12,23 @@ const DESTINATION = DESTINATIONS.TRANS_EVENT | DESTINATIONS.ERROR_EVENT
|
|
|
12
12
|
const semver = require('semver')
|
|
13
13
|
|
|
14
14
|
module.exports = function instrument(shim) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
const grpcVersion = shim.require('./package.json').version
|
|
16
|
+
const genericShim = shim.makeSpecializedShim(shim.GENERIC, 'grpc-client-interceptor')
|
|
17
|
+
|
|
18
|
+
if (semver.gte(grpcVersion, '1.8.0')) {
|
|
19
|
+
const resolvingCall = genericShim.require('./build/src/resolving-call')
|
|
20
|
+
genericShim.wrap(resolvingCall.ResolvingCall.prototype, 'start', wrapStart)
|
|
21
|
+
} else {
|
|
22
|
+
const callStream = genericShim.require('./build/src/call-stream')
|
|
23
|
+
genericShim.wrap(callStream.Http2CallStream.prototype, 'start', wrapStart)
|
|
24
|
+
}
|
|
18
25
|
|
|
19
26
|
const webFrameworkShim = shim.makeSpecializedShim(shim.WEB_FRAMEWORK, 'server')
|
|
27
|
+
if (semver.lt(grpcVersion, '1.4.0')) {
|
|
28
|
+
shim.logger.debug('gRPC server-side instrumentation only supported on grpc-js >=1.4.0')
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
const server = webFrameworkShim.require('./build/src/server')
|
|
21
33
|
webFrameworkShim.setFramework('gRPC')
|
|
22
34
|
webFrameworkShim.wrap(server.Server.prototype, 'register', wrapRegister)
|
|
@@ -41,9 +53,11 @@ function wrapStart(shim, original) {
|
|
|
41
53
|
|
|
42
54
|
const channel = this.channel
|
|
43
55
|
const authorityName = (channel.target && channel.target.path) || channel.getDefaultAuthority
|
|
56
|
+
// in 1.8.0 this changed from methodName to method
|
|
57
|
+
const method = this.methodName || this.method
|
|
44
58
|
|
|
45
59
|
const segment = shim.createSegment({
|
|
46
|
-
name: `External/${authorityName}${
|
|
60
|
+
name: `External/${authorityName}${method}`,
|
|
47
61
|
opaque: true,
|
|
48
62
|
recorder: recordExternal(authorityName, 'gRPC')
|
|
49
63
|
})
|
|
@@ -89,10 +103,10 @@ function wrapStart(shim, original) {
|
|
|
89
103
|
|
|
90
104
|
const protocol = 'grpc'
|
|
91
105
|
|
|
92
|
-
const url = `${protocol}://${authorityName}${
|
|
106
|
+
const url = `${protocol}://${authorityName}${method}`
|
|
93
107
|
|
|
94
108
|
segment.addAttribute('http.url', url)
|
|
95
|
-
segment.addAttribute('http.method',
|
|
109
|
+
segment.addAttribute('http.method', method)
|
|
96
110
|
|
|
97
111
|
if (originalListener && originalListener.onReceiveStatus) {
|
|
98
112
|
const onReceiveStatuts = shim.bindSegment(originalListener.onReceiveStatus, segment)
|
|
@@ -212,20 +226,3 @@ function shouldTrackError(statusCode, config) {
|
|
|
212
226
|
!config.grpc.ignore_status_codes.includes(statusCode)
|
|
213
227
|
)
|
|
214
228
|
}
|
|
215
|
-
|
|
216
|
-
module.exports = function instrument(shim) {
|
|
217
|
-
const genericShim = shim.makeSpecializedShim(shim.GENERIC, 'call-stream')
|
|
218
|
-
const callStream = genericShim.require('./build/src/call-stream')
|
|
219
|
-
genericShim.wrap(callStream.Http2CallStream.prototype, 'start', wrapStart)
|
|
220
|
-
|
|
221
|
-
const webFrameworkShim = shim.makeSpecializedShim(shim.WEB_FRAMEWORK, 'server')
|
|
222
|
-
const grpcVersion = shim.require('./package.json').version
|
|
223
|
-
if (semver.lt(grpcVersion, '1.4.0')) {
|
|
224
|
-
shim.logger.debug('gRPC server-side instrumentation only supported on grpc-js >=1.4.0')
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const server = webFrameworkShim.require('./build/src/server')
|
|
229
|
-
webFrameworkShim.setFramework('gRPC')
|
|
230
|
-
webFrameworkShim.wrap(server.Server.prototype, 'register', wrapRegister)
|
|
231
|
-
}
|