dd-trace 6.22.0 → 6.24.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 +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/diagnose.js +4 -4
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/test-optimization-validation/approval-artifacts.js +2 -2
- package/ci/test-optimization-validation/approval.js +2 -2
- package/ci/test-optimization-validation/artifact-id.js +2 -3
- package/ci/test-optimization-validation/ci-package-scripts.js +1 -1
- package/ci/test-optimization-validation/cli.js +1 -1
- package/ci/test-optimization-validation/command-runner.js +2 -3
- package/ci/test-optimization-validation/executable.js +1 -1
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
- package/ci/test-optimization-validation/literal-environment.js +2 -2
- package/ci/test-optimization-validation/manifest-scaffold.js +1 -1
- package/ci/test-optimization-validation/offline-fixtures.js +1 -1
- package/ci/test-optimization-validation/redaction.js +3 -3
- package/ci/test-optimization-validation/runner-contract.js +10 -10
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -1
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -5
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -0
- package/index.d.ts +35 -5
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +23 -20
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +70 -7
- package/packages/datadog-instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/cucumber.js +64 -21
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/graphql.js +9 -3
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +27 -8
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +332 -137
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +92 -13
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/nova-sonic/session.js +25 -16
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -26
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/stripe.js +23 -12
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -47
- package/packages/datadog-instrumentations/src/vitest-main.js +33 -3
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +5 -2
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +16 -6
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +277 -44
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -437
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
- package/packages/dd-trace/src/aiguard/sdk.js +0 -11
- package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
- package/packages/dd-trace/src/appsec/stack_trace.js +3 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
- package/packages/dd-trace/src/config/defaults.js +4 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
- package/packages/dd-trace/src/config/index.js +140 -39
- package/packages/dd-trace/src/config/parsers.js +9 -1
- package/packages/dd-trace/src/config/supported-configurations.json +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +25 -6
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +4 -4
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +4 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- 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/genai/util.js +8 -4
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +9 -1
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +17 -5
- package/packages/dd-trace/src/llmobs/span_processor.js +222 -12
- package/packages/dd-trace/src/llmobs/tagger.js +21 -8
- package/packages/dd-trace/src/llmobs/util.js +10 -4
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/writer.js +7 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
- package/packages/dd-trace/src/openfeature/index.js +6 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +18 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/tracer.js +9 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
- package/packages/dd-trace/src/plugin_manager.js +1 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/plugins/tracing.js +1 -2
- package/packages/dd-trace/src/plugins/util/git.js +102 -40
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
- package/packages/dd-trace/src/plugins/util/test.js +28 -6
- package/packages/dd-trace/src/plugins/util/web.js +106 -20
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/proxy.js +15 -4
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +21 -9
- package/packages/dd-trace/src/span_stats.js +32 -3
- package/packages/dd-trace/src/startup-log.js +2 -1
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/util.js +9 -5
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -5,6 +5,8 @@ const realSetTimeout = setTimeout
|
|
|
5
5
|
const realClearTimeout = clearTimeout
|
|
6
6
|
|
|
7
7
|
const { performance } = require('node:perf_hooks')
|
|
8
|
+
|
|
9
|
+
const { getTestAnnotations } = require('../../dd-trace/src/ci-visibility/test-annotations')
|
|
8
10
|
const satisfies = require('../../../vendor/dist/semifies')
|
|
9
11
|
|
|
10
12
|
const shimmer = require('../../datadog-shimmer')
|
|
@@ -188,7 +190,7 @@ function isAutomaticFailureVideoAttachment (attachment) {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
function isValidKnownTests (receivedKnownTests) {
|
|
191
|
-
return !!receivedKnownTests
|
|
193
|
+
return !!receivedKnownTests?.playwright
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
function getTestFullyQualifiedName (test) {
|
|
@@ -279,10 +281,12 @@ function shouldRunEarlyFlakeDetection () {
|
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
function isTestEfdManaged (test) {
|
|
282
|
-
return
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
return !test._ddIsAutomaticRetryExcluded && !getTestAnnotations(test.fn).noAutoRetry && (
|
|
285
|
+
!!test._ddIsEfdManagedTest || (
|
|
286
|
+
(test._ddIsNew || test._ddIsModified) &&
|
|
287
|
+
!test._ddIsAttemptToFix &&
|
|
288
|
+
shouldRunEarlyFlakeDetection()
|
|
289
|
+
)
|
|
286
290
|
)
|
|
287
291
|
}
|
|
288
292
|
|
|
@@ -440,13 +444,31 @@ function shouldSkipEfdRetryTest (test) {
|
|
|
440
444
|
return shouldSkipEfdRetry(test._ddEfdRetryIndex, retryCount)
|
|
441
445
|
}
|
|
442
446
|
|
|
447
|
+
/** @param {object} test */
|
|
448
|
+
function getExclusionTags (test) {
|
|
449
|
+
const { mustFail, noAutoRetry } = getTestAnnotations(test.fn)
|
|
450
|
+
const properties = test._ddAssignedProperties
|
|
451
|
+
const tags = {}
|
|
452
|
+
if (mustFail) tags['test.test_management.prevent_failure_suppression'] = 'true'
|
|
453
|
+
if (noAutoRetry) tags['test.test_management.no_auto_retry'] = 'true'
|
|
454
|
+
if (properties?.attempt_to_fix) tags['test.test_management.is_attempt_to_fix'] = 'true'
|
|
455
|
+
if (properties?.disabled) tags['test.test_management.is_test_disabled'] = 'true'
|
|
456
|
+
if (properties?.quarantined) tags['test.test_management.is_quarantined'] = 'true'
|
|
457
|
+
return tags
|
|
458
|
+
}
|
|
459
|
+
|
|
443
460
|
function getTestProperties (test) {
|
|
444
461
|
const testName = getTestFullname(test)
|
|
445
462
|
const testSuite = getTestSuitePath(test._requireFile, rootDir)
|
|
446
463
|
|
|
447
464
|
const { attempt_to_fix: attemptToFix, disabled, quarantined } =
|
|
448
465
|
testManagementTests?.playwright?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
|
|
449
|
-
|
|
466
|
+
const { mustFail, noAutoRetry } = getTestAnnotations(test.fn)
|
|
467
|
+
return {
|
|
468
|
+
attemptToFix: attemptToFix && !noAutoRetry && !test._ddIsAutomaticRetryExcluded,
|
|
469
|
+
disabled: disabled && !mustFail,
|
|
470
|
+
quarantined: quarantined && !mustFail,
|
|
471
|
+
}
|
|
450
472
|
}
|
|
451
473
|
|
|
452
474
|
function isNewTest (test) {
|
|
@@ -480,6 +502,7 @@ function deepCloneSuite (suite, filterTest, tags = [], configureCopiedTest) {
|
|
|
480
502
|
} else {
|
|
481
503
|
if (filterTest(entry)) {
|
|
482
504
|
const copiedTest = entry._clone()
|
|
505
|
+
copiedTest._ddAssignedProperties = entry._ddAssignedProperties
|
|
483
506
|
originalTestIdsByRetry.set(copiedTest, originalTestIdsByRetry.get(entry) ?? entry.id)
|
|
484
507
|
if (configureCopiedTest) {
|
|
485
508
|
configureCopiedTest(copiedTest, entry)
|
|
@@ -799,6 +822,7 @@ function testBeginHandler (test, browserName, shouldCreateTestSpan) {
|
|
|
799
822
|
if (shouldCreateTestSpan) {
|
|
800
823
|
const testName = getTestFullname(test)
|
|
801
824
|
const testCtx = {
|
|
825
|
+
extraTags: getExclusionTags(test),
|
|
802
826
|
testName,
|
|
803
827
|
testSuiteAbsolutePath,
|
|
804
828
|
testSourceFileAbsolutePath,
|
|
@@ -850,6 +874,7 @@ function finishTestSuiteIfDone (testSuiteAbsolutePath, projects) {
|
|
|
850
874
|
const browserName = getBrowserNameFromProjects(projects, test)
|
|
851
875
|
recordSkippedTestOptimizationExecution(test, testSuiteAbsolutePath)
|
|
852
876
|
testSkipCh.publish({
|
|
877
|
+
extraTags: getExclusionTags(test),
|
|
853
878
|
testName: getTestFullname(test),
|
|
854
879
|
testSuiteAbsolutePath,
|
|
855
880
|
testSourceFileAbsolutePath: test.location.file,
|
|
@@ -885,7 +910,7 @@ function finishTestSuiteIfDone (testSuiteAbsolutePath, projects) {
|
|
|
885
910
|
* @param {object[]} projects
|
|
886
911
|
*/
|
|
887
912
|
function hasAutomaticRetries (test, projects) {
|
|
888
|
-
if (!automaticRetryProjects.has(getTestProject(projects, test))) return false
|
|
913
|
+
if (test._ddIsAutomaticRetryExcluded || !automaticRetryProjects.has(getTestProject(projects, test))) return false
|
|
889
914
|
for (let suite = test.parent; suite; suite = suite.parent) {
|
|
890
915
|
if (suite._retries !== undefined) return false
|
|
891
916
|
}
|
|
@@ -984,7 +1009,7 @@ function testEndHandler ({
|
|
|
984
1009
|
const testProperties = getTestProperties(test)
|
|
985
1010
|
if (
|
|
986
1011
|
isDynamicAtrEnabled &&
|
|
987
|
-
isFlakyTestRetriesEnabled &&
|
|
1012
|
+
isFlakyTestRetriesEnabled && !getTestAnnotations(test.fn).noAutoRetry &&
|
|
988
1013
|
!testProperties.attemptToFix &&
|
|
989
1014
|
!test._ddIsEfdRetry &&
|
|
990
1015
|
!isEfdManagedTest &&
|
|
@@ -1057,7 +1082,9 @@ function testEndHandler ({
|
|
|
1057
1082
|
const atrRetryCount = isDynamicAtrEnabled
|
|
1058
1083
|
? dynamicAtrRetryCountByTestKey.get(dynamicAtrTestKey) ?? test.retries
|
|
1059
1084
|
: flakyTestRetriesCount
|
|
1060
|
-
if (
|
|
1085
|
+
if (!test._ddIsAutomaticRetryExcluded && !getTestAnnotations(test.fn).noAutoRetry &&
|
|
1086
|
+
isFlakyTestRetriesEnabled &&
|
|
1087
|
+
!testProperties.attemptToFix && !test._ddIsEfdRetry &&
|
|
1061
1088
|
!(test._ddIsNew || test._ddIsModified) &&
|
|
1062
1089
|
atrRetryCount != null && atrRetryCount > 0 &&
|
|
1063
1090
|
// Serial suites can add skipped results before a test's first execution.
|
|
@@ -1076,7 +1103,8 @@ function testEndHandler ({
|
|
|
1076
1103
|
? test.id ?? test._id
|
|
1077
1104
|
: undefined
|
|
1078
1105
|
const isAtrRetry = testResult?.retry > 0 &&
|
|
1079
|
-
isFlakyTestRetriesEnabled &&
|
|
1106
|
+
isFlakyTestRetriesEnabled && !test._ddIsAutomaticRetryExcluded &&
|
|
1107
|
+
!getTestAnnotations(test.fn).noAutoRetry && hasAutomaticRetries(test, projects) &&
|
|
1080
1108
|
!test._ddIsAttemptToFix &&
|
|
1081
1109
|
!test._ddIsEfdRetry
|
|
1082
1110
|
|
|
@@ -1101,7 +1129,7 @@ function testEndHandler ({
|
|
|
1101
1129
|
steps: testResult?.steps || [],
|
|
1102
1130
|
isRetry: testResult?.retry > 0,
|
|
1103
1131
|
error,
|
|
1104
|
-
extraTags: annotationTags,
|
|
1132
|
+
extraTags: { ...annotationTags, ...getExclusionTags(test) },
|
|
1105
1133
|
isNew: test._ddIsNew,
|
|
1106
1134
|
hasDynamicName: test._ddIsNew && DYNAMIC_NAME_RE.test(getTestFullname(test)),
|
|
1107
1135
|
isAttemptToFix: test._ddIsAttemptToFix,
|
|
@@ -1339,7 +1367,8 @@ function onDispatcherCreateWorker (dispatcher, worker) {
|
|
|
1339
1367
|
worker[kDdPlaywrightFailureVideos].push(videos)
|
|
1340
1368
|
}
|
|
1341
1369
|
const isAtrRetry = testResult?.retry > 0 &&
|
|
1342
|
-
isFlakyTestRetriesEnabled &&
|
|
1370
|
+
isFlakyTestRetriesEnabled && !test._ddIsAutomaticRetryExcluded &&
|
|
1371
|
+
!getTestAnnotations(test.fn).noAutoRetry && hasAutomaticRetries(test, projects) &&
|
|
1343
1372
|
!test._ddIsAttemptToFix &&
|
|
1344
1373
|
!test._ddIsEfdRetry
|
|
1345
1374
|
|
|
@@ -1365,6 +1394,7 @@ function onDispatcherCreateWorker (dispatcher, worker) {
|
|
|
1365
1394
|
(!isFinalExecution || (isSerialTest(test) && test.results.length <= test.retries))
|
|
1366
1395
|
|
|
1367
1396
|
const ddProperties = {
|
|
1397
|
+
_ddAssignedProperties: test._ddAssignedProperties,
|
|
1368
1398
|
_ddRetryTestId: retryTestId,
|
|
1369
1399
|
_ddDeferFinalStatus: deferFinalStatus,
|
|
1370
1400
|
_ddIsDisabled: test._ddIsDisabled,
|
|
@@ -1485,6 +1515,7 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
1485
1515
|
const playwrightConfig = config?.config || runnerConfig.config || runnerConfig
|
|
1486
1516
|
rootDir = getRootDir(this, config)
|
|
1487
1517
|
const projects = getProjectsFromRunner(this, config)
|
|
1518
|
+
sessionProjects = projects
|
|
1488
1519
|
const isFailureScreenshotEnabled = isFailureScreenshotCaptureEnabled(projects)
|
|
1489
1520
|
const isFailureVideoEnabled = isFailureVideoCaptureEnabled(projects)
|
|
1490
1521
|
const isFailureVideoUploadSupported = satisfies(playwrightVersion, MINIMUM_FAILURE_VIDEO_UPLOAD_VERSION_RANGE)
|
|
@@ -1554,11 +1585,11 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
1554
1585
|
isKnownTestsEnabled = false
|
|
1555
1586
|
} else {
|
|
1556
1587
|
knownTests = receivedKnownTests
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1588
|
+
if (!isValidKnownTests(receivedKnownTests)) {
|
|
1589
|
+
isEarlyFlakeDetectionFaulty = true
|
|
1590
|
+
isEarlyFlakeDetectionEnabled = false
|
|
1591
|
+
isKnownTestsEnabled = false
|
|
1592
|
+
}
|
|
1562
1593
|
}
|
|
1563
1594
|
} catch (err) {
|
|
1564
1595
|
isEarlyFlakeDetectionEnabled = false
|
|
@@ -2196,10 +2227,6 @@ function applyRetriesToTests (
|
|
|
2196
2227
|
}
|
|
2197
2228
|
|
|
2198
2229
|
function processRootSuite (createRootSuiteReturnValue) {
|
|
2199
|
-
if (!isKnownTestsEnabled && !isTestManagementTestsEnabled && !isImpactedTestsEnabled) {
|
|
2200
|
-
return createRootSuiteReturnValue
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
2230
|
if (!createRootSuiteReturnValue) {
|
|
2204
2231
|
return createRootSuiteReturnValue
|
|
2205
2232
|
}
|
|
@@ -2211,6 +2238,28 @@ function processRootSuite (createRootSuiteReturnValue) {
|
|
|
2211
2238
|
}
|
|
2212
2239
|
|
|
2213
2240
|
const allTests = rootSuite.allTests()
|
|
2241
|
+
const excludedSerialSuites = new Set()
|
|
2242
|
+
for (const test of allTests) {
|
|
2243
|
+
if (!getTestAnnotations(test.fn).noAutoRetry) continue
|
|
2244
|
+
for (let suite = test.parent; suite; suite = suite.parent) {
|
|
2245
|
+
if (suite._parallelMode === 'serial') excludedSerialSuites.add(suite)
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
for (const test of allTests) {
|
|
2249
|
+
test._ddAssignedProperties = isTestManagementTestsEnabled
|
|
2250
|
+
? testManagementTests?.playwright?.suites
|
|
2251
|
+
?.[getTestSuitePath(test._requireFile, rootDir)]?.tests?.[getTestFullname(test)]?.properties
|
|
2252
|
+
: undefined
|
|
2253
|
+
test._ddIsAutomaticRetryExcluded = false
|
|
2254
|
+
const hasInjectedRetries = isFlakyTestRetriesEnabled && hasAutomaticRetries(test, sessionProjects)
|
|
2255
|
+
let excludeRetries = getTestAnnotations(test.fn).noAutoRetry
|
|
2256
|
+
// Serial retries need every prerequisite, so exclude the group from both ATR and EFD.
|
|
2257
|
+
for (let suite = test.parent; !excludeRetries && suite; suite = suite.parent) {
|
|
2258
|
+
excludeRetries = excludedSerialSuites.has(suite)
|
|
2259
|
+
}
|
|
2260
|
+
test._ddIsAutomaticRetryExcluded = excludeRetries
|
|
2261
|
+
if (hasInjectedRetries && excludeRetries) test.retries = 0
|
|
2262
|
+
}
|
|
2214
2263
|
|
|
2215
2264
|
if (isTestManagementTestsEnabled) {
|
|
2216
2265
|
const fileSuitesWithManagedTestsToProjects = new Map()
|
|
@@ -2269,7 +2318,8 @@ function processRootSuite (createRootSuiteReturnValue) {
|
|
|
2269
2318
|
const fileSuitesWithImpactedTestsToProjects = new Map()
|
|
2270
2319
|
for (const impactedTest of impactedTests) {
|
|
2271
2320
|
impactedTest._ddIsModified = true
|
|
2272
|
-
if (
|
|
2321
|
+
if (!impactedTest._ddIsAutomaticRetryExcluded &&
|
|
2322
|
+
shouldRunEarlyFlakeDetection() && impactedTest.expectedStatus !== 'skipped' &&
|
|
2273
2323
|
!impactedTest._ddIsAttemptToFix) {
|
|
2274
2324
|
// Prevent ATR or `--retries` from retrying tests that EFD manages.
|
|
2275
2325
|
impactedTest.retries = 0
|
|
@@ -2283,7 +2333,7 @@ function processRootSuite (createRootSuiteReturnValue) {
|
|
|
2283
2333
|
// If something changes in the file, all tests in the file are impacted, except attempt-to-fix tests managed above.
|
|
2284
2334
|
applyRetriesToTests(
|
|
2285
2335
|
fileSuitesWithImpactedTestsToProjects,
|
|
2286
|
-
(test) => !test._ddIsAttemptToFix,
|
|
2336
|
+
(test) => !test._ddIsAttemptToFix && !test._ddIsAutomaticRetryExcluded,
|
|
2287
2337
|
[
|
|
2288
2338
|
'_ddIsModified',
|
|
2289
2339
|
'_ddIsEfdRetry',
|
|
@@ -2316,7 +2366,8 @@ function processRootSuite (createRootSuiteReturnValue) {
|
|
|
2316
2366
|
const fileSuitesWithNewTestsToProjects = new Map()
|
|
2317
2367
|
for (const newTest of newTests) {
|
|
2318
2368
|
newTest._ddIsNew = true
|
|
2319
|
-
if (
|
|
2369
|
+
if (!newTest._ddIsAutomaticRetryExcluded &&
|
|
2370
|
+
shouldRunEarlyFlakeDetection() && newTest.expectedStatus !== 'skipped' &&
|
|
2320
2371
|
!newTest._ddIsModified && !newTest._ddIsAttemptToFix) {
|
|
2321
2372
|
// Prevent ATR or `--retries` from retrying tests that EFD manages.
|
|
2322
2373
|
newTest.retries = 0
|
|
@@ -2330,7 +2381,7 @@ function processRootSuite (createRootSuiteReturnValue) {
|
|
|
2330
2381
|
|
|
2331
2382
|
applyRetriesToTests(
|
|
2332
2383
|
fileSuitesWithNewTestsToProjects,
|
|
2333
|
-
(test) => !test._ddIsAttemptToFix && isNewTest(test),
|
|
2384
|
+
(test) => !test._ddIsAttemptToFix && !test._ddIsAutomaticRetryExcluded && isNewTest(test),
|
|
2334
2385
|
[
|
|
2335
2386
|
'_ddIsNew',
|
|
2336
2387
|
'_ddIsEfdRetry',
|
|
@@ -2615,6 +2666,7 @@ function instrumentWorkerMainMethods (workerMain) {
|
|
|
2615
2666
|
// Probably yet another test worker exporter is needed in addition to the ones for mocha, jest and cucumber
|
|
2616
2667
|
// it's probably hard to tell that's a playwright worker though, as I don't think there is a specific env variable
|
|
2617
2668
|
const testCtx = {
|
|
2669
|
+
extraTags: getExclusionTags(test),
|
|
2618
2670
|
testName,
|
|
2619
2671
|
testSuiteAbsolutePath,
|
|
2620
2672
|
testSourceFileAbsolutePath,
|
|
@@ -2730,7 +2782,7 @@ function instrumentWorkerMainMethods (workerMain) {
|
|
|
2730
2782
|
deferFinalStatus: test._ddDeferFinalStatus,
|
|
2731
2783
|
steps: steps.filter(step => step.testId === testId),
|
|
2732
2784
|
error,
|
|
2733
|
-
extraTags: annotationTags,
|
|
2785
|
+
extraTags: { ...annotationTags, ...getExclusionTags(test) },
|
|
2734
2786
|
isNew: test._ddIsNew,
|
|
2735
2787
|
hasDynamicName: test._ddIsNew && DYNAMIC_NAME_RE.test(getTestFullname(test)),
|
|
2736
2788
|
isRetry: retry > 0,
|
|
@@ -2767,6 +2819,8 @@ function instrumentWorkerMainMethods (workerMain) {
|
|
|
2767
2819
|
} else if (event === 'stepEnd') {
|
|
2768
2820
|
const stepInfo = stepInfoByStepId[payload.stepId]
|
|
2769
2821
|
delete stepInfoByStepId[payload.stepId]
|
|
2822
|
+
if (!stepInfo) return dispatchEvent.apply(this, arguments)
|
|
2823
|
+
|
|
2770
2824
|
steps.push({
|
|
2771
2825
|
testId: stepInfo.testId,
|
|
2772
2826
|
startTime: new Date(stepInfo.startTime),
|
|
@@ -2821,6 +2875,7 @@ function generateSummaryWrapper (generateSummary) {
|
|
|
2821
2875
|
|
|
2822
2876
|
recordSkippedTestOptimizationExecution(test, testSuiteAbsolutePath)
|
|
2823
2877
|
testSkipCh.publish({
|
|
2878
|
+
extraTags: getExclusionTags(test),
|
|
2824
2879
|
testName: getTestFullname(test),
|
|
2825
2880
|
testSuiteAbsolutePath,
|
|
2826
2881
|
testSourceFileAbsolutePath,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel } = require('./helpers/instrument')
|
|
4
|
+
|
|
5
|
+
const deriveStartChannel = channel('tracing:orchestrion:react-router:derive:start')
|
|
6
|
+
const loaderStartChannel = channel('apm:react-router:loader:start')
|
|
7
|
+
const actionStartChannel = channel('apm:react-router:action:start')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{ pattern?: string, unstable_pattern?: string }} RouteHandlerInfo
|
|
11
|
+
* @typedef {object} HandlerContext
|
|
12
|
+
* @property {string} routeId
|
|
13
|
+
* @property {string} [pattern]
|
|
14
|
+
* @property {(result: unknown, rejected: boolean) => void} [complete]
|
|
15
|
+
* @typedef {(callHandler: () => Promise<unknown>, info: RouteHandlerInfo) => Promise<unknown>} HandlerHook
|
|
16
|
+
* @typedef {{ loader: HandlerHook, action: HandlerHook }} RouteHooks
|
|
17
|
+
* @typedef {{ id: string, instrument: (hooks: RouteHooks) => void }} InstrumentableRoute
|
|
18
|
+
* @typedef {{ instrumentations?: object[], unstable_instrumentations?: object[] }} EntryModule
|
|
19
|
+
* @typedef {{ module?: EntryModule }} Entry
|
|
20
|
+
* @typedef {{ entry?: Entry }} ServerBuild
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {() => Promise<unknown>} callHandler
|
|
25
|
+
* @param {RouteHandlerInfo} info
|
|
26
|
+
* @param {string} routeId
|
|
27
|
+
* @param {import('node:diagnostics_channel').Channel} startChannel
|
|
28
|
+
*/
|
|
29
|
+
function callRouteHandler (callHandler, info, routeId, startChannel) {
|
|
30
|
+
if (!startChannel.hasSubscribers) return callHandler()
|
|
31
|
+
|
|
32
|
+
/** @type {HandlerContext} */
|
|
33
|
+
const context = {
|
|
34
|
+
routeId,
|
|
35
|
+
pattern: info?.pattern ?? info?.unstable_pattern,
|
|
36
|
+
complete: undefined,
|
|
37
|
+
}
|
|
38
|
+
const result = startChannel.runStores(context, callHandler)
|
|
39
|
+
const complete = context.complete
|
|
40
|
+
if (!complete) return result
|
|
41
|
+
|
|
42
|
+
return result.then(
|
|
43
|
+
value => {
|
|
44
|
+
complete(value, false)
|
|
45
|
+
return value
|
|
46
|
+
},
|
|
47
|
+
error => {
|
|
48
|
+
complete(error, true)
|
|
49
|
+
throw error
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const datadogInstrumentation = {
|
|
55
|
+
/** @param {InstrumentableRoute} route */
|
|
56
|
+
route (route) {
|
|
57
|
+
const routeId = route.id
|
|
58
|
+
route.instrument({
|
|
59
|
+
/**
|
|
60
|
+
* @param {() => Promise<unknown>} callHandler
|
|
61
|
+
* @param {RouteHandlerInfo} info
|
|
62
|
+
*/
|
|
63
|
+
loader (callHandler, info) {
|
|
64
|
+
return callRouteHandler(callHandler, info, routeId, loaderStartChannel)
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* @param {() => Promise<unknown>} callHandler
|
|
68
|
+
* @param {RouteHandlerInfo} info
|
|
69
|
+
*/
|
|
70
|
+
action (callHandler, info) {
|
|
71
|
+
return callRouteHandler(callHandler, info, routeId, actionStartChannel)
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @param {ServerBuild} build */
|
|
78
|
+
function injectInstrumentation (build) {
|
|
79
|
+
const entry = build?.entry
|
|
80
|
+
const entryModule = entry?.module
|
|
81
|
+
if (!entryModule || typeof entryModule !== 'object') return build
|
|
82
|
+
|
|
83
|
+
const stable = entryModule.instrumentations
|
|
84
|
+
const unstable = entryModule.unstable_instrumentations
|
|
85
|
+
return {
|
|
86
|
+
...build,
|
|
87
|
+
entry: {
|
|
88
|
+
...entry,
|
|
89
|
+
module: {
|
|
90
|
+
...entryModule,
|
|
91
|
+
instrumentations: Array.isArray(stable) ? [datadogInstrumentation, ...stable] : [datadogInstrumentation],
|
|
92
|
+
unstable_instrumentations: Array.isArray(unstable)
|
|
93
|
+
? [datadogInstrumentation, ...unstable]
|
|
94
|
+
: [datadogInstrumentation],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** @param {unknown} message */
|
|
101
|
+
function onDeriveStart (message) {
|
|
102
|
+
const context = /** @type {{ arguments: ServerBuild[] }} */ (message)
|
|
103
|
+
context.arguments[0] = injectInstrumentation(context.arguments[0])
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
deriveStartChannel.subscribe(onDeriveStart)
|
|
@@ -58,19 +58,30 @@ function wrapConstructEventAsync (constructEventAsync) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
const wrappedMethods = new WeakSet()
|
|
62
|
+
|
|
63
|
+
// Stripe >=9 <11.10 and >=18 share `webhooks` across clients. Stripe >=11.10 <18
|
|
64
|
+
// creates it per client. checkout.sessions and paymentIntents are separate for each client.
|
|
65
|
+
// Rewrapping shared webhook methods adds one layer per client, causing duplicate
|
|
66
|
+
// publications and eventually a stack overflow. Track installed functions so replacements
|
|
67
|
+
// still get wrapped and restored wrappers are reused.
|
|
68
|
+
/**
|
|
69
|
+
* @param {object|undefined} target
|
|
70
|
+
* @param {string} name
|
|
71
|
+
* @param {Function} wrapper
|
|
72
|
+
*/
|
|
73
|
+
function wrapOnce (target, name, wrapper) {
|
|
74
|
+
if (typeof target?.[name] !== 'function' || wrappedMethods.has(target[name])) return
|
|
75
|
+
|
|
76
|
+
shimmer.wrap(target, name, wrapper)
|
|
77
|
+
wrappedMethods.add(target[name])
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
function instrumentStripeInstance (stripe) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
shimmer.wrap(stripe.paymentIntents, 'create', wrapPaymentIntentCreate)
|
|
67
|
-
}
|
|
68
|
-
if (typeof stripe.webhooks?.constructEvent === 'function') {
|
|
69
|
-
shimmer.wrap(stripe.webhooks, 'constructEvent', wrapConstructEvent)
|
|
70
|
-
}
|
|
71
|
-
if (typeof stripe.webhooks?.constructEventAsync === 'function') {
|
|
72
|
-
shimmer.wrap(stripe.webhooks, 'constructEventAsync', wrapConstructEventAsync)
|
|
73
|
-
}
|
|
81
|
+
wrapOnce(stripe.checkout?.sessions, 'create', wrapSessionCreate)
|
|
82
|
+
wrapOnce(stripe.paymentIntents, 'create', wrapPaymentIntentCreate)
|
|
83
|
+
wrapOnce(stripe.webhooks, 'constructEvent', wrapConstructEvent)
|
|
84
|
+
wrapOnce(stripe.webhooks, 'constructEventAsync', wrapConstructEventAsync)
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
// stripe <22: the constructor mutates this (when invoked with 'new') and
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { tracingChannel } = require('dc-polyfill')
|
|
4
|
+
|
|
5
|
+
const systemOneChannel = tracingChannel('orchestrion:@typesafe-ai/sdk:TypeSafeClient_systemOne')
|
|
6
|
+
const apiPromiseChannel = tracingChannel('orchestrion:@typesafe-ai/sdk:APIPromise_constructor')
|
|
7
|
+
|
|
8
|
+
const systemOneContexts = new WeakMap()
|
|
9
|
+
|
|
10
|
+
// `systemOne` returns its `APIPromise` without awaiting it, so the span finishes once the response arrives
|
|
11
|
+
systemOneChannel.end.subscribe(ctx => {
|
|
12
|
+
if (!systemOneChannel.start.hasSubscribers) return
|
|
13
|
+
|
|
14
|
+
// Copied like the SDK copies it, since the caller may change the object for its next call before this one finishes
|
|
15
|
+
const request = ctx.arguments[0]
|
|
16
|
+
if (request && typeof request === 'object') ctx.request = { ...request }
|
|
17
|
+
|
|
18
|
+
if (!ctx.error && ctx.result && typeof ctx.result === 'object') {
|
|
19
|
+
systemOneContexts.set(ctx.result, ctx)
|
|
20
|
+
} else {
|
|
21
|
+
finish(ctx)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// Every `APIPromise` method (awaiting, `asResponse()`, `withResponse()`, `map()`) reads the response promise passed to
|
|
26
|
+
// the constructor, so observing it covers each of them, and calls that are never awaited.
|
|
27
|
+
apiPromiseChannel.start.subscribe(ctx => {
|
|
28
|
+
const responsePromise = ctx.arguments[0]
|
|
29
|
+
if (!systemOneChannel.start.hasSubscribers || typeof responsePromise?.then !== 'function') return
|
|
30
|
+
|
|
31
|
+
ctx.arguments[0] = responsePromise.then(response => {
|
|
32
|
+
const systemOneCtx = systemOneContexts.get(ctx.self)
|
|
33
|
+
if (systemOneCtx) readResponse(systemOneCtx, response)
|
|
34
|
+
return response
|
|
35
|
+
}, error => {
|
|
36
|
+
const systemOneCtx = systemOneContexts.get(ctx.self)
|
|
37
|
+
if (systemOneCtx) finish(systemOneCtx, undefined, error)
|
|
38
|
+
throw error
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reads the body from a clone so the caller's response stays unread.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} ctx
|
|
46
|
+
* @param {Response} response
|
|
47
|
+
*/
|
|
48
|
+
function readResponse (ctx, response) {
|
|
49
|
+
try {
|
|
50
|
+
response.clone().text().then(body => {
|
|
51
|
+
ctx.responseText = body
|
|
52
|
+
finish(ctx, parseBody(body))
|
|
53
|
+
}, error => finish(ctx, undefined, error))
|
|
54
|
+
} catch (error) {
|
|
55
|
+
finish(ctx, undefined, error)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Parses the body the way the SDK does: JSON when it parses, otherwise the text itself.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} text
|
|
63
|
+
*/
|
|
64
|
+
function parseBody (text) {
|
|
65
|
+
if (text.length === 0) return
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(text)
|
|
68
|
+
} catch {
|
|
69
|
+
return text
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {object} ctx
|
|
75
|
+
* @param {unknown} [result]
|
|
76
|
+
* @param {Error} [error]
|
|
77
|
+
*/
|
|
78
|
+
function finish (ctx, result, error) {
|
|
79
|
+
if (ctx.finished) return
|
|
80
|
+
ctx.finished = true
|
|
81
|
+
|
|
82
|
+
if (error) {
|
|
83
|
+
ctx.error = error
|
|
84
|
+
systemOneChannel.error.publish(ctx)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ctx.result = result
|
|
88
|
+
systemOneChannel.asyncEnd.publish(ctx)
|
|
89
|
+
}
|