dd-trace 6.23.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.
Files changed (168) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/support.js +15 -1
  3. package/ci/diagnose.js +4 -4
  4. package/ci/test-annotations.d.ts +5 -0
  5. package/ci/test-annotations.js +5 -0
  6. package/ci/test-optimization-validation/approval-artifacts.js +2 -2
  7. package/ci/test-optimization-validation/approval.js +2 -2
  8. package/ci/test-optimization-validation/artifact-id.js +2 -3
  9. package/ci/test-optimization-validation/ci-package-scripts.js +1 -1
  10. package/ci/test-optimization-validation/cli.js +1 -1
  11. package/ci/test-optimization-validation/command-runner.js +2 -3
  12. package/ci/test-optimization-validation/executable.js +1 -1
  13. package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
  14. package/ci/test-optimization-validation/literal-environment.js +2 -2
  15. package/ci/test-optimization-validation/manifest-scaffold.js +1 -1
  16. package/ci/test-optimization-validation/offline-fixtures.js +1 -1
  17. package/ci/test-optimization-validation/redaction.js +3 -3
  18. package/ci/test-optimization-validation/runner-contract.js +10 -10
  19. package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -1
  20. package/ci/vitest-no-worker-init-annotations.mjs +4 -0
  21. package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
  22. package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
  23. package/ci/vitest-no-worker-init-setup.mjs +34 -12
  24. package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
  25. package/ext/exporters.js +1 -0
  26. package/index.d.ts +19 -0
  27. package/loader-hook.mjs +53 -0
  28. package/openfeature/exposure-hook.d.ts +66 -0
  29. package/openfeature/exposure-hook.js +5 -0
  30. package/package.json +11 -9
  31. package/packages/datadog-core/src/storage.js +1 -1
  32. package/packages/datadog-esbuild/index.js +70 -7
  33. package/packages/datadog-instrumentations/src/cucumber.js +53 -19
  34. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  35. package/packages/datadog-instrumentations/src/graphql.js +9 -3
  36. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  37. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  38. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  39. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -1
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +8 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +8 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
  50. package/packages/datadog-instrumentations/src/jest.js +265 -82
  51. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  52. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  53. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  54. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  55. package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
  56. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  57. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  58. package/packages/datadog-instrumentations/src/pg.js +2 -1
  59. package/packages/datadog-instrumentations/src/playwright.js +81 -28
  60. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  61. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  62. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
  63. package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
  64. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  65. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  66. package/packages/datadog-instrumentations/src/vitest.js +10 -8
  67. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  68. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +274 -44
  69. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  70. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  71. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  72. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  73. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  74. package/packages/datadog-plugin-cypress/src/support.js +1217 -439
  75. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  76. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  77. package/packages/datadog-plugin-jest/src/index.js +25 -3
  78. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  79. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  80. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  81. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  82. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  83. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  84. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  85. package/packages/dd-trace/src/agent/info.js +2 -1
  86. package/packages/dd-trace/src/aiguard/sdk.js +0 -11
  87. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
  88. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
  89. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
  90. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
  91. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  92. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  93. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  94. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  95. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
  96. package/packages/dd-trace/src/config/defaults.js +4 -3
  97. package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -0
  98. package/packages/dd-trace/src/config/index.js +95 -39
  99. package/packages/dd-trace/src/config/parsers.js +9 -1
  100. package/packages/dd-trace/src/config/supported-configurations.json +16 -0
  101. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  102. package/packages/dd-trace/src/encode/0.4.js +2 -2
  103. package/packages/dd-trace/src/esm-module-load.js +58 -0
  104. package/packages/dd-trace/src/exporter.js +25 -6
  105. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  106. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  107. package/packages/dd-trace/src/exporters/common/request.js +4 -4
  108. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  109. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  110. package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
  111. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  112. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  113. package/packages/dd-trace/src/llmobs/index.js +13 -2
  114. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  115. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  116. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +8 -4
  117. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  118. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  119. package/packages/dd-trace/src/llmobs/sdk.js +2 -1
  120. package/packages/dd-trace/src/llmobs/span_processor.js +210 -12
  121. package/packages/dd-trace/src/llmobs/tagger.js +3 -0
  122. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  123. package/packages/dd-trace/src/log/writer.js +7 -1
  124. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
  125. package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
  126. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  127. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  128. package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
  129. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  130. package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
  131. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  132. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  133. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  134. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  135. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  136. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  137. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  138. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  139. package/packages/dd-trace/src/opentracing/tracer.js +9 -13
  140. package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
  141. package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
  142. package/packages/dd-trace/src/plugins/index.js +3 -0
  143. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  144. package/packages/dd-trace/src/plugins/util/git.js +11 -5
  145. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
  146. package/packages/dd-trace/src/plugins/util/test.js +26 -6
  147. package/packages/dd-trace/src/plugins/util/web.js +16 -0
  148. package/packages/dd-trace/src/process-tags/index.js +1 -1
  149. package/packages/dd-trace/src/profiling/config.js +6 -3
  150. package/packages/dd-trace/src/proxy.js +15 -4
  151. package/packages/dd-trace/src/serverless.js +3 -2
  152. package/packages/dd-trace/src/span_processor.js +21 -9
  153. package/packages/dd-trace/src/span_stats.js +28 -2
  154. package/packages/dd-trace/src/startup-log.js +2 -1
  155. package/packages/dd-trace/src/tagger.js +7 -5
  156. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  157. package/packages/dd-trace/src/telemetry/index.js +3 -0
  158. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  159. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
  160. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  161. package/packages/dd-trace/src/util.js +1 -1
  162. package/register.js +2 -1
  163. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  164. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  165. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  166. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  167. package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
  168. package/vendor/dist/@opentelemetry/resources/index.js +0 -1
@@ -22,7 +22,6 @@
22
22
  "@opentelemetry/api","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
23
23
  "@opentelemetry/api-logs","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
24
24
  "@opentelemetry/core","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
25
- "@opentelemetry/resources","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
26
25
  "@opentelemetry/semantic-conventions","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
27
26
  "@oxc-parser/binding-android-arm-eabi","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
28
27
  "@oxc-parser/binding-android-arm64","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
@@ -1,3 +1,17 @@
1
1
  'use strict'
2
2
 
3
- require('../../packages/datadog-plugin-cypress/src/support')
3
+ /* global Cypress */
4
+
5
+ const hasCypressLifecycle = require('../../packages/datadog-plugin-cypress/src/lifecycle-owner')
6
+ const root = Cypress.mocha.getRootSuite()
7
+ const installed = Symbol.for('dd-trace.cypress.support-installed')
8
+
9
+ if (!hasCypressLifecycle(root)) {
10
+ if (!root[installed]) {
11
+ require('../../packages/datadog-plugin-cypress/src/support')
12
+ root[installed] = true
13
+ }
14
+
15
+ const install = root[Symbol.for('dd-trace.cypress.install-lifecycle')]
16
+ if (typeof install === 'function') install()
17
+ }
package/ci/diagnose.js CHANGED
@@ -1273,7 +1273,7 @@ function getProjectPreferenceScores (root, manifests) {
1273
1273
  /**
1274
1274
  * Normalizes repository and package names for conservative identity comparison.
1275
1275
  *
1276
- * @param {string} value repository or package name
1276
+ * @param {unknown} value repository or package name from manifest metadata
1277
1277
  * @returns {Set<string>} normalized identity tokens
1278
1278
  */
1279
1279
  function getIdentityTokens (value) {
@@ -1332,7 +1332,7 @@ function isIneligibleFrameworkCommand (frameworkId, command) {
1332
1332
  * @param {string} command package script command
1333
1333
  */
1334
1334
  function isCucumberRunnerCommand (command) {
1335
- return CUCUMBER_RUNNER_COMMAND_RE.test(String(command || ''))
1335
+ return CUCUMBER_RUNNER_COMMAND_RE.test(command)
1336
1336
  }
1337
1337
 
1338
1338
  /**
@@ -2009,7 +2009,7 @@ function coerceVersion (rawVersion) {
2009
2009
  * @param {string} rawVersion package manifest version/range
2010
2010
  */
2011
2011
  function isAmbiguousRange (rawVersion) {
2012
- const version = String(rawVersion || '').trim()
2012
+ const version = rawVersion.trim()
2013
2013
  if (!version || version.includes('||')) return true
2014
2014
  return /<=?\s*\d/.test(version)
2015
2015
  }
@@ -2091,7 +2091,7 @@ function hasShaMetadata (env) {
2091
2091
  * @param {string|undefined} value value to inspect
2092
2092
  */
2093
2093
  function isTrueLike (value) {
2094
- return /^(?:1|true)$/i.test(String(value || ''))
2094
+ return /^(?:1|true)$/i.test(String(value))
2095
2095
  }
2096
2096
 
2097
2097
  /**
@@ -0,0 +1,5 @@
1
+ /** Prevent Datadog from quarantining or disabling this test callback. */
2
+ export function preventFailureSuppression<T extends (...args: never[]) => unknown>(callback: T): T;
3
+
4
+ /** Prevent ATR, Early Flake Detection, and Attempt to Fix retries for this test callback. */
5
+ export function noAutoRetry<T extends (...args: never[]) => unknown>(callback: T): T;
@@ -0,0 +1,5 @@
1
+ 'use strict'
2
+
3
+ const { preventFailureSuppression, noAutoRetry } = require('../packages/dd-trace/src/ci-visibility/test-annotations')
4
+
5
+ module.exports = { preventFailureSuppression, noAutoRetry }
@@ -70,11 +70,11 @@ function assertExpectedProjectFiles (expected, actual) {
70
70
  * Loads the reviewed approval file only after its exact bytes match the user-approved SHA-256.
71
71
  *
72
72
  * @param {string} approvalPath approval JSON path
73
- * @param {string} expectedDigest user-approved SHA-256
73
+ * @param {string | undefined} expectedDigest user-approved SHA-256
74
74
  * @returns {{material: object, path: string}} verified approval material
75
75
  */
76
76
  function loadApprovedPlan (approvalPath, expectedDigest) {
77
- if (!APPROVAL_DIGEST_PATTERN.test(String(expectedDigest || ''))) {
77
+ if (!APPROVAL_DIGEST_PATTERN.test(expectedDigest || '')) {
78
78
  throw new Error('Invalid --sha256 value. Render a fresh plan with --print-plan.')
79
79
  }
80
80
 
@@ -351,11 +351,11 @@ function resolvePhysicalPath (filename) {
351
351
  /**
352
352
  * Validates an approval digest before live validation executes project code.
353
353
  *
354
- * @param {string} digest supplied approval digest
354
+ * @param {string | undefined} digest supplied approval digest
355
355
  * @param {object} input approval inputs
356
356
  */
357
357
  function assertApprovalDigest (digest, input) {
358
- if (!APPROVAL_DIGEST_PATTERN.test(String(digest || ''))) {
358
+ if (!APPROVAL_DIGEST_PATTERN.test(digest || '')) {
359
359
  throw new Error('Invalid approved plan SHA-256. Render a fresh plan with --print-plan.')
360
360
  }
361
361
 
@@ -7,10 +7,9 @@ const MAX_PREFIX_LENGTH = 72
7
7
  /**
8
8
  * Maps an arbitrary manifest identifier to a bounded, portable, collision-resistant path segment.
9
9
  *
10
- * @param {string} value original identifier
10
+ * @param {string} source original identifier
11
11
  */
12
- function getArtifactId (value) {
13
- const source = String(value)
12
+ function getArtifactId (source) {
14
13
  const prefix = source.replaceAll(/[^a-zA-Z0-9._-]+/g, '-').slice(0, MAX_PREFIX_LENGTH) || 'framework'
15
14
  const digest = crypto.createHash('sha256').update(source).digest('hex').slice(0, 12)
16
15
  return `${prefix}-${digest}`
@@ -98,7 +98,7 @@ function expandCommand (command, scripts, path, stack, state) {
98
98
  * @returns {string[]|undefined} literal command segments
99
99
  */
100
100
  function splitLiteralAndChain (command) {
101
- const source = String(command || '').trim()
101
+ const source = command.trim()
102
102
  if (!source || DYNAMIC_VALUE_PATTERN.test(source)) return
103
103
  const segments = []
104
104
  let quote
@@ -724,7 +724,7 @@ function normalizeScenarioSelection (scenario) {
724
724
  * @param {string} target target value
725
725
  */
726
726
  function normalizeFrameworkTarget (target) {
727
- const normalized = String(target).trim().replace(/(?<!:):+$/, '')
727
+ const normalized = target.trim().replace(/(?<!:):+$/, '')
728
728
  if (!normalized) throw new Error('Framework target cannot be empty.')
729
729
  return normalized
730
730
  }
@@ -615,10 +615,9 @@ function serializeApprovalCommand (command) {
615
615
  /**
616
616
  * Quotes arguments whose boundaries would otherwise be ambiguous in an approval plan.
617
617
  *
618
- * @param {string} value argument value
618
+ * @param {string} argument argument value
619
619
  */
620
- function formatApprovalArgument (value) {
621
- const argument = String(value)
620
+ function formatApprovalArgument (argument) {
622
621
  if (/^[A-Za-z0-9_@%+=:,./\\-]+$/.test(argument)) return argument
623
622
  if (process.platform === 'win32') return JSON.stringify(argument)
624
623
  return `'${argument.replaceAll('\'', '\'"\'"\'')}'`
@@ -137,7 +137,7 @@ function splitNodeOptions (source) {
137
137
  let started = false
138
138
  let quote
139
139
 
140
- for (let index = 0; index < String(source).length; index++) {
140
+ for (let index = 0; index < source.length; index++) {
141
141
  const character = source[index]
142
142
  if (character === '\0') throw new Error('NODE_OPTIONS contains a null byte.')
143
143
  if (!quote && /\s/.test(character)) {
@@ -88,7 +88,7 @@ const JAVASCRIPT_STRING_ESCAPES = Object.freeze({
88
88
  * @param {string|null|undefined} version installed Cucumber version
89
89
  */
90
90
  function supportsConfigIsolation (version) {
91
- const match = /^[v=]?(\d+)(?:\.|$)/.exec(String(version || ''))
91
+ const match = /^[v=]?(\d+)(?:\.|$)/.exec(String(version))
92
92
  return Boolean(match && Number(match[1]) >= 8)
93
93
  }
94
94
 
@@ -12,7 +12,7 @@ const ASSIGNMENT_PATTERN =
12
12
  * @returns {{assignments: Array<{name: string, source: string, value: string}>, length: number}} parsed prefix
13
13
  */
14
14
  function parseLiteralEnvironmentPrefix (command) {
15
- const source = String(command || '')
15
+ const source = command
16
16
  const assignments = []
17
17
  let offset = 0
18
18
 
@@ -39,7 +39,7 @@ function parseLiteralEnvironmentPrefix (command) {
39
39
  * @param {string} [platform] target platform
40
40
  */
41
41
  function removeEmptyLiteralEnvironmentAssignments (command, name, platform = process.platform) {
42
- const source = String(command || '')
42
+ const source = command
43
43
  const prefix = parseLiteralEnvironmentPrefix(source)
44
44
  const retained = prefix.assignments.filter(assignment => {
45
45
  return !environmentNamesEqual(assignment.name, name, platform) || assignment.value !== ''
@@ -892,7 +892,7 @@ function findPreferredRepresentativeRoot (projectRoot, repositoryRoot) {
892
892
  /**
893
893
  * Normalizes repository and package names for exact identity comparison.
894
894
  *
895
- * @param {string} value package identity
895
+ * @param {unknown} value package identity from manifest metadata
896
896
  */
897
897
  function normalizeProjectIdentity (value) {
898
898
  const unscoped = String(value || '').toLowerCase().replace(/^@[^/]+\//, '')
@@ -59,7 +59,7 @@ function createOfflineFixture ({
59
59
  skippableTests = [],
60
60
  testManagementTests = {},
61
61
  }) {
62
- if (!/^[a-f0-9]{64}$/.test(approvedPlanSha256 || '')) {
62
+ if (!/^[a-f0-9]{64}$/.test(approvedPlanSha256)) {
63
63
  throw new Error('Offline validation requires an approved plan digest before creating fixtures.')
64
64
  }
65
65
  if (!OFFLINE_FIXTURE_NONCE_PATTERN.test(offlineFixtureNonce || '')) {
@@ -196,11 +196,11 @@ function sanitizeString (value) {
196
196
  * @param {unknown} value candidate text
197
197
  */
198
198
  function hasUnicodeDefaultIgnorable (value) {
199
- return DEFAULT_IGNORABLE_TEST_PATTERN.test(String(value ?? ''))
199
+ return DEFAULT_IGNORABLE_TEST_PATTERN.test(String(value))
200
200
  }
201
201
 
202
202
  function hasUnsafeInvisibleCharacter (value) {
203
- const text = String(value ?? '')
203
+ const text = String(value)
204
204
  return hasUnicodeDefaultIgnorable(text) || UNSAFE_CONTROL_TEST_PATTERN.test(text)
205
205
  }
206
206
 
@@ -230,7 +230,7 @@ function sanitizeConsoleText (value) {
230
230
  * @param {string} name key or environment variable name
231
231
  */
232
232
  function isSensitiveName (name) {
233
- const normalized = String(name || '').replaceAll(/[-.]/g, '_')
233
+ const normalized = name.replaceAll(/[-.]/g, '_')
234
234
  return SENSITIVE_NAME_PATTERN.test(normalized) ||
235
235
  SENSITIVE_AUTH_NAME_PATTERN.test(normalized) ||
236
236
  SENSITIVE_COOKIE_NAME_PATTERN.test(normalized) ||
@@ -88,7 +88,7 @@ const ENVIRONMENT_EXPANSION_PATTERN = /\$|%[^%]+%|![^!]+!/
88
88
  * Extracts bounded runner configuration from a detected package script.
89
89
  *
90
90
  * @param {string} framework framework name
91
- * @param {string} command detected package script
91
+ * @param {string | undefined} command detected package script
92
92
  * @param {string} projectRoot detected project root
93
93
  * @param {string} repositoryRoot repository root
94
94
  * @param {string} [platform] target platform
@@ -176,11 +176,11 @@ function getRunnerConfigurationContract (framework, runnerArgs, environment, pro
176
176
  /**
177
177
  * Rejects shell-expanded allowlisted environment assignments before command tokenization.
178
178
  *
179
- * @param {string} command detected package script
179
+ * @param {string | undefined} command detected package script
180
180
  * @returns {string|undefined} validation error
181
181
  */
182
182
  function getDynamicRunnerEnvironmentError (command) {
183
- const source = String(command || '')
183
+ const source = String(command)
184
184
  for (const match of source.matchAll(
185
185
  /(?:^|\s)([A-Za-z_][A-Za-z0-9_]*)=(?:"([^"]*)"|'([^']*)'|([^\s]+))/g
186
186
  )) {
@@ -198,7 +198,7 @@ function getDynamicRunnerEnvironmentError (command) {
198
198
  * Returns literal existing test roots selected by a direct framework invocation.
199
199
  *
200
200
  * @param {string} framework framework name
201
- * @param {string} command detected package script
201
+ * @param {string | undefined} command detected package script
202
202
  * @param {string} projectRoot detected project root
203
203
  * @param {string} repositoryRoot repository root
204
204
  * @returns {string[]} physical search roots
@@ -333,13 +333,13 @@ function getArgumentOptionValues (args, expected) {
333
333
  /**
334
334
  * Selects a project-owned runner only for an exact `node <regular-file>` package script.
335
335
  *
336
- * @param {string} command detected package script
336
+ * @param {string | undefined} command detected package script
337
337
  * @param {string} projectRoot detected project root
338
338
  * @param {string} repositoryRoot repository root
339
339
  * @returns {string|undefined} physical runner path
340
340
  */
341
341
  function getProjectNodeRunner (command, projectRoot, repositoryRoot) {
342
- if (CONTROL_PATTERN.test(String(command || ''))) return
342
+ if (CONTROL_PATTERN.test(command || '')) return
343
343
  const tokens = tokenizeCommand(command)
344
344
  if (tokens.length !== 2 || !/^node(?:\.exe)?$/i.test(path.basename(tokens[0])) || tokens[1].startsWith('-')) return
345
345
 
@@ -445,12 +445,12 @@ function getRunnerInputError (args, environment, projectRoot, repositoryRoot, co
445
445
  /**
446
446
  * Finds a direct framework executable behind inert launch wrappers.
447
447
  *
448
- * @param {string} command detected package script
448
+ * @param {string | undefined} command detected package script
449
449
  * @param {string} framework framework name
450
450
  * @returns {{error?: string, runnerIndex: number, tokens: string[]}|undefined} parsed invocation
451
451
  */
452
452
  function getFrameworkInvocation (command, framework) {
453
- if (CONTROL_PATTERN.test(String(command || '')) || command === `direct ${framework} binary`) return
453
+ if (CONTROL_PATTERN.test(command || '') || command === `direct ${framework} binary`) return
454
454
  const tokens = tokenizeCommand(command)
455
455
  const executable = getRunnerExecutableName(framework)
456
456
  const runnerIndex = tokens.findIndex(token => {
@@ -652,12 +652,12 @@ function resolveInputFile (input, projectRoot) {
652
652
  /**
653
653
  * Tokenizes bounded package-script evidence without expanding variables or invoking a shell.
654
654
  *
655
- * @param {string} command package script
655
+ * @param {string | undefined} command package script
656
656
  * @returns {string[]} inert tokens
657
657
  */
658
658
  function tokenizeCommand (command) {
659
659
  const tokens = []
660
- for (const match of String(command || '').matchAll(/"([^"\r\n]*)"|'([^'\r\n]*)'|([^\s"']+)/g)) {
660
+ for (const match of (command || '').matchAll(/"([^"\r\n]*)"|'([^'\r\n]*)'|([^\s"']+)/g)) {
661
661
  tokens.push(match[1] ?? match[2] ?? match[3])
662
662
  }
663
663
  return tokens
@@ -595,7 +595,7 @@ function readProjectSource (filename, projectFileSources) {
595
595
  */
596
596
  function containsLiteral (source, value) {
597
597
  const normalizedSource = source.replaceAll('\r\n', '\n')
598
- const normalizedValue = String(value).replaceAll('\r\n', '\n').trim()
598
+ const normalizedValue = value.replaceAll('\r\n', '\n').trim()
599
599
  return normalizedValue !== '' && normalizedSource.includes(normalizedValue)
600
600
  }
601
601
 
@@ -0,0 +1,4 @@
1
+ import * as declarations from '../packages/dd-trace/src/ci-visibility/test-declaration-annotations.js'
2
+
3
+ export const { captureDeclarations } = declarations.default ||
4
+ globalThis[Symbol.for('dd-trace.vitest.declaration-annotations')]
@@ -0,0 +1,22 @@
1
+ import { createRequire } from 'node:module'
2
+ import { pathToFileURL } from 'node:url'
3
+
4
+ import { captureDeclarations } from './vitest-no-worker-init-annotations.mjs'
5
+
6
+ // Vitest's resolver selects the running installation even when config.root contains another copy.
7
+ const worker = globalThis.__vitest_worker__
8
+ // Vitest 3 uses Vite Node's resolveId RPC; Vitest 4+ uses Vite's named environments.
9
+ const { id } = worker.moduleCache
10
+ ? await worker.rpc.resolveId('vitest', undefined, 'ssr')
11
+ : await worker.rpc.resolve('vitest', undefined, '__vitest__')
12
+ const vitestUrl = id.startsWith('file:') ? id : pathToFileURL(id).href
13
+ const vitestRequire = createRequire(vitestUrl)
14
+ const vitest = await import(vitestUrl)
15
+ const vitestRunner = vitest.TestRunner || await import(pathToFileURL(vitestRequire.resolve('vitest/suite')).href)
16
+
17
+ globalThis[Symbol.for('dd-trace.vitest.api')] = vitest
18
+ globalThis[Symbol.for('dd-trace.vitest.set-fn')] = vitestRunner.setTestFn || vitestRunner.setFn
19
+ globalThis[Symbol.for('dd-trace.vitest.skip-task')] = skip => skip('Skipped by Datadog Test Optimization')
20
+ captureDeclarations(vitest.test, vitestRunner.getCurrentSuite)
21
+
22
+ await import('./vitest-no-worker-init-setup.mjs')
@@ -1,35 +1,10 @@
1
- try {
2
- // Vitest does not expose setFn from its public setup API; keep this optional for strict installers.
3
- const vitestRunner = await import('@vitest/runner')
4
- globalThis[Symbol.for('dd-trace.vitest.set-fn')] = vitestRunner.setFn
5
- trackNativeRetryOptions(vitestRunner.getCurrentSuite())
6
- } catch {}
1
+ import * as vitest from 'vitest'
2
+
3
+ import { captureDeclarations } from './vitest-no-worker-init-annotations.mjs'
4
+
5
+ const vitestRunner = vitest.TestRunner || await import('vitest/suite')
6
+ globalThis[Symbol.for('dd-trace.vitest.set-fn')] = vitestRunner.setTestFn || vitestRunner.setFn
7
+ captureDeclarations(vitest.test, vitestRunner.getCurrentSuite)
7
8
  globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('@vitest/browser/context')
8
9
 
9
10
  await import('./vitest-no-worker-init-setup.mjs')
10
-
11
- /**
12
- * Legacy Vitest inherits numeric retries and loses their origin during collection.
13
- * These collectors and their chainable callbacks are created at runtime.
14
- * @param {object} collector
15
- */
16
- function trackNativeRetryOptions (collector) {
17
- const original = collector.test.fn
18
- collector.test.fn = function (name, optionsOrFn, fnOrOptions) {
19
- const options = optionsOrFn !== null && typeof optionsOrFn === 'object' ? optionsOrFn : fnOrOptions
20
- const length = collector.tasks.length
21
- const result = original.apply(this, arguments)
22
- if ((options?.retry !== undefined || collector.options?.retry !== undefined) && collector.tasks.length > length) {
23
- const task = collector.tasks.at(-1)
24
- task.meta = { ...task.meta, __ddTestOptNativeRetry: true }
25
- }
26
- return result
27
- }
28
- const push = collector.tasks.push
29
- collector.tasks.push = function (...tasks) {
30
- for (const task of tasks) {
31
- if (task.type === 'collector') trackNativeRetryOptions(task)
32
- }
33
- return push.apply(this, tasks)
34
- }
35
- }
@@ -1,4 +1,5 @@
1
- import { afterEach, beforeAll, beforeEach, inject } from 'vitest'
1
+ const { afterEach, beforeAll, beforeEach, inject } =
2
+ globalThis[Symbol.for('dd-trace.vitest.api')] || await import('vitest')
2
3
 
3
4
  // Instrumentation-less setup for DD_EXPERIMENTAL_TEST_OPT_VITEST_NO_WORKER_INIT.
4
5
  // It applies Test Optimization execution changes without initializing dd-trace and also supports Browser Mode.
@@ -84,9 +85,11 @@ if (isNoWorkerInitActive) {
84
85
  beforeEach(function ({ onTestFinished, task, skip }) {
85
86
  const testSuite = getTestSuite(task)
86
87
  const testName = getTestName(task)
87
- const isAttemptToFixTest = attemptToFixTests[testSuite]?.[testName]
88
+ const annotations = task.meta?.__ddTestOptAnnotations || {}
89
+ const isAttemptToFixTest = attemptToFixTests[testSuite]?.[testName] && !annotations.noAutoRetry
88
90
  const isEarlyFlakeDetectionTestAttempt = isEarlyFlakeDetectionTask(task)
89
- const isQuarantinedTest = quarantinedTests[testSuite]?.[testName] && !isAttemptToFixTest
91
+ const isQuarantinedTest = quarantinedTests[testSuite]?.[testName] &&
92
+ !annotations.mustFail && !isAttemptToFixTest
90
93
  const attemptIndex = getNextAttemptIndex(task)
91
94
  const attemptStart = now()
92
95
  if (task.retry?.__ddTestOptAtr && retryAttemptIndexByTask.get(task).index === 0) {
@@ -98,7 +101,7 @@ if (isNoWorkerInitActive) {
98
101
  recordTestOptimizationStatus(task, attemptIndex - 1)
99
102
  }
100
103
 
101
- if (!isAttemptToFixTest && disabledTests[testSuite]?.[testName]) {
104
+ if (!isAttemptToFixTest && !annotations.mustFail && disabledTests[testSuite]?.[testName]) {
102
105
  skip('Skipped by Datadog Test Optimization')
103
106
  } else if (isAttemptToFixTest && attemptIndex > 0) {
104
107
  task.result.state = 'run'
@@ -148,13 +151,19 @@ function applyExecutionChanges (suite, isEfdSuiteAdmissionAllowed) {
148
151
 
149
152
  const testSuite = getTestSuite(task)
150
153
  const testName = getTestName(task)
151
- if (attemptToFixTests[testSuite]?.[testName]) {
154
+ const annotations = task.meta?.__ddTestOptAnnotations || {}
155
+ if (annotations.noAutoRetry && !annotations.hasFrameworkRetry &&
156
+ (task.retry?.__ddTestOptAtr || isAutomaticRetryProject(task))) {
157
+ task.retry = 0
158
+ }
159
+ if (attemptToFixTests[testSuite]?.[testName] && !annotations.noAutoRetry) {
152
160
  task.retry = 0
153
161
  task.repeats = attemptToFixRetries
154
162
  task.meta.__ddTestOptAtfRetries = attemptToFixRetries
155
- } else if (disabledTests[testSuite]?.[testName]) {
163
+ } else if (disabledTests[testSuite]?.[testName] && !annotations.mustFail) {
156
164
  task.mode = 'skip'
157
- } else if (isEfdSuiteAdmissionAllowed && isEarlyFlakeDetectionTest(testSuite, testName)) {
165
+ } else if (!annotations.noAutoRetry && isEfdSuiteAdmissionAllowed &&
166
+ isEarlyFlakeDetectionTest(testSuite, testName)) {
158
167
  task.retry = 0
159
168
  task.repeats = earlyFlakeDetectionRetries
160
169
  task.meta.__ddTestOptEfdRetries = earlyFlakeDetectionRetries
@@ -165,6 +174,15 @@ function applyExecutionChanges (suite, isEfdSuiteAdmissionAllowed) {
165
174
  }
166
175
  }
167
176
 
177
+ /** @param {object} task */
178
+ function isAutomaticRetryProject (task) {
179
+ if (!flakyTestRetriesConfiguration) return false
180
+ const projectName = task.file.projectName
181
+ return projectName
182
+ ? flakyTestRetriesConfiguration.projectNames.includes(projectName)
183
+ : flakyTestRetriesConfiguration.includesUnnamedProject
184
+ }
185
+
168
186
  /**
169
187
  * Stops Datadog-managed retries at the initial attempt's duration budget, after the complete lifecycle.
170
188
  *
@@ -383,7 +401,7 @@ function recordTestOptimizationStatus (task, attemptIndex = task.result?.repeatC
383
401
  const testSuite = getTestSuite(task)
384
402
  const testName = getTestName(task)
385
403
 
386
- if (attemptToFixTests[testSuite]?.[testName]) {
404
+ if (attemptToFixTests[testSuite]?.[testName] && !task.meta?.__ddTestOptAnnotations?.noAutoRetry) {
387
405
  recordAttemptToFixStatus(task, attemptIndex, onlyIfNewErrors)
388
406
  } else if (isEarlyFlakeDetectionTask(task)) {
389
407
  recordEarlyFlakeDetectionStatus(task, attemptIndex, onlyIfNewErrors)
@@ -564,7 +582,7 @@ function getFinalAttemptIndex (task) {
564
582
  const testSuite = getTestSuite(task)
565
583
  const testName = getTestName(task)
566
584
 
567
- if (attemptToFixTests[testSuite]?.[testName]) {
585
+ if (attemptToFixTests[testSuite]?.[testName] && !task.meta?.__ddTestOptAnnotations?.noAutoRetry) {
568
586
  return getAttemptToFixRetryCount(task)
569
587
  }
570
588
  if (isEarlyFlakeDetectionTask(task)) {
@@ -589,7 +607,8 @@ function switchQuarantinedFinalFailure (task) {
589
607
  const testName = getTestName(task)
590
608
  if (
591
609
  !quarantinedTests[testSuite]?.[testName] ||
592
- attemptToFixTests[testSuite]?.[testName] ||
610
+ task.meta?.__ddTestOptAnnotations?.mustFail ||
611
+ (attemptToFixTests[testSuite]?.[testName] && !task.meta?.__ddTestOptAnnotations?.noAutoRetry) ||
593
612
  task.result?.state !== 'fail'
594
613
  ) {
595
614
  return
@@ -615,7 +634,8 @@ function markQuarantinedFailure (task) {
615
634
  const testName = getTestName(task)
616
635
  if (
617
636
  !quarantinedTests[testSuite]?.[testName] ||
618
- attemptToFixTests[testSuite]?.[testName] ||
637
+ task.meta?.__ddTestOptAnnotations?.mustFail ||
638
+ (attemptToFixTests[testSuite]?.[testName] && !task.meta?.__ddTestOptAnnotations?.noAutoRetry) ||
619
639
  task.result?.state !== 'fail'
620
640
  ) {
621
641
  return
@@ -768,9 +788,11 @@ function getEarlyFlakeDetectionSuiteCandidate (suite) {
768
788
 
769
789
  const testSuite = getTestSuite(task)
770
790
  const testName = getTestName(task)
791
+ const annotations = task.meta?.__ddTestOptAnnotations || {}
771
792
  if (
793
+ annotations.noAutoRetry ||
772
794
  attemptToFixTests[testSuite]?.[testName] ||
773
- disabledTests[testSuite]?.[testName] ||
795
+ (disabledTests[testSuite]?.[testName] && !annotations.mustFail) ||
774
796
  !isEarlyFlakeDetectionTest(testSuite, testName)
775
797
  ) {
776
798
  continue
@@ -1,3 +1,9 @@
1
+ import { test, TestRunner } from 'vitest'
2
+
3
+ import { captureDeclarations } from './vitest-no-worker-init-annotations.mjs'
4
+
5
+ captureDeclarations(test, TestRunner.getCurrentSuite)
6
+
1
7
  globalThis[Symbol.for('dd-trace.vitest.browser-context-importer')] = () => import('vitest/browser')
2
8
  globalThis[Symbol.for('dd-trace.vitest.skip-task')] = skip => skip('Skipped by Datadog Test Optimization')
3
9
 
package/ext/exporters.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
  module.exports = {
3
3
  LOG: 'log',
4
+ LLMOBS: 'llmobs',
4
5
  AGENT: 'agent',
5
6
  AGENTLESS: 'agentless',
6
7
  DATADOG: 'datadog',
package/index.d.ts CHANGED
@@ -357,6 +357,7 @@ interface Plugins {
357
357
  "postgres": tracer.plugins.postgres;
358
358
  "prisma": tracer.plugins.prisma;
359
359
  "protobufjs": tracer.plugins.protobufjs;
360
+ "react-router": tracer.plugins.react_router;
360
361
  "redis": tracer.plugins.redis;
361
362
  "restify": tracer.plugins.restify;
362
363
  "rhea": tracer.plugins.rhea;
@@ -365,6 +366,7 @@ interface Plugins {
365
366
  "sharedb": tracer.plugins.sharedb;
366
367
  "supabase": tracer.plugins.supabase;
367
368
  "tedious": tracer.plugins.tedious;
369
+ "typesafe": tracer.plugins.typesafe;
368
370
  "undici": tracer.plugins.undici;
369
371
  "vitest": tracer.plugins.vitest;
370
372
  "web": tracer.plugins.web;
@@ -3248,6 +3250,17 @@ declare namespace tracer {
3248
3250
  */
3249
3251
  interface protobufjs extends Integration {}
3250
3252
 
3253
+ /**
3254
+ * This plugin automatically instruments
3255
+ * [React Router](https://reactrouter.com/) Framework Mode via the
3256
+ * ServerInstrumentation API (`createRequestHandler`), tagging Express/http
3257
+ * spans with parameterized routes and creating loader/action child spans.
3258
+ *
3259
+ * Requires `react-router` >= 7.9.5 (stable `instrumentations` in >= 7.15).
3260
+ * Configure request span options on `http` or the host framework integration.
3261
+ */
3262
+ interface react_router extends Pick<Instrumentation, 'enabled' | 'measured'> {}
3263
+
3251
3264
  /**
3252
3265
  * This plugin automatically instruments the
3253
3266
  * [redis](https://github.com/NodeRedis/node_redis) module.
@@ -3353,6 +3366,12 @@ declare namespace tracer {
3353
3366
  */
3354
3367
  interface tedious extends Instrumentation {}
3355
3368
 
3369
+ /**
3370
+ * This plugin automatically instruments the
3371
+ * [@typesafe-ai/sdk](https://www.npmjs.com/package/@typesafe-ai/sdk) module.
3372
+ */
3373
+ interface typesafe extends Instrumentation, LLMObsIntegration {}
3374
+
3356
3375
  /**
3357
3376
  * This plugin automatically instruments the
3358
3377
  * [undici](https://github.com/nodejs/undici) module.