dd-trace 2.7.1 → 2.8.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/LICENSE-3rdparty.csv +1 -2
- package/package.json +3 -5
- package/packages/datadog-instrumentations/index.js +2 -0
- package/packages/datadog-instrumentations/src/amqp10.js +33 -32
- package/packages/datadog-instrumentations/src/amqplib.js +16 -11
- package/packages/datadog-instrumentations/src/cassandra-driver.js +53 -51
- package/packages/datadog-instrumentations/src/connect.js +5 -5
- package/packages/datadog-instrumentations/src/couchbase.js +41 -39
- package/packages/datadog-instrumentations/src/cucumber.js +38 -38
- package/packages/datadog-instrumentations/src/dns.js +20 -19
- package/packages/datadog-instrumentations/src/elasticsearch.js +30 -32
- package/packages/datadog-instrumentations/src/hapi.js +210 -0
- package/packages/datadog-instrumentations/src/http/client.js +44 -44
- package/packages/datadog-instrumentations/src/http/server.js +15 -13
- package/packages/datadog-instrumentations/src/ioredis.js +16 -17
- package/packages/datadog-instrumentations/src/jest.js +5 -5
- package/packages/datadog-instrumentations/src/koa.js +8 -8
- package/packages/datadog-instrumentations/src/memcached.js +14 -12
- package/packages/datadog-instrumentations/src/mocha.js +37 -39
- package/packages/datadog-instrumentations/src/moleculer/client.js +46 -0
- package/packages/datadog-instrumentations/src/moleculer/server.js +59 -0
- package/packages/datadog-instrumentations/src/moleculer.js +4 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +29 -33
- package/packages/datadog-instrumentations/src/mysql.js +30 -29
- package/packages/datadog-instrumentations/src/mysql2.js +8 -9
- package/packages/datadog-instrumentations/src/net.js +23 -24
- package/packages/datadog-instrumentations/src/pg.js +30 -30
- package/packages/datadog-instrumentations/src/redis.js +49 -47
- package/packages/datadog-instrumentations/src/rhea.js +51 -49
- package/packages/datadog-instrumentations/src/router.js +5 -5
- package/packages/datadog-instrumentations/src/sharedb.js +20 -20
- package/packages/datadog-instrumentations/src/tedious.js +19 -19
- package/packages/datadog-plugin-amqp10/src/index.js +2 -7
- package/packages/datadog-plugin-amqplib/src/index.js +1 -2
- package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -5
- package/packages/datadog-plugin-couchbase/src/index.js +3 -4
- package/packages/datadog-plugin-cucumber/src/index.js +1 -9
- package/packages/datadog-plugin-dns/src/index.js +3 -4
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -5
- package/packages/datadog-plugin-hapi/src/index.js +34 -3
- package/packages/datadog-plugin-http/src/client.js +1 -3
- package/packages/datadog-plugin-http/src/server.js +0 -4
- package/packages/datadog-plugin-jest/src/index.js +2 -3
- package/packages/datadog-plugin-kafkajs/src/index.js +0 -4
- package/packages/datadog-plugin-memcached/src/index.js +1 -5
- package/packages/datadog-plugin-mocha/src/index.js +3 -7
- package/packages/datadog-plugin-moleculer/src/client.js +34 -44
- package/packages/datadog-plugin-moleculer/src/index.js +32 -3
- package/packages/datadog-plugin-moleculer/src/server.js +28 -50
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -5
- package/packages/datadog-plugin-mysql/src/index.js +1 -5
- package/packages/datadog-plugin-net/src/index.js +3 -7
- package/packages/datadog-plugin-pg/src/index.js +1 -5
- package/packages/datadog-plugin-redis/src/index.js +1 -5
- package/packages/datadog-plugin-rhea/src/index.js +1 -5
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/datadog-plugin-sharedb/src/index.js +1 -5
- package/packages/datadog-plugin-tedious/src/index.js +1 -5
- package/packages/dd-trace/lib/version.js +1 -1
- package/packages/dd-trace/src/appsec/callbacks/ddwaf.js +2 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +3 -1
- package/packages/dd-trace/src/plugins/plugin.js +0 -8
- package/packages/dd-trace/src/plugins/util/test.js +5 -1
- package/scripts/install_plugin_modules.js +23 -11
- package/packages/datadog-plugin-hapi/src/route.js +0 -75
- package/packages/datadog-plugin-hapi/src/server.js +0 -204
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -17,7 +17,6 @@ require,lodash.sortby,MIT,Copyright JS Foundation and other contributors
|
|
|
17
17
|
require,lodash.uniq,MIT,Copyright JS Foundation and other contributors
|
|
18
18
|
require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk
|
|
19
19
|
require,module-details-from-path,MIT,Copyright 2016 Thomas Watson Steen
|
|
20
|
-
require,multer,MIT,Copyright 2014 Hage Yaapa
|
|
21
20
|
require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
|
|
22
21
|
require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
|
|
23
22
|
require,performance-now,MIT,Copyright 2013 Braveg1rl
|
|
@@ -31,7 +30,6 @@ dev,chai,MIT,Copyright 2017 Chai.js Assertion Library
|
|
|
31
30
|
dev,chalk,MIT,Copyright Sindre Sorhus
|
|
32
31
|
dev,checksum,MIT,Copyright Daniel D. Shaw
|
|
33
32
|
dev,cli-table3,MIT,Copyright 2014 James Talmage
|
|
34
|
-
dev,codecov,MIT,Copyright 2014 Gregg Caines
|
|
35
33
|
dev,dotenv,BSD-2-Clause,Copyright 2015 Scott Motte
|
|
36
34
|
dev,eslint,MIT,Copyright JS Foundation and other contributors https://js.foundation
|
|
37
35
|
dev,eslint-config-standard,MIT,Copyright Feross Aboukhadijeh
|
|
@@ -47,6 +45,7 @@ dev,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
|
|
|
47
45
|
dev,jszip,MIT,Copyright 2015-2016 Stuart Knightley and contributors
|
|
48
46
|
dev,mkdirp,MIT,Copyright 2010 James Halliday
|
|
49
47
|
dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation
|
|
48
|
+
dev,multer,MIT,Copyright 2014 Hage Yaapa
|
|
50
49
|
dev,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
|
|
51
50
|
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
|
|
52
51
|
dev,nyc,ISC,Copyright 2015 Contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"test:shimmer:ci": "nyc --no-clean --include 'packages/datadog-shimmer/src/**/*.js' -- npm run test:shimmer",
|
|
33
33
|
"leak:core": "node ./scripts/install_plugin_modules && (cd packages/memwatch && yarn) && NODE_PATH=./packages/memwatch/node_modules node --no-warnings ./node_modules/.bin/tape 'packages/dd-trace/test/leak/**/*.js'",
|
|
34
34
|
"leak:plugins": "yarn services && (cd packages/memwatch && yarn) && NODE_PATH=./packages/memwatch/node_modules node --no-warnings ./node_modules/.bin/tape \"packages/datadog-plugin-@($(echo $PLUGINS))/test/leak.js\"",
|
|
35
|
-
"codecov": "codecov",
|
|
36
35
|
"junit:upload": "node ./scripts/junit_report.js"
|
|
37
36
|
},
|
|
38
37
|
"repository": {
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"node": ">=12"
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
|
-
"@datadog/native-appsec": "^1.
|
|
61
|
+
"@datadog/native-appsec": "^1.2.0",
|
|
63
62
|
"@datadog/native-metrics": "^1.2.0",
|
|
64
63
|
"@datadog/pprof": "^0.4.0",
|
|
65
64
|
"@datadog/sketches-js": "^1.0.4",
|
|
@@ -77,7 +76,6 @@
|
|
|
77
76
|
"lodash.uniq": "^4.5.0",
|
|
78
77
|
"methods": "^1.1.2",
|
|
79
78
|
"module-details-from-path": "^1.0.3",
|
|
80
|
-
"multer": "^1.4.2",
|
|
81
79
|
"opentracing": ">=0.12.1",
|
|
82
80
|
"path-to-regexp": "^0.1.2",
|
|
83
81
|
"performance-now": "^2.1.0",
|
|
@@ -93,7 +91,6 @@
|
|
|
93
91
|
"chalk": "^3.0.0",
|
|
94
92
|
"checksum": "^0.1.1",
|
|
95
93
|
"cli-table3": "^0.5.1",
|
|
96
|
-
"codecov": "3.8.1",
|
|
97
94
|
"dotenv": "8.2.0",
|
|
98
95
|
"eslint": "^7.32.0",
|
|
99
96
|
"eslint-config-standard": "^11.0.0-beta.0",
|
|
@@ -109,6 +106,7 @@
|
|
|
109
106
|
"jszip": "^3.5.0",
|
|
110
107
|
"mkdirp": "^0.5.1",
|
|
111
108
|
"mocha": "8",
|
|
109
|
+
"multer": "^1.4.2",
|
|
112
110
|
"msgpack-lite": "^0.1.26",
|
|
113
111
|
"nock": "^11.3.3",
|
|
114
112
|
"nyc": "^15.1.0",
|
|
@@ -16,6 +16,7 @@ require('./src/fastify')
|
|
|
16
16
|
require('./src/find-my-way')
|
|
17
17
|
require('./src/generic-pool')
|
|
18
18
|
require('./src/google-cloud-pubsub')
|
|
19
|
+
require('./src/hapi')
|
|
19
20
|
require('./src/http')
|
|
20
21
|
require('./src/ioredis')
|
|
21
22
|
require('./src/jest')
|
|
@@ -23,6 +24,7 @@ require('./src/kafkajs')
|
|
|
23
24
|
require('./src/knex')
|
|
24
25
|
require('./src/koa')
|
|
25
26
|
require('./src/memcached')
|
|
27
|
+
require('./src/moleculer')
|
|
26
28
|
require('./src/mongodb-core')
|
|
27
29
|
require('./src/mongoose')
|
|
28
30
|
require('./src/mysql')
|
|
@@ -9,62 +9,63 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
9
9
|
|
|
10
10
|
addHook({ name: 'amqp10', file: 'lib/sender_link.js', versions: ['>=3'] }, SenderLink => {
|
|
11
11
|
const startCh = channel('apm:amqp10:send:start')
|
|
12
|
-
const
|
|
13
|
-
const endCh = channel('apm:amqp10:send:end')
|
|
12
|
+
const finishCh = channel('apm:amqp10:send:finish')
|
|
14
13
|
const errorCh = channel('apm:amqp10:send:error')
|
|
15
14
|
shimmer.wrap(SenderLink.prototype, 'send', send => function (msg, options) {
|
|
16
15
|
if (!startCh.hasSubscribers) {
|
|
17
16
|
return send.apply(this, arguments)
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
19
|
+
return asyncResource.runInAsyncScope(() => {
|
|
20
|
+
startCh.publish({ link: this })
|
|
21
|
+
try {
|
|
22
|
+
const promise = send.apply(this, arguments)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
24
|
+
if (!promise) {
|
|
25
|
+
finish(finishCh, errorCh)
|
|
26
|
+
return promise
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
promise.then(asyncResource.bind(() => finish(finishCh, errorCh)),
|
|
30
|
+
asyncResource.bind(e => finish(finishCh, errorCh, e)))
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
32
|
+
return promise
|
|
33
|
+
} catch (err) {
|
|
34
|
+
finish(finishCh, errorCh, err)
|
|
35
|
+
throw err
|
|
36
|
+
}
|
|
37
|
+
})
|
|
40
38
|
})
|
|
41
39
|
return SenderLink
|
|
42
40
|
})
|
|
43
41
|
|
|
44
42
|
addHook({ name: 'amqp10', file: 'lib/receiver_link.js', versions: ['>=3'] }, ReceiverLink => {
|
|
45
43
|
const startCh = channel('apm:amqp10:receive:start')
|
|
46
|
-
const
|
|
44
|
+
const finishCh = channel('apm:amqp10:receive:finish')
|
|
47
45
|
const errorCh = channel('apm:amqp10:receive:error')
|
|
48
46
|
shimmer.wrap(ReceiverLink.prototype, '_messageReceived', messageReceived => function (transferFrame) {
|
|
49
47
|
if (!transferFrame || transferFrame.aborted || transferFrame.more) {
|
|
50
48
|
return messageReceived.apply(this, arguments)
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
51
|
+
return asyncResource.runInAsyncScope(() => {
|
|
52
|
+
startCh.publish({ link: this })
|
|
53
|
+
try {
|
|
54
|
+
return messageReceived.apply(this, arguments)
|
|
55
|
+
} catch (err) {
|
|
56
|
+
errorCh.publish(err)
|
|
57
|
+
throw err
|
|
58
|
+
} finally {
|
|
59
|
+
finishCh.publish()
|
|
60
|
+
}
|
|
61
|
+
})
|
|
61
62
|
})
|
|
62
63
|
return ReceiverLink
|
|
63
64
|
})
|
|
64
65
|
|
|
65
|
-
function finish (
|
|
66
|
+
function finish (finishCh, errorCh, error) {
|
|
66
67
|
if (error) {
|
|
67
68
|
errorCh.publish(error)
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
finishCh.publish()
|
|
70
71
|
}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
channel,
|
|
5
|
-
addHook
|
|
5
|
+
addHook,
|
|
6
|
+
AsyncResource
|
|
6
7
|
} = require('./helpers/instrument')
|
|
7
8
|
const kebabCase = require('lodash.kebabcase')
|
|
8
9
|
const shimmer = require('../../datadog-shimmer')
|
|
9
10
|
|
|
10
11
|
const startCh = channel('apm:amqplib:command:start')
|
|
11
|
-
const
|
|
12
|
+
const finishCh = channel('apm:amqplib:command:finish')
|
|
12
13
|
const errorCh = channel('apm:amqplib:command:error')
|
|
13
14
|
|
|
14
15
|
let methods = {}
|
|
@@ -40,17 +41,21 @@ function instrument (send, channel, args, method, fields, message) {
|
|
|
40
41
|
if (!startCh.hasSubscribers) {
|
|
41
42
|
return send.apply(channel, args)
|
|
42
43
|
}
|
|
43
|
-
startCh.publish({ channel, method, fields, message })
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
errorCh.publish(err)
|
|
45
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
46
|
+
return asyncResource.runInAsyncScope(() => {
|
|
47
|
+
startCh.publish({ channel, method, fields, message })
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
try {
|
|
50
|
+
return send.apply(channel, args)
|
|
51
|
+
} catch (err) {
|
|
52
|
+
errorCh.publish(err)
|
|
53
|
+
|
|
54
|
+
throw err
|
|
55
|
+
} finally {
|
|
56
|
+
finishCh.publish()
|
|
57
|
+
}
|
|
58
|
+
})
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
function isCamelCase (str) {
|
|
@@ -8,8 +8,7 @@ const {
|
|
|
8
8
|
const shimmer = require('../../datadog-shimmer')
|
|
9
9
|
|
|
10
10
|
const startCh = channel('apm:cassandra:query:start')
|
|
11
|
-
const
|
|
12
|
-
const endCh = channel('apm:cassandra:query:end')
|
|
11
|
+
const finishCh = channel('apm:cassandra:query:finish')
|
|
13
12
|
const errorCh = channel('apm:cassandra:query:error')
|
|
14
13
|
const addConnectionCh = channel(`apm:cassandra:query:addConnection`)
|
|
15
14
|
|
|
@@ -18,34 +17,34 @@ addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
|
|
|
18
17
|
if (!startCh.hasSubscribers) {
|
|
19
18
|
return batch.apply(this, arguments)
|
|
20
19
|
}
|
|
20
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
21
21
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
22
|
-
startCh.publish({ keyspace: this.keyspace, query: queries })
|
|
23
|
-
|
|
24
22
|
const lastIndex = arguments.length - 1
|
|
25
23
|
let cb = arguments[lastIndex]
|
|
26
24
|
|
|
27
25
|
if (typeof cb === 'function') {
|
|
28
|
-
cb =
|
|
29
|
-
arguments[lastIndex] = wrapCallback(
|
|
26
|
+
cb = callbackResource.bind(cb)
|
|
27
|
+
arguments[lastIndex] = wrapCallback(finishCh, errorCh, asyncResource, cb)
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
promiseAsyncResource
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
return asyncResource.runInAsyncScope(() => {
|
|
31
|
+
startCh.publish({ keyspace: this.keyspace, query: queries })
|
|
32
|
+
try {
|
|
33
|
+
const res = batch.apply(this, arguments)
|
|
34
|
+
if (typeof res === 'function' || !res) {
|
|
35
|
+
return wrapCallback(finishCh, errorCh, asyncResource, res)
|
|
36
|
+
} else {
|
|
37
|
+
const promiseAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
38
|
+
return res.then(
|
|
39
|
+
promiseAsyncResource.bind(() => finish(finishCh, errorCh)),
|
|
40
|
+
promiseAsyncResource.bind(err => finish(finishCh, errorCh, err))
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
finish(finishCh, errorCh, e)
|
|
45
|
+
throw e
|
|
42
46
|
}
|
|
43
|
-
}
|
|
44
|
-
finish(asyncEndCh, errorCh, e)
|
|
45
|
-
throw e
|
|
46
|
-
} finally {
|
|
47
|
-
endCh.publish(undefined)
|
|
48
|
-
}
|
|
47
|
+
})
|
|
49
48
|
})
|
|
50
49
|
return cassandra
|
|
51
50
|
})
|
|
@@ -55,17 +54,19 @@ addHook({ name: 'cassandra-driver', versions: ['>=4.4'] }, cassandra => {
|
|
|
55
54
|
if (!startCh.hasSubscribers) {
|
|
56
55
|
return _execute.apply(this, arguments)
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
58
|
+
return asyncResource.runInAsyncScope(() => {
|
|
59
|
+
startCh.publish({ keyspace: this.keyspace, query })
|
|
60
|
+
const promise = _execute.apply(this, arguments)
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
const promiseAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
promise.then(
|
|
65
|
+
promiseAsyncResource.bind(() => finish(finishCh, errorCh)),
|
|
66
|
+
promiseAsyncResource.bind(err => finish(finishCh, errorCh, err))
|
|
67
|
+
)
|
|
68
|
+
return promise
|
|
69
|
+
})
|
|
69
70
|
})
|
|
70
71
|
return cassandra
|
|
71
72
|
})
|
|
@@ -76,6 +77,7 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'] }, cassandra => {
|
|
|
76
77
|
if (!startCh.hasSubscribers) {
|
|
77
78
|
return _innerExecute.apply(this, arguments)
|
|
78
79
|
}
|
|
80
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
79
81
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
80
82
|
const isValid = (args) => {
|
|
81
83
|
return args.length === 4 || typeof args[3] === 'function'
|
|
@@ -85,24 +87,24 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 4.3'] }, cassandra => {
|
|
|
85
87
|
return _innerExecute.apply(this, arguments)
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
return asyncResource.runInAsyncScope(() => {
|
|
91
|
+
startCh.publish({ keyspace: this.keyspace, query })
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const lastIndex = arguments.length - 1
|
|
94
|
+
let cb = arguments[lastIndex]
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
if (typeof cb === 'function') {
|
|
97
|
+
cb = callbackResource.bind(cb)
|
|
98
|
+
arguments[lastIndex] = wrapCallback(finishCh, errorCh, asyncResource, cb)
|
|
99
|
+
}
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
101
|
+
try {
|
|
102
|
+
return _innerExecute.apply(this, arguments)
|
|
103
|
+
} catch (e) {
|
|
104
|
+
finish(finishCh, errorCh, e)
|
|
105
|
+
throw e
|
|
106
|
+
}
|
|
107
|
+
})
|
|
106
108
|
}
|
|
107
109
|
)
|
|
108
110
|
return cassandra
|
|
@@ -167,16 +169,16 @@ addHook({ name: 'cassandra-driver', versions: ['3 - 3.2'], file: 'lib/request-ha
|
|
|
167
169
|
return RequestHandler
|
|
168
170
|
})
|
|
169
171
|
|
|
170
|
-
function finish (
|
|
172
|
+
function finish (finishCh, errorCh, error) {
|
|
171
173
|
if (error) {
|
|
172
174
|
errorCh.publish(error)
|
|
173
175
|
}
|
|
174
|
-
|
|
176
|
+
finishCh.publish(undefined)
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
function wrapCallback (
|
|
178
|
-
return
|
|
179
|
-
finish(
|
|
179
|
+
function wrapCallback (finishCh, errorCh, asyncResource, callback) {
|
|
180
|
+
return asyncResource.bind(function (err) {
|
|
181
|
+
finish(finishCh, errorCh, err)
|
|
180
182
|
if (callback) {
|
|
181
183
|
return callback.apply(this, arguments)
|
|
182
184
|
}
|
|
@@ -5,7 +5,7 @@ const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
|
5
5
|
|
|
6
6
|
const enterChannel = channel('apm:connect:middleware:enter')
|
|
7
7
|
const errorChannel = channel('apm:connect:middleware:error')
|
|
8
|
-
const
|
|
8
|
+
const nextChannel = channel('apm:connect:middleware:next')
|
|
9
9
|
const handleChannel = channel('apm:connect:request:handle')
|
|
10
10
|
|
|
11
11
|
function wrapConnect (connect) {
|
|
@@ -64,10 +64,10 @@ function wrapLayerHandle (layer) {
|
|
|
64
64
|
const lastIndex = arguments.length - 1
|
|
65
65
|
const name = original._name || original.name
|
|
66
66
|
const req = arguments[arguments.length > 3 ? 1 : 0]
|
|
67
|
-
const next =
|
|
67
|
+
const next = arguments[lastIndex]
|
|
68
68
|
|
|
69
69
|
if (typeof next === 'function') {
|
|
70
|
-
arguments[lastIndex] = wrapNext(req,
|
|
70
|
+
arguments[lastIndex] = wrapNext(req, next)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return middlewareResource.runInAsyncScope(() => {
|
|
@@ -79,7 +79,7 @@ function wrapLayerHandle (layer) {
|
|
|
79
79
|
return original.apply(this, arguments)
|
|
80
80
|
} catch (e) {
|
|
81
81
|
errorChannel.publish(e)
|
|
82
|
-
|
|
82
|
+
nextChannel.publish({ req })
|
|
83
83
|
|
|
84
84
|
throw e
|
|
85
85
|
}
|
|
@@ -93,7 +93,7 @@ function wrapNext (req, next) {
|
|
|
93
93
|
errorChannel.publish(error)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
nextChannel.publish({ req })
|
|
97
97
|
|
|
98
98
|
next.apply(null, arguments)
|
|
99
99
|
}
|
|
@@ -9,8 +9,7 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
9
9
|
|
|
10
10
|
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Bucket => {
|
|
11
11
|
const startCh = channel('apm:couchbase:query:start')
|
|
12
|
-
const
|
|
13
|
-
const endCh = channel('apm:couchbase:query:end')
|
|
12
|
+
const finishCh = channel('apm:couchbase:query:finish')
|
|
14
13
|
const errorCh = channel('apm:couchbase:query:error')
|
|
15
14
|
|
|
16
15
|
Bucket.prototype._maybeInvoke = wrapMaybeInvoke(Bucket.prototype._maybeInvoke)
|
|
@@ -25,27 +24,28 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Buck
|
|
|
25
24
|
|
|
26
25
|
const n1qlQuery = q && q.statement
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
28
|
+
return asyncResource.runInAsyncScope(() => {
|
|
29
|
+
startCh.publish({ resource: n1qlQuery, bucket: this })
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
emitter.once('rows', asyncResource.bind(() => {
|
|
32
|
+
finishCh.publish(undefined)
|
|
33
|
+
}))
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
emitter.once('error', asyncResource.bind((error) => {
|
|
36
|
+
errorCh.publish(error)
|
|
37
|
+
finishCh.publish(undefined)
|
|
38
|
+
}))
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
try {
|
|
41
|
+
return _n1qlReq.apply(this, arguments)
|
|
42
|
+
} catch (err) {
|
|
43
|
+
err.stack // trigger getting the stack at the original throwing point
|
|
44
|
+
errorCh.publish(err)
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
46
|
+
throw err
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
Bucket.prototype.upsert = wrap('apm:couchbase:upsert', Bucket.prototype.upsert)
|
|
@@ -103,8 +103,7 @@ function wrapQuery (query) {
|
|
|
103
103
|
|
|
104
104
|
function wrap (prefix, fn) {
|
|
105
105
|
const startCh = channel(prefix + ':start')
|
|
106
|
-
const
|
|
107
|
-
const asyncEndCh = channel(prefix + ':async-end')
|
|
106
|
+
const finishCh = channel(prefix + ':finish')
|
|
108
107
|
const errorCh = channel(prefix + ':error')
|
|
109
108
|
|
|
110
109
|
const wrapped = function (key, value, options, callback) {
|
|
@@ -116,28 +115,31 @@ function wrap (prefix, fn) {
|
|
|
116
115
|
|
|
117
116
|
if (callbackIndex < 0) return fn.apply(this, arguments)
|
|
118
117
|
|
|
119
|
-
const
|
|
118
|
+
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
119
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
return asyncResource.runInAsyncScope(() => {
|
|
122
|
+
const cb = callbackResource.bind(arguments[callbackIndex])
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
if (error) {
|
|
125
|
-
errorCh.publish(error)
|
|
126
|
-
}
|
|
127
|
-
asyncEndCh.publish(result)
|
|
128
|
-
return cb.apply(this, arguments)
|
|
129
|
-
}
|
|
124
|
+
startCh.publish({ bucket: this })
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
arguments[callbackIndex] = asyncResource.bind(function (error, result) {
|
|
127
|
+
if (error) {
|
|
128
|
+
errorCh.publish(error)
|
|
129
|
+
}
|
|
130
|
+
finishCh.publish(result)
|
|
131
|
+
return cb.apply(this, arguments)
|
|
132
|
+
})
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
try {
|
|
135
|
+
return fn.apply(this, arguments)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
error.stack // trigger getting the stack at the original throwing point
|
|
138
|
+
errorCh.publish(error)
|
|
139
|
+
|
|
140
|
+
throw error
|
|
141
|
+
}
|
|
142
|
+
})
|
|
141
143
|
}
|
|
142
144
|
return shimmer.wrap(fn, wrapped)
|
|
143
145
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { addHook, channel } = require('./helpers/instrument')
|
|
3
|
+
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
4
4
|
const shimmer = require('../../datadog-shimmer')
|
|
5
5
|
|
|
6
6
|
const runStartCh = channel('ci:cucumber:run:start')
|
|
7
|
-
const
|
|
8
|
-
const runAsyncEndCh = channel('ci:cucumber:run:async-end')
|
|
7
|
+
const runFinishCh = channel('ci:cucumber:run:finish')
|
|
9
8
|
const runStepStartCh = channel('ci:cucumber:run-step:start')
|
|
10
|
-
const runStepEndCh = channel('ci:cucumber:run-step:end')
|
|
11
9
|
const errorCh = channel('ci:cucumber:error')
|
|
12
10
|
|
|
13
11
|
// TODO: remove in a later major version
|
|
@@ -49,23 +47,24 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
49
47
|
return run.apply(this, arguments)
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
51
|
+
return asyncResource.runInAsyncScope(() => {
|
|
52
|
+
runStartCh.publish({ pickleName: this.pickle.name, pickleUri: this.pickle.uri })
|
|
53
|
+
try {
|
|
54
|
+
const promise = run.apply(this, arguments)
|
|
55
|
+
promise.finally(() => {
|
|
56
|
+
const result = this.getWorstStepResult()
|
|
57
|
+
const { status, skipReason, errorMessage } = isLatestVersion
|
|
58
|
+
? getStatusFromResultLatest(result) : getStatusFromResult(result)
|
|
59
|
+
|
|
60
|
+
runFinishCh.publish({ status, skipReason, errorMessage })
|
|
61
|
+
})
|
|
62
|
+
return promise
|
|
63
|
+
} catch (err) {
|
|
64
|
+
errorCh.publish(err)
|
|
65
|
+
throw err
|
|
66
|
+
}
|
|
67
|
+
})
|
|
69
68
|
})
|
|
70
69
|
shimmer.wrap(pl.prototype, 'runStep', runStep => function () {
|
|
71
70
|
if (!runStepStartCh.hasSubscribers) {
|
|
@@ -80,23 +79,24 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
80
79
|
resource = testStep.isHook ? 'hook' : testStep.pickleStep.text
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
83
|
+
return asyncResource.runInAsyncScope(() => {
|
|
84
|
+
runStepStartCh.publish({ resource })
|
|
85
|
+
try {
|
|
86
|
+
const promise = runStep.apply(this, arguments)
|
|
87
|
+
|
|
88
|
+
promise.then((result) => {
|
|
89
|
+
const { status, skipReason, errorMessage } = isLatestVersion
|
|
90
|
+
? getStatusFromResultLatest(result) : getStatusFromResult(result)
|
|
91
|
+
|
|
92
|
+
runFinishCh.publish({ isStep: true, status, skipReason, errorMessage })
|
|
93
|
+
})
|
|
94
|
+
return promise
|
|
95
|
+
} catch (err) {
|
|
96
|
+
errorCh.publish(err)
|
|
97
|
+
throw err
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
100
|
})
|
|
101
101
|
}
|
|
102
102
|
|