dd-trace 5.20.0 → 5.22.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/index.d.ts +2 -1
- package/package.json +6 -6
- package/packages/datadog-instrumentations/src/aerospike.js +1 -1
- package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
- package/packages/datadog-instrumentations/src/aws-sdk.js +4 -4
- package/packages/datadog-instrumentations/src/body-parser.js +17 -5
- package/packages/datadog-instrumentations/src/cassandra-driver.js +2 -2
- package/packages/datadog-instrumentations/src/child_process.js +2 -2
- package/packages/datadog-instrumentations/src/connect.js +4 -4
- package/packages/datadog-instrumentations/src/cookie-parser.js +4 -4
- package/packages/datadog-instrumentations/src/couchbase.js +12 -12
- package/packages/datadog-instrumentations/src/cucumber.js +16 -5
- package/packages/datadog-instrumentations/src/dns.js +10 -10
- package/packages/datadog-instrumentations/src/elasticsearch.js +4 -4
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +3 -3
- package/packages/datadog-instrumentations/src/express.js +4 -4
- package/packages/datadog-instrumentations/src/fastify.js +6 -6
- package/packages/datadog-instrumentations/src/fetch.js +1 -1
- package/packages/datadog-instrumentations/src/find-my-way.js +2 -2
- package/packages/datadog-instrumentations/src/fs.js +2 -2
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +2 -2
- package/packages/datadog-instrumentations/src/grpc/client.js +4 -6
- package/packages/datadog-instrumentations/src/grpc/server.js +2 -2
- package/packages/datadog-instrumentations/src/hapi.js +10 -13
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -2
- package/packages/datadog-instrumentations/src/http/client.js +3 -3
- package/packages/datadog-instrumentations/src/jest.js +5 -4
- package/packages/datadog-instrumentations/src/knex.js +2 -2
- package/packages/datadog-instrumentations/src/koa.js +5 -5
- package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
- package/packages/datadog-instrumentations/src/mariadb.js +8 -8
- package/packages/datadog-instrumentations/src/memcached.js +2 -2
- package/packages/datadog-instrumentations/src/microgateway-core.js +4 -4
- package/packages/datadog-instrumentations/src/mocha/common.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +91 -70
- package/packages/datadog-instrumentations/src/mocha/utils.js +2 -3
- package/packages/datadog-instrumentations/src/mocha.js +4 -0
- package/packages/datadog-instrumentations/src/moleculer/server.js +2 -2
- package/packages/datadog-instrumentations/src/mongodb-core.js +7 -7
- package/packages/datadog-instrumentations/src/mongoose.js +5 -6
- package/packages/datadog-instrumentations/src/mysql.js +3 -3
- package/packages/datadog-instrumentations/src/mysql2.js +6 -6
- package/packages/datadog-instrumentations/src/net.js +2 -2
- package/packages/datadog-instrumentations/src/next.js +5 -5
- package/packages/datadog-instrumentations/src/nyc.js +23 -0
- package/packages/datadog-instrumentations/src/openai.js +58 -69
- package/packages/datadog-instrumentations/src/oracledb.js +8 -8
- package/packages/datadog-instrumentations/src/passport-http.js +1 -1
- package/packages/datadog-instrumentations/src/passport-local.js +1 -1
- package/packages/datadog-instrumentations/src/passport-utils.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +1 -1
- package/packages/datadog-instrumentations/src/pino.js +4 -4
- package/packages/datadog-instrumentations/src/playwright.js +6 -4
- package/packages/datadog-instrumentations/src/redis.js +2 -2
- package/packages/datadog-instrumentations/src/restify.js +4 -4
- package/packages/datadog-instrumentations/src/rhea.js +4 -4
- package/packages/datadog-instrumentations/src/router.js +5 -5
- package/packages/datadog-instrumentations/src/sharedb.js +2 -2
- package/packages/datadog-instrumentations/src/vitest.js +22 -5
- package/packages/datadog-instrumentations/src/winston.js +2 -3
- package/packages/datadog-plugin-cucumber/src/index.js +12 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +21 -10
- package/packages/datadog-plugin-hapi/src/index.js +2 -2
- package/packages/datadog-plugin-jest/src/index.js +18 -4
- package/packages/datadog-plugin-mocha/src/index.js +25 -6
- package/packages/datadog-plugin-nyc/src/index.js +35 -0
- package/packages/datadog-plugin-openai/src/index.js +58 -47
- package/packages/datadog-plugin-playwright/src/index.js +9 -4
- package/packages/datadog-plugin-vitest/src/index.js +30 -4
- package/packages/datadog-shimmer/src/shimmer.js +144 -10
- package/packages/dd-trace/src/appsec/blocking.js +23 -17
- package/packages/dd-trace/src/appsec/graphql.js +3 -1
- package/packages/dd-trace/src/appsec/iast/iast-log.js +2 -1
- package/packages/dd-trace/src/appsec/remote_config/manager.js +4 -1
- package/packages/dd-trace/src/appsec/rule_manager.js +8 -0
- package/packages/dd-trace/src/appsec/telemetry.js +3 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +40 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +8 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -4
- package/packages/dd-trace/src/ci-visibility/telemetry.js +29 -2
- package/packages/dd-trace/src/config.js +157 -142
- package/packages/dd-trace/src/lambda/handler.js +1 -0
- package/packages/dd-trace/src/lambda/index.js +12 -1
- package/packages/dd-trace/src/opentelemetry/context_manager.js +22 -39
- package/packages/dd-trace/src/opentelemetry/span_context.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +23 -14
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +9 -1
- package/packages/dd-trace/src/opentracing/propagation/log.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +61 -6
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +2 -2
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/git.js +14 -1
- package/packages/dd-trace/src/plugins/util/test.js +1 -5
- package/packages/dd-trace/src/profiler.js +15 -5
- package/packages/dd-trace/src/profiling/config.js +2 -4
- package/packages/dd-trace/src/profiling/exporter_cli.js +13 -1
- package/packages/dd-trace/src/profiling/exporters/agent.js +7 -1
- package/packages/dd-trace/src/profiling/profiler.js +0 -9
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +49 -58
- package/packages/dd-trace/src/proxy.js +21 -21
- package/packages/dd-trace/src/telemetry/index.js +24 -7
- package/packages/dd-trace/src/telemetry/logs/index.js +20 -0
package/index.d.ts
CHANGED
|
@@ -1837,9 +1837,10 @@ declare namespace tracer {
|
|
|
1837
1837
|
/**
|
|
1838
1838
|
* Construct a new TracerProvider to register with @opentelemetry/api
|
|
1839
1839
|
*
|
|
1840
|
+
* @param config Configuration object for the TracerProvider
|
|
1840
1841
|
* @returns TracerProvider A TracerProvider instance
|
|
1841
1842
|
*/
|
|
1842
|
-
new(): TracerProvider;
|
|
1843
|
+
new(config?: Record<string, unknown>): TracerProvider;
|
|
1843
1844
|
|
|
1844
1845
|
/**
|
|
1845
1846
|
* Returns a Tracer, creating one if one with the given name and version is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"node": ">=18"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@datadog/native-appsec": "8.
|
|
76
|
-
"@datadog/native-iast-rewriter": "2.4.
|
|
77
|
-
"@datadog/native-iast-taint-tracking": "3.
|
|
75
|
+
"@datadog/native-appsec": "8.1.1",
|
|
76
|
+
"@datadog/native-iast-rewriter": "2.4.1",
|
|
77
|
+
"@datadog/native-iast-taint-tracking": "3.1.0",
|
|
78
78
|
"@datadog/native-metrics": "^2.0.0",
|
|
79
79
|
"@datadog/pprof": "5.3.0",
|
|
80
80
|
"@datadog/sketches-js": "^2.1.0",
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
"tlhunter-sorted-set": "^0.1.0"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@types/node": "
|
|
106
|
+
"@types/node": "^16.18.103",
|
|
107
107
|
"autocannon": "^4.5.2",
|
|
108
108
|
"aws-sdk": "^2.1446.0",
|
|
109
|
-
"axios": "^1.
|
|
109
|
+
"axios": "^1.7.4",
|
|
110
110
|
"benchmark": "^2.1.4",
|
|
111
111
|
"body-parser": "^1.20.2",
|
|
112
112
|
"chai": "^4.3.7",
|
|
@@ -55,7 +55,7 @@ function apolloExpress4Hook (express4) {
|
|
|
55
55
|
return function expressMiddleware (server, options) {
|
|
56
56
|
const originalMiddleware = originalExpressMiddleware.apply(this, arguments)
|
|
57
57
|
|
|
58
|
-
return shimmer.
|
|
58
|
+
return shimmer.wrapFunction(originalMiddleware, originalMiddleware => function (req, res, next) {
|
|
59
59
|
if (!graphqlMiddlewareChannel.start.hasSubscribers) {
|
|
60
60
|
return originalMiddleware.apply(this, arguments)
|
|
61
61
|
}
|
|
@@ -75,7 +75,7 @@ function wrapSmithySend (send) {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
if (typeof cb === 'function') {
|
|
78
|
-
args[args.length - 1] = function (err, result) {
|
|
78
|
+
args[args.length - 1] = shimmer.wrapFunction(cb, cb => function (err, result) {
|
|
79
79
|
const message = getMessage(request, err, result)
|
|
80
80
|
|
|
81
81
|
completeChannel.publish(message)
|
|
@@ -89,7 +89,7 @@ function wrapSmithySend (send) {
|
|
|
89
89
|
responseFinishChannel.publish(message.response.error)
|
|
90
90
|
}
|
|
91
91
|
})
|
|
92
|
-
}
|
|
92
|
+
})
|
|
93
93
|
} else { // always a promise
|
|
94
94
|
return send.call(this, command, ...args)
|
|
95
95
|
.then(
|
|
@@ -113,7 +113,7 @@ function wrapSmithySend (send) {
|
|
|
113
113
|
|
|
114
114
|
function wrapCb (cb, serviceName, request, ar) {
|
|
115
115
|
// eslint-disable-next-line n/handle-callback-err
|
|
116
|
-
return function wrappedCb (err, response) {
|
|
116
|
+
return shimmer.wrapFunction(cb, cb => function wrappedCb (err, response) {
|
|
117
117
|
const obj = { request, response }
|
|
118
118
|
return ar.runInAsyncScope(() => {
|
|
119
119
|
channel(`apm:aws:response:start:${serviceName}`).publish(obj)
|
|
@@ -141,7 +141,7 @@ function wrapCb (cb, serviceName, request, ar) {
|
|
|
141
141
|
throw e
|
|
142
142
|
}
|
|
143
143
|
})
|
|
144
|
-
}
|
|
144
|
+
})
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
function getMessage (request, error, result) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const shimmer = require('../../datadog-shimmer')
|
|
4
|
-
const { channel, addHook } = require('./helpers/instrument')
|
|
4
|
+
const { channel, addHook, AsyncResource } = require('./helpers/instrument')
|
|
5
5
|
|
|
6
6
|
const bodyParserReadCh = channel('datadog:body-parser:read:finish')
|
|
7
7
|
|
|
8
8
|
function publishRequestBodyAndNext (req, res, next) {
|
|
9
|
-
return function () {
|
|
9
|
+
return shimmer.wrapFunction(next, next => function () {
|
|
10
10
|
if (bodyParserReadCh.hasSubscribers && req) {
|
|
11
11
|
const abortController = new AbortController()
|
|
12
12
|
const body = req.body
|
|
@@ -17,15 +17,27 @@ function publishRequestBodyAndNext (req, res, next) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return next.apply(this, arguments)
|
|
20
|
-
}
|
|
20
|
+
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
addHook({
|
|
24
24
|
name: 'body-parser',
|
|
25
25
|
file: 'lib/read.js',
|
|
26
|
-
versions: ['>=1.4.0']
|
|
26
|
+
versions: ['>=1.4.0 <1.20.0']
|
|
27
|
+
}, read => {
|
|
28
|
+
return shimmer.wrapFunction(read, read => function (req, res, next) {
|
|
29
|
+
const nextResource = new AsyncResource('bound-anonymous-fn')
|
|
30
|
+
arguments[2] = nextResource.bind(publishRequestBodyAndNext(req, res, next))
|
|
31
|
+
return read.apply(this, arguments)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
addHook({
|
|
36
|
+
name: 'body-parser',
|
|
37
|
+
file: 'lib/read.js',
|
|
38
|
+
versions: ['>=1.20.0']
|
|
27
39
|
}, read => {
|
|
28
|
-
return shimmer.
|
|
40
|
+
return shimmer.wrapFunction(read, read => function (req, res, next) {
|
|
29
41
|
arguments[2] = publishRequestBodyAndNext(req, res, next)
|
|
30
42
|
return read.apply(this, arguments)
|
|
31
43
|
})
|
|
@@ -180,12 +180,12 @@ function finish (finishCh, errorCh, error) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
function wrapCallback (finishCh, errorCh, asyncResource, callback) {
|
|
183
|
-
return asyncResource.bind(function (err) {
|
|
183
|
+
return shimmer.wrapFunction(callback, callback => asyncResource.bind(function (err) {
|
|
184
184
|
finish(finishCh, errorCh, err)
|
|
185
185
|
if (callback) {
|
|
186
186
|
return callback.apply(this, arguments)
|
|
187
187
|
}
|
|
188
|
-
})
|
|
188
|
+
}))
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
function isRequestValid (exec, args, length) {
|
|
@@ -133,8 +133,8 @@ function wrapChildProcessAsyncMethod (shell = false) {
|
|
|
133
133
|
|
|
134
134
|
if (childProcessMethod[util.promisify.custom]) {
|
|
135
135
|
const wrapedChildProcessCustomPromisifyMethod =
|
|
136
|
-
shimmer.
|
|
137
|
-
wrapChildProcessCustomPromisifyMethod(
|
|
136
|
+
shimmer.wrapFunction(childProcessMethod[util.promisify.custom],
|
|
137
|
+
promisify => wrapChildProcessCustomPromisifyMethod(promisify, shell))
|
|
138
138
|
|
|
139
139
|
// should do it in this way because the original property is readonly
|
|
140
140
|
const descriptor = Object.getOwnPropertyDescriptor(childProcessMethod, util.promisify.custom)
|
|
@@ -59,7 +59,7 @@ function wrapLayerHandle (layer) {
|
|
|
59
59
|
|
|
60
60
|
const original = layer.handle
|
|
61
61
|
|
|
62
|
-
return shimmer.
|
|
62
|
+
return shimmer.wrapFunction(original, original => function () {
|
|
63
63
|
if (!enterChannel.hasSubscribers) return original.apply(this, arguments)
|
|
64
64
|
|
|
65
65
|
const lastIndex = arguments.length - 1
|
|
@@ -90,7 +90,7 @@ function wrapLayerHandle (layer) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function wrapNext (req, next) {
|
|
93
|
-
return function (error) {
|
|
93
|
+
return shimmer.wrapFunction(next, next => function (error) {
|
|
94
94
|
if (error) {
|
|
95
95
|
errorChannel.publish({ req, error })
|
|
96
96
|
}
|
|
@@ -99,11 +99,11 @@ function wrapNext (req, next) {
|
|
|
99
99
|
finishChannel.publish({ req })
|
|
100
100
|
|
|
101
101
|
next.apply(this, arguments)
|
|
102
|
-
}
|
|
102
|
+
})
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
addHook({ name: 'connect', versions: ['>=3'] }, connect => {
|
|
106
|
-
return shimmer.
|
|
106
|
+
return shimmer.wrapFunction(connect, connect => wrapConnect(connect))
|
|
107
107
|
})
|
|
108
108
|
|
|
109
109
|
addHook({ name: 'connect', versions: ['2.2.2'] }, connect => {
|
|
@@ -6,7 +6,7 @@ const { channel, addHook } = require('./helpers/instrument')
|
|
|
6
6
|
const cookieParserReadCh = channel('datadog:cookie-parser:read:finish')
|
|
7
7
|
|
|
8
8
|
function publishRequestCookieAndNext (req, res, next) {
|
|
9
|
-
return function cookieParserWrapper () {
|
|
9
|
+
return shimmer.wrapFunction(next, next => function cookieParserWrapper () {
|
|
10
10
|
if (cookieParserReadCh.hasSubscribers && req) {
|
|
11
11
|
const abortController = new AbortController()
|
|
12
12
|
|
|
@@ -18,17 +18,17 @@ function publishRequestCookieAndNext (req, res, next) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return next.apply(this, arguments)
|
|
21
|
-
}
|
|
21
|
+
})
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
addHook({
|
|
25
25
|
name: 'cookie-parser',
|
|
26
26
|
versions: ['>=1.0.0']
|
|
27
27
|
}, cookieParser => {
|
|
28
|
-
return shimmer.
|
|
28
|
+
return shimmer.wrapFunction(cookieParser, cookieParser => function () {
|
|
29
29
|
const cookieMiddleware = cookieParser.apply(this, arguments)
|
|
30
30
|
|
|
31
|
-
return shimmer.
|
|
31
|
+
return shimmer.wrapFunction(cookieMiddleware, cookieMiddleware => function (req, res, next) {
|
|
32
32
|
arguments[2] = publishRequestCookieAndNext(req, res, next)
|
|
33
33
|
return cookieMiddleware.apply(this, arguments)
|
|
34
34
|
})
|
|
@@ -37,7 +37,7 @@ function wrapMaybeInvoke (_maybeInvoke) {
|
|
|
37
37
|
|
|
38
38
|
return _maybeInvoke.apply(this, arguments)
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return wrapped
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function wrapQuery (query) {
|
|
@@ -51,7 +51,7 @@ function wrapQuery (query) {
|
|
|
51
51
|
const res = query.apply(this, arguments)
|
|
52
52
|
return res
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return wrapped
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function wrap (prefix, fn) {
|
|
@@ -76,13 +76,13 @@ function wrap (prefix, fn) {
|
|
|
76
76
|
|
|
77
77
|
startCh.publish({ bucket: { name: this.name || this._name }, seedNodes: this._dd_hosts })
|
|
78
78
|
|
|
79
|
-
arguments[callbackIndex] = asyncResource.bind(function (error, result) {
|
|
79
|
+
arguments[callbackIndex] = shimmer.wrapFunction(cb, cb => asyncResource.bind(function (error, result) {
|
|
80
80
|
if (error) {
|
|
81
81
|
errorCh.publish(error)
|
|
82
82
|
}
|
|
83
83
|
finishCh.publish(result)
|
|
84
84
|
return cb.apply(this, arguments)
|
|
85
|
-
})
|
|
85
|
+
}))
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
88
|
return fn.apply(this, arguments)
|
|
@@ -94,7 +94,7 @@ function wrap (prefix, fn) {
|
|
|
94
94
|
}
|
|
95
95
|
})
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return wrapped
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// semver >=3
|
|
@@ -118,13 +118,13 @@ function wrapCBandPromise (fn, name, startData, thisArg, args) {
|
|
|
118
118
|
// v3 offers callback or promises event handling
|
|
119
119
|
// NOTE: this does not work with v3.2.0-3.2.1 cluster.query, as there is a bug in the couchbase source code
|
|
120
120
|
const cb = callbackResource.bind(args[cbIndex])
|
|
121
|
-
args[cbIndex] = asyncResource.bind(function (error, result) {
|
|
121
|
+
args[cbIndex] = shimmer.wrapFunction(cb, cb => asyncResource.bind(function (error, result) {
|
|
122
122
|
if (error) {
|
|
123
123
|
errorCh.publish(error)
|
|
124
124
|
}
|
|
125
125
|
finishCh.publish({ result })
|
|
126
126
|
return cb.apply(thisArg, arguments)
|
|
127
|
-
})
|
|
127
|
+
}))
|
|
128
128
|
}
|
|
129
129
|
const res = fn.apply(thisArg, args)
|
|
130
130
|
|
|
@@ -166,8 +166,8 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.12'] }, Buc
|
|
|
166
166
|
const finishCh = channel('apm:couchbase:query:finish')
|
|
167
167
|
const errorCh = channel('apm:couchbase:query:error')
|
|
168
168
|
|
|
169
|
-
Bucket.prototype
|
|
170
|
-
Bucket.prototype
|
|
169
|
+
shimmer.wrap(Bucket.prototype, '_maybeInvoke', maybeInvoke => wrapMaybeInvoke(maybeInvoke))
|
|
170
|
+
shimmer.wrap(Bucket.prototype, 'query', query => wrapQuery(query))
|
|
171
171
|
|
|
172
172
|
shimmer.wrap(Bucket.prototype, '_n1qlReq', _n1qlReq => function (host, q, adhoc, emitter) {
|
|
173
173
|
if (!startCh.hasSubscribers) {
|
|
@@ -203,15 +203,15 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.12'] }, Buc
|
|
|
203
203
|
})
|
|
204
204
|
|
|
205
205
|
wrapAllNames(['upsert', 'insert', 'replace', 'append', 'prepend'], name => {
|
|
206
|
-
Bucket.prototype
|
|
206
|
+
shimmer.wrap(Bucket.prototype, name, fn => wrap(`apm:couchbase:${name}`, fn))
|
|
207
207
|
})
|
|
208
208
|
|
|
209
209
|
return Bucket
|
|
210
210
|
})
|
|
211
211
|
|
|
212
212
|
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.12'] }, Cluster => {
|
|
213
|
-
Cluster.prototype
|
|
214
|
-
Cluster.prototype
|
|
213
|
+
shimmer.wrap(Cluster.prototype, '_maybeInvoke', maybeInvoke => wrapMaybeInvoke(maybeInvoke))
|
|
214
|
+
shimmer.wrap(Cluster.prototype, 'query', query => wrapQuery(query))
|
|
215
215
|
|
|
216
216
|
shimmer.wrap(Cluster.prototype, 'openBucket', openBucket => {
|
|
217
217
|
return function () {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
3
3
|
|
|
4
|
-
const { NUM_FAILED_TEST_RETRIES } = require('../../dd-trace/src/plugins/util/test')
|
|
5
4
|
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
6
5
|
const shimmer = require('../../datadog-shimmer')
|
|
7
6
|
const log = require('../../dd-trace/src/log')
|
|
@@ -28,6 +27,8 @@ const workerReportTraceCh = channel('ci:cucumber:worker-report:trace')
|
|
|
28
27
|
|
|
29
28
|
const itrSkippedSuitesCh = channel('ci:cucumber:itr:skipped-suites')
|
|
30
29
|
|
|
30
|
+
const getCodeCoverageCh = channel('ci:nyc:get-coverage')
|
|
31
|
+
|
|
31
32
|
const {
|
|
32
33
|
getCoveredFilenamesFromCoverage,
|
|
33
34
|
resetCoverage,
|
|
@@ -64,6 +65,7 @@ let isSuitesSkippingEnabled = false
|
|
|
64
65
|
let isEarlyFlakeDetectionEnabled = false
|
|
65
66
|
let earlyFlakeDetectionNumRetries = 0
|
|
66
67
|
let isFlakyTestRetriesEnabled = false
|
|
68
|
+
let numTestRetries = 0
|
|
67
69
|
let knownTests = []
|
|
68
70
|
let skippedSuites = []
|
|
69
71
|
let isSuitesSkipped = false
|
|
@@ -186,7 +188,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
186
188
|
testStartCh.publish(testStartPayload)
|
|
187
189
|
})
|
|
188
190
|
try {
|
|
189
|
-
this.eventBroadcaster.on('envelope', (testCase) => {
|
|
191
|
+
this.eventBroadcaster.on('envelope', shimmer.wrapFunction(null, () => (testCase) => {
|
|
190
192
|
// Only supported from >=8.0.0
|
|
191
193
|
if (testCase?.testCaseFinished) {
|
|
192
194
|
const { testCaseFinished: { willBeRetried } } = testCase
|
|
@@ -204,7 +206,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
204
206
|
})
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
|
-
})
|
|
209
|
+
}))
|
|
208
210
|
let promise
|
|
209
211
|
|
|
210
212
|
asyncResource.runInAsyncScope(() => {
|
|
@@ -305,6 +307,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false) {
|
|
|
305
307
|
earlyFlakeDetectionNumRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionNumRetries
|
|
306
308
|
isSuitesSkippingEnabled = configurationResponse.libraryConfig?.isSuitesSkippingEnabled
|
|
307
309
|
isFlakyTestRetriesEnabled = configurationResponse.libraryConfig?.isFlakyTestRetriesEnabled
|
|
310
|
+
numTestRetries = configurationResponse.libraryConfig?.flakyTestRetriesCount
|
|
308
311
|
|
|
309
312
|
if (isEarlyFlakeDetectionEnabled) {
|
|
310
313
|
const knownTestsResponse = await getChannelPromise(knownTestsCh)
|
|
@@ -342,8 +345,8 @@ function getWrappedStart (start, frameworkVersion, isParallel = false) {
|
|
|
342
345
|
const processArgv = process.argv.slice(2).join(' ')
|
|
343
346
|
const command = process.env.npm_lifecycle_script || `cucumber-js ${processArgv}`
|
|
344
347
|
|
|
345
|
-
if (isFlakyTestRetriesEnabled && !this.options.retry) {
|
|
346
|
-
this.options.retry =
|
|
348
|
+
if (isFlakyTestRetriesEnabled && !this.options.retry && numTestRetries > 0) {
|
|
349
|
+
this.options.retry = numTestRetries
|
|
347
350
|
}
|
|
348
351
|
|
|
349
352
|
sessionAsyncResource.runInAsyncScope(() => {
|
|
@@ -356,10 +359,18 @@ function getWrappedStart (start, frameworkVersion, isParallel = false) {
|
|
|
356
359
|
|
|
357
360
|
const success = await start.apply(this, arguments)
|
|
358
361
|
|
|
362
|
+
let untestedCoverage
|
|
363
|
+
if (getCodeCoverageCh.hasSubscribers) {
|
|
364
|
+
untestedCoverage = await getChannelPromise(getCodeCoverageCh)
|
|
365
|
+
}
|
|
366
|
+
|
|
359
367
|
let testCodeCoverageLinesTotal
|
|
360
368
|
|
|
361
369
|
if (global.__coverage__) {
|
|
362
370
|
try {
|
|
371
|
+
if (untestedCoverage) {
|
|
372
|
+
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
373
|
+
}
|
|
363
374
|
testCodeCoverageLinesTotal = originalCoverageMap.getCoverageSummary().lines.pct
|
|
364
375
|
} catch (e) {
|
|
365
376
|
// ignore errors
|
|
@@ -21,16 +21,16 @@ const rrtypeMap = new WeakMap()
|
|
|
21
21
|
const names = ['dns', 'node:dns']
|
|
22
22
|
|
|
23
23
|
addHook({ name: names }, dns => {
|
|
24
|
-
dns
|
|
25
|
-
dns
|
|
26
|
-
dns
|
|
27
|
-
dns
|
|
24
|
+
shimmer.wrap(dns, 'lookup', fn => wrap('apm:dns:lookup', fn, 2))
|
|
25
|
+
shimmer.wrap(dns, 'lookupService', fn => wrap('apm:dns:lookup_service', fn, 2))
|
|
26
|
+
shimmer.wrap(dns, 'resolve', fn => wrap('apm:dns:resolve', fn, 2))
|
|
27
|
+
shimmer.wrap(dns, 'reverse', fn => wrap('apm:dns:reverse', fn, 2))
|
|
28
28
|
|
|
29
29
|
patchResolveShorthands(dns)
|
|
30
30
|
|
|
31
31
|
if (dns.Resolver) {
|
|
32
|
-
dns.Resolver.prototype
|
|
33
|
-
dns.Resolver.prototype
|
|
32
|
+
shimmer.wrap(dns.Resolver.prototype, 'resolve', fn => wrap('apm:dns:resolve', fn, 2))
|
|
33
|
+
shimmer.wrap(dns.Resolver.prototype, 'reverse', fn => wrap('apm:dns:reverse', fn, 2))
|
|
34
34
|
|
|
35
35
|
patchResolveShorthands(dns.Resolver.prototype)
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ function patchResolveShorthands (prototype) {
|
|
|
43
43
|
.filter(method => !!prototype[method])
|
|
44
44
|
.forEach(method => {
|
|
45
45
|
rrtypeMap.set(prototype[method], rrtypes[method])
|
|
46
|
-
prototype
|
|
46
|
+
shimmer.wrap(prototype, method, fn => wrap('apm:dns:resolve', fn, 2, rrtypes[method]))
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -72,13 +72,13 @@ function wrap (prefix, fn, expectedArgs, rrtype) {
|
|
|
72
72
|
return asyncResource.runInAsyncScope(() => {
|
|
73
73
|
startCh.publish(startArgs)
|
|
74
74
|
|
|
75
|
-
arguments[arguments.length - 1] = asyncResource.bind(function (error, result) {
|
|
75
|
+
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => asyncResource.bind(function (error, result) {
|
|
76
76
|
if (error) {
|
|
77
77
|
errorCh.publish(error)
|
|
78
78
|
}
|
|
79
79
|
finishCh.publish(result)
|
|
80
80
|
cb.apply(this, arguments)
|
|
81
|
-
})
|
|
81
|
+
}))
|
|
82
82
|
|
|
83
83
|
try {
|
|
84
84
|
return fn.apply(this, arguments)
|
|
@@ -92,5 +92,5 @@ function wrap (prefix, fn, expectedArgs, rrtype) {
|
|
|
92
92
|
})
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
return
|
|
95
|
+
return wrapped
|
|
96
96
|
}
|
|
@@ -48,12 +48,12 @@ function createWrapSelect () {
|
|
|
48
48
|
return function () {
|
|
49
49
|
if (arguments.length === 1) {
|
|
50
50
|
const cb = arguments[0]
|
|
51
|
-
arguments[0] = function (err, connection) {
|
|
51
|
+
arguments[0] = shimmer.wrapFunction(cb, cb => function (err, connection) {
|
|
52
52
|
if (connectCh.hasSubscribers && connection && connection.host) {
|
|
53
53
|
connectCh.publish({ hostname: connection.host.host, port: connection.host.port })
|
|
54
54
|
}
|
|
55
55
|
cb(err, connection)
|
|
56
|
-
}
|
|
56
|
+
})
|
|
57
57
|
}
|
|
58
58
|
return request.apply(this, arguments)
|
|
59
59
|
}
|
|
@@ -86,10 +86,10 @@ function createWrapRequest (name) {
|
|
|
86
86
|
if (typeof cb === 'function') {
|
|
87
87
|
cb = parentResource.bind(cb)
|
|
88
88
|
|
|
89
|
-
arguments[lastIndex] = asyncResource.bind(function (error) {
|
|
89
|
+
arguments[lastIndex] = shimmer.wrapFunction(cb, cb => asyncResource.bind(function (error) {
|
|
90
90
|
finish(params, error)
|
|
91
91
|
return cb.apply(null, arguments)
|
|
92
|
-
})
|
|
92
|
+
}))
|
|
93
93
|
return request.apply(this, arguments)
|
|
94
94
|
} else {
|
|
95
95
|
const promise = request.apply(this, arguments)
|
|
@@ -22,15 +22,15 @@ addHook({ name: 'express-mongo-sanitize', versions: ['>=1.0.0'] }, expressMongoS
|
|
|
22
22
|
return sanitizedObject
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
return shimmer.
|
|
25
|
+
return shimmer.wrapFunction(expressMongoSanitize, expressMongoSanitize => function () {
|
|
26
26
|
const middleware = expressMongoSanitize.apply(this, arguments)
|
|
27
27
|
|
|
28
|
-
return shimmer.
|
|
28
|
+
return shimmer.wrapFunction(middleware, middleware => function (req, res, next) {
|
|
29
29
|
if (!sanitizeMiddlewareFinished.hasSubscribers) {
|
|
30
30
|
return middleware.apply(this, arguments)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const wrappedNext = shimmer.
|
|
33
|
+
const wrappedNext = shimmer.wrapFunction(next, next => function () {
|
|
34
34
|
sanitizeMiddlewareFinished.publish({
|
|
35
35
|
sanitizedProperties: propertiesToSanitize,
|
|
36
36
|
req
|
|
@@ -49,7 +49,7 @@ addHook({ name: 'express', versions: ['>=4'] }, express => {
|
|
|
49
49
|
const queryParserReadCh = channel('datadog:query:read:finish')
|
|
50
50
|
|
|
51
51
|
function publishQueryParsedAndNext (req, res, next) {
|
|
52
|
-
return function () {
|
|
52
|
+
return shimmer.wrapFunction(next, next => function () {
|
|
53
53
|
if (queryParserReadCh.hasSubscribers && req) {
|
|
54
54
|
const abortController = new AbortController()
|
|
55
55
|
const query = req.query
|
|
@@ -60,7 +60,7 @@ function publishQueryParsedAndNext (req, res, next) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return next.apply(this, arguments)
|
|
63
|
-
}
|
|
63
|
+
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
addHook({
|
|
@@ -68,10 +68,10 @@ addHook({
|
|
|
68
68
|
versions: ['>=4'],
|
|
69
69
|
file: 'lib/middleware/query.js'
|
|
70
70
|
}, query => {
|
|
71
|
-
return shimmer.
|
|
71
|
+
return shimmer.wrapFunction(query, query => function () {
|
|
72
72
|
const queryMiddleware = query.apply(this, arguments)
|
|
73
73
|
|
|
74
|
-
return shimmer.
|
|
74
|
+
return shimmer.wrapFunction(queryMiddleware, queryMiddleware => function (req, res, next) {
|
|
75
75
|
arguments[2] = publishQueryParsedAndNext(req, res, next)
|
|
76
76
|
return queryMiddleware.apply(this, arguments)
|
|
77
77
|
})
|
|
@@ -34,12 +34,12 @@ function wrapFastify (fastify, hasParsingEvents) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function wrapAddHook (addHook) {
|
|
37
|
-
return function addHookWithTrace (name, fn) {
|
|
37
|
+
return shimmer.wrapFunction(addHook, addHook => function addHookWithTrace (name, fn) {
|
|
38
38
|
fn = arguments[arguments.length - 1]
|
|
39
39
|
|
|
40
40
|
if (typeof fn !== 'function') return addHook.apply(this, arguments)
|
|
41
41
|
|
|
42
|
-
arguments[arguments.length - 1] = shimmer.
|
|
42
|
+
arguments[arguments.length - 1] = shimmer.wrapFunction(fn, fn => function (request, reply, done) {
|
|
43
43
|
const req = getReq(request)
|
|
44
44
|
|
|
45
45
|
try {
|
|
@@ -78,7 +78,7 @@ function wrapAddHook (addHook) {
|
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
return addHook.apply(this, arguments)
|
|
81
|
-
}
|
|
81
|
+
})
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function onRequest (request, reply, done) {
|
|
@@ -151,7 +151,7 @@ function publishError (error, req) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
addHook({ name: 'fastify', versions: ['>=3'] }, fastify => {
|
|
154
|
-
const wrapped = shimmer.
|
|
154
|
+
const wrapped = shimmer.wrapFunction(fastify, fastify => wrapFastify(fastify, true))
|
|
155
155
|
|
|
156
156
|
wrapped.fastify = wrapped
|
|
157
157
|
wrapped.default = wrapped
|
|
@@ -160,9 +160,9 @@ addHook({ name: 'fastify', versions: ['>=3'] }, fastify => {
|
|
|
160
160
|
})
|
|
161
161
|
|
|
162
162
|
addHook({ name: 'fastify', versions: ['2'] }, fastify => {
|
|
163
|
-
return shimmer.
|
|
163
|
+
return shimmer.wrapFunction(fastify, fastify => wrapFastify(fastify, true))
|
|
164
164
|
})
|
|
165
165
|
|
|
166
166
|
addHook({ name: 'fastify', versions: ['1'] }, fastify => {
|
|
167
|
-
return shimmer.
|
|
167
|
+
return shimmer.wrapFunction(fastify, fastify => wrapFastify(fastify, false))
|
|
168
168
|
})
|
|
@@ -8,5 +8,5 @@ if (globalThis.fetch) {
|
|
|
8
8
|
const ch = tracingChannel('apm:fetch:request')
|
|
9
9
|
const wrapFetch = createWrapFetch(globalThis.Request, ch)
|
|
10
10
|
|
|
11
|
-
globalThis.fetch = shimmer.
|
|
11
|
+
globalThis.fetch = shimmer.wrapFunction(fetch, fetch => wrapFetch(fetch))
|
|
12
12
|
}
|
|
@@ -9,11 +9,11 @@ function wrapOn (on) {
|
|
|
9
9
|
return function onWithTrace (method, path, opts) {
|
|
10
10
|
const index = typeof opts === 'function' ? 2 : 3
|
|
11
11
|
const handler = arguments[index]
|
|
12
|
-
const wrapper = function (req) {
|
|
12
|
+
const wrapper = shimmer.wrapFunction(handler, handler => function (req) {
|
|
13
13
|
routeChannel.publish({ req, route: path })
|
|
14
14
|
|
|
15
15
|
return handler.apply(this, arguments)
|
|
16
|
-
}
|
|
16
|
+
})
|
|
17
17
|
|
|
18
18
|
if (typeof handler === 'function') {
|
|
19
19
|
arguments[index] = wrapper
|
|
@@ -271,7 +271,7 @@ function createWrapFunction (prefix = '', override = '') {
|
|
|
271
271
|
if (cb) {
|
|
272
272
|
const outerResource = new AsyncResource('bound-anonymous-fn')
|
|
273
273
|
|
|
274
|
-
arguments[lastIndex] = innerResource.bind(function (e) {
|
|
274
|
+
arguments[lastIndex] = shimmer.wrapFunction(cb, cb => innerResource.bind(function (e) {
|
|
275
275
|
if (e !== null && typeof e === 'object') { // fs.exists receives a boolean
|
|
276
276
|
errorChannel.publish(e)
|
|
277
277
|
}
|
|
@@ -279,7 +279,7 @@ function createWrapFunction (prefix = '', override = '') {
|
|
|
279
279
|
finishChannel.publish()
|
|
280
280
|
|
|
281
281
|
return outerResource.runInAsyncScope(() => cb.apply(this, arguments))
|
|
282
|
-
})
|
|
282
|
+
}))
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
return innerResource.runInAsyncScope(() => {
|
|
@@ -76,7 +76,7 @@ function wrapMethod (method) {
|
|
|
76
76
|
if (typeof cb === 'function') {
|
|
77
77
|
const outerAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
78
78
|
|
|
79
|
-
arguments[arguments.length - 1] = innerAsyncResource.bind(function (error) {
|
|
79
|
+
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => innerAsyncResource.bind(function (error) {
|
|
80
80
|
if (error) {
|
|
81
81
|
requestErrorCh.publish(error)
|
|
82
82
|
}
|
|
@@ -84,7 +84,7 @@ function wrapMethod (method) {
|
|
|
84
84
|
requestFinishCh.publish()
|
|
85
85
|
|
|
86
86
|
return outerAsyncResource.runInAsyncScope(() => cb.apply(this, arguments))
|
|
87
|
-
})
|
|
87
|
+
}))
|
|
88
88
|
|
|
89
89
|
return method.apply(this, arguments)
|
|
90
90
|
} else {
|