dd-trace 5.21.0 → 5.23.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 +2 -0
- package/index.d.ts +20 -8
- package/package.json +11 -5
- 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 +4 -4
- 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 +294 -56
- 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/register.js +1 -1
- package/packages/datadog-instrumentations/src/http/client.js +3 -3
- package/packages/datadog-instrumentations/src/jest.js +8 -5
- package/packages/datadog-instrumentations/src/kafkajs.js +67 -31
- 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 +7 -5
- package/packages/datadog-instrumentations/src/mocha/common.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +139 -53
- package/packages/datadog-instrumentations/src/mocha/utils.js +37 -18
- package/packages/datadog-instrumentations/src/mocha/worker.js +29 -1
- 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/openai.js +62 -71
- 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 +60 -5
- 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 +188 -12
- package/packages/datadog-instrumentations/src/winston.js +2 -3
- package/packages/datadog-plugin-amqplib/src/consumer.js +1 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +33 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +24 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +39 -10
- package/packages/datadog-plugin-cypress/src/support.js +4 -1
- package/packages/datadog-plugin-hapi/src/index.js +2 -2
- package/packages/datadog-plugin-http/src/client.js +1 -42
- package/packages/datadog-plugin-http2/src/client.js +1 -26
- package/packages/datadog-plugin-jest/src/index.js +18 -1
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +20 -0
- package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -2
- package/packages/datadog-plugin-kafkajs/src/index.js +3 -1
- package/packages/datadog-plugin-mocha/src/index.js +18 -0
- package/packages/datadog-plugin-openai/src/index.js +85 -65
- package/packages/datadog-plugin-playwright/src/index.js +9 -0
- package/packages/datadog-plugin-rhea/src/consumer.js +1 -3
- package/packages/datadog-plugin-vitest/src/index.js +68 -3
- package/packages/datadog-shimmer/src/shimmer.js +144 -10
- package/packages/dd-trace/src/appsec/addresses.js +3 -1
- package/packages/dd-trace/src/appsec/blocking.js +23 -17
- package/packages/dd-trace/src/appsec/channels.js +4 -2
- 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/rasp/index.js +103 -0
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +86 -0
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +37 -0
- package/packages/dd-trace/src/appsec/rasp/utils.js +63 -0
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -0
- package/packages/dd-trace/src/appsec/remote_config/index.js +16 -7
- package/packages/dd-trace/src/appsec/remote_config/manager.js +93 -52
- 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/appsec/waf/waf_context_wrapper.js +33 -14
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +4 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +15 -1
- package/packages/dd-trace/src/config.js +100 -40
- package/packages/dd-trace/src/constants.js +11 -1
- package/packages/dd-trace/src/data_streams_context.js +3 -0
- package/packages/dd-trace/src/datastreams/fnv.js +23 -0
- package/packages/dd-trace/src/datastreams/pathway.js +12 -5
- package/packages/dd-trace/src/datastreams/processor.js +35 -0
- package/packages/dd-trace/src/datastreams/schemas/schema.js +8 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +125 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +29 -0
- package/packages/dd-trace/src/debugger/devtools_client/config.js +24 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +57 -0
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +23 -0
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +164 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +28 -0
- package/packages/dd-trace/src/debugger/devtools_client/session.js +7 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +47 -0
- package/packages/dd-trace/src/debugger/devtools_client/status.js +109 -0
- package/packages/dd-trace/src/debugger/index.js +92 -0
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +29 -2
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- 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/opentracing/propagation/text_map.js +1 -6
- package/packages/dd-trace/src/payload-tagging/config/aws.json +30 -0
- package/packages/dd-trace/src/payload-tagging/config/index.js +30 -0
- package/packages/dd-trace/src/payload-tagging/index.js +93 -0
- package/packages/dd-trace/src/payload-tagging/tagging.js +83 -0
- package/packages/dd-trace/src/plugin_manager.js +11 -10
- package/packages/dd-trace/src/plugins/ci_plugin.js +33 -8
- package/packages/dd-trace/src/plugins/util/env.js +5 -2
- package/packages/dd-trace/src/plugins/util/test.js +24 -4
- package/packages/dd-trace/src/profiler.js +15 -5
- package/packages/dd-trace/src/profiling/config.js +7 -4
- package/packages/dd-trace/src/profiling/exporter_cli.js +13 -1
- package/packages/dd-trace/src/profiling/exporters/agent.js +8 -2
- package/packages/dd-trace/src/profiling/profiler.js +0 -9
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +13 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +24 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +48 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +24 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +108 -32
- package/packages/dd-trace/src/profiling/profilers/shared.js +5 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +9 -3
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +59 -60
- package/packages/dd-trace/src/proxy.js +31 -24
- package/packages/dd-trace/src/span_stats.js +4 -2
- package/packages/dd-trace/src/telemetry/index.js +23 -6
- package/packages/dd-trace/src/telemetry/logs/index.js +20 -0
- package/packages/dd-trace/src/appsec/rasp.js +0 -176
|
@@ -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 {
|
|
@@ -88,12 +88,10 @@ function wrapMethod (method, path, type, hasPeer) {
|
|
|
88
88
|
return method
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
const wrapped = function () {
|
|
91
|
+
const wrapped = shimmer.wrapFunction(method, method => function () {
|
|
92
92
|
const args = ensureMetadata(this, arguments, 1)
|
|
93
93
|
return callMethod(this, method, args, path, args[1], type, hasPeer)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Object.assign(wrapped, method)
|
|
94
|
+
})
|
|
97
95
|
|
|
98
96
|
patched.add(wrapped)
|
|
99
97
|
|
|
@@ -101,7 +99,7 @@ function wrapMethod (method, path, type, hasPeer) {
|
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
function wrapCallback (ctx, callback = () => { }) {
|
|
104
|
-
return function (err) {
|
|
102
|
+
return shimmer.wrapFunction(callback, callback => function (err) {
|
|
105
103
|
if (err) {
|
|
106
104
|
ctx.error = err
|
|
107
105
|
errorChannel.publish(ctx)
|
|
@@ -111,7 +109,7 @@ function wrapCallback (ctx, callback = () => { }) {
|
|
|
111
109
|
return callback.apply(this, arguments)
|
|
112
110
|
// No async end channel needed
|
|
113
111
|
})
|
|
114
|
-
}
|
|
112
|
+
})
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
function createWrapEmit (ctx, hasPeer = false) {
|
|
@@ -119,7 +119,7 @@ function wrapStream (call, ctx, onCancel) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function wrapCallback (callback = () => {}, call, ctx, onCancel) {
|
|
122
|
-
return function (err, value, trailer, flags) {
|
|
122
|
+
return shimmer.wrapFunction(callback, callback => function (err, value, trailer, flags) {
|
|
123
123
|
if (err) {
|
|
124
124
|
ctx.error = err
|
|
125
125
|
errorChannel.publish(ctx)
|
|
@@ -136,7 +136,7 @@ function wrapCallback (callback = () => {}, call, ctx, onCancel) {
|
|
|
136
136
|
return callback.apply(this, arguments)
|
|
137
137
|
// No async end channel needed
|
|
138
138
|
})
|
|
139
|
-
}
|
|
139
|
+
})
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
function wrapSendStatus (sendStatus, ctx) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const tracingChannel = require('dc-polyfill').tracingChannel
|
|
3
4
|
const shimmer = require('../../datadog-shimmer')
|
|
4
|
-
const { addHook, channel
|
|
5
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
5
6
|
|
|
6
7
|
const handleChannel = channel('apm:hapi:request:handle')
|
|
7
8
|
const routeChannel = channel('apm:hapi:request:route')
|
|
8
9
|
const errorChannel = channel('apm:hapi:request:error')
|
|
9
|
-
const
|
|
10
|
+
const hapiTracingChannel = tracingChannel('apm:hapi:extension')
|
|
10
11
|
|
|
11
12
|
function wrapServer (server) {
|
|
12
13
|
return function (options) {
|
|
@@ -27,17 +28,17 @@ function wrapServer (server) {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function wrapStart (start) {
|
|
30
|
-
return function () {
|
|
31
|
+
return shimmer.wrapFunction(start, start => function () {
|
|
31
32
|
if (this && typeof this.ext === 'function') {
|
|
32
33
|
this.ext('onPreResponse', onPreResponse)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
return start.apply(this, arguments)
|
|
36
|
-
}
|
|
37
|
+
})
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
function wrapExt (ext) {
|
|
40
|
-
return function (events, method, options) {
|
|
41
|
+
return shimmer.wrapFunction(ext, ext => function (events, method, options) {
|
|
41
42
|
if (events !== null && typeof events === 'object') {
|
|
42
43
|
arguments[0] = wrapEvents(events)
|
|
43
44
|
} else {
|
|
@@ -45,7 +46,7 @@ function wrapExt (ext) {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return ext.apply(this, arguments)
|
|
48
|
-
}
|
|
49
|
+
})
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function wrapDispatch (dispatch) {
|
|
@@ -91,19 +92,15 @@ function wrapEvents (events) {
|
|
|
91
92
|
function wrapHandler (handler) {
|
|
92
93
|
if (typeof handler !== 'function') return handler
|
|
93
94
|
|
|
94
|
-
return function (request, h) {
|
|
95
|
+
return shimmer.wrapFunction(handler, handler => function (request, h) {
|
|
95
96
|
const req = request && request.raw && request.raw.req
|
|
96
97
|
|
|
97
98
|
if (!req) return handler.apply(this, arguments)
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return asyncResource.runInAsyncScope(() => {
|
|
102
|
-
enterChannel.publish({ req })
|
|
103
|
-
|
|
100
|
+
return hapiTracingChannel.traceSync(() => {
|
|
104
101
|
return handler.apply(this, arguments)
|
|
105
102
|
})
|
|
106
|
-
}
|
|
103
|
+
})
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
function onPreResponse (request, h) {
|
|
@@ -98,7 +98,7 @@ for (const packageName of names) {
|
|
|
98
98
|
log.error(e)
|
|
99
99
|
continue
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
101
|
+
if (typeof namesAndSuccesses[`${name}@${version}`] === 'undefined') {
|
|
102
102
|
namesAndSuccesses[`${name}@${version}`] = false
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -52,11 +52,11 @@ function patch (http, methodName) {
|
|
|
52
52
|
let callback = args.callback
|
|
53
53
|
|
|
54
54
|
if (callback) {
|
|
55
|
-
callback = function () {
|
|
55
|
+
callback = shimmer.wrapFunction(args.callback, cb => function () {
|
|
56
56
|
return asyncStartChannel.runStores(ctx, () => {
|
|
57
|
-
return
|
|
57
|
+
return cb.apply(this, arguments)
|
|
58
58
|
})
|
|
59
|
-
}
|
|
59
|
+
})
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const options = args.options
|
|
@@ -12,8 +12,7 @@ const {
|
|
|
12
12
|
getTestParametersString,
|
|
13
13
|
addEfdStringToTestName,
|
|
14
14
|
removeEfdStringFromTestName,
|
|
15
|
-
getIsFaultyEarlyFlakeDetection
|
|
16
|
-
NUM_FAILED_TEST_RETRIES
|
|
15
|
+
getIsFaultyEarlyFlakeDetection
|
|
17
16
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
18
17
|
const {
|
|
19
18
|
getFormattedJestTestParameters,
|
|
@@ -132,6 +131,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
132
131
|
|
|
133
132
|
this.isEarlyFlakeDetectionEnabled = this.testEnvironmentOptions._ddIsEarlyFlakeDetectionEnabled
|
|
134
133
|
this.isFlakyTestRetriesEnabled = this.testEnvironmentOptions._ddIsFlakyTestRetriesEnabled
|
|
134
|
+
this.flakyTestRetriesCount = this.testEnvironmentOptions._ddFlakyTestRetriesCount
|
|
135
135
|
|
|
136
136
|
if (this.isEarlyFlakeDetectionEnabled) {
|
|
137
137
|
const hasKnownTests = !!knownTests.jest
|
|
@@ -149,7 +149,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
149
149
|
if (this.isFlakyTestRetriesEnabled) {
|
|
150
150
|
const currentNumRetries = this.global[RETRY_TIMES]
|
|
151
151
|
if (!currentNumRetries) {
|
|
152
|
-
this.global[RETRY_TIMES] =
|
|
152
|
+
this.global[RETRY_TIMES] = this.flakyTestRetriesCount
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -404,7 +404,7 @@ addHook({
|
|
|
404
404
|
|
|
405
405
|
addHook({
|
|
406
406
|
name: '@jest/test-sequencer',
|
|
407
|
-
versions: ['>=
|
|
407
|
+
versions: ['>=28']
|
|
408
408
|
}, (sequencerPackage, frameworkVersion) => {
|
|
409
409
|
shimmer.wrap(sequencerPackage.default.prototype, 'shard', shard => function () {
|
|
410
410
|
const shardedTests = shard.apply(this, arguments)
|
|
@@ -638,7 +638,7 @@ addHook({
|
|
|
638
638
|
|
|
639
639
|
function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
640
640
|
const adapter = jestAdapter.default ? jestAdapter.default : jestAdapter
|
|
641
|
-
const newAdapter = shimmer.
|
|
641
|
+
const newAdapter = shimmer.wrapFunction(adapter, adapter => function () {
|
|
642
642
|
const environment = arguments[2]
|
|
643
643
|
if (!environment) {
|
|
644
644
|
return adapter.apply(this, arguments)
|
|
@@ -648,6 +648,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
|
648
648
|
testSuiteStartCh.publish({
|
|
649
649
|
testSuite: environment.testSuite,
|
|
650
650
|
testEnvironmentOptions: environment.testEnvironmentOptions,
|
|
651
|
+
testSourceFile: environment.testSourceFile,
|
|
651
652
|
displayName: environment.displayName,
|
|
652
653
|
frameworkVersion: jestVersion
|
|
653
654
|
})
|
|
@@ -765,6 +766,7 @@ addHook({
|
|
|
765
766
|
_ddTestModuleId,
|
|
766
767
|
_ddTestSessionId,
|
|
767
768
|
_ddTestCommand,
|
|
769
|
+
_ddTestSessionName,
|
|
768
770
|
_ddForcedToRun,
|
|
769
771
|
_ddUnskippable,
|
|
770
772
|
_ddItrCorrelationId,
|
|
@@ -773,6 +775,7 @@ addHook({
|
|
|
773
775
|
_ddEarlyFlakeDetectionNumRetries,
|
|
774
776
|
_ddRepositoryRoot,
|
|
775
777
|
_ddIsFlakyTestRetriesEnabled,
|
|
778
|
+
_ddFlakyTestRetriesCount,
|
|
776
779
|
...restOfTestEnvironmentOptions
|
|
777
780
|
} = testEnvironmentOptions
|
|
778
781
|
|
|
@@ -17,6 +17,10 @@ const consumerCommitCh = channel('apm:kafkajs:consume:commit')
|
|
|
17
17
|
const consumerFinishCh = channel('apm:kafkajs:consume:finish')
|
|
18
18
|
const consumerErrorCh = channel('apm:kafkajs:consume:error')
|
|
19
19
|
|
|
20
|
+
const batchConsumerStartCh = channel('apm:kafkajs:consume-batch:start')
|
|
21
|
+
const batchConsumerFinishCh = channel('apm:kafkajs:consume-batch:finish')
|
|
22
|
+
const batchConsumerErrorCh = channel('apm:kafkajs:consume-batch:error')
|
|
23
|
+
|
|
20
24
|
function commitsFromEvent (event) {
|
|
21
25
|
const { payload: { groupId, topics } } = event
|
|
22
26
|
const commitList = []
|
|
@@ -96,6 +100,17 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
96
100
|
return createConsumer.apply(this, arguments)
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
const eachMessageExtractor = (args) => {
|
|
104
|
+
const { topic, partition, message } = args[0]
|
|
105
|
+
return { topic, partition, message, groupId }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const eachBatchExtractor = (args) => {
|
|
109
|
+
const { batch } = args[0]
|
|
110
|
+
const { topic, partition, messages } = batch
|
|
111
|
+
return { topic, partition, messages, groupId }
|
|
112
|
+
}
|
|
113
|
+
|
|
99
114
|
const consumer = createConsumer.apply(this, arguments)
|
|
100
115
|
|
|
101
116
|
consumer.on(consumer.events.COMMIT_OFFSETS, commitsFromEvent)
|
|
@@ -103,43 +118,64 @@ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKaf
|
|
|
103
118
|
const run = consumer.run
|
|
104
119
|
|
|
105
120
|
const groupId = arguments[0].groupId
|
|
106
|
-
consumer.run = function ({ eachMessage, ...runArgs }) {
|
|
107
|
-
|
|
121
|
+
consumer.run = function ({ eachMessage, eachBatch, ...runArgs }) {
|
|
122
|
+
eachMessage = wrapFunction(
|
|
123
|
+
eachMessage,
|
|
124
|
+
consumerStartCh,
|
|
125
|
+
consumerFinishCh,
|
|
126
|
+
consumerErrorCh,
|
|
127
|
+
eachMessageExtractor
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
eachBatch = wrapFunction(
|
|
131
|
+
eachBatch,
|
|
132
|
+
batchConsumerStartCh,
|
|
133
|
+
batchConsumerFinishCh,
|
|
134
|
+
batchConsumerErrorCh,
|
|
135
|
+
eachBatchExtractor
|
|
136
|
+
)
|
|
108
137
|
|
|
109
138
|
return run({
|
|
110
|
-
eachMessage
|
|
111
|
-
|
|
112
|
-
return innerAsyncResource.runInAsyncScope(() => {
|
|
113
|
-
const { topic, partition, message } = eachMessageArgs[0]
|
|
114
|
-
consumerStartCh.publish({ topic, partition, message, groupId })
|
|
115
|
-
try {
|
|
116
|
-
const result = eachMessage.apply(this, eachMessageArgs)
|
|
117
|
-
if (result && typeof result.then === 'function') {
|
|
118
|
-
result.then(
|
|
119
|
-
innerAsyncResource.bind(() => consumerFinishCh.publish(undefined)),
|
|
120
|
-
innerAsyncResource.bind(err => {
|
|
121
|
-
if (err) {
|
|
122
|
-
consumerErrorCh.publish(err)
|
|
123
|
-
}
|
|
124
|
-
consumerFinishCh.publish(undefined)
|
|
125
|
-
})
|
|
126
|
-
)
|
|
127
|
-
} else {
|
|
128
|
-
consumerFinishCh.publish(undefined)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return result
|
|
132
|
-
} catch (e) {
|
|
133
|
-
consumerErrorCh.publish(e)
|
|
134
|
-
consumerFinishCh.publish(undefined)
|
|
135
|
-
throw e
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
},
|
|
139
|
+
eachMessage,
|
|
140
|
+
eachBatch,
|
|
139
141
|
...runArgs
|
|
140
142
|
})
|
|
141
143
|
}
|
|
144
|
+
|
|
142
145
|
return consumer
|
|
143
146
|
})
|
|
144
147
|
return Kafka
|
|
145
148
|
})
|
|
149
|
+
|
|
150
|
+
const wrapFunction = (fn, startCh, finishCh, errorCh, extractArgs) => {
|
|
151
|
+
return typeof fn === 'function'
|
|
152
|
+
? function (...args) {
|
|
153
|
+
const innerAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
154
|
+
return innerAsyncResource.runInAsyncScope(() => {
|
|
155
|
+
const extractedArgs = extractArgs(args)
|
|
156
|
+
startCh.publish(extractedArgs)
|
|
157
|
+
try {
|
|
158
|
+
const result = fn.apply(this, args)
|
|
159
|
+
if (result && typeof result.then === 'function') {
|
|
160
|
+
result.then(
|
|
161
|
+
innerAsyncResource.bind(() => finishCh.publish(undefined)),
|
|
162
|
+
innerAsyncResource.bind(err => {
|
|
163
|
+
if (err) {
|
|
164
|
+
errorCh.publish(err)
|
|
165
|
+
}
|
|
166
|
+
finishCh.publish(undefined)
|
|
167
|
+
})
|
|
168
|
+
)
|
|
169
|
+
} else {
|
|
170
|
+
finishCh.publish(undefined)
|
|
171
|
+
}
|
|
172
|
+
return result
|
|
173
|
+
} catch (e) {
|
|
174
|
+
errorCh.publish(e)
|
|
175
|
+
finishCh.publish(undefined)
|
|
176
|
+
throw e
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
: fn
|
|
181
|
+
}
|
|
@@ -81,8 +81,8 @@ addHook({
|
|
|
81
81
|
function wrapCallbackWithFinish (callback, finish) {
|
|
82
82
|
if (typeof callback !== 'function') return callback
|
|
83
83
|
|
|
84
|
-
return function () {
|
|
84
|
+
return shimmer.wrapFunction(callback, callback => function () {
|
|
85
85
|
finish()
|
|
86
86
|
callback.apply(this, arguments)
|
|
87
|
-
}
|
|
87
|
+
})
|
|
88
88
|
}
|
|
@@ -71,7 +71,7 @@ function wrapStack (layer) {
|
|
|
71
71
|
|
|
72
72
|
middleware = original || middleware
|
|
73
73
|
|
|
74
|
-
const handler = shimmer.
|
|
74
|
+
const handler = shimmer.wrapFunction(middleware, middleware => wrapMiddleware(middleware, layer))
|
|
75
75
|
|
|
76
76
|
originals.set(handler, middleware)
|
|
77
77
|
|
|
@@ -84,7 +84,7 @@ function wrapMiddleware (fn, layer) {
|
|
|
84
84
|
|
|
85
85
|
const name = fn.name
|
|
86
86
|
|
|
87
|
-
return function (ctx, next) {
|
|
87
|
+
return shimmer.wrapFunction(fn, fn => function (ctx, next) {
|
|
88
88
|
if (!ctx || !enterChannel.hasSubscribers) return fn.apply(this, arguments)
|
|
89
89
|
|
|
90
90
|
const req = ctx.req
|
|
@@ -122,7 +122,7 @@ function wrapMiddleware (fn, layer) {
|
|
|
122
122
|
} finally {
|
|
123
123
|
exitChannel.publish({ req })
|
|
124
124
|
}
|
|
125
|
-
}
|
|
125
|
+
})
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function fulfill (ctx, error) {
|
|
@@ -142,11 +142,11 @@ function fulfill (ctx, error) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
function wrapNext (req, next) {
|
|
145
|
-
return function () {
|
|
145
|
+
return shimmer.wrapFunction(next, next => function () {
|
|
146
146
|
nextChannel.publish({ req })
|
|
147
147
|
|
|
148
148
|
return next.apply(this, arguments)
|
|
149
|
-
}
|
|
149
|
+
})
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
addHook({ name: 'koa', versions: ['>=2'] }, Koa => {
|
|
@@ -77,7 +77,7 @@ addHook({ name: 'ldapjs', versions: ['>=2'] }, ldapjs => {
|
|
|
77
77
|
if (callbackIndex > -1) {
|
|
78
78
|
const callback = arguments[callbackIndex]
|
|
79
79
|
// eslint-disable-next-line n/handle-callback-err
|
|
80
|
-
arguments[callbackIndex] = shimmer.
|
|
80
|
+
arguments[callbackIndex] = shimmer.wrapFunction(callback, callback => function (err, corkedEmitter) {
|
|
81
81
|
if (corkedEmitter !== null && typeof corkedEmitter === 'object' && typeof corkedEmitter.on === 'function') {
|
|
82
82
|
wrapEmitter(corkedEmitter)
|
|
83
83
|
}
|
|
@@ -11,7 +11,7 @@ const skipCh = channel('apm:mariadb:pool:skip')
|
|
|
11
11
|
const unskipCh = channel('apm:mariadb:pool:unskip')
|
|
12
12
|
|
|
13
13
|
function wrapCommandStart (start, callbackResource) {
|
|
14
|
-
return function () {
|
|
14
|
+
return shimmer.wrapFunction(start, start => function () {
|
|
15
15
|
if (!startCh.hasSubscribers) return start.apply(this, arguments)
|
|
16
16
|
|
|
17
17
|
const resolve = callbackResource.bind(this.resolve)
|
|
@@ -44,7 +44,7 @@ function wrapCommandStart (start, callbackResource) {
|
|
|
44
44
|
startCh.publish({ sql: this.sql, conf: this.opts })
|
|
45
45
|
return start.apply(this, arguments)
|
|
46
46
|
})
|
|
47
|
-
}
|
|
47
|
+
})
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function wrapCommand (Command) {
|
|
@@ -98,7 +98,7 @@ function createWrapQueryCallback (options) {
|
|
|
98
98
|
arguments.length = arguments.length + 1
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
arguments[arguments.length - 1] = asyncResource.bind(function (err) {
|
|
101
|
+
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => asyncResource.bind(function (err) {
|
|
102
102
|
if (err) {
|
|
103
103
|
errorCh.publish(err)
|
|
104
104
|
}
|
|
@@ -108,7 +108,7 @@ function createWrapQueryCallback (options) {
|
|
|
108
108
|
if (typeof cb === 'function') {
|
|
109
109
|
return callbackResource.runInAsyncScope(() => cb.apply(this, arguments))
|
|
110
110
|
}
|
|
111
|
-
})
|
|
111
|
+
}))
|
|
112
112
|
|
|
113
113
|
return asyncResource.runInAsyncScope(() => {
|
|
114
114
|
startCh.publish({ sql, conf: options })
|
|
@@ -119,7 +119,7 @@ function createWrapQueryCallback (options) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
function wrapConnection (
|
|
122
|
+
function wrapConnection (promiseMethod, Connection) {
|
|
123
123
|
return function (options) {
|
|
124
124
|
Connection.apply(this, arguments)
|
|
125
125
|
|
|
@@ -170,13 +170,13 @@ addHook({ name, file: 'lib/pool.js', versions: ['>=3'] }, (Pool) => {
|
|
|
170
170
|
})
|
|
171
171
|
|
|
172
172
|
addHook({ name, file: 'lib/connection.js', versions: ['>=2.5.2 <3'] }, (Connection) => {
|
|
173
|
-
return shimmer.
|
|
173
|
+
return shimmer.wrapFunction(Connection, wrapConnection.bind(null, '_queryPromise'))
|
|
174
174
|
})
|
|
175
175
|
|
|
176
176
|
addHook({ name, file: 'lib/connection.js', versions: ['>=2.0.4 <=2.5.1'] }, (Connection) => {
|
|
177
|
-
return shimmer.
|
|
177
|
+
return shimmer.wrapFunction(Connection, wrapConnection.bind(null, 'query'))
|
|
178
178
|
})
|
|
179
179
|
|
|
180
180
|
addHook({ name, file: 'lib/pool-base.js', versions: ['>=2.0.4 <3'] }, (PoolBase) => {
|
|
181
|
-
return shimmer.
|
|
181
|
+
return shimmer.wrapFunction(PoolBase, wrapPoolBase)
|
|
182
182
|
})
|
|
@@ -26,14 +26,14 @@ addHook({ name: 'memcached', versions: ['>=2.2'] }, Memcached => {
|
|
|
26
26
|
const query = queryCompiler.apply(this, arguments)
|
|
27
27
|
const callback = callbackResource.bind(query.callback)
|
|
28
28
|
|
|
29
|
-
query.callback = asyncResource.bind(function (err) {
|
|
29
|
+
query.callback = shimmer.wrapFunction(callback, callback => asyncResource.bind(function (err) {
|
|
30
30
|
if (err) {
|
|
31
31
|
errorCh.publish(err)
|
|
32
32
|
}
|
|
33
33
|
finishCh.publish()
|
|
34
34
|
|
|
35
35
|
return callback.apply(this, arguments)
|
|
36
|
-
})
|
|
36
|
+
}))
|
|
37
37
|
startCh.publish({ client, server, query })
|
|
38
38
|
|
|
39
39
|
return query
|
|
@@ -8,7 +8,9 @@ const routeChannel = channel('apm:microgateway-core:request:route')
|
|
|
8
8
|
const errorChannel = channel('apm:microgateway-core:request:error')
|
|
9
9
|
|
|
10
10
|
const name = 'microgateway-core'
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
// TODO Remove " <=3.0.0" when "volos-util-apigee" module is fixed
|
|
13
|
+
const versions = ['>=2.1 <=3.0.0']
|
|
12
14
|
const requestResources = new WeakMap()
|
|
13
15
|
|
|
14
16
|
function wrapConfigProxyFactory (configProxyFactory) {
|
|
@@ -40,7 +42,7 @@ function wrapPluginsFactory (pluginsFactory) {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
function wrapNext (req, res, next) {
|
|
43
|
-
return function nextWithTrace (err) {
|
|
45
|
+
return shimmer.wrapFunction(next, next => function nextWithTrace (err) {
|
|
44
46
|
const requestResource = requestResources.get(req)
|
|
45
47
|
|
|
46
48
|
requestResource.runInAsyncScope(() => {
|
|
@@ -54,13 +56,13 @@ function wrapNext (req, res, next) {
|
|
|
54
56
|
})
|
|
55
57
|
|
|
56
58
|
return next.apply(this, arguments)
|
|
57
|
-
}
|
|
59
|
+
})
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
addHook({ name, versions, file: 'lib/config-proxy-middleware.js' }, configProxyFactory => {
|
|
61
|
-
return shimmer.
|
|
63
|
+
return shimmer.wrapFunction(configProxyFactory, wrapConfigProxyFactory)
|
|
62
64
|
})
|
|
63
65
|
|
|
64
66
|
addHook({ name, versions, file: 'lib/plugins-middleware.js' }, pluginsFactory => {
|
|
65
|
-
return shimmer.
|
|
67
|
+
return shimmer.wrapFunction(pluginsFactory, wrapPluginsFactory)
|
|
66
68
|
})
|
|
@@ -15,7 +15,7 @@ addHook({
|
|
|
15
15
|
|
|
16
16
|
patched.add(mochaEach)
|
|
17
17
|
|
|
18
|
-
return shimmer.
|
|
18
|
+
return shimmer.wrapFunction(mochaEach, mochaEach => function () {
|
|
19
19
|
const [params] = arguments
|
|
20
20
|
const { it, ...rest } = mochaEach.apply(this, arguments)
|
|
21
21
|
return {
|