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
@@ -960,10 +960,10 @@ function getJitDefaultArguments (rootCtx, descriptor, argumentFactory, mutable)
960
960
  if (mutable) {
961
961
  return argumentFactory === undefined
962
962
  ? {}
963
- : argumentFactory(rootCtx.variableValues, cloneArgumentValue)
963
+ : argumentFactory(rootCtx.variableValues, cloneArgumentValue, descriptor)
964
964
  }
965
965
  if (descriptor.hasArgumentVariables) {
966
- return argumentFactory(rootCtx.variableValues)
966
+ return argumentFactory(rootCtx.variableValues, undefined, descriptor)
967
967
  }
968
968
  return descriptor.staticArguments
969
969
  }
@@ -53,7 +53,7 @@ function getRequestCache (owner, configuredLimit) {
53
53
 
54
54
  /**
55
55
  * @param {string | null | undefined} operationName
56
- * @param {boolean} calculateSignature
56
+ * @param {boolean | undefined} calculateSignature
57
57
  */
58
58
  function operationCacheKey (operationName, calculateSignature) {
59
59
  return `${calculateSignature === false ? 0 : 1}\n${operationName ?? ''}`
@@ -62,7 +62,7 @@ function operationCacheKey (operationName, calculateSignature) {
62
62
  /**
63
63
  * @param {unknown} source
64
64
  * @param {string | null | undefined} operationName
65
- * @param {boolean} calculateSignature
65
+ * @param {boolean | undefined} calculateSignature
66
66
  * @param {RequestCache | undefined} requestCache
67
67
  * @returns {RequestOperation | undefined}
68
68
  */
@@ -156,7 +156,7 @@ function refineRequestSpanMetadata (requestSpan, signature, type, name) {
156
156
  * @param {import('graphql').DocumentNode | undefined} document
157
157
  * @param {unknown} requestSource
158
158
  * @param {string | null | undefined} operationName
159
- * @param {boolean} calculateSignature
159
+ * @param {boolean | undefined} calculateSignature
160
160
  * @param {boolean} validated
161
161
  * @param {RequestCache | undefined} requestCache
162
162
  */
@@ -193,7 +193,7 @@ function refineRequestSpan (
193
193
  * @param {RequestCache} requestCache
194
194
  * @param {string | object} source
195
195
  * @param {string | null | undefined} operationName
196
- * @param {boolean} calculateSignature
196
+ * @param {boolean | undefined} calculateSignature
197
197
  * @param {RequestOperation} operation
198
198
  * @param {import('graphql').DocumentNode} document
199
199
  */
@@ -229,7 +229,7 @@ function cacheRequestOperation (
229
229
  /**
230
230
  * @param {import('graphql').DocumentNode} document
231
231
  * @param {string | null | undefined} operationName
232
- * @param {boolean} calculateSignature
232
+ * @param {boolean | undefined} calculateSignature
233
233
  * @returns {RequestOperation | undefined}
234
234
  */
235
235
  function getRequestOperation (document, operationName, calculateSignature) {
@@ -36,6 +36,8 @@ const {
36
36
  TEST_MANAGEMENT_ENABLED,
37
37
  TEST_MANAGEMENT_IS_QUARANTINED,
38
38
  TEST_MANAGEMENT_IS_DISABLED,
39
+ TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION,
40
+ TEST_MANAGEMENT_NO_AUTO_RETRY,
39
41
  TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
40
42
  TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
41
43
  TEST_HAS_FAILED_ALL_RETRIES,
@@ -436,6 +438,7 @@ class JestPlugin extends CiPlugin {
436
438
  attemptToFixFailed,
437
439
  isAtrRetry,
438
440
  finalStatus,
441
+ deferredFinish,
439
442
  earlyFlakeAbortReason,
440
443
  promises,
441
444
  }) => {
@@ -468,6 +471,20 @@ class JestPlugin extends CiPlugin {
468
471
  this.getTestTelemetryTags(span)
469
472
  )
470
473
 
474
+ if (deferredFinish) {
475
+ // Native describe retries can stop after later process errors or hooks.
476
+ // Delay publication, not the execution's monotonic end time or child cleanup.
477
+ const finishTime = span._getTime()
478
+ finishAllTraceSpans(span)
479
+ this.activeTestSpan = null
480
+ deferredFinish.finish = finalStatus => {
481
+ if (finalStatus) span.setTag(TEST_FINAL_STATUS, finalStatus)
482
+ span.finish(finishTime)
483
+ if (finalStatus) this.cancelDiBreakpointHitWait()
484
+ }
485
+ return
486
+ }
487
+
471
488
  const finish = () => {
472
489
  span.finish()
473
490
  finishAllTraceSpans(span)
@@ -562,6 +579,9 @@ class JestPlugin extends CiPlugin {
562
579
  isQuarantined,
563
580
  isModified,
564
581
  hasDynamicName,
582
+ mustFail,
583
+ noAutoRetry,
584
+ assignedManagementProperties,
565
585
  testSuiteAbsolutePath,
566
586
  } = test
567
587
 
@@ -570,6 +590,8 @@ class JestPlugin extends CiPlugin {
570
590
  [TEST_PARAMETERS]: testParameters,
571
591
  [TEST_FRAMEWORK_VERSION]: frameworkVersion,
572
592
  }
593
+ if (mustFail) extraTags[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] = 'true'
594
+ if (noAutoRetry) extraTags[TEST_MANAGEMENT_NO_AUTO_RETRY] = 'true'
573
595
  if (testStartLine) {
574
596
  extraTags[TEST_SOURCE_START] = testStartLine
575
597
  }
@@ -580,7 +602,7 @@ class JestPlugin extends CiPlugin {
580
602
  extraTags[JEST_DISPLAY_NAME] = displayName
581
603
  }
582
604
 
583
- if (isAttemptToFix) {
605
+ if (assignedManagementProperties?.isAttemptToFix ?? isAttemptToFix) {
584
606
  extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
585
607
  }
586
608
 
@@ -595,11 +617,11 @@ class JestPlugin extends CiPlugin {
595
617
  extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.ext
596
618
  }
597
619
 
598
- if (isDisabled) {
620
+ if (assignedManagementProperties?.isDisabled ?? isDisabled) {
599
621
  extraTags[TEST_MANAGEMENT_IS_DISABLED] = 'true'
600
622
  }
601
623
 
602
- if (isQuarantined) {
624
+ if (assignedManagementProperties?.isQuarantined ?? isQuarantined) {
603
625
  extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
604
626
  }
605
627
 
@@ -16,6 +16,7 @@ const {
16
16
  getDynamicAtrRetryCount,
17
17
  } = require('../../dd-trace/src/ci-visibility/dynamic-atr-retries')
18
18
  const { FINAL_FLUSH_TIMEOUT } = require('../../dd-trace/src/ci-visibility/final-flush')
19
+ const { getTestAnnotations, copyTestAnnotations } = require('../../dd-trace/src/ci-visibility/test-annotations')
19
20
  const {
20
21
  SCREENSHOT_UPLOAD_RESULT_ERROR,
21
22
  SCREENSHOT_UPLOAD_RESULT_UPLOADED,
@@ -283,6 +284,7 @@ class MochaPlugin extends CiPlugin {
283
284
  static id = 'mocha'
284
285
 
285
286
  #pendingWebdriverioVideos = new Set()
287
+ #webdriverioJasmineAnnotations = new Map()
286
288
  #webdriverioCapture
287
289
  #webdriverioVideoFlushTimer
288
290
 
@@ -402,6 +404,7 @@ class MochaPlugin extends CiPlugin {
402
404
  suiteFiles: new Map(),
403
405
  suiteStatuses: new Map(),
404
406
  tests: new Map(),
407
+ testAnnotations: this.#webdriverioJasmineAnnotations,
405
408
  }
406
409
  }
407
410
  })
@@ -414,6 +417,29 @@ class MochaPlugin extends CiPlugin {
414
417
  setWebdriverioRumTestCorrelation(ctx, activeSpan)
415
418
  })
416
419
 
420
+ this.addSub('tracing:orchestrion:@wdio/jasmine-framework:JasmineAdapter_init:start', () => {
421
+ // Declarations run during adapter initialization, before coordinator settings arrive.
422
+ this.#webdriverioJasmineAnnotations = new Map()
423
+ })
424
+
425
+ this.addSub('tracing:orchestrion:@wdio/utils:runSpec:end', (ctx) => {
426
+ if (!ctx.result?.id) return
427
+ const annotations = getTestAnnotations(ctx.arguments?.[1])
428
+ if (annotations.mustFail || annotations.noAutoRetry) {
429
+ if (ctx.result.type === 'test') {
430
+ if (ctx.result.fn) {
431
+ // Mocha's runnable holds WebdriverIO's wrapper rather than the annotated callback.
432
+ copyTestAnnotations(ctx.arguments[1], ctx.result.fn)
433
+ } else {
434
+ // Mocha discards callbacks inherited from a pending suite.
435
+ ctx.result._ddDeclaredAnnotations = annotations
436
+ }
437
+ } else {
438
+ this.#webdriverioJasmineAnnotations.set(ctx.result.id, annotations)
439
+ }
440
+ }
441
+ })
442
+
417
443
  this.addBind(jasmineTestFunctionStartCh, (ctx) => {
418
444
  if (this.testFrameworkAdapter !== WEBDRIVERIO_JASMINE_ADAPTER) {
419
445
  return storage('legacy').getStore()
@@ -853,7 +879,7 @@ class MochaPlugin extends CiPlugin {
853
879
  const store = storage('legacy').getStore()
854
880
  // skipped through it.skip, so the span is not created yet
855
881
  // for this test
856
- if (!store) {
882
+ if (!ctx.currentStore) {
857
883
  const span = this.startTestSpan(ctx)
858
884
 
859
885
  ctx.parentStore = store
@@ -1139,9 +1165,14 @@ class MochaPlugin extends CiPlugin {
1139
1165
  const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
1140
1166
  const properties = this.libraryConfig?.testManagementTests?.mocha
1141
1167
  ?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
1142
- const isAttemptToFix = this.libraryConfig?.isTestManagementTestsEnabled && properties.attempt_to_fix
1143
- const isDisabled = this.libraryConfig?.isTestManagementTestsEnabled && properties.disabled
1144
- const isQuarantined = this.libraryConfig?.isTestManagementTestsEnabled && properties.quarantined
1168
+ const testAnnotations = state.testAnnotations.get(result.id) || getTestAnnotations()
1169
+ const assignedProperties = this.libraryConfig?.isTestManagementTestsEnabled ? properties : undefined
1170
+ const isAttemptToFix = this.libraryConfig?.isTestManagementTestsEnabled &&
1171
+ !testAnnotations.noAutoRetry && properties.attempt_to_fix
1172
+ const isDisabled = this.libraryConfig?.isTestManagementTestsEnabled &&
1173
+ !testAnnotations.mustFail && properties.disabled
1174
+ const isQuarantined = this.libraryConfig?.isTestManagementTestsEnabled &&
1175
+ !testAnnotations.mustFail && properties.quarantined
1145
1176
  const isModified = this.libraryConfig?.isImpactedTestsEnabled && isModifiedTest(
1146
1177
  getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot || this.sourceRoot),
1147
1178
  null,
@@ -1152,10 +1183,10 @@ class MochaPlugin extends CiPlugin {
1152
1183
  const knownTests = this.libraryConfig?.knownTests?.mocha
1153
1184
  const isNew = this.libraryConfig?.isKnownTestsEnabled && knownTests &&
1154
1185
  !(knownTests[testSuite] || []).includes(testName)
1155
- const isEarlyFlakeDetection = this.libraryConfig?.isEarlyFlakeDetectionEnabled &&
1186
+ const isEarlyFlakeDetection = !testAnnotations.noAutoRetry && this.libraryConfig?.isEarlyFlakeDetectionEnabled &&
1156
1187
  hasEfdRetries(this.libraryConfig.earlyFlakeDetectionRetryPolicy) &&
1157
1188
  !isAttemptToFix && !isDisabled && (isNew || isModified)
1158
- const isAtr = this.libraryConfig?.isFlakyTestRetriesEnabled &&
1189
+ const isAtr = !testAnnotations.noAutoRetry && this.libraryConfig?.isFlakyTestRetriesEnabled &&
1159
1190
  !isAttemptToFix && !isEarlyFlakeDetection
1160
1191
  let retryCount = 0
1161
1192
  if (isAttemptToFix) {
@@ -1177,6 +1208,8 @@ class MochaPlugin extends CiPlugin {
1177
1208
  }
1178
1209
 
1179
1210
  const test = {
1211
+ assignedProperties,
1212
+ testAnnotations,
1180
1213
  attempt: 0,
1181
1214
  attemptStart: undefined,
1182
1215
  currentStore: undefined,
@@ -1242,6 +1275,8 @@ class MochaPlugin extends CiPlugin {
1242
1275
  test.attemptStart = performance.now()
1243
1276
  test.hasFinalHookFailure = false
1244
1277
  const span = this.startTestSpan({
1278
+ assignedProperties: test.assignedProperties,
1279
+ testAnnotations: test.testAnnotations,
1245
1280
  hasDynamicName: test.hasDynamicName,
1246
1281
  isAttemptToFix: test.isAttemptToFix,
1247
1282
  isDisabled: test.isDisabled,
@@ -1923,6 +1958,12 @@ class MochaPlugin extends CiPlugin {
1923
1958
  } = testInfo
1924
1959
 
1925
1960
  const extraTags = {}
1961
+ const { testAnnotations, assignedProperties } = testInfo
1962
+ if (testAnnotations?.mustFail) extraTags['test.test_management.prevent_failure_suppression'] = 'true'
1963
+ if (testAnnotations?.noAutoRetry) extraTags['test.test_management.no_auto_retry'] = 'true'
1964
+ if (assignedProperties?.attempt_to_fix) extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
1965
+ if (assignedProperties?.disabled) extraTags[TEST_MANAGEMENT_IS_DISABLED] = 'true'
1966
+ if (assignedProperties?.quarantined) extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
1926
1967
  const testParametersString = getTestParametersString(this._testTitleToParams, title)
1927
1968
  if (testParametersString) {
1928
1969
  extraTags[TEST_PARAMETERS] = testParametersString
@@ -4,6 +4,8 @@ const { URL } = require('url')
4
4
  const log = require('../../dd-trace/src/log')
5
5
 
6
6
  const easyConnectProtocol = /^tcps?:\/\//i
7
+ let cachedConnectString
8
+ let cachedInfo
7
9
 
8
10
  function parseOracleDescriptor (descriptor) {
9
11
  const hostnameMatch = descriptor.match(/HOST\s*=\s*([^)]+)/i)
@@ -22,18 +24,26 @@ function parseOracleDescriptor (descriptor) {
22
24
  module.exports = function getDBInformation (connAttrs) {
23
25
  // Users can pass either connectString or connectionString
24
26
  const connectString = ((connAttrs.connectString || connAttrs.connectionString) ?? '').trim()
27
+ if (connectString === cachedConnectString) return cachedInfo
28
+
29
+ let dbInfo
25
30
  if (connectString.startsWith('(')) {
26
- return parseOracleDescriptor(connectString)
27
- }
28
- try {
29
- const url = new URL(easyConnectProtocol.test(connectString) ? connectString : `oracle://${connectString}`)
30
- return {
31
- hostname: url.hostname || 'localhost', // Default Oracle hostname
32
- port: url.port || '1521', // Default Oracle port
33
- dbInstance: url.pathname && url.pathname.slice(1) || 'XEPDB1', // Default Oracle service name
31
+ dbInfo = parseOracleDescriptor(connectString)
32
+ } else {
33
+ try {
34
+ const url = new URL(easyConnectProtocol.test(connectString) ? connectString : `oracle://${connectString}`)
35
+ dbInfo = {
36
+ hostname: url.hostname || 'localhost', // Default Oracle hostname
37
+ port: url.port || '1521', // Default Oracle port
38
+ dbInstance: url.pathname && url.pathname.slice(1) || 'XEPDB1', // Default Oracle service name
39
+ }
40
+ } catch (error) {
41
+ log.error('Invalid oracle connection string', error)
42
+ return {}
34
43
  }
35
- } catch (error) {
36
- log.error('Invalid oracle connection string', error)
37
- return {}
38
44
  }
45
+
46
+ cachedConnectString = connectString
47
+ cachedInfo = dbInfo
48
+ return dbInfo
39
49
  }
@@ -510,6 +510,8 @@ class PlaywrightPlugin extends CiPlugin {
510
510
  testSourceFileAbsolutePath
511
511
  )
512
512
 
513
+ span.addTags(ctx.extraTags)
514
+
513
515
  if (isDisabled) {
514
516
  span.setTag(TEST_MANAGEMENT_IS_DISABLED, 'true')
515
517
  }
@@ -699,6 +701,7 @@ class PlaywrightPlugin extends CiPlugin {
699
701
  })
700
702
 
701
703
  this.addSub('ci:playwright:test:skip', ({
704
+ extraTags,
702
705
  testName,
703
706
  testSuiteAbsolutePath,
704
707
  testSourceFileAbsolutePath,
@@ -725,6 +728,7 @@ class PlaywrightPlugin extends CiPlugin {
725
728
  testSourceFileAbsolutePath
726
729
  )
727
730
 
731
+ span.addTags(extraTags)
728
732
  span.setTag(TEST_STATUS, 'skip')
729
733
  span.setTag(TEST_FINAL_STATUS, 'skip')
730
734
 
@@ -0,0 +1,118 @@
1
+ 'use strict'
2
+
3
+ const { storage } = require('../../datadog-core')
4
+ const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
5
+ const { getRequest } = require('../../dd-trace/src/appsec/store')
6
+ const { COMPONENT } = require('../../dd-trace/src/constants')
7
+ const log = require('../../dd-trace/src/log')
8
+ const web = require('../../dd-trace/src/plugins/util/web')
9
+ const WebPlugin = require('../../datadog-plugin-web/src')
10
+ const { HTTP_ROUTE, HTTP_URL, RESOURCE_NAME } = require('../../../ext/tags')
11
+
12
+ /**
13
+ * @typedef {{ arguments: unknown[], result: Array<{ route?: { path?: string } }> | null }} RouteMatchContext
14
+ * @typedef {object} HandlerContext
15
+ * @property {string} routeId
16
+ * @property {string} [pattern]
17
+ * @property {(result: unknown, rejected: boolean) => void} [complete]
18
+ */
19
+
20
+ class ReactRouterPlugin extends WebPlugin {
21
+ static id = 'react-router'
22
+
23
+ /**
24
+ * @param {object} tracer
25
+ * @param {import('../../dd-trace/src/config/config-base')} tracerConfig
26
+ */
27
+ constructor (tracer, tracerConfig) {
28
+ super(tracer, tracerConfig)
29
+
30
+ this.addSub('tracing:orchestrion:react-router:matchServerRoutes:end', ctx => {
31
+ this.#setRouteFromMatches(/** @type {RouteMatchContext} */ (ctx))
32
+ })
33
+ this.addBind('apm:react-router:loader:start', ctx => {
34
+ return this.#startHandlerSpan('loader', /** @type {HandlerContext} */ (ctx))
35
+ })
36
+ this.addBind('apm:react-router:action:start', ctx => {
37
+ return this.#startHandlerSpan('action', /** @type {HandlerContext} */ (ctx))
38
+ })
39
+ }
40
+
41
+ /** @param {RouteMatchContext} ctx */
42
+ #setRouteFromMatches (ctx) {
43
+ const matches = ctx.result
44
+ if (!matches?.length) return
45
+
46
+ const store = storage('legacy').getStore()
47
+ const request = getRequest(store) ?? store?.req
48
+ const span = (request && web.root(request)) || web.rootFromSpan(
49
+ /** @type {import('../../dd-trace/src/opentracing/span') | undefined} */ (store?.span)
50
+ )
51
+ if (!span) return
52
+ const httpUrl = /** @type {string} */ (span.context().getTag(HTTP_URL))
53
+
54
+ let pathname
55
+ try {
56
+ pathname = new URL(httpUrl, 'http://localhost').pathname
57
+ } catch (error) {
58
+ log.debug('Skipping React Router route for invalid HTTP URL: %s', error)
59
+ return
60
+ }
61
+ const args = ctx.arguments
62
+ const matchedPathname = typeof args[1] === 'string' ? args[1] : args[3] ?? args[2]
63
+ if (pathname.endsWith('/_root.data') && typeof matchedPathname === 'string' &&
64
+ pathname.toLowerCase() === ((matchedPathname.endsWith('/')
65
+ ? matchedPathname.slice(0, -1)
66
+ : matchedPathname) + '/_root.data').toLowerCase()) {
67
+ pathname = matchedPathname
68
+ } else if (pathname.endsWith('.data')) {
69
+ pathname = pathname.slice(0, -'.data'.length)
70
+ }
71
+ if (pathname.length > 1 && pathname.endsWith('/')) pathname = pathname.slice(0, -1)
72
+
73
+ if (pathname !== matchedPathname && pathname + '/' !== matchedPathname &&
74
+ !(pathname.endsWith('/_') && pathname.slice(0, -1) === matchedPathname)) return
75
+
76
+ let route = ''
77
+ for (const match of matches) {
78
+ const path = match.route?.path
79
+ if (path) route = path.startsWith('/') ? path : route + '/' + path
80
+ }
81
+ route = route.replaceAll(/\/+/g, '/') || '/'
82
+
83
+ span.setTag(HTTP_ROUTE, route)
84
+ }
85
+
86
+ /**
87
+ * @param {'loader' | 'action'} kind
88
+ * @param {HandlerContext} ctx
89
+ */
90
+ #startHandlerSpan (kind, ctx) {
91
+ const store = storage('legacy').getStore()
92
+ const childOf = store?.span
93
+ if (!childOf) return store
94
+
95
+ const span = this.tracer.startSpan('react-router.' + kind, {
96
+ childOf,
97
+ integrationName: ReactRouterPlugin.id,
98
+ tags: {
99
+ [COMPONENT]: ReactRouterPlugin.id,
100
+ [RESOURCE_NAME]: ctx.pattern,
101
+ 'react-router.route_id': ctx.routeId,
102
+ },
103
+ })
104
+ analyticsSampler.sample(span, this.config.measured, true)
105
+
106
+ ctx.complete = (result, rejected) => {
107
+ const outcome = /** @type {{ status?: string, error?: Error }} */ (result)
108
+ const error = rejected ? result : outcome?.status === 'error' ? outcome.error : undefined
109
+ if (error !== undefined && !span.context().getTag('error')) {
110
+ span.setTag('error', error)
111
+ }
112
+ span.finish()
113
+ }
114
+ return { ...store, span }
115
+ }
116
+ }
117
+
118
+ module.exports = ReactRouterPlugin
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
+ const TypeSafeLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/typesafe')
5
+ const TypeSafeTracingPlugin = require('./tracing')
6
+
7
+ class TypeSafePlugin extends CompositePlugin {
8
+ static id = 'typesafe'
9
+ static get plugins () {
10
+ return {
11
+ llmobs: TypeSafeLLMObsPlugin,
12
+ tracing: TypeSafeTracingPlugin,
13
+ }
14
+ }
15
+ }
16
+
17
+ module.exports = TypeSafePlugin
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
+
5
+ class TypeSafeTracingPlugin extends TracingPlugin {
6
+ static id = 'typesafe'
7
+ static operation = 'request'
8
+ static system = 'typesafe'
9
+ static prefix = 'tracing:orchestrion:@typesafe-ai/sdk:TypeSafeClient_systemOne'
10
+
11
+ bindStart (ctx) {
12
+ this.startSpan('typesafe.request', {
13
+ meta: {
14
+ 'resource.name': 'TypeSafeClient.systemOne',
15
+ 'typesafe.request.model': ctx.arguments?.[0]?.model ?? ctx.self?.defaultModel,
16
+ },
17
+ }, ctx)
18
+
19
+ return ctx.currentStore
20
+ }
21
+
22
+ asyncEnd (ctx) {
23
+ const span = ctx.currentStore?.span
24
+ if (!span) return
25
+
26
+ if (ctx.result?.model) span.setTag('typesafe.response.model', ctx.result.model)
27
+ span.finish()
28
+ }
29
+ }
30
+
31
+ module.exports = TypeSafeTracingPlugin
@@ -29,6 +29,8 @@ const {
29
29
  TEST_MANAGEMENT_IS_QUARANTINED,
30
30
  TEST_MANAGEMENT_IS_DISABLED,
31
31
  TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
32
+ TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION,
33
+ TEST_MANAGEMENT_NO_AUTO_RETRY,
32
34
  TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
33
35
  TEST_HAS_FAILED_ALL_RETRIES,
34
36
  getLibraryCapabilitiesTags: getDefaultLibraryCapabilitiesTags,
@@ -118,6 +120,7 @@ class VitestPlugin extends CiPlugin {
118
120
  isAttemptToFix,
119
121
  isQuarantined,
120
122
  isDisabled,
123
+ annotations,
121
124
  mightHitProbe,
122
125
  isRetryReasonEfd,
123
126
  isRetryReasonAttemptToFix,
@@ -162,6 +165,8 @@ class VitestPlugin extends CiPlugin {
162
165
  if (hasDynamicName) {
163
166
  extraTags[TEST_HAS_DYNAMIC_NAME] = 'true'
164
167
  }
168
+ if (annotations?.mustFail) extraTags[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] = 'true'
169
+ if (annotations?.noAutoRetry) extraTags[TEST_MANAGEMENT_NO_AUTO_RETRY] = 'true'
165
170
  if (isAttemptToFix) {
166
171
  extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
167
172
  }
@@ -344,6 +349,7 @@ class VitestPlugin extends CiPlugin {
344
349
  isAttemptToFix,
345
350
  isDisabled,
346
351
  isQuarantined,
352
+ annotations,
347
353
  isRumActive,
348
354
  isTestFrameworkWorker,
349
355
  requestErrorTags,
@@ -365,6 +371,8 @@ class VitestPlugin extends CiPlugin {
365
371
  [TEST_STATUS]: 'skip',
366
372
  [TEST_FINAL_STATUS]: 'skip',
367
373
  }
374
+ if (annotations?.mustFail) extraTags[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] = 'true'
375
+ if (annotations?.noAutoRetry) extraTags[TEST_MANAGEMENT_NO_AUTO_RETRY] = 'true'
368
376
  if (isAttemptToFix) extraTags[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] = 'true'
369
377
  if (isDisabled) extraTags[TEST_MANAGEMENT_IS_DISABLED] = 'true'
370
378
  if (isQuarantined) extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
@@ -17,7 +17,8 @@ module.exports = {
17
17
  * Fetches agent information from the /info endpoint
18
18
  * @param {URL} url - The agent URL
19
19
  * @param {Function} callback - Callback function with signature (err, agentInfo)
20
- * @param {{ deadline?: number, signal?: AbortSignal, path?: string, retry?: boolean }} [options]
20
+ * @param {{ deadline?: number, keepProcessAlive?: boolean, signal?: AbortSignal, path?: string, retry?: boolean }}
21
+ * [options]
21
22
  * Request finalization and routing options
22
23
  * @param {Function} [makeRequest] - Request implementation
23
24
  */
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const log = require('../log')
4
3
  const AIGuardClient = require('./client')
5
4
  const { createEvaluationOutcome, EvaluationReporter } = require('./evaluation')
6
5
  const { AIGuardAbortError } = require('./errors')
@@ -8,7 +7,6 @@ const NoopAIGuard = require('./noop')
8
7
  const TAGS = require('./tags')
9
8
 
10
9
  class AIGuard extends NoopAIGuard {
11
- #initialized
12
10
  #tracer
13
11
  #client
14
12
  #reporter
@@ -22,23 +20,14 @@ class AIGuard extends NoopAIGuard {
22
20
  constructor (tracer, config) {
23
21
  super()
24
22
 
25
- if (!config.DD_API_KEY || !config.DD_APP_KEY) {
26
- log.error('AIGuard: missing api and/or app keys, use env DD_API_KEY and DD_APP_KEY')
27
- this.#initialized = false
28
- return
29
- }
30
23
  this.#tracer = tracer
31
24
  this.#client = new AIGuardClient(config)
32
25
  this.#reporter = new EvaluationReporter(config)
33
26
  this.#redactionEnabled = config.aiguard.DD_AI_GUARD_REDACTION_ENABLED
34
27
  this.#meta = { service: config.service, env: config.env }
35
- this.#initialized = true
36
28
  }
37
29
 
38
30
  evaluate (messages, opts) {
39
- if (!this.#initialized) {
40
- return super.evaluate(messages, opts)
41
- }
42
31
  const { block = true, source = TAGS.SOURCE_SDK, integration = TAGS.INTEGRATION_NONE, childOf } = opts ?? {}
43
32
  // Only pass `childOf` when truthy so `tracer.trace`'s default (`scope().active()`)
44
33
  // still applies for SDK callers that don't supply an explicit parent.
@@ -1,8 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const getConfig = require('../../config')
4
- const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
5
- const { joinEVPProxyPath } = require('../../evp_proxy/path')
6
4
  const id = require('../../id')
7
5
  const log = require('../../log')
8
6
  const {
@@ -16,6 +14,7 @@ const {
16
14
  } = require('../../ci-visibility/telemetry')
17
15
  const { getNumFromKnownTests } = require('../../plugins/util/test')
18
16
  const request = require('../requests/request')
17
+ const { createApiRequestRoute } = require('../requests/route')
19
18
  const { buildCacheKey, writeToCache, withCache } = require('../requests/fs-cache')
20
19
  const { validateKnownTestsResponse } = require('../test-optimization-http-cache-schema')
21
20
 
@@ -147,32 +146,26 @@ function fetchFromApi ({
147
146
  custom,
148
147
  cacheKey,
149
148
  }, done) {
149
+ const path = '/api/v2/ci/libraries/tests'
150
+ const route = createApiRequestRoute(getConfig(), { url, path, isEvpProxy, evpProxyPrefix })
151
+ if (!route) {
152
+ return done(new Error('Known tests were not fetched because Datadog API key is not defined.'))
153
+ }
154
+
150
155
  const options = {
151
- path: '/api/v2/ci/libraries/tests',
156
+ ...route,
152
157
  method: 'POST',
153
158
  headers: {
159
+ ...route.headers,
154
160
  'Content-Type': 'application/json',
155
161
  },
156
162
  timeout: 20_000,
157
- url,
158
163
  }
159
164
 
160
165
  if (isGzipCompatible) {
161
166
  options.headers['accept-encoding'] = 'gzip'
162
167
  }
163
168
 
164
- if (isEvpProxy) {
165
- options.path = joinEVPProxyPath(evpProxyPrefix, '/api/v2/ci/libraries/tests')
166
- options.headers[EVP_SUBDOMAIN_HEADER_NAME] = 'api'
167
- } else {
168
- const { DD_API_KEY } = getConfig()
169
- if (!DD_API_KEY) {
170
- return done(new Error('Known tests were not fetched because Datadog API key is not defined.'))
171
- }
172
-
173
- options.headers['dd-api-key'] = DD_API_KEY
174
- }
175
-
176
169
  const configurations = {
177
170
  'os.platform': osPlatform,
178
171
  'os.version': osVersion,
@@ -27,6 +27,7 @@ const {
27
27
  } = require('../requests/upload-test-screenshot')
28
28
  const { parsers } = require('../../config/parsers')
29
29
  const log = require('../../log')
30
+ const telemetry = require('../../telemetry')
30
31
  const { getSegment } = require('../../util')
31
32
  const BufferingExporter = require('../../exporters/common/buffering-exporter')
32
33
  const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('../../plugins/util/tags')
@@ -264,7 +265,8 @@ class CiVisibilityExporter extends BufferingExporter {
264
265
  }
265
266
  })
266
267
 
267
- globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(() => this.flush(() => {}))
268
+ // Final upload errors are recorded after telemetry's initial app-closing drain.
269
+ globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(() => this.flush(() => telemetry.flush()))
268
270
  }
269
271
 
270
272
  shouldRequestSkippableSuites () {
@@ -624,7 +626,7 @@ class CiVisibilityExporter extends BufferingExporter {
624
626
  repositoryUrl,
625
627
  (err) => {
626
628
  if (err) {
627
- log.error('Error uploading git metadata: %s', err.message)
629
+ log.error('Error uploading git metadata', err)
628
630
  } else {
629
631
  log.debug('Successfully uploaded git metadata')
630
632
  }