dd-trace 6.7.0 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ci/test-optimization-validation/command-output-policy.js +5 -5
- package/ci/test-optimization-validation/framework-adapters/playwright.js +5 -5
- package/ci/test-optimization-validation/generated-files.js +9 -9
- package/ci/test-optimization-validation/generated-test-contract.js +1 -3
- package/ci/test-optimization-validation/manifest-scaffold.js +1 -2
- package/ci/test-optimization-validation/offline-output.js +6 -6
- package/ci/test-optimization-validation/runner-command.js +1 -1
- package/ci/test-optimization-validation/safe-files.js +4 -4
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +1 -1
- package/ci/test-optimization-validation/scenarios/test-management.js +2 -2
- package/ci/vitest-no-worker-init-setup.mjs +348 -51
- package/index.d.ts +77 -13
- package/package.json +9 -3
- package/packages/datadog-core/src/utils/src/kebabcase.js +8 -2
- package/packages/datadog-esbuild/index.js +4 -2
- package/packages/datadog-esbuild/src/utils.js +1 -1
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +4 -4
- package/packages/datadog-instrumentations/src/cucumber.js +9 -6
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +57 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +50 -18
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +39 -0
- package/packages/datadog-instrumentations/src/http/client.js +1 -3
- package/packages/datadog-instrumentations/src/jest.js +8 -14
- package/packages/datadog-instrumentations/src/mocha/common.js +1 -3
- package/packages/datadog-instrumentations/src/mocha/main.js +2 -42
- package/packages/datadog-instrumentations/src/mocha/utils.js +68 -2
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +19 -0
- package/packages/datadog-instrumentations/src/mocha/worker.js +446 -42
- package/packages/datadog-instrumentations/src/moleculer/client.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +3 -2
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +525 -56
- package/packages/datadog-instrumentations/src/vitest-main.js +90 -10
- package/packages/datadog-instrumentations/src/webdriverio.js +914 -0
- package/packages/datadog-plugin-aerospike/src/index.js +1 -3
- package/packages/datadog-plugin-amqplib/src/client.js +1 -1
- package/packages/datadog-plugin-amqplib/src/producer.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +2 -2
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +1 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -3
- package/packages/datadog-plugin-bullmq/src/producer.js +3 -3
- package/packages/datadog-plugin-child_process/src/index.js +3 -3
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +5 -8
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +1 -1
- package/packages/datadog-plugin-fastify/src/tracing.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +0 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +14 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -10
- package/packages/datadog-plugin-graphql/src/execute.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -1
- package/packages/datadog-plugin-jest/src/index.js +2 -3
- package/packages/datadog-plugin-jest/src/util.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- package/packages/datadog-plugin-mocha/src/index.js +25 -6
- package/packages/datadog-plugin-prisma/src/index.js +5 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +16 -13
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +2 -1
- package/packages/datadog-plugin-vitest/src/index.js +84 -11
- package/packages/datadog-webpack/index.js +2 -2
- package/packages/dd-trace/src/appsec/downstream_requests.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/track_event.js +1 -1
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +7 -6
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +4 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/webdriverio.js +26 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -1
- package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -3
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +1 -1
- package/packages/dd-trace/src/config/defaults.js +14 -6
- package/packages/dd-trace/src/config/generated-config-types.d.ts +2 -2
- package/packages/dd-trace/src/config/index.js +15 -0
- package/packages/dd-trace/src/config/parsers.js +19 -1
- package/packages/dd-trace/src/config/supported-configurations.json +5 -6
- package/packages/dd-trace/src/datastreams/encoding.js +3 -4
- package/packages/dd-trace/src/debugger/devtools_client/log.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +1 -4
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +16 -2
- package/packages/dd-trace/src/encode/tags-processors.js +2 -2
- package/packages/dd-trace/src/exporters/common/url.js +3 -5
- package/packages/dd-trace/src/exporters/electron/index.js +4 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +2 -2
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -1
- package/packages/dd-trace/src/llmobs/experiments/client.js +4 -2
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +66 -14
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +289 -95
- package/packages/dd-trace/src/llmobs/experiments/index.js +51 -12
- package/packages/dd-trace/src/llmobs/experiments/noop.js +95 -10
- package/packages/dd-trace/src/llmobs/experiments/result.js +13 -2
- package/packages/dd-trace/src/llmobs/experiments/util.js +218 -0
- package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +4 -11
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -7
- package/packages/dd-trace/src/llmobs/tagger.js +1 -2
- package/packages/dd-trace/src/llmobs/writers/spans.js +12 -6
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -1
- package/packages/dd-trace/src/opentracing/span.js +1 -1
- package/packages/dd-trace/src/opentracing/span_context.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +105 -20
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -0
- package/packages/dd-trace/src/plugins/util/ci.js +7 -6
- package/packages/dd-trace/src/plugins/util/git.js +1 -1
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +2 -2
- package/packages/dd-trace/src/plugins/util/tags.js +2 -0
- package/packages/dd-trace/src/plugins/util/test.js +38 -12
- package/packages/dd-trace/src/plugins/util/url.js +5 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +1 -1
- package/packages/dd-trace/src/priority_sampler.js +6 -3
- package/packages/dd-trace/src/profiling/profilers/poisson.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/shared.js +2 -2
- package/packages/dd-trace/src/ritm.js +5 -20
- package/packages/dd-trace/src/startup-log.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +3 -1
- package/packages/dd-trace/src/util.js +16 -0
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +12 -12
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/source-map/index.js +1 -1
|
@@ -53,6 +53,7 @@ const {
|
|
|
53
53
|
newTestsWithDynamicNames,
|
|
54
54
|
attemptToFixExecutions,
|
|
55
55
|
loggedAttemptToFixTests,
|
|
56
|
+
adjustRunnerFailuresForTestOptimization,
|
|
56
57
|
} = require('./utils')
|
|
57
58
|
|
|
58
59
|
require('./common')
|
|
@@ -114,17 +115,6 @@ function warnDeprecatedMochaVersion (frameworkVersion) {
|
|
|
114
115
|
)
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
// Tests from workers do not come with `isFailed` method
|
|
118
|
-
function isTestFailed (test) {
|
|
119
|
-
if (test.isFailed) {
|
|
120
|
-
return test.isFailed()
|
|
121
|
-
}
|
|
122
|
-
if (test.isPending) {
|
|
123
|
-
return !test.isPending() && test.state === 'failed'
|
|
124
|
-
}
|
|
125
|
-
return false
|
|
126
|
-
}
|
|
127
|
-
|
|
128
118
|
function getRootSuiteStatus (rootTests) {
|
|
129
119
|
let status = 'pass'
|
|
130
120
|
if (rootTests.every(t => t.isPending())) {
|
|
@@ -309,37 +299,7 @@ function getOnEndHandler (isParallel, onDone) {
|
|
|
309
299
|
status = 'fail'
|
|
310
300
|
}
|
|
311
301
|
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* If Early Flake Detection (EFD) is enabled the logic is as follows:
|
|
315
|
-
* - If all attempts for a test are failing, the test has failed and we will let the test process fail.
|
|
316
|
-
* - If just a single attempt passes, we will prevent the test process from failing.
|
|
317
|
-
* The rationale behind is the following: you may still be able to block your CI pipeline by gating
|
|
318
|
-
* on flakiness (the test will be considered flaky), but you may choose to unblock the pipeline too.
|
|
319
|
-
*/
|
|
320
|
-
for (const tests of Object.values(efdTests)) {
|
|
321
|
-
const failingEfdTests = tests.filter(test => isTestFailed(test))
|
|
322
|
-
const areAllEfdTestsFailing = failingEfdTests.length === tests.length
|
|
323
|
-
const nonQuarantinedFailingEfdTests = failingEfdTests.filter(test => !testsQuarantined.has(test))
|
|
324
|
-
if (nonQuarantinedFailingEfdTests.length && !areAllEfdTestsFailing) {
|
|
325
|
-
this.stats.failures -= nonQuarantinedFailingEfdTests.length
|
|
326
|
-
this.failures -= nonQuarantinedFailingEfdTests.length
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// We subtract the errors from quarantined tests from the total number of failures.
|
|
332
|
-
// Attempt-to-fix tests ignore quarantine/disabled suppression and keep their framework result.
|
|
333
|
-
if (config.isTestManagementTestsEnabled) {
|
|
334
|
-
let numFailedQuarantinedTests = 0
|
|
335
|
-
for (const test of testsQuarantined) {
|
|
336
|
-
if (isTestFailed(test)) {
|
|
337
|
-
numFailedQuarantinedTests++
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
this.stats.failures -= numFailedQuarantinedTests
|
|
341
|
-
this.failures -= numFailedQuarantinedTests
|
|
342
|
-
}
|
|
302
|
+
adjustRunnerFailuresForTestOptimization(this, config)
|
|
343
303
|
|
|
344
304
|
// Recompute status after EFD and quarantine adjustments have reduced failure counts
|
|
345
305
|
if (status === 'fail') {
|
|
@@ -48,6 +48,59 @@ function waitForHitProbe () {
|
|
|
48
48
|
}
|
|
49
49
|
const loggedAttemptToFixTests = new Set()
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Checks whether a Mocha test failed, including serialized tests from parallel workers.
|
|
53
|
+
*
|
|
54
|
+
* @param {object} test
|
|
55
|
+
* @returns {boolean}
|
|
56
|
+
*/
|
|
57
|
+
function isTestFailed (test) {
|
|
58
|
+
if (test.isFailed) {
|
|
59
|
+
return test.isFailed()
|
|
60
|
+
}
|
|
61
|
+
if (test.isPending) {
|
|
62
|
+
return !test.isPending() && test.state === 'failed'
|
|
63
|
+
}
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Applies EFD and quarantine failure suppression to a completed Mocha runner.
|
|
69
|
+
*
|
|
70
|
+
* @param {object} runner
|
|
71
|
+
* @param {object} config
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
function adjustRunnerFailuresForTestOptimization (runner, config) {
|
|
75
|
+
if (config.isEarlyFlakeDetectionEnabled) {
|
|
76
|
+
for (const tests of Object.values(efdTests)) {
|
|
77
|
+
const executedEfdTests = tests.filter(test => !test.isPending())
|
|
78
|
+
const failingEfdTests = tests.filter(test => isTestFailed(test))
|
|
79
|
+
const areAllEfdTestsFailing = failingEfdTests.length === executedEfdTests.length
|
|
80
|
+
const nonQuarantinedFailingEfdTests = failingEfdTests.filter(test => !testsQuarantined.has(test))
|
|
81
|
+
if (nonQuarantinedFailingEfdTests.length && !areAllEfdTestsFailing) {
|
|
82
|
+
if (runner.stats) {
|
|
83
|
+
runner.stats.failures -= nonQuarantinedFailingEfdTests.length
|
|
84
|
+
}
|
|
85
|
+
runner.failures -= nonQuarantinedFailingEfdTests.length
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (config.isTestManagementTestsEnabled) {
|
|
91
|
+
let numFailedQuarantinedTests = 0
|
|
92
|
+
for (const test of testsQuarantined) {
|
|
93
|
+
if (isTestFailed(test)) {
|
|
94
|
+
numFailedQuarantinedTests++
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (runner.stats) {
|
|
98
|
+
runner.stats.failures -= numFailedQuarantinedTests
|
|
99
|
+
}
|
|
100
|
+
runner.failures -= numFailedQuarantinedTests
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
51
104
|
function getAfterEachHooks (testOrHook) {
|
|
52
105
|
const hooks = []
|
|
53
106
|
|
|
@@ -165,6 +218,7 @@ function isDatadogManagedRetryTest (test, config) {
|
|
|
165
218
|
* Checks whether a runnable belongs to an Early Flake Detection execution.
|
|
166
219
|
* @param {{
|
|
167
220
|
* _ddIsAttemptToFix?: boolean,
|
|
221
|
+
* _ddIsDisabled?: boolean,
|
|
168
222
|
* _ddIsEfdRetry?: boolean,
|
|
169
223
|
* _ddIsModified?: boolean,
|
|
170
224
|
* _ddIsNew?: boolean
|
|
@@ -174,6 +228,7 @@ function isDatadogManagedRetryTest (test, config) {
|
|
|
174
228
|
*/
|
|
175
229
|
function isEarlyFlakeDetectionTest (test, config) {
|
|
176
230
|
return !test._ddIsAttemptToFix &&
|
|
231
|
+
!test._ddIsDisabled &&
|
|
177
232
|
config.isEarlyFlakeDetectionEnabled &&
|
|
178
233
|
(test._ddIsEfdRetry || test._ddIsNew || test._ddIsModified)
|
|
179
234
|
}
|
|
@@ -949,7 +1004,12 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
949
1004
|
onDone: (isModified) => {
|
|
950
1005
|
if (isModified) {
|
|
951
1006
|
test._ddIsModified = true
|
|
952
|
-
if (
|
|
1007
|
+
if (
|
|
1008
|
+
!test.isPending() &&
|
|
1009
|
+
!test._ddIsDisabled &&
|
|
1010
|
+
!test._ddIsAttemptToFix &&
|
|
1011
|
+
config.isEarlyFlakeDetectionEnabled
|
|
1012
|
+
) {
|
|
953
1013
|
retryTest(
|
|
954
1014
|
test,
|
|
955
1015
|
getConfiguredEfdRetryCount(config),
|
|
@@ -968,7 +1028,12 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
968
1028
|
suite.tests.forEach((test) => {
|
|
969
1029
|
if (!test.isPending() && isNewTest(test, config.knownTests)) {
|
|
970
1030
|
test._ddIsNew = true
|
|
971
|
-
if (
|
|
1031
|
+
if (
|
|
1032
|
+
config.isEarlyFlakeDetectionEnabled &&
|
|
1033
|
+
!test._ddIsDisabled &&
|
|
1034
|
+
!test._ddIsAttemptToFix &&
|
|
1035
|
+
!test._ddIsModified
|
|
1036
|
+
) {
|
|
972
1037
|
retryTest(
|
|
973
1038
|
test,
|
|
974
1039
|
getConfiguredEfdRetryCount(config),
|
|
@@ -1015,4 +1080,5 @@ module.exports = {
|
|
|
1015
1080
|
testsStatuses,
|
|
1016
1081
|
attemptToFixExecutions,
|
|
1017
1082
|
loggedAttemptToFixTests,
|
|
1083
|
+
adjustRunnerFailuresForTestOptimization,
|
|
1018
1084
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
createWebdriverioWorkerMessage,
|
|
5
|
+
WEBDRIVERIO_WORKER_ENV,
|
|
6
|
+
WEBDRIVERIO_WORKER_EVENT,
|
|
7
|
+
WEBDRIVERIO_WORKER_ORIGIN,
|
|
8
|
+
} = require('../../../dd-trace/src/ci-visibility/exporters/test-worker/webdriverio')
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
CONFIGURATION_REQUEST: 'dd:test-optimization:webdriverio:configuration:request',
|
|
12
|
+
CONFIGURATION_RESPONSE: 'dd:test-optimization:webdriverio:configuration:response',
|
|
13
|
+
createWebdriverioWorkerMessage,
|
|
14
|
+
SUITE_FINISH: 'dd:test-optimization:webdriverio:test-suite:finish',
|
|
15
|
+
WORKER_READY: 'dd:test-optimization:webdriverio:worker:ready',
|
|
16
|
+
WEBDRIVERIO_WORKER_ENV,
|
|
17
|
+
WEBDRIVERIO_WORKER_EVENT,
|
|
18
|
+
WEBDRIVERIO_WORKER_ORIGIN,
|
|
19
|
+
}
|