newrelic 7.5.2 → 8.3.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 +4989 -4886
- package/THIRD_PARTY_NOTICES.md +625 -216
- package/api.js +105 -174
- package/bin/test-naming-rules.js +38 -32
- package/bin/tracetractor +0 -1
- package/index.js +12 -18
- package/lib/agent.js +108 -111
- package/lib/aggregators/base-aggregator.js +1 -1
- package/lib/aggregators/event-aggregator.js +6 -6
- package/lib/attributes.js +12 -13
- package/lib/collector/api.js +32 -42
- package/lib/collector/facts.js +67 -65
- package/lib/collector/http-agents.js +30 -27
- package/lib/collector/parse-response.js +1 -2
- package/lib/collector/remote-method.js +43 -36
- package/lib/collector/serverless.js +13 -18
- package/lib/collector/ssl/certificates.js +1056 -1056
- package/lib/config/attribute-filter.js +90 -82
- package/lib/config/default.js +30 -18
- package/lib/config/env.js +17 -12
- package/lib/config/harvest-config-validator.js +1 -1
- package/lib/config/index.js +160 -177
- package/lib/config/merge-server-config.js +7 -5
- package/lib/custom-events/custom-event-aggregator.js +1 -1
- package/lib/db/parse-sql.js +6 -9
- package/lib/db/parsed-statement.js +6 -13
- package/lib/db/query-parsers/sql.js +6 -9
- package/lib/db/query-sample.js +7 -3
- package/lib/db/query-trace-aggregator.js +12 -12
- package/lib/db/utils.js +1 -1
- package/lib/environment.js +173 -138
- package/lib/errors/error-collector.js +18 -31
- package/lib/errors/error-event-aggregator.js +1 -1
- package/lib/errors/error-trace-aggregator.js +2 -3
- package/lib/errors/helper.js +21 -30
- package/lib/errors/index.js +16 -28
- package/lib/feature_flags.js +5 -8
- package/lib/grpc/connection/states.js +6 -6
- package/lib/grpc/connection.js +35 -46
- package/lib/header-attributes.js +49 -53
- package/lib/instrumentation/amqplib.js +8 -17
- package/lib/instrumentation/bluebird.js +61 -20
- package/lib/instrumentation/cassandra-driver.js +2 -2
- package/lib/instrumentation/connect.js +4 -3
- package/lib/instrumentation/core/async_hooks.js +11 -4
- package/lib/instrumentation/core/child_process.js +20 -28
- package/lib/instrumentation/core/crypto.js +1 -7
- package/lib/instrumentation/core/dns.js +3 -7
- package/lib/instrumentation/core/domain.js +2 -8
- package/lib/instrumentation/core/fs.js +22 -37
- package/lib/instrumentation/core/globals.js +3 -7
- package/lib/instrumentation/core/http-outbound.js +15 -40
- package/lib/instrumentation/core/http.js +29 -63
- package/lib/instrumentation/core/inspector.js +6 -10
- package/lib/instrumentation/core/net.js +3 -1
- package/lib/instrumentation/core/timers.js +17 -24
- package/lib/instrumentation/core/zlib.js +2 -10
- package/lib/instrumentation/express.js +4 -2
- package/lib/instrumentation/fastify/spec-builders.js +5 -0
- package/lib/instrumentation/fastify.js +37 -10
- package/lib/instrumentation/hapi/hapi-17.js +9 -10
- package/lib/instrumentation/hapi.js +15 -15
- package/lib/instrumentation/ioredis.js +1 -2
- package/lib/instrumentation/memcached.js +39 -43
- package/lib/instrumentation/mongodb/common.js +218 -0
- package/lib/instrumentation/mongodb/constants.js +87 -0
- package/lib/instrumentation/mongodb/v2-mongo.js +110 -0
- package/lib/instrumentation/mongodb/v3-mongo.js +80 -0
- package/lib/instrumentation/mongodb/v4-mongo.js +90 -0
- package/lib/instrumentation/mongodb.js +20 -312
- package/lib/instrumentation/mysql.js +33 -26
- package/lib/instrumentation/oracle.js +10 -14
- package/lib/instrumentation/pg.js +30 -21
- package/lib/instrumentation/promise.js +20 -17
- package/lib/instrumentation/redis.js +30 -30
- package/lib/instrumentation/when.js +9 -1
- package/lib/instrumentations.js +24 -24
- package/lib/logger.js +1 -1
- package/lib/metrics/index.js +37 -17
- package/lib/metrics/mapper.js +9 -9
- package/lib/metrics/metric-aggregator.js +5 -10
- package/lib/metrics/names.js +8 -7
- package/lib/metrics/normalizer/rule.js +6 -7
- package/lib/metrics/normalizer/tx_segment.js +17 -13
- package/lib/metrics/normalizer.js +30 -33
- package/lib/metrics/recorders/custom.js +3 -1
- package/lib/metrics/recorders/distributed-trace.js +3 -18
- package/lib/metrics/recorders/generic.js +3 -2
- package/lib/metrics/recorders/http.js +4 -6
- package/lib/metrics/recorders/http_external.js +1 -3
- package/lib/metrics/recorders/message-transaction.js +2 -12
- package/lib/metrics/recorders/other.js +2 -12
- package/lib/parse-proc-cpuinfo.js +11 -16
- package/lib/parse-proc-meminfo.js +5 -3
- package/lib/prioritized-attributes.js +12 -17
- package/lib/priority-queue.js +1 -1
- package/lib/proxy/grpc.js +1 -1
- package/lib/reservoir.js +9 -3
- package/lib/sampler.js +12 -13
- package/lib/serverless/api-gateway.js +3 -3
- package/lib/serverless/aws-lambda.js +28 -37
- package/lib/shim/conglomerate-shim.js +4 -4
- package/lib/shim/datastore-shim.js +29 -38
- package/lib/shim/index.js +8 -9
- package/lib/shim/message-shim.js +111 -113
- package/lib/shim/promise-shim.js +18 -13
- package/lib/shim/shim.js +72 -66
- package/lib/shim/specs/index.js +18 -19
- package/lib/shim/transaction-shim.js +26 -36
- package/lib/shim/webframework-shim.js +25 -35
- package/lib/shimmer.js +184 -166
- package/lib/spans/create-span-event-aggregator.js +24 -44
- package/lib/spans/span-context.js +4 -10
- package/lib/spans/span-event-aggregator.js +68 -13
- package/lib/spans/span-event.js +5 -7
- package/lib/spans/span-streamer.js +10 -18
- package/lib/spans/streaming-span-event-aggregator.js +1 -1
- package/lib/spans/streaming-span-event.js +4 -4
- package/lib/stats/apdex.js +5 -11
- package/lib/stats/index.js +12 -17
- package/lib/system-info.js +7 -3
- package/lib/timer.js +30 -16
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/handle.js +19 -19
- package/lib/transaction/index.js +94 -112
- package/lib/transaction/name-state.js +5 -6
- package/lib/transaction/trace/aggregator.js +78 -73
- package/lib/transaction/trace/exclusive-time-calculator.js +5 -9
- package/lib/transaction/trace/index.js +26 -24
- package/lib/transaction/trace/segment.js +39 -56
- package/lib/transaction/tracecontext.js +37 -45
- package/lib/transaction/tracer/index.js +79 -44
- package/lib/transaction/transaction-event-aggregator.js +29 -31
- package/lib/uninstrumented.js +4 -5
- package/lib/util/attribute-types.js +1 -5
- package/lib/util/byte-limit.js +0 -1
- package/lib/util/cat.js +5 -13
- package/lib/util/codec.js +8 -4
- package/lib/util/deep-equal.js +48 -18
- package/lib/util/flatten.js +5 -2
- package/lib/util/hashes.js +2 -2
- package/lib/util/label-parser.js +7 -13
- package/lib/util/logger.js +31 -13
- package/lib/util/process-version.js +1 -1
- package/lib/util/properties.js +1 -1
- package/lib/util/sql/obfuscate.js +7 -17
- package/lib/util/stream-sink.js +2 -3
- package/lib/util/urltils.js +9 -13
- package/lib/utilization/aws-info.js +2 -3
- package/lib/utilization/azure-info.js +32 -30
- package/lib/utilization/common.js +5 -4
- package/lib/utilization/docker-info.js +4 -6
- package/lib/utilization/gcp-info.js +36 -35
- package/lib/utilization/index.js +1 -1
- package/lib/utilization/kubernetes-info.js +2 -2
- package/lib/utilization/pcf-info.js +4 -4
- package/package.json +32 -18
- package/stub_api.js +8 -6
|
@@ -26,37 +26,78 @@ module.exports = function initialize(agent, bluebird, moduleName, shim) {
|
|
|
26
26
|
// _execute is in bluebird 3.x
|
|
27
27
|
shim.wrapExecutorCaller(proto, ['_execute', '_resolveFromResolver'])
|
|
28
28
|
shim.wrapThen(proto, [
|
|
29
|
-
'asCallback',
|
|
30
|
-
'
|
|
29
|
+
'asCallback',
|
|
30
|
+
'done',
|
|
31
|
+
'each',
|
|
32
|
+
'filter',
|
|
33
|
+
'finally',
|
|
34
|
+
'lastly',
|
|
35
|
+
'map',
|
|
36
|
+
'mapSeries',
|
|
37
|
+
'nodeify',
|
|
38
|
+
'reduce',
|
|
39
|
+
'spread',
|
|
40
|
+
'tap',
|
|
41
|
+
'tapCatch',
|
|
42
|
+
'then'
|
|
31
43
|
])
|
|
32
44
|
shim.wrapCatch(proto, ['catch', 'caught', 'error'])
|
|
33
45
|
shim.wrapCast(proto, [
|
|
34
|
-
'all',
|
|
35
|
-
'
|
|
36
|
-
'
|
|
46
|
+
'all',
|
|
47
|
+
'any',
|
|
48
|
+
'bind',
|
|
49
|
+
'call',
|
|
50
|
+
'catchReturn',
|
|
51
|
+
'catchThrow',
|
|
52
|
+
'delay',
|
|
53
|
+
'get',
|
|
54
|
+
'props',
|
|
55
|
+
'race',
|
|
56
|
+
'reflect',
|
|
57
|
+
'return',
|
|
58
|
+
'some',
|
|
59
|
+
'thenReturn',
|
|
60
|
+
'thenThrow',
|
|
61
|
+
'throw',
|
|
62
|
+
'timeout'
|
|
37
63
|
])
|
|
38
64
|
|
|
39
65
|
shim.wrapCast(Promise, [
|
|
40
|
-
'all',
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
66
|
+
'all',
|
|
67
|
+
'allSettled',
|
|
68
|
+
'any',
|
|
69
|
+
'attempt',
|
|
70
|
+
'bind',
|
|
71
|
+
'cast',
|
|
72
|
+
'delay',
|
|
73
|
+
'each',
|
|
74
|
+
'filter',
|
|
75
|
+
'fromCallback',
|
|
76
|
+
'fromNode',
|
|
77
|
+
'fulfilled',
|
|
78
|
+
'join',
|
|
79
|
+
'map',
|
|
80
|
+
'mapSeries',
|
|
81
|
+
'props',
|
|
82
|
+
'race',
|
|
83
|
+
'reduce',
|
|
84
|
+
'reject',
|
|
85
|
+
'rejected',
|
|
86
|
+
'resolve',
|
|
87
|
+
'some',
|
|
88
|
+
'try'
|
|
44
89
|
])
|
|
45
90
|
shim.wrapPromisify(Promise, ['coroutine', 'method', 'promisify'])
|
|
46
91
|
|
|
47
92
|
// Using `getNewLibraryCopy` needs to trigger re-instrumenting.
|
|
48
|
-
shim.wrap(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var copy = original.apply(this, arguments)
|
|
55
|
-
module.exports(agent, copy, moduleName, shim)
|
|
56
|
-
return copy
|
|
57
|
-
}
|
|
93
|
+
shim.wrap(bluebird.Promise, 'getNewLibraryCopy', function wrapNewCopy(shim, original) {
|
|
94
|
+
return function wrappedNewCopy() {
|
|
95
|
+
shim.logger.trace('Instrumenting new library copy...')
|
|
96
|
+
var copy = original.apply(this, arguments)
|
|
97
|
+
module.exports(agent, copy, moduleName, shim)
|
|
98
|
+
return copy
|
|
58
99
|
}
|
|
59
|
-
)
|
|
100
|
+
})
|
|
60
101
|
|
|
61
102
|
// Need to copy over `coroutine.addYieldHandler`
|
|
62
103
|
var coroutine = Promise && Promise.coroutine
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
module.exports = function initialize(agent, cassandra, moduleName, shim) {
|
|
9
9
|
var proto = cassandra.Client.prototype
|
|
10
10
|
shim.setDatastore(shim.CASSANDRA)
|
|
11
|
-
shim.recordOperation(proto, ['connect', 'shutdown'], {callback: shim.LAST})
|
|
12
|
-
shim.recordQuery(proto, '_innerExecute', {query: shim.FIRST, callback: shim.LAST})
|
|
11
|
+
shim.recordOperation(proto, ['connect', 'shutdown'], { callback: shim.LAST })
|
|
12
|
+
shim.recordQuery(proto, '_innerExecute', { query: shim.FIRST, callback: shim.LAST })
|
|
13
13
|
shim.recordBatchQuery(proto, 'batch', {
|
|
14
14
|
query: findBatchQueryArg,
|
|
15
15
|
callback: shim.LAST
|
|
@@ -14,11 +14,12 @@ module.exports = function initialize(agent, connect, moduleName, shim) {
|
|
|
14
14
|
shim.setFramework(shim.CONNECT)
|
|
15
15
|
|
|
16
16
|
shim.setRouteParser(function parseRoute(shim, fn, fnName, route) {
|
|
17
|
-
return route
|
|
17
|
+
return route
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
var proto =
|
|
21
|
-
|
|
20
|
+
var proto =
|
|
21
|
+
(connect && connect.HTTPServer && connect.HTTPServer.prototype) || // v1
|
|
22
|
+
(connect && connect.proto) // v2
|
|
22
23
|
|
|
23
24
|
shim.wrapMiddlewareMounter(proto, 'use', {
|
|
24
25
|
route: shim.FIRST,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
var logger = require('../../logger').child({component: 'async_hooks'})
|
|
8
|
+
var logger = require('../../logger').child({ component: 'async_hooks' })
|
|
9
9
|
var promInit = require('../promise')
|
|
10
10
|
|
|
11
11
|
module.exports = initialize
|
|
@@ -191,9 +191,16 @@ function getPromiseResolveStyleHooks(segmentMap, agent, shim) {
|
|
|
191
191
|
if (hookSegment === null) {
|
|
192
192
|
shim.setActiveSegment(hookSegment)
|
|
193
193
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Clean up any unresolved promises that have been destroyed.
|
|
198
|
+
// This defaults to true but does have a significant performance impact
|
|
199
|
+
// when customers have a lot of promises.
|
|
200
|
+
// See: https://github.com/newrelic/node-newrelic/issues/760
|
|
201
|
+
if (agent.config.feature_flag.unresolved_promise_cleanup) {
|
|
202
|
+
logger.info('Adding destroy hook to clean up unresolved promises.')
|
|
203
|
+
hooks.destroy = function destroyHandler(id) {
|
|
197
204
|
segmentMap.delete(id)
|
|
198
205
|
}
|
|
199
206
|
}
|
|
@@ -15,13 +15,9 @@ function initialize(agent, childProcess, moduleName, shim) {
|
|
|
15
15
|
|
|
16
16
|
const methods = ['exec', 'execFile']
|
|
17
17
|
|
|
18
|
-
shim.record(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function recordExec(shim, fn, name) {
|
|
22
|
-
return {name: 'child_process.' + name, callback: shim.LAST}
|
|
23
|
-
}
|
|
24
|
-
)
|
|
18
|
+
shim.record(childProcess, methods, function recordExec(shim, fn, name) {
|
|
19
|
+
return { name: 'child_process.' + name, callback: shim.LAST }
|
|
20
|
+
})
|
|
25
21
|
|
|
26
22
|
if (childProcess.ChildProcess) {
|
|
27
23
|
wrapChildProcessClass(shim, childProcess.ChildProcess)
|
|
@@ -30,32 +26,28 @@ function initialize(agent, childProcess, moduleName, shim) {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
function wrapChildProcessClass(shim, childProcessClass) {
|
|
33
|
-
shim.wrap(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return function wrappedChildProcessOn() {
|
|
38
|
-
const args = shim.argsToArray.apply(shim, arguments)
|
|
39
|
-
const cbIndex = args.length - 1
|
|
29
|
+
shim.wrap(childProcessClass.prototype, 'on', function wrapChildProcessClassOn(shim, fn) {
|
|
30
|
+
return function wrappedChildProcessOn() {
|
|
31
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
32
|
+
const cbIndex = args.length - 1
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
const originalListener = args[cbIndex]
|
|
35
|
+
if (!shim.isFunction(originalListener)) {
|
|
36
|
+
return fn.apply(this, arguments)
|
|
37
|
+
}
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
shim.bindSegment(args, cbIndex)
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
// Leverage events.removeListener() mechanism that checks listener
|
|
42
|
+
// property to allow our wrapped listeners to match and remove appropriately.
|
|
43
|
+
// Avoids having to instrument removeListener() and potentially doubling
|
|
44
|
+
// lookup. Since our wrapping will only be referenced by the events
|
|
45
|
+
// collection, we should not need to unwrap.
|
|
46
|
+
args[cbIndex].listener = originalListener
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
}
|
|
48
|
+
return fn.apply(this, args)
|
|
57
49
|
}
|
|
58
|
-
)
|
|
50
|
+
})
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
makePromisifyCompatible(shim, childProcess)
|
|
@@ -10,13 +10,7 @@ module.exports = initialize
|
|
|
10
10
|
function initialize(agent, crypto, moduleName, shim) {
|
|
11
11
|
shim.record(
|
|
12
12
|
crypto,
|
|
13
|
-
[
|
|
14
|
-
'pbkdf2',
|
|
15
|
-
'randomBytes',
|
|
16
|
-
'pseudoRandomBytes',
|
|
17
|
-
'randomFill',
|
|
18
|
-
'scrypt'
|
|
19
|
-
],
|
|
13
|
+
['pbkdf2', 'randomBytes', 'pseudoRandomBytes', 'randomFill', 'scrypt'],
|
|
20
14
|
function recordCryptoMethod(shim, fn, name) {
|
|
21
15
|
return {
|
|
22
16
|
name: 'crypto.' + name,
|
|
@@ -23,11 +23,7 @@ function initialize(agent, dns, moduleName, shim) {
|
|
|
23
23
|
'reverse'
|
|
24
24
|
]
|
|
25
25
|
|
|
26
|
-
shim.record(
|
|
27
|
-
dns,
|
|
28
|
-
|
|
29
|
-
function recordDnsMethod(shim, fn, name) {
|
|
30
|
-
return { name: 'dns.' + name, callback: shim.LAST }
|
|
31
|
-
}
|
|
32
|
-
)
|
|
26
|
+
shim.record(dns, methods, function recordDnsMethod(shim, fn, name) {
|
|
27
|
+
return { name: 'dns.' + name, callback: shim.LAST }
|
|
28
|
+
})
|
|
33
29
|
}
|
|
@@ -9,18 +9,12 @@ module.exports = initialize
|
|
|
9
9
|
|
|
10
10
|
function initialize(agent, domain, name, shim) {
|
|
11
11
|
var proto = domain.Domain.prototype
|
|
12
|
-
shim.wrap(
|
|
13
|
-
proto,
|
|
14
|
-
'emit',
|
|
15
|
-
wrapEmit
|
|
16
|
-
)
|
|
12
|
+
shim.wrap(proto, 'emit', wrapEmit)
|
|
17
13
|
|
|
18
14
|
function wrapEmit(shim, original) {
|
|
19
15
|
return function wrappedEmit(ev) {
|
|
20
16
|
var shouldRestoreContext =
|
|
21
|
-
ev === 'error' &&
|
|
22
|
-
shim.getActiveSegment() === null &&
|
|
23
|
-
shim.getSegment(this)
|
|
17
|
+
ev === 'error' && shim.getActiveSegment() === null && shim.getSegment(this)
|
|
24
18
|
|
|
25
19
|
if (!shouldRestoreContext) {
|
|
26
20
|
return original.apply(this, arguments)
|
|
@@ -44,10 +44,7 @@ function initialize(agent, fs, moduleName, shim) {
|
|
|
44
44
|
'ftruncate'
|
|
45
45
|
]
|
|
46
46
|
|
|
47
|
-
const nonRecordedMethods = [
|
|
48
|
-
'write',
|
|
49
|
-
'read'
|
|
50
|
-
]
|
|
47
|
+
const nonRecordedMethods = ['write', 'read']
|
|
51
48
|
|
|
52
49
|
shim.record(fs, methods, recordFs)
|
|
53
50
|
|
|
@@ -58,48 +55,36 @@ function initialize(agent, fs, moduleName, shim) {
|
|
|
58
55
|
|
|
59
56
|
fs.realpath.native = shim.getOriginal(fs.realpath).native
|
|
60
57
|
|
|
61
|
-
shim.record(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function recordRealpathNative(shim, fn) {
|
|
65
|
-
return recordFs(shim, fn, 'realpath.native')
|
|
66
|
-
}
|
|
67
|
-
)
|
|
58
|
+
shim.record(fs.realpath, 'native', function recordRealpathNative(shim, fn) {
|
|
59
|
+
return recordFs(shim, fn, 'realpath.native')
|
|
60
|
+
})
|
|
68
61
|
|
|
69
|
-
shim.wrap(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!shim.getActiveSegment()) {
|
|
76
|
-
return fn.apply(this, arguments)
|
|
77
|
-
}
|
|
62
|
+
shim.wrap(fs, nonRecordedMethods, function wrapNonRecordedFs(shim, fn) {
|
|
63
|
+
return function wrappedNonRecordedFs() {
|
|
64
|
+
// these are called in tight loops so opting out early
|
|
65
|
+
if (!shim.getActiveSegment()) {
|
|
66
|
+
return fn.apply(this, arguments)
|
|
67
|
+
}
|
|
78
68
|
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
70
|
+
const cbIndex = args.length - 1
|
|
81
71
|
|
|
82
|
-
|
|
72
|
+
shim.bindSegment(args, cbIndex)
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
}
|
|
74
|
+
return fn.apply(this, args)
|
|
86
75
|
}
|
|
87
|
-
)
|
|
76
|
+
})
|
|
88
77
|
|
|
89
|
-
shim.wrap(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return function wrappedFsWatch() {
|
|
94
|
-
const result = fn.apply(this, arguments)
|
|
95
|
-
shim.bindSegment(result, 'emit')
|
|
78
|
+
shim.wrap(fs, ['watch', 'watchFile'], function wrapFsWatch(shim, fn) {
|
|
79
|
+
return function wrappedFsWatch() {
|
|
80
|
+
const result = fn.apply(this, arguments)
|
|
81
|
+
shim.bindSegment(result, 'emit')
|
|
96
82
|
|
|
97
|
-
|
|
98
|
-
}
|
|
83
|
+
return result
|
|
99
84
|
}
|
|
100
|
-
)
|
|
85
|
+
})
|
|
101
86
|
|
|
102
87
|
function recordFs(shim, fn, name) {
|
|
103
|
-
return {name: NAMES.FS.PREFIX + name, callback: shim.LAST, recorder: record}
|
|
88
|
+
return { name: NAMES.FS.PREFIX + name, callback: shim.LAST, recorder: record }
|
|
104
89
|
}
|
|
105
90
|
}
|
|
@@ -9,7 +9,6 @@ var asyncHooks = require('./async_hooks')
|
|
|
9
9
|
|
|
10
10
|
module.exports = initialize
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
function initialize(agent, nodule, name, shim) {
|
|
14
13
|
let exceptionCallbackRegistered = false
|
|
15
14
|
|
|
@@ -42,13 +41,10 @@ function initialize(agent, nodule, name, shim) {
|
|
|
42
41
|
if (process.listenerCount('unhandledRejection') === 0) {
|
|
43
42
|
// If there are no unhandledRejection handlers report the error.
|
|
44
43
|
const segment = promise.__NR_id
|
|
45
|
-
?
|
|
46
|
-
:
|
|
44
|
+
? asyncHooks.segmentMap.get(promise.__NR_id)
|
|
45
|
+
: promise.__NR_context && promise.__NR_context.getSegment()
|
|
47
46
|
const tx = segment && segment.transaction
|
|
48
|
-
shim.logger.trace(
|
|
49
|
-
'Captured unhandled rejection for transaction %s',
|
|
50
|
-
tx && tx.id
|
|
51
|
-
)
|
|
47
|
+
shim.logger.trace('Captured unhandled rejection for transaction %s', tx && tx.id)
|
|
52
48
|
agent.errors.add(tx, error)
|
|
53
49
|
}
|
|
54
50
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
var recordExternal = require('../../metrics/recorders/http_external')
|
|
9
9
|
var urltils = require('../../util/urltils')
|
|
10
10
|
var hashes = require('../../util/hashes')
|
|
11
|
-
var logger = require('../../logger').child({component: 'outbound'})
|
|
11
|
+
var logger = require('../../logger').child({ component: 'outbound' })
|
|
12
12
|
var shimmer = require('../../shimmer')
|
|
13
13
|
var url = require('url')
|
|
14
14
|
var copy = require('../../util/copy')
|
|
@@ -43,14 +43,11 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
43
43
|
let hostname = opts.hostname || opts.host || DEFAULT_HOST
|
|
44
44
|
let port = opts.port || opts.defaultPort
|
|
45
45
|
if (!port) {
|
|
46
|
-
port =
|
|
46
|
+
port = !opts.protocol || opts.protocol === 'http:' ? DEFAULT_PORT : DEFAULT_SSL_PORT
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (!hostname || port < 1) {
|
|
50
|
-
logger.warn(
|
|
51
|
-
'Invalid host name (%s) or port (%s) for outbound request.',
|
|
52
|
-
hostname, port
|
|
53
|
-
)
|
|
50
|
+
logger.warn('Invalid host name (%s) or port (%s) for outbound request.', hostname, port)
|
|
54
51
|
return makeRequest(opts)
|
|
55
52
|
}
|
|
56
53
|
|
|
@@ -75,7 +72,6 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
75
72
|
return makeRequest(opts)
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
|
|
79
75
|
return agent.tracer.addSegment(
|
|
80
76
|
name,
|
|
81
77
|
recordExternal(hostname, 'http'),
|
|
@@ -118,11 +114,7 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
118
114
|
})
|
|
119
115
|
)
|
|
120
116
|
} else {
|
|
121
|
-
opts.headers = Object.assign(
|
|
122
|
-
Object.create(null),
|
|
123
|
-
opts.headers,
|
|
124
|
-
outboundHeaders
|
|
125
|
-
)
|
|
117
|
+
opts.headers = Object.assign(Object.create(null), opts.headers, outboundHeaders)
|
|
126
118
|
}
|
|
127
119
|
|
|
128
120
|
segment.start()
|
|
@@ -136,7 +128,8 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
136
128
|
|
|
137
129
|
if (parsed.parameters) {
|
|
138
130
|
// Scrub and parse returns on object with a null prototype.
|
|
139
|
-
|
|
131
|
+
// eslint-disable-next-line guard-for-in
|
|
132
|
+
for (let key in parsed.parameters) {
|
|
140
133
|
segment.addSpanAttribute(`request.parameters.${key}`, parsed.parameters[key])
|
|
141
134
|
}
|
|
142
135
|
}
|
|
@@ -177,10 +170,7 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
177
170
|
*/
|
|
178
171
|
function handleError(segment, req, error) {
|
|
179
172
|
if (req.listenerCount('error') > 0) {
|
|
180
|
-
logger.trace(
|
|
181
|
-
error,
|
|
182
|
-
'Not capturing outbound error because user has already handled it.'
|
|
183
|
-
)
|
|
173
|
+
logger.trace(error, 'Not capturing outbound error because user has already handled it.')
|
|
184
174
|
return false
|
|
185
175
|
}
|
|
186
176
|
|
|
@@ -205,10 +195,7 @@ function handleResponse(segment, hostname, req, res) {
|
|
|
205
195
|
|
|
206
196
|
// If CAT is enabled, grab those headers!
|
|
207
197
|
const agent = segment.transaction.agent
|
|
208
|
-
if (
|
|
209
|
-
agent.config.cross_application_tracer.enabled &&
|
|
210
|
-
!agent.config.distributed_tracing.enabled
|
|
211
|
-
) {
|
|
198
|
+
if (agent.config.cross_application_tracer.enabled && !agent.config.distributed_tracing.enabled) {
|
|
212
199
|
pullCatHeaders(agent.config, segment, hostname, res.headers['x-newrelic-app-data'])
|
|
213
200
|
}
|
|
214
201
|
|
|
@@ -232,9 +219,7 @@ function pullCatHeaders(config, segment, host, obfAppData) {
|
|
|
232
219
|
}
|
|
233
220
|
|
|
234
221
|
if (!config.trusted_account_ids) {
|
|
235
|
-
logger.trace(
|
|
236
|
-
'config.trusted_account_ids is not set - not parsing response CAT headers'
|
|
237
|
-
)
|
|
222
|
+
logger.trace('config.trusted_account_ids is not set - not parsing response CAT headers')
|
|
238
223
|
return
|
|
239
224
|
}
|
|
240
225
|
|
|
@@ -244,8 +229,7 @@ function pullCatHeaders(config, segment, host, obfAppData) {
|
|
|
244
229
|
} else {
|
|
245
230
|
var appData = null
|
|
246
231
|
try {
|
|
247
|
-
appData =
|
|
248
|
-
JSON.parse(hashes.deobfuscateNameUsingKey(obfAppData, config.encoding_key))
|
|
232
|
+
appData = JSON.parse(hashes.deobfuscateNameUsingKey(obfAppData, config.encoding_key))
|
|
249
233
|
} catch (e) {
|
|
250
234
|
logger.warn('Got an unparsable CAT header x-newrelic-app-data: %s', obfAppData)
|
|
251
235
|
return
|
|
@@ -259,13 +243,12 @@ function pullCatHeaders(config, segment, host, obfAppData) {
|
|
|
259
243
|
} else {
|
|
260
244
|
segment.catId = appData[0]
|
|
261
245
|
segment.catTransaction = appData[1]
|
|
262
|
-
segment.name =
|
|
263
|
-
|
|
246
|
+
segment.name =
|
|
247
|
+
NAMES.EXTERNAL.TRANSACTION + host + '/' + segment.catId + '/' + segment.catTransaction
|
|
264
248
|
if (appData.length >= 6) {
|
|
265
249
|
segment.addAttribute('transaction_guid', appData[5])
|
|
266
250
|
}
|
|
267
|
-
logger.trace('Got inbound response CAT headers in transaction %s',
|
|
268
|
-
segment.transaction.id)
|
|
251
|
+
logger.trace('Got inbound response CAT headers in transaction %s', segment.transaction.id)
|
|
269
252
|
}
|
|
270
253
|
}
|
|
271
254
|
}
|
|
@@ -294,19 +277,11 @@ function _addCATHeaders(agent, tx, outboundHeaders) {
|
|
|
294
277
|
tx.pushPathHash(pathHash)
|
|
295
278
|
|
|
296
279
|
try {
|
|
297
|
-
let txData = JSON.stringify([
|
|
298
|
-
tx.id,
|
|
299
|
-
false,
|
|
300
|
-
tx.tripId || tx.id,
|
|
301
|
-
pathHash
|
|
302
|
-
])
|
|
280
|
+
let txData = JSON.stringify([tx.id, false, tx.tripId || tx.id, pathHash])
|
|
303
281
|
txData = hashes.obfuscateNameUsingKey(txData, agent.config.encoding_key)
|
|
304
282
|
outboundHeaders[NEWRELIC_TRANSACTION_HEADER] = txData
|
|
305
283
|
|
|
306
|
-
logger.trace(
|
|
307
|
-
'Added outbound request CAT headers in transaction %s',
|
|
308
|
-
tx.id
|
|
309
|
-
)
|
|
284
|
+
logger.trace('Added outbound request CAT headers in transaction %s', tx.id)
|
|
310
285
|
} catch (err) {
|
|
311
286
|
logger.trace(err, 'Failed to create CAT payload')
|
|
312
287
|
}
|