dd-trace 5.101.0 → 5.103.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/ext/exporters.js +1 -0
- package/package.json +20 -17
- package/packages/datadog-esbuild/src/utils.js +2 -2
- package/packages/datadog-instrumentations/src/aerospike.js +2 -2
- package/packages/datadog-instrumentations/src/ai.js +9 -9
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +5 -5
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-sdk.js +151 -67
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +2 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +7 -7
- package/packages/datadog-instrumentations/src/child_process.js +12 -12
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +7 -7
- package/packages/datadog-instrumentations/src/cookie-parser.js +4 -4
- package/packages/datadog-instrumentations/src/cookie.js +2 -2
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +4 -4
- package/packages/datadog-instrumentations/src/cucumber.js +78 -17
- package/packages/datadog-instrumentations/src/dns.js +0 -3
- package/packages/datadog-instrumentations/src/elasticsearch.js +8 -11
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +6 -6
- package/packages/datadog-instrumentations/src/express-session.js +4 -4
- package/packages/datadog-instrumentations/src/express.js +10 -11
- package/packages/datadog-instrumentations/src/fastify.js +2 -2
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +14 -14
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +13 -12
- package/packages/datadog-instrumentations/src/grpc/server.js +2 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +9 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/kafka.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/hono.js +2 -2
- package/packages/datadog-instrumentations/src/http/client.js +6 -6
- package/packages/datadog-instrumentations/src/http/server.js +9 -9
- package/packages/datadog-instrumentations/src/ioredis.js +16 -12
- package/packages/datadog-instrumentations/src/jest.js +382 -81
- package/packages/datadog-instrumentations/src/kafkajs.js +165 -174
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +12 -12
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +13 -13
- package/packages/datadog-instrumentations/src/memcached.js +2 -2
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +3 -3
- package/packages/datadog-instrumentations/src/mocha/main.js +85 -11
- package/packages/datadog-instrumentations/src/mocha/utils.js +133 -16
- package/packages/datadog-instrumentations/src/mocha/worker.js +7 -5
- package/packages/datadog-instrumentations/src/mongodb-core.js +42 -30
- package/packages/datadog-instrumentations/src/mongodb.js +5 -5
- package/packages/datadog-instrumentations/src/mongoose.js +21 -21
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +4 -4
- package/packages/datadog-instrumentations/src/mysql.js +16 -16
- package/packages/datadog-instrumentations/src/mysql2.js +4 -4
- package/packages/datadog-instrumentations/src/net.js +14 -8
- package/packages/datadog-instrumentations/src/nyc.js +5 -5
- package/packages/datadog-instrumentations/src/openai.js +19 -19
- package/packages/datadog-instrumentations/src/oracledb.js +6 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/pg.js +39 -25
- package/packages/datadog-instrumentations/src/pino.js +6 -10
- package/packages/datadog-instrumentations/src/playwright.js +445 -68
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +20 -12
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/router.js +12 -12
- package/packages/datadog-instrumentations/src/stripe.js +12 -12
- package/packages/datadog-instrumentations/src/vitest.js +107 -26
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-aws-sdk/src/base.js +70 -28
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +20 -13
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +46 -36
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +14 -15
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +74 -55
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-aws-sdk/src/util.js +22 -0
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +215 -26
- package/packages/datadog-plugin-cypress/src/support.js +13 -1
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +3 -1
- package/packages/datadog-plugin-graphql/src/execute.js +6 -28
- package/packages/datadog-plugin-graphql/src/resolve.js +30 -35
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +29 -0
- package/packages/datadog-plugin-grpc/src/client.js +6 -7
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +3 -7
- package/packages/datadog-plugin-jest/src/index.js +92 -50
- package/packages/datadog-plugin-jest/src/util.js +1 -2
- package/packages/datadog-plugin-mocha/src/index.js +5 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +36 -69
- package/packages/datadog-plugin-mysql/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/services.js +2 -1
- package/packages/datadog-plugin-openai/src/tracing.js +12 -23
- package/packages/datadog-plugin-pg/src/index.js +3 -3
- package/packages/datadog-plugin-playwright/src/index.js +5 -1
- package/packages/datadog-plugin-redis/src/index.js +18 -23
- package/packages/datadog-plugin-vitest/src/index.js +8 -1
- package/packages/datadog-shimmer/src/shimmer.js +7 -1
- package/packages/dd-trace/src/aiguard/index.js +3 -1
- package/packages/dd-trace/src/aiguard/sdk.js +36 -30
- package/packages/dd-trace/src/aiguard/tags.js +20 -11
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +21 -24
- package/packages/dd-trace/src/appsec/reporter.js +3 -1
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +31 -16
- package/packages/dd-trace/src/azure_metadata.js +17 -6
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +4 -4
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +6 -4
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +1 -1
- package/packages/dd-trace/src/config/defaults.js +3 -14
- package/packages/dd-trace/src/config/generated-config-types.d.ts +3 -1
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +4 -0
- package/packages/dd-trace/src/config/index.js +2 -2
- package/packages/dd-trace/src/config/major-overrides.js +98 -0
- package/packages/dd-trace/src/config/parsers.js +7 -1
- package/packages/dd-trace/src/config/supported-configurations.json +51 -38
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/processor.js +3 -4
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +2 -1
- package/packages/dd-trace/src/debugger/index.js +7 -7
- package/packages/dd-trace/src/dogstatsd.js +2 -2
- package/packages/dd-trace/src/encode/0.4.js +748 -232
- package/packages/dd-trace/src/encode/0.5.js +47 -10
- package/packages/dd-trace/src/encode/agentless-json.js +1 -1
- package/packages/dd-trace/src/exporter.js +2 -0
- package/packages/dd-trace/src/exporters/agent/index.js +2 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -2
- package/packages/dd-trace/src/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +2 -1
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/git_metadata.js +10 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -2
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +45 -15
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +6 -3
- package/packages/dd-trace/src/llmobs/sdk.js +24 -26
- package/packages/dd-trace/src/llmobs/span_processor.js +25 -5
- package/packages/dd-trace/src/llmobs/util.js +1 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +2 -1
- package/packages/dd-trace/src/msgpack/chunk.js +6 -3
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/writers/base.js +2 -1
- package/packages/dd-trace/src/openfeature/writers/exposures.js +33 -52
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +0 -22
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +20 -9
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -11
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +49 -4
- package/packages/dd-trace/src/plugins/database.js +54 -12
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/plugin.js +2 -4
- package/packages/dd-trace/src/plugins/util/ci.js +9 -9
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +56 -12
- package/packages/dd-trace/src/plugins/util/url.js +1 -3
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +5 -7
- package/packages/dd-trace/src/priority_sampler.js +1 -1
- package/packages/dd-trace/src/profiling/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +3 -23
- package/packages/dd-trace/src/profiling/profilers/wall.js +5 -6
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +1 -1
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +2 -1
- package/packages/dd-trace/src/runtime_metrics/index.js +2 -2
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +5 -8
- package/packages/dd-trace/src/scope.js +3 -10
- package/packages/dd-trace/src/serverless.js +6 -6
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +27 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +24 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/span_stats.js +1 -1
- package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
- package/packages/dd-trace/src/telemetry/endpoints.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +2 -2
- package/packages/dd-trace/src/tracer.js +7 -7
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
|
@@ -9,23 +9,23 @@ const deserializeChannel = dc.channel('apm:protobufjs:deserialize-end')
|
|
|
9
9
|
|
|
10
10
|
function wrapSerialization (messageClass) {
|
|
11
11
|
if (messageClass?.encode) {
|
|
12
|
-
shimmer.wrap(messageClass, 'encode', original => function () {
|
|
12
|
+
shimmer.wrap(messageClass, 'encode', original => function (...args) {
|
|
13
13
|
if (!serializeChannel.hasSubscribers) {
|
|
14
|
-
return original.apply(this,
|
|
14
|
+
return original.apply(this, args)
|
|
15
15
|
}
|
|
16
16
|
serializeChannel.publish({ messageClass: this })
|
|
17
|
-
return original.apply(this,
|
|
17
|
+
return original.apply(this, args)
|
|
18
18
|
})
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function wrapDeserialization (messageClass) {
|
|
23
23
|
if (messageClass?.decode) {
|
|
24
|
-
shimmer.wrap(messageClass, 'decode', original => function () {
|
|
24
|
+
shimmer.wrap(messageClass, 'decode', original => function (...args) {
|
|
25
25
|
if (!deserializeChannel.hasSubscribers) {
|
|
26
|
-
return original.apply(this,
|
|
26
|
+
return original.apply(this, args)
|
|
27
27
|
}
|
|
28
|
-
const result = original.apply(this,
|
|
28
|
+
const result = original.apply(this, args)
|
|
29
29
|
deserializeChannel.publish({ messageClass: result })
|
|
30
30
|
return result
|
|
31
31
|
})
|
|
@@ -34,8 +34,8 @@ function wrapDeserialization (messageClass) {
|
|
|
34
34
|
|
|
35
35
|
function wrapSetup (messageClass) {
|
|
36
36
|
if (messageClass?.setup) {
|
|
37
|
-
shimmer.wrap(messageClass, 'setup', original => function () {
|
|
38
|
-
const result = original.apply(this,
|
|
37
|
+
shimmer.wrap(messageClass, 'setup', original => function (...args) {
|
|
38
|
+
const result = original.apply(this, args)
|
|
39
39
|
|
|
40
40
|
wrapSerialization(messageClass)
|
|
41
41
|
wrapDeserialization(messageClass)
|
|
@@ -74,8 +74,8 @@ function wrapReflection (protobuf) {
|
|
|
74
74
|
]
|
|
75
75
|
|
|
76
76
|
for (const method of reflectionMethods) {
|
|
77
|
-
shimmer.wrap(method.target, method.name, original => function () {
|
|
78
|
-
const result = original.apply(this,
|
|
77
|
+
shimmer.wrap(method.target, method.name, original => function (...args) {
|
|
78
|
+
const result = original.apply(this, args)
|
|
79
79
|
if (result.nested) {
|
|
80
80
|
for (const type in result.nested) {
|
|
81
81
|
wrapSetup(result.nested[type])
|
|
@@ -97,8 +97,8 @@ addHook({
|
|
|
97
97
|
name: 'protobufjs',
|
|
98
98
|
versions: ['>=6.8.0'],
|
|
99
99
|
}, protobuf => {
|
|
100
|
-
shimmer.wrap(protobuf.Root.prototype, 'load', original => function () {
|
|
101
|
-
const result = original.apply(this,
|
|
100
|
+
shimmer.wrap(protobuf.Root.prototype, 'load', original => function (...args) {
|
|
101
|
+
const result = original.apply(this, args)
|
|
102
102
|
if (isPromise(result)) {
|
|
103
103
|
return result.then(root => {
|
|
104
104
|
wrapProtobufClasses(root)
|
|
@@ -110,14 +110,14 @@ addHook({
|
|
|
110
110
|
return result
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
-
shimmer.wrap(protobuf.Root.prototype, 'loadSync', original => function () {
|
|
114
|
-
const root = original.apply(this,
|
|
113
|
+
shimmer.wrap(protobuf.Root.prototype, 'loadSync', original => function (...args) {
|
|
114
|
+
const root = original.apply(this, args)
|
|
115
115
|
wrapProtobufClasses(root)
|
|
116
116
|
return root
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
shimmer.wrap(protobuf, 'Type', Original => function () {
|
|
120
|
-
const typeInstance = new Original(...
|
|
119
|
+
shimmer.wrap(protobuf, 'Type', Original => function (...args) {
|
|
120
|
+
const typeInstance = new Original(...args)
|
|
121
121
|
wrapSetup(typeInstance)
|
|
122
122
|
return typeInstance
|
|
123
123
|
})
|
|
@@ -13,6 +13,7 @@ const errorCh = channel('apm:redis:command:error')
|
|
|
13
13
|
let createClientUrl
|
|
14
14
|
let createClientName
|
|
15
15
|
const instanceInfo = new WeakMap()
|
|
16
|
+
const connectionInfoCache = new WeakMap()
|
|
16
17
|
|
|
17
18
|
function wrapAddCommand (addCommand) {
|
|
18
19
|
return function (command) {
|
|
@@ -20,10 +21,7 @@ function wrapAddCommand (addCommand) {
|
|
|
20
21
|
return addCommand.apply(this, arguments)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
-
const args = command.slice(1)
|
|
25
|
-
|
|
26
|
-
const ctx = getStartCtx(this, name, args)
|
|
24
|
+
const ctx = getStartCtx(this, command[0], command, 1)
|
|
27
25
|
return startCh.runStores(ctx, () => {
|
|
28
26
|
const res = addCommand.apply(this, arguments)
|
|
29
27
|
|
|
@@ -35,7 +33,7 @@ function wrapAddCommand (addCommand) {
|
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
function wrapCommandQueueClass (cls) {
|
|
38
|
-
|
|
36
|
+
return class RedisCommandQueue extends cls {
|
|
39
37
|
constructor (...args) {
|
|
40
38
|
super(...args)
|
|
41
39
|
let url = { host: 'localhost', port: 6379 }
|
|
@@ -50,7 +48,6 @@ function wrapCommandQueueClass (cls) {
|
|
|
50
48
|
instanceInfo.set(this, { connectionName: createClientName, url })
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
return ret
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
function wrapCreateClient (request) {
|
|
@@ -137,22 +134,33 @@ addHook({ name: 'redis', versions: ['>=0.12 <2.6'] }, redis => {
|
|
|
137
134
|
return redis
|
|
138
135
|
})
|
|
139
136
|
|
|
140
|
-
function getStartCtx (client, command, args) {
|
|
141
|
-
|
|
137
|
+
function getStartCtx (client, command, args, argsStartIndex) {
|
|
138
|
+
let cached = connectionInfoCache.get(client)
|
|
139
|
+
if (cached === undefined) {
|
|
140
|
+
const info = instanceInfo.get(client)
|
|
141
|
+
cached = {
|
|
142
|
+
connectionOptions:
|
|
143
|
+
client.connection_options || client.connection_option || client.connectionOption || info?.url,
|
|
144
|
+
connectionName: info?.connectionName,
|
|
145
|
+
}
|
|
146
|
+
connectionInfoCache.set(client, cached)
|
|
147
|
+
}
|
|
142
148
|
|
|
143
149
|
return {
|
|
144
150
|
db: client.selected_db,
|
|
145
151
|
command,
|
|
146
152
|
args,
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
argsStartIndex,
|
|
154
|
+
connectionOptions: cached.connectionOptions,
|
|
155
|
+
connectionName: cached.connectionName,
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
function wrapCallback (finishCh, errorCh, ctx, callback) {
|
|
153
|
-
|
|
160
|
+
if (typeof callback !== 'function') return callback
|
|
161
|
+
return function (err) {
|
|
154
162
|
return finish(finishCh, errorCh, ctx, err, callback, this, arguments)
|
|
155
|
-
}
|
|
163
|
+
}
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
function finish (finishCh, errorCh, ctx, error, callback, thisArg, args) {
|
|
@@ -72,11 +72,11 @@ function wrapFn (fn) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function wrapNext (req, next) {
|
|
75
|
-
return shimmer.wrapFunction(next, next => function () {
|
|
75
|
+
return shimmer.wrapFunction(next, next => function (...args) {
|
|
76
76
|
nextChannel.publish({ req })
|
|
77
77
|
finishChannel.publish({ req })
|
|
78
78
|
|
|
79
|
-
next.apply(this,
|
|
79
|
+
next.apply(this, args)
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -45,17 +45,17 @@ function createWrapRouterMethod (name, compile) {
|
|
|
45
45
|
function wrapLayerHandle (layer, original) {
|
|
46
46
|
original._name = original._name || layer.name
|
|
47
47
|
|
|
48
|
-
return shimmer.wrapFunction(original, original => function () {
|
|
49
|
-
if (!enterChannel.hasSubscribers) return original.apply(this,
|
|
48
|
+
return shimmer.wrapFunction(original, original => function (...args) {
|
|
49
|
+
if (!enterChannel.hasSubscribers) return original.apply(this, args)
|
|
50
50
|
|
|
51
51
|
const matchers = getLayerMatchers(layer)
|
|
52
|
-
const lastIndex =
|
|
52
|
+
const lastIndex = args.length - 1
|
|
53
53
|
const name = original._name || original.name
|
|
54
|
-
const req =
|
|
55
|
-
const next =
|
|
54
|
+
const req = args[args.length > 3 ? 1 : 0]
|
|
55
|
+
const next = args[lastIndex]
|
|
56
56
|
|
|
57
57
|
if (typeof next === 'function') {
|
|
58
|
-
|
|
58
|
+
args[lastIndex] = wrapNext(req, next)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
let route
|
|
@@ -77,7 +77,7 @@ function createWrapRouterMethod (name, compile) {
|
|
|
77
77
|
enterChannel.publish({ name, req, route, layer })
|
|
78
78
|
|
|
79
79
|
try {
|
|
80
|
-
return original.apply(this,
|
|
80
|
+
return original.apply(this, args)
|
|
81
81
|
} catch (error) {
|
|
82
82
|
errorChannel.publish({ req, error })
|
|
83
83
|
nextChannel.publish({ req })
|
|
@@ -251,8 +251,8 @@ addHook({ name: 'router', versions: ['>=2'] }, Router => {
|
|
|
251
251
|
const wrapRouterMethod = createWrapRouterMethod('router', getCompileToRegexp())
|
|
252
252
|
|
|
253
253
|
const WrappedRouter = shimmer.wrapFunction(Router, function (originalRouter) {
|
|
254
|
-
return function wrappedMethod () {
|
|
255
|
-
const router = originalRouter.apply(this,
|
|
254
|
+
return function wrappedMethod (...args) {
|
|
255
|
+
const router = originalRouter.apply(this, args)
|
|
256
256
|
|
|
257
257
|
shimmer.wrap(router, 'handle', function wrapHandle (originalHandle) {
|
|
258
258
|
return function wrappedHandle (req, res, next) {
|
|
@@ -310,8 +310,8 @@ addHook({
|
|
|
310
310
|
})
|
|
311
311
|
|
|
312
312
|
function wrapParam (original) {
|
|
313
|
-
return function wrappedProcessParams () {
|
|
314
|
-
|
|
313
|
+
return function wrappedProcessParams (...args) {
|
|
314
|
+
args[1] = shimmer.wrapFunction(args[1], (originalFn) => {
|
|
315
315
|
return function wrappedFn (req, res) {
|
|
316
316
|
if (routerParamStartCh.hasSubscribers && Object.keys(req.params).length && !visitedParams.has(req.params)) {
|
|
317
317
|
visitedParams.add(req.params)
|
|
@@ -332,7 +332,7 @@ function wrapParam (original) {
|
|
|
332
332
|
}
|
|
333
333
|
})
|
|
334
334
|
|
|
335
|
-
return original.apply(this,
|
|
335
|
+
return original.apply(this, args)
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
|
|
@@ -8,8 +8,8 @@ const paymentIntentCreateFinishCh = channel('datadog:stripe:paymentIntent:create
|
|
|
8
8
|
const constructEventFinishCh = channel('datadog:stripe:constructEvent:finish')
|
|
9
9
|
|
|
10
10
|
function wrapSessionCreate (create) {
|
|
11
|
-
return function wrappedSessionCreate () {
|
|
12
|
-
const promise = create.apply(this,
|
|
11
|
+
return function wrappedSessionCreate (...args) {
|
|
12
|
+
const promise = create.apply(this, args)
|
|
13
13
|
|
|
14
14
|
if (!checkoutSessionCreateFinishCh.hasSubscribers) return promise
|
|
15
15
|
|
|
@@ -21,8 +21,8 @@ function wrapSessionCreate (create) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function wrapPaymentIntentCreate (create) {
|
|
24
|
-
return function wrappedPaymentIntentCreate () {
|
|
25
|
-
const promise = create.apply(this,
|
|
24
|
+
return function wrappedPaymentIntentCreate (...args) {
|
|
25
|
+
const promise = create.apply(this, args)
|
|
26
26
|
|
|
27
27
|
if (!paymentIntentCreateFinishCh.hasSubscribers) return promise
|
|
28
28
|
|
|
@@ -34,8 +34,8 @@ function wrapPaymentIntentCreate (create) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function wrapConstructEvent (constructEvent) {
|
|
37
|
-
return function wrappedConstructEvent () {
|
|
38
|
-
const result = constructEvent.apply(this,
|
|
37
|
+
return function wrappedConstructEvent (...args) {
|
|
38
|
+
const result = constructEvent.apply(this, args)
|
|
39
39
|
|
|
40
40
|
// no need to check for hasSubscribers,
|
|
41
41
|
// if it's false, the publish function will be noop
|
|
@@ -46,8 +46,8 @@ function wrapConstructEvent (constructEvent) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function wrapConstructEventAsync (constructEventAsync) {
|
|
49
|
-
return function wrappedConstructEventAsync () {
|
|
50
|
-
const promise = constructEventAsync.apply(this,
|
|
49
|
+
return function wrappedConstructEventAsync (...args) {
|
|
50
|
+
const promise = constructEventAsync.apply(this, args)
|
|
51
51
|
|
|
52
52
|
if (!constructEventFinishCh.hasSubscribers) return promise
|
|
53
53
|
|
|
@@ -77,8 +77,8 @@ function instrumentStripeInstance (stripe) {
|
|
|
77
77
|
// returns nothing; without 'new' it delegates to 'new Stripe(...)' and returns
|
|
78
78
|
// that result. We need to instrument whichever object actually got populated
|
|
79
79
|
function wrapLegacyStripe (Stripe) {
|
|
80
|
-
return function wrappedStripe () {
|
|
81
|
-
const result = Stripe.apply(this,
|
|
80
|
+
return function wrappedStripe (...args) {
|
|
81
|
+
const result = Stripe.apply(this, args)
|
|
82
82
|
const stripe = this instanceof Stripe ? this : result
|
|
83
83
|
instrumentStripeInstance(stripe)
|
|
84
84
|
return stripe
|
|
@@ -88,8 +88,8 @@ function wrapLegacyStripe (Stripe) {
|
|
|
88
88
|
// stripe >=22: the constructor is a factory that always returns a fresh Stripe
|
|
89
89
|
// instance regardless of 'new', so we just instrument and forward the result
|
|
90
90
|
function wrapStripe (Stripe) {
|
|
91
|
-
return function wrappedStripe () {
|
|
92
|
-
const stripe = Stripe.apply(this,
|
|
91
|
+
return function wrappedStripe (...args) {
|
|
92
|
+
const stripe = Stripe.apply(this, args)
|
|
93
93
|
instrumentStripeInstance(stripe)
|
|
94
94
|
return stripe
|
|
95
95
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const realSetTimeout = setTimeout
|
|
5
5
|
|
|
6
6
|
const path = require('node:path')
|
|
7
|
+
const { performance } = require('node:perf_hooks')
|
|
7
8
|
|
|
8
9
|
const shimmer = require('../../datadog-shimmer')
|
|
9
10
|
const log = require('../../dd-trace/src/log')
|
|
@@ -12,6 +13,8 @@ const {
|
|
|
12
13
|
VITEST_WORKER_LOGS_PAYLOAD_CODE,
|
|
13
14
|
DYNAMIC_NAME_RE,
|
|
14
15
|
getTestSuitePath,
|
|
16
|
+
getEfdRetryCount,
|
|
17
|
+
getMaxEfdRetryCount,
|
|
15
18
|
recordAttemptToFixExecution,
|
|
16
19
|
collectTestOptimizationSummariesFromTraces,
|
|
17
20
|
logAttemptToFixTestExecution,
|
|
@@ -61,6 +64,10 @@ const disabledTasks = new WeakSet()
|
|
|
61
64
|
const quarantinedTasks = new WeakSet()
|
|
62
65
|
const attemptToFixTasks = new WeakSet()
|
|
63
66
|
const modifiedTasks = new WeakSet()
|
|
67
|
+
const efdDeterminedRetries = new WeakMap()
|
|
68
|
+
const efdSlowAbortedTasks = new WeakSet()
|
|
69
|
+
const efdExecutionStartByTask = new WeakMap()
|
|
70
|
+
const efdSkippedRetryResults = new WeakMap()
|
|
64
71
|
const attemptToFixExecutions = new Map()
|
|
65
72
|
const loggedAttemptToFixTests = new Set()
|
|
66
73
|
let isRetryReasonEfd = false
|
|
@@ -71,6 +78,7 @@ let isFlakyTestRetriesEnabled = false
|
|
|
71
78
|
let flakyTestRetriesCount = 0
|
|
72
79
|
let isEarlyFlakeDetectionEnabled = false
|
|
73
80
|
let earlyFlakeDetectionNumRetries = 0
|
|
81
|
+
let earlyFlakeDetectionSlowTestRetries = {}
|
|
74
82
|
let isEarlyFlakeDetectionFaulty = false
|
|
75
83
|
let isKnownTestsEnabled = false
|
|
76
84
|
let isTestManagementTestsEnabled = false
|
|
@@ -87,6 +95,13 @@ let vitestPool = null
|
|
|
87
95
|
|
|
88
96
|
const BREAKPOINT_HIT_GRACE_PERIOD_MS = 400
|
|
89
97
|
|
|
98
|
+
function getConfiguredEfdRetryCount (slowTestRetries, fallbackRetryCount) {
|
|
99
|
+
if (!slowTestRetries || !Object.keys(slowTestRetries).length) {
|
|
100
|
+
return fallbackRetryCount
|
|
101
|
+
}
|
|
102
|
+
return getMaxEfdRetryCount(slowTestRetries)
|
|
103
|
+
}
|
|
104
|
+
|
|
90
105
|
function getTestCommand () {
|
|
91
106
|
return `vitest ${process.argv.slice(2).join(' ')}`
|
|
92
107
|
}
|
|
@@ -110,6 +125,7 @@ function getProvidedContext () {
|
|
|
110
125
|
_ddIsDiEnabled,
|
|
111
126
|
_ddKnownTests: knownTests,
|
|
112
127
|
_ddEarlyFlakeDetectionNumRetries: numRepeats,
|
|
128
|
+
_ddEarlyFlakeDetectionSlowTestRetries: slowTestRetries,
|
|
113
129
|
_ddIsKnownTestsEnabled: isKnownTestsEnabled,
|
|
114
130
|
_ddIsTestManagementTestsEnabled: isTestManagementTestsEnabled,
|
|
115
131
|
_ddTestManagementAttemptToFixRetries: testManagementAttemptToFixRetries,
|
|
@@ -125,6 +141,7 @@ function getProvidedContext () {
|
|
|
125
141
|
isEarlyFlakeDetectionEnabled: _ddIsEarlyFlakeDetectionEnabled,
|
|
126
142
|
knownTests,
|
|
127
143
|
numRepeats,
|
|
144
|
+
slowTestRetries: slowTestRetries ?? {},
|
|
128
145
|
isKnownTestsEnabled,
|
|
129
146
|
isTestManagementTestsEnabled,
|
|
130
147
|
testManagementAttemptToFixRetries,
|
|
@@ -141,6 +158,7 @@ function getProvidedContext () {
|
|
|
141
158
|
isEarlyFlakeDetectionEnabled: false,
|
|
142
159
|
knownTests: {},
|
|
143
160
|
numRepeats: 0,
|
|
161
|
+
slowTestRetries: {},
|
|
144
162
|
isKnownTestsEnabled: false,
|
|
145
163
|
isTestManagementTestsEnabled: false,
|
|
146
164
|
testManagementAttemptToFixRetries: 0,
|
|
@@ -219,12 +237,8 @@ function getSessionStatus (state) {
|
|
|
219
237
|
|
|
220
238
|
// From https://github.com/vitest-dev/vitest/blob/51c04e2f44d91322b334f8ccbcdb368facc3f8ec/packages/runner/src/run.ts#L243-L250
|
|
221
239
|
function getVitestTestStatus (test, retryCount) {
|
|
222
|
-
if (test.result.state !== 'fail') {
|
|
223
|
-
|
|
224
|
-
return 'pass'
|
|
225
|
-
} else if (test.repeats && (test.retry ?? 0) === retryCount) {
|
|
226
|
-
return 'pass'
|
|
227
|
-
}
|
|
240
|
+
if (test.result.state !== 'fail' && (!test.repeats || (test.retry ?? 0) === retryCount)) {
|
|
241
|
+
return 'pass'
|
|
228
242
|
}
|
|
229
243
|
return 'fail'
|
|
230
244
|
}
|
|
@@ -291,8 +305,8 @@ function recordFinalAttemptToFixExecution (task, status, providedContext) {
|
|
|
291
305
|
* @returns {Function}
|
|
292
306
|
*/
|
|
293
307
|
function wrapTestScopedFn (task, fn) {
|
|
294
|
-
return shimmer.wrapFunction(fn, fn => function () {
|
|
295
|
-
return testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this,
|
|
308
|
+
return shimmer.wrapFunction(fn, fn => function (...args) {
|
|
309
|
+
return testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, args))
|
|
296
310
|
})
|
|
297
311
|
}
|
|
298
312
|
|
|
@@ -331,6 +345,7 @@ function getSortWrapper (sort, frameworkVersion) {
|
|
|
331
345
|
flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
332
346
|
isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
333
347
|
earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
348
|
+
earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
334
349
|
isDiEnabled = libraryConfig.isDiEnabled
|
|
335
350
|
isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
336
351
|
isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
@@ -389,7 +404,9 @@ function getSortWrapper (sort, frameworkVersion) {
|
|
|
389
404
|
workspaceProject._provided._ddIsKnownTestsEnabled = isKnownTestsEnabled
|
|
390
405
|
workspaceProject._provided._ddKnownTests = knownTests
|
|
391
406
|
workspaceProject._provided._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
392
|
-
workspaceProject._provided._ddEarlyFlakeDetectionNumRetries =
|
|
407
|
+
workspaceProject._provided._ddEarlyFlakeDetectionNumRetries =
|
|
408
|
+
getConfiguredEfdRetryCount(earlyFlakeDetectionSlowTestRetries, earlyFlakeDetectionNumRetries)
|
|
409
|
+
workspaceProject._provided._ddEarlyFlakeDetectionSlowTestRetries = earlyFlakeDetectionSlowTestRetries
|
|
393
410
|
} catch {
|
|
394
411
|
log.warn('Could not send known tests to workers so Early Flake Detection will not work.')
|
|
395
412
|
}
|
|
@@ -527,13 +544,13 @@ function getFinishWrapper (exitOrClose) {
|
|
|
527
544
|
|
|
528
545
|
function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
529
546
|
return function (oldCliOrStartVitest) {
|
|
530
|
-
return function () {
|
|
547
|
+
return function (...args) {
|
|
531
548
|
if (!testSessionStartCh.hasSubscribers || isSessionStarted) {
|
|
532
|
-
return oldCliOrStartVitest.apply(this,
|
|
549
|
+
return oldCliOrStartVitest.apply(this, args)
|
|
533
550
|
}
|
|
534
551
|
isSessionStarted = true
|
|
535
552
|
testSessionStartCh.publish({ command: getTestCommand(), frameworkVersion })
|
|
536
|
-
return oldCliOrStartVitest.apply(this,
|
|
553
|
+
return oldCliOrStartVitest.apply(this, args)
|
|
537
554
|
}
|
|
538
555
|
}
|
|
539
556
|
}
|
|
@@ -644,11 +661,11 @@ function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
|
644
661
|
const forksPoolWorker = getForksPoolWorkerExport(cliApiPackage)
|
|
645
662
|
if (forksPoolWorker) {
|
|
646
663
|
// function is async
|
|
647
|
-
shimmer.wrap(forksPoolWorker.value.prototype, 'start', start => function () {
|
|
664
|
+
shimmer.wrap(forksPoolWorker.value.prototype, 'start', start => function (...args) {
|
|
648
665
|
vitestPool = 'child_process'
|
|
649
666
|
this.env.DD_VITEST_WORKER = '1'
|
|
650
667
|
|
|
651
|
-
return start.apply(this,
|
|
668
|
+
return start.apply(this, args)
|
|
652
669
|
})
|
|
653
670
|
shimmer.wrap(forksPoolWorker.value.prototype, 'on', getWrappedOn)
|
|
654
671
|
}
|
|
@@ -656,10 +673,10 @@ function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
|
656
673
|
const threadsPoolWorker = getThreadsPoolWorkerExport(cliApiPackage)
|
|
657
674
|
if (threadsPoolWorker) {
|
|
658
675
|
// function is async
|
|
659
|
-
shimmer.wrap(threadsPoolWorker.value.prototype, 'start', start => function () {
|
|
676
|
+
shimmer.wrap(threadsPoolWorker.value.prototype, 'start', start => function (...args) {
|
|
660
677
|
vitestPool = 'worker_threads'
|
|
661
678
|
this.env.DD_VITEST_WORKER = '1'
|
|
662
|
-
return start.apply(this,
|
|
679
|
+
return start.apply(this, args)
|
|
663
680
|
})
|
|
664
681
|
shimmer.wrap(threadsPoolWorker.value.prototype, 'on', getWrappedOn)
|
|
665
682
|
}
|
|
@@ -721,7 +738,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
721
738
|
onDone: (isImpacted) => {
|
|
722
739
|
if (isImpacted) {
|
|
723
740
|
if (isEarlyFlakeDetectionEnabled) {
|
|
724
|
-
isRetryReasonEfd =
|
|
741
|
+
isRetryReasonEfd = true
|
|
725
742
|
task.repeats = numRepeats
|
|
726
743
|
}
|
|
727
744
|
modifiedTasks.add(task)
|
|
@@ -739,7 +756,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
739
756
|
onDone: (isNew) => {
|
|
740
757
|
if (isNew && !attemptToFixTasks.has(task)) {
|
|
741
758
|
if (isEarlyFlakeDetectionEnabled && !modifiedTasks.has(task)) {
|
|
742
|
-
isRetryReasonEfd =
|
|
759
|
+
isRetryReasonEfd = true
|
|
743
760
|
task.repeats = numRepeats
|
|
744
761
|
}
|
|
745
762
|
newTasks.add(task)
|
|
@@ -811,6 +828,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
811
828
|
isTestManagementTestsEnabled,
|
|
812
829
|
testManagementTests,
|
|
813
830
|
isFlakyTestRetriesEnabled,
|
|
831
|
+
slowTestRetries,
|
|
814
832
|
} = getProvidedContext()
|
|
815
833
|
|
|
816
834
|
if (isKnownTestsEnabled) {
|
|
@@ -832,6 +850,39 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
832
850
|
}
|
|
833
851
|
|
|
834
852
|
const { retry: numAttempt, repeats: numRepetition } = retryInfo
|
|
853
|
+
const isEfdManagedTask = isEarlyFlakeDetectionEnabled && taskToStatuses.has(task) && !attemptToFixTasks.has(task)
|
|
854
|
+
|
|
855
|
+
if (isEfdManagedTask && numRepetition > 0 && !efdDeterminedRetries.has(task)) {
|
|
856
|
+
const previousExecutionStart = efdExecutionStartByTask.get(task)
|
|
857
|
+
const duration = previousExecutionStart === undefined
|
|
858
|
+
? task.result?.duration ?? 0
|
|
859
|
+
: performance.now() - previousExecutionStart
|
|
860
|
+
const retryCount = getEfdRetryCount(duration, slowTestRetries)
|
|
861
|
+
efdDeterminedRetries.set(task, retryCount)
|
|
862
|
+
task.repeats = retryCount
|
|
863
|
+
if (retryCount === 0) {
|
|
864
|
+
efdSlowAbortedTasks.add(task)
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const efdRetryCount = efdDeterminedRetries.get(task)
|
|
869
|
+
if (isEfdManagedTask && efdRetryCount !== undefined && numRepetition > efdRetryCount) {
|
|
870
|
+
if (task.result) {
|
|
871
|
+
efdSkippedRetryResults.set(task, {
|
|
872
|
+
...task.result,
|
|
873
|
+
errors: task.result.errors?.slice(),
|
|
874
|
+
})
|
|
875
|
+
}
|
|
876
|
+
if (vitestSetFn) {
|
|
877
|
+
const noop = function () {}
|
|
878
|
+
noop.__ddTraceWrapped = true
|
|
879
|
+
vitestSetFn(task, noop)
|
|
880
|
+
}
|
|
881
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
882
|
+
}
|
|
883
|
+
if (isEfdManagedTask) {
|
|
884
|
+
efdExecutionStartByTask.set(task, performance.now())
|
|
885
|
+
}
|
|
835
886
|
|
|
836
887
|
// We finish the previous test here because we know it has failed already
|
|
837
888
|
if (numAttempt > 0) {
|
|
@@ -963,8 +1014,8 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
963
1014
|
for (let i = 0; i < hookArray.length; i++) {
|
|
964
1015
|
const currentFn = hookArray[i]
|
|
965
1016
|
const originalFn = originalHookFns.get(currentFn) || currentFn
|
|
966
|
-
const wrappedFn = shimmer.wrapFunction(originalFn, fn => function () {
|
|
967
|
-
const result = testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this,
|
|
1017
|
+
const wrappedFn = shimmer.wrapFunction(originalFn, fn => function (...args) {
|
|
1018
|
+
const result = testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, args))
|
|
968
1019
|
|
|
969
1020
|
if (hookType === 'beforeEach') {
|
|
970
1021
|
return wrapBeforeEachCleanupResult(task, result)
|
|
@@ -985,23 +1036,50 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
985
1036
|
|
|
986
1037
|
// test finish (only passed tests)
|
|
987
1038
|
shimmer.wrap(VitestTestRunner.prototype, 'onAfterTryTask', onAfterTryTask =>
|
|
988
|
-
async function (task,
|
|
1039
|
+
async function (task, retryInfo) {
|
|
989
1040
|
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
990
1041
|
return onAfterTryTask.apply(this, arguments)
|
|
991
1042
|
}
|
|
992
1043
|
const result = await onAfterTryTask.apply(this, arguments)
|
|
993
1044
|
|
|
994
|
-
const {
|
|
1045
|
+
const {
|
|
1046
|
+
isEarlyFlakeDetectionEnabled,
|
|
1047
|
+
testManagementAttemptToFixRetries,
|
|
1048
|
+
slowTestRetries,
|
|
1049
|
+
} = getProvidedContext()
|
|
995
1050
|
|
|
996
|
-
const status = getVitestTestStatus(task,
|
|
1051
|
+
const status = getVitestTestStatus(task, retryInfo.retry)
|
|
997
1052
|
const ctx = taskToCtx.get(task)
|
|
998
1053
|
|
|
999
1054
|
const { isDiEnabled } = getProvidedContext()
|
|
1000
1055
|
|
|
1001
|
-
if (
|
|
1056
|
+
if (efdSkippedRetryResults.has(task)) {
|
|
1057
|
+
task.result = efdSkippedRetryResults.get(task)
|
|
1058
|
+
efdSkippedRetryResults.delete(task)
|
|
1059
|
+
return result
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
if (isDiEnabled && retryInfo.retry > 1) {
|
|
1002
1063
|
await waitForHitProbe()
|
|
1003
1064
|
}
|
|
1004
1065
|
|
|
1066
|
+
if (
|
|
1067
|
+
isEarlyFlakeDetectionEnabled &&
|
|
1068
|
+
(retryInfo.repeats ?? 0) === 0 &&
|
|
1069
|
+
taskToStatuses.has(task) &&
|
|
1070
|
+
!attemptToFixTasks.has(task) &&
|
|
1071
|
+
!efdDeterminedRetries.has(task)
|
|
1072
|
+
) {
|
|
1073
|
+
const executionStart = efdExecutionStartByTask.get(task)
|
|
1074
|
+
const duration = executionStart === undefined ? task.result?.duration ?? 0 : performance.now() - executionStart
|
|
1075
|
+
const retryCount = getEfdRetryCount(duration, slowTestRetries)
|
|
1076
|
+
efdDeterminedRetries.set(task, retryCount)
|
|
1077
|
+
task.repeats = retryCount
|
|
1078
|
+
if (retryCount === 0) {
|
|
1079
|
+
efdSlowAbortedTasks.add(task)
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1005
1083
|
let attemptToFixPassed = false
|
|
1006
1084
|
let attemptToFixFailed = false
|
|
1007
1085
|
if (attemptToFixTasks.has(task)) {
|
|
@@ -1234,6 +1312,7 @@ addHook({
|
|
|
1234
1312
|
testPassCh.publish({
|
|
1235
1313
|
task,
|
|
1236
1314
|
finalStatus: isSkippedByTestManagement ? 'skip' : 'pass',
|
|
1315
|
+
earlyFlakeAbortReason: efdSlowAbortedTasks.has(task) ? 'slow' : undefined,
|
|
1237
1316
|
...testCtx.currentStore,
|
|
1238
1317
|
})
|
|
1239
1318
|
}
|
|
@@ -1255,8 +1334,9 @@ addHook({
|
|
|
1255
1334
|
providedContext.isEarlyFlakeDetectionEnabled && (newTasks.has(task) || modifiedTasks.has(task))
|
|
1256
1335
|
if (isEfdRetry) {
|
|
1257
1336
|
const statuses = taskToStatuses.get(task)
|
|
1258
|
-
|
|
1259
|
-
|
|
1337
|
+
const efdRetryCount = efdDeterminedRetries.get(task) ?? providedContext.numRepeats
|
|
1338
|
+
// statuses only includes repetitions (not the initial run), so we check against retry count (not +1)
|
|
1339
|
+
if (efdRetryCount > 0 && statuses && statuses.length === efdRetryCount &&
|
|
1260
1340
|
statuses.every(status => status === 'fail')) {
|
|
1261
1341
|
hasFailedAllRetries = true
|
|
1262
1342
|
}
|
|
@@ -1297,6 +1377,7 @@ addHook({
|
|
|
1297
1377
|
hasFailedAllRetries,
|
|
1298
1378
|
attemptToFixFailed,
|
|
1299
1379
|
finalStatus,
|
|
1380
|
+
earlyFlakeAbortReason: efdSlowAbortedTasks.has(task) ? 'slow' : undefined,
|
|
1300
1381
|
...testCtx.currentStore,
|
|
1301
1382
|
})
|
|
1302
1383
|
}
|
|
@@ -33,8 +33,8 @@ addHook({ name: 'winston', file: 'lib/winston/logger.js', versions: ['>=3'] }, L
|
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
shimmer.wrap(Logger.prototype, 'configure', configure => function () {
|
|
37
|
-
const configureResponse = configure.apply(this,
|
|
36
|
+
shimmer.wrap(Logger.prototype, 'configure', configure => function (...args) {
|
|
37
|
+
const configureResponse = configure.apply(this, args)
|
|
38
38
|
// After the original `configure`, because it resets transports
|
|
39
39
|
if (addTransport.hasSubscribers) {
|
|
40
40
|
addTransport.publish(this)
|
|
@@ -55,8 +55,8 @@ addHook({ name: 'winston', file: 'lib/winston/logger.js', versions: ['1', '2'] }
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
function wrapMethod (method, logCh) {
|
|
58
|
-
return function methodWithTrace () {
|
|
59
|
-
const result = method.apply(this,
|
|
58
|
+
return function methodWithTrace (...args) {
|
|
59
|
+
const result = method.apply(this, args)
|
|
60
60
|
|
|
61
61
|
if (logCh.hasSubscribers) {
|
|
62
62
|
for (const name in this.transports) {
|
|
@@ -62,24 +62,24 @@ const setSocketCh = channel('tracing:ws:server:connect:setSocket')
|
|
|
62
62
|
let kWebSocketSymbol
|
|
63
63
|
|
|
64
64
|
function wrapHandleUpgrade (handleUpgrade) {
|
|
65
|
-
return function () {
|
|
66
|
-
const [req, socket, , cb] =
|
|
65
|
+
return function (...args) {
|
|
66
|
+
const [req, socket, , cb] = args
|
|
67
67
|
if (!serverCh.start.hasSubscribers || typeof cb !== 'function') {
|
|
68
|
-
return handleUpgrade.apply(this,
|
|
68
|
+
return handleUpgrade.apply(this, args)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const ctx = { req, socket }
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
args[3] = function (...args) {
|
|
74
74
|
return serverCh.asyncStart.runStores(ctx, () => {
|
|
75
75
|
try {
|
|
76
|
-
return cb.apply(this,
|
|
76
|
+
return cb.apply(this, args)
|
|
77
77
|
} finally {
|
|
78
78
|
serverCh.asyncEnd.publish(ctx)
|
|
79
79
|
}
|
|
80
|
-
}, this, ...
|
|
80
|
+
}, this, ...args)
|
|
81
81
|
}
|
|
82
|
-
return serverCh.traceSync(handleUpgrade, ctx, this, ...
|
|
82
|
+
return serverCh.traceSync(handleUpgrade, ctx, this, ...args)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|