dd-trace 5.133.0 → 5.135.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 (194) 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 -5
  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 +35 -5
  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 +23 -20
  31. package/packages/datadog-core/src/storage.js +1 -1
  32. package/packages/datadog-esbuild/index.js +70 -7
  33. package/packages/datadog-instrumentations/index.js +2 -1
  34. package/packages/datadog-instrumentations/src/cucumber.js +64 -21
  35. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  36. package/packages/datadog-instrumentations/src/graphql.js +9 -3
  37. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  38. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +27 -8
  39. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  40. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  41. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
  42. package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +10 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +13 -0
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
  55. package/packages/datadog-instrumentations/src/jest.js +332 -137
  56. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  57. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  58. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  59. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  60. package/packages/datadog-instrumentations/src/mocha/utils.js +92 -13
  61. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  62. package/packages/datadog-instrumentations/src/nova-sonic/session.js +25 -16
  63. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  64. package/packages/datadog-instrumentations/src/pg.js +2 -1
  65. package/packages/datadog-instrumentations/src/playwright.js +81 -26
  66. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  67. package/packages/datadog-instrumentations/src/stripe.js +23 -12
  68. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  69. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -47
  70. package/packages/datadog-instrumentations/src/vitest-main.js +33 -3
  71. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  72. package/packages/datadog-instrumentations/src/vitest-util.js +5 -2
  73. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  74. package/packages/datadog-instrumentations/src/vitest.js +16 -6
  75. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  76. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +277 -44
  77. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  78. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  79. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  80. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  81. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  82. package/packages/datadog-plugin-cypress/src/support.js +1217 -437
  83. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  84. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  85. package/packages/datadog-plugin-jest/src/index.js +25 -3
  86. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  87. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  88. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  89. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  90. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  91. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  92. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  93. package/packages/dd-trace/src/agent/info.js +2 -1
  94. package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
  95. package/packages/dd-trace/src/aiguard/sdk.js +0 -11
  96. package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
  97. package/packages/dd-trace/src/appsec/stack_trace.js +3 -2
  98. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
  99. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
  100. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
  101. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
  102. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
  103. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  104. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  105. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  106. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  107. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
  108. package/packages/dd-trace/src/config/defaults.js +4 -3
  109. package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
  110. package/packages/dd-trace/src/config/index.js +140 -39
  111. package/packages/dd-trace/src/config/parsers.js +9 -1
  112. package/packages/dd-trace/src/config/supported-configurations.json +25 -0
  113. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
  114. package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
  115. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
  116. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  117. package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
  118. package/packages/dd-trace/src/encode/0.4.js +2 -2
  119. package/packages/dd-trace/src/esm-module-load.js +58 -0
  120. package/packages/dd-trace/src/exporter.js +25 -6
  121. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  122. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  123. package/packages/dd-trace/src/exporters/common/request.js +4 -4
  124. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  125. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  126. package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
  127. package/packages/dd-trace/src/llmobs/constants/tags.js +4 -0
  128. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  129. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  130. package/packages/dd-trace/src/llmobs/index.js +13 -2
  131. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  132. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  133. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +8 -4
  134. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
  135. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +9 -1
  136. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  137. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  138. package/packages/dd-trace/src/llmobs/sdk.js +17 -5
  139. package/packages/dd-trace/src/llmobs/span_processor.js +222 -12
  140. package/packages/dd-trace/src/llmobs/tagger.js +21 -8
  141. package/packages/dd-trace/src/llmobs/util.js +10 -4
  142. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  143. package/packages/dd-trace/src/log/writer.js +7 -1
  144. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
  145. package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
  146. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  147. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  148. package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
  149. package/packages/dd-trace/src/openfeature/index.js +6 -0
  150. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  151. package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
  152. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  153. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  154. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  155. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  156. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  157. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  158. package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
  159. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  160. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +18 -1
  161. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  162. package/packages/dd-trace/src/opentracing/tracer.js +9 -13
  163. package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
  164. package/packages/dd-trace/src/plugin_manager.js +1 -2
  165. package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
  166. package/packages/dd-trace/src/plugins/index.js +3 -0
  167. package/packages/dd-trace/src/plugins/tracing.js +1 -2
  168. package/packages/dd-trace/src/plugins/util/git.js +102 -40
  169. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
  170. package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
  171. package/packages/dd-trace/src/plugins/util/test.js +28 -6
  172. package/packages/dd-trace/src/plugins/util/web.js +106 -20
  173. package/packages/dd-trace/src/process-tags/index.js +1 -1
  174. package/packages/dd-trace/src/profiling/config.js +6 -3
  175. package/packages/dd-trace/src/proxy.js +15 -4
  176. package/packages/dd-trace/src/serverless.js +3 -2
  177. package/packages/dd-trace/src/span_processor.js +21 -9
  178. package/packages/dd-trace/src/span_stats.js +32 -3
  179. package/packages/dd-trace/src/startup-log.js +2 -1
  180. package/packages/dd-trace/src/tagger.js +7 -5
  181. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  182. package/packages/dd-trace/src/telemetry/index.js +3 -0
  183. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  184. package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -1
  185. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  186. package/packages/dd-trace/src/util.js +9 -5
  187. package/register.js +2 -1
  188. package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
  189. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  190. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  191. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  192. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  193. package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
  194. package/vendor/dist/@opentelemetry/resources/index.js +0 -1
@@ -3,8 +3,10 @@
3
3
  const os = require('os')
4
4
  const path = require('path')
5
5
  const fs = require('fs')
6
+ const { execFileSync } = require('node:child_process')
6
7
 
7
8
  const log = require('../../log')
9
+ const { getEnvironmentVariables } = require('../../config/helper')
8
10
  const {
9
11
  incrementCountMetric,
10
12
  distributionMetric,
@@ -49,7 +51,8 @@ function sanitizedExec (
49
51
  operationMetric,
50
52
  durationMetric,
51
53
  errorMetric,
52
- shouldTrim = true
54
+ shouldTrim = true,
55
+ executionOptions
53
56
  ) {
54
57
  return legacyStorage.run({ noop: true }, () => {
55
58
  let startTime
@@ -60,7 +63,14 @@ function sanitizedExec (
60
63
  startTime = Date.now()
61
64
  }
62
65
  try {
63
- let result = cachedExec('git', flags, { stdio: 'pipe' }).toString()
66
+ const exec = executionOptions?.uncached ? execFileSync : cachedExec
67
+ /** @type {import('node:child_process').ExecFileSyncOptions} */
68
+ const options = { stdio: 'pipe' }
69
+ if (executionOptions?.timeout) options.timeout = executionOptions.timeout
70
+ if (executionOptions?.localOnly) {
71
+ options.env = { ...getEnvironmentVariables(), GIT_NO_LAZY_FETCH: '1', GIT_ALLOW_PROTOCOL: '' }
72
+ }
73
+ let result = exec('git', flags, options).toString()
64
74
 
65
75
  if (shouldTrim) {
66
76
  result = result.replaceAll(/(\r\n|\n|\r)/g, '')
@@ -78,7 +88,12 @@ function sanitizedExec (
78
88
  exitCode: err.status || err.errno,
79
89
  })
80
90
  }
81
- log.error('Git plugin error executing command', err)
91
+ if (executionOptions?.expectedFailure) {
92
+ log.debug('Git plugin error executing command', err)
93
+ } else {
94
+ log.error('Git plugin error executing command', err)
95
+ }
96
+ if (executionOptions?.throwOnError) throw err
82
97
  return ''
83
98
  }
84
99
  })
@@ -103,12 +118,14 @@ function isGitAvailable () {
103
118
  }
104
119
  }
105
120
 
106
- function isShallowRepository () {
121
+ function isShallowRepository (uncached = false) {
107
122
  return sanitizedExec(
108
123
  ['rev-parse', '--is-shallow-repository'],
109
124
  { name: TELEMETRY_GIT_COMMAND, tags: { command: 'check_shallow' } },
110
125
  { name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'check_shallow' } },
111
- { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'check_shallow' } }
126
+ { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'check_shallow' } },
127
+ true,
128
+ { uncached }
112
129
  ) === 'true'
113
130
  }
114
131
 
@@ -213,7 +230,7 @@ function getLatestCommits () {
213
230
  distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'get_local_commits' }, Date.now() - startTime)
214
231
  return result
215
232
  } catch (err) {
216
- log.error('Get latest commits failed: %s', err.message)
233
+ log.error('Get latest commits failed', err)
217
234
  incrementCountMetric(
218
235
  TELEMETRY_GIT_COMMAND_ERRORS,
219
236
  { command: 'get_local_commits', errorType: err.status }
@@ -223,6 +240,13 @@ function getLatestCommits () {
223
240
  }
224
241
 
225
242
  function getGitDiff (baseCommit, targetCommit) {
243
+ // Fetch the required snapshots explicitly; a depth-1 metadata fetch does not provide their ancestry.
244
+ for (const commit of targetCommit ? [baseCommit, targetCommit] : [baseCommit]) {
245
+ if (!hasLocalGitObject(commit)) {
246
+ // Use the current checkout state so a stale cache cannot shorten a complete clone.
247
+ fetchHeadCommitSha(commit, isShallowRepository(true))
248
+ }
249
+ }
226
250
  const flags = ['diff', '-U0', '--word-diff=porcelain', baseCommit]
227
251
  if (targetCommit) {
228
252
  flags.push(targetCommit)
@@ -232,7 +256,8 @@ function getGitDiff (baseCommit, targetCommit) {
232
256
  { name: TELEMETRY_GIT_COMMAND, tags: { command: 'diff' } },
233
257
  { name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'diff' } },
234
258
  { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'diff' } },
235
- false // important not to trim or we'll lose the line breaks which we need to detect impacted tests
259
+ false, // important not to trim or we'll lose the line breaks which we need to detect impacted tests
260
+ { uncached: true }
236
261
  )
237
262
  }
238
263
 
@@ -241,7 +266,9 @@ function getGitRemoteName () {
241
266
  ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
242
267
  { name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_remote_name' } },
243
268
  { name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_remote_name' } },
244
- { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_remote_name' } }
269
+ { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_remote_name' } },
270
+ true,
271
+ { expectedFailure: true } // Detached HEADs and branches without an upstream use the remote-list fallback.
245
272
  )
246
273
 
247
274
  if (upstreamRemote) {
@@ -370,7 +397,7 @@ function getCommitsRevList (commitsToExclude, commitsToInclude) {
370
397
  .split('\n')
371
398
  .filter(Boolean)
372
399
  } catch (err) {
373
- log.error('Get commits to upload failed: %s', err.message)
400
+ log.error('Get commits to upload failed', err)
374
401
  incrementCountMetric(
375
402
  TELEMETRY_GIT_COMMAND_ERRORS,
376
403
  { command: 'get_objects', errorType: err.code, exitCode: err.status || err.errno } // err.status might be null
@@ -414,7 +441,7 @@ function generatePackFilesForCommits (commitsToUpload) {
414
441
  try {
415
442
  result = execGitPackObjects(temporaryPath)
416
443
  } catch (err) {
417
- log.error('Git plugin error executing git pack-objects command', err)
444
+ log.debug('Git plugin error executing git pack-objects command, trying the working directory', err)
418
445
  incrementCountMetric(
419
446
  TELEMETRY_GIT_COMMAND_ERRORS,
420
447
  { command: 'pack_objects', exitCode: err.status || err.errno, errorType: err.code }
@@ -464,6 +491,7 @@ function getGitMetadata (ciMetadata) {
464
491
  authorEmail: ciAuthorEmail,
465
492
  ciWorkspacePath,
466
493
  headCommitSha,
494
+ pullRequestBaseBranchSha,
467
495
  } = ciMetadata
468
496
 
469
497
  // With stdio: 'pipe', errors in this command will not be output to the parent process,
@@ -486,8 +514,25 @@ function getGitMetadata (ciMetadata) {
486
514
  }
487
515
 
488
516
  if (headCommitSha) {
489
- if (isShallowRepository()) {
490
- fetchHeadCommitSha(headCommitSha)
517
+ const shallow = isShallowRepository(true)
518
+ const fetchedAtDepthOne = shallow && fetchHeadCommitSha(headCommitSha)
519
+ const headFlags = [
520
+ 'show',
521
+ '-s',
522
+ '--format=\'%H","%aI","%an","%ae","%cI","%cn","%ce","%B\'',
523
+ headCommitSha,
524
+ ]
525
+ // Only explicit, bounded fetches may contact the remote during head metadata recovery.
526
+ const headOptions = { uncached: true, localOnly: true }
527
+ let headInfo = sanitizedExec(headFlags, null, null, null, false, headOptions)
528
+ if (!headInfo && (fetchedAtDepthOne || !shallow)) {
529
+ fetchHeadCommitSha(headCommitSha, false)
530
+ headInfo = sanitizedExec(headFlags, null, null, null, false, headOptions)
531
+ }
532
+
533
+ // Prepare a known diff base while the remote is available, including when Git upload is disabled.
534
+ if (shallow && pullRequestBaseBranchSha && !hasLocalGitObject(pullRequestBaseBranchSha)) {
535
+ fetchHeadCommitSha(pullRequestBaseBranchSha)
491
536
  }
492
537
 
493
538
  const [
@@ -499,18 +544,7 @@ function getGitMetadata (ciMetadata) {
499
544
  headCommitterName,
500
545
  headCommitterEmail,
501
546
  headCommitMessage,
502
- ] = sanitizedExec(
503
- [
504
- 'show',
505
- '-s',
506
- '--format=\'%H","%aI","%an","%ae","%cI","%cn","%ce","%B\'',
507
- headCommitSha,
508
- ],
509
- null,
510
- null,
511
- null,
512
- false
513
- ).split('","')
547
+ ] = headInfo.split('","')
514
548
 
515
549
  if (gitHeadCommitSha) {
516
550
  tags[GIT_COMMIT_HEAD_AUTHOR_DATE] = headAuthorDate
@@ -558,23 +592,51 @@ function getGitInformationDiscrepancy () {
558
592
  return { gitRepositoryUrl, gitCommitSHA }
559
593
  }
560
594
 
561
- function fetchHeadCommitSha (headSha) {
562
- const remoteName = getGitRemoteName()
595
+ /** @param {string} sha */
596
+ function hasLocalGitObject (sha) {
597
+ return legacyStorage.run({ noop: true }, () => {
598
+ try {
599
+ execFileSync('git', ['cat-file', '-e', sha], {
600
+ stdio: 'pipe',
601
+ // Older Git versions ignore GIT_NO_LAZY_FETCH, so also disallow transports for this local-only probe.
602
+ env: { ...getEnvironmentVariables(), GIT_NO_LAZY_FETCH: '1', GIT_ALLOW_PROTOCOL: '' },
603
+ })
604
+ return true
605
+ } catch {
606
+ return false
607
+ }
608
+ })
609
+ }
563
610
 
564
- sanitizedExec(
565
- [
566
- 'fetch',
567
- '--update-shallow',
568
- '--filter=blob:none',
569
- '--recurse-submodules=no',
570
- '--no-write-fetch-head',
571
- remoteName,
572
- headSha,
573
- ],
574
- { name: TELEMETRY_GIT_COMMAND, tags: { command: 'fetch_head_commit_sha' } },
575
- { name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'fetch_head_commit_sha' } },
576
- { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'fetch_head_commit_sha' } }
577
- )
611
+ function fetchHeadCommitSha (headSha, useDepth = true) {
612
+ const remoteName = getGitRemoteName()
613
+ // Existing heads retain the original repair/history behavior; a failed bounded fetch also retries that path.
614
+ const depths = useDepth && !hasLocalGitObject(headSha) ? [true, false] : [false]
615
+ for (const shallow of depths) {
616
+ try {
617
+ sanitizedExec(
618
+ [
619
+ 'fetch',
620
+ ...(shallow ? ['--depth=1'] : []),
621
+ '--update-shallow',
622
+ '--filter=blob:none',
623
+ '--recurse-submodules=no',
624
+ '--no-write-fetch-head',
625
+ remoteName,
626
+ headSha,
627
+ ],
628
+ { name: TELEMETRY_GIT_COMMAND, tags: { command: 'fetch_head_commit_sha' } },
629
+ { name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'fetch_head_commit_sha' } },
630
+ { name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'fetch_head_commit_sha' } },
631
+ true,
632
+ { uncached: true, throwOnError: true, timeout: 5000 }
633
+ )
634
+ return shallow
635
+ } catch {
636
+ // sanitizedExec records the failure; retry without a depth limit if the bounded fetch failed.
637
+ }
638
+ }
639
+ return false
578
640
  }
579
641
 
580
642
  module.exports = {
@@ -27,7 +27,7 @@ const KNOWN_METHODS = new Set([
27
27
 
28
28
  // Datadog HTTP meta keys replaced by OTel names — omitted when rebuilding meta.
29
29
  const DD_HTTP_META_KEYS = new Set([
30
- 'http.method', 'http.status_code', 'http.useragent', 'http.client_ip', 'http.endpoint', 'http.url', 'out.host',
30
+ 'http.method', 'http.status_code', 'http.useragent', 'http.client_ip', 'http.url', 'out.host',
31
31
  ])
32
32
  const NETWORK_DESTINATION_PORT = 'network.destination.port'
33
33
 
@@ -155,7 +155,7 @@ function defaultPortForUrl (url) {
155
155
  * `span_format`) when `DD_TRACE_OTEL_SEMANTICS_ENABLED` is set, so every HTTP
156
156
  * integration is covered from one place. No-op for non-HTTP spans. The span
157
157
  * keeps the Datadog tag names throughout its lifetime — only the serialized
158
- * output is renamed — so runtime consumers (peer.service, AppSec, trace stats)
158
+ * output is renamed — so runtime consumers (peer.service, AppSec)
159
159
  * are unaffected.
160
160
  *
161
161
  * @param {FormattedHttpSpan} formattedSpan
@@ -219,8 +219,6 @@ function applyHttpOtelSemantics (formattedSpan) {
219
219
  const clientIp = meta['http.client_ip']
220
220
  if (clientIp !== undefined) newMeta[CLIENT_ADDRESS] = clientIp
221
221
 
222
- // http.endpoint is Datadog-only (omitted above); it has no OTel equivalent.
223
-
224
222
  if (kind === 'server') {
225
223
  // FIXME: some server frameworks (e.g. Next.js — `packages/datadog-plugin-next`)
226
224
  // never populate `http.url`, so the OTel `url.*` / `server.*` attributes below
@@ -12,8 +12,9 @@ const NODE_MODULES_PATTERN_START = `node_modules${sep}`
12
12
  * current file path ends with the expected path structure from the repo root.
13
13
  * This is needed for local and CI where dd-trace-js is not in node_modules.
14
14
  * In production, these frames are already filtered by isNodeModulesFrame.
15
+ * Bundled into ESM output, `__filename` is not defined, and dd-trace is not running from its repo.
15
16
  */
16
- const SHOULD_FILTER_DD_TRACE_INSTRUMENTAION = __filename.endsWith(
17
+ const SHOULD_FILTER_DD_TRACE_INSTRUMENTAION = typeof __filename === 'string' && __filename.endsWith(
17
18
  join('packages', 'dd-trace', 'src', 'plugins', 'util', 'stacktrace.js')
18
19
  )
19
20
 
@@ -310,6 +310,8 @@ const DI_DEBUG_ERROR_LINE_SUFFIX = 'line'
310
310
 
311
311
  // Test Management tags
312
312
  const TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX = 'test.test_management.is_attempt_to_fix'
313
+ const TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION = 'test.test_management.prevent_failure_suppression'
314
+ const TEST_MANAGEMENT_NO_AUTO_RETRY = 'test.test_management.no_auto_retry'
313
315
  const TEST_MANAGEMENT_IS_DISABLED = 'test.test_management.is_test_disabled'
314
316
  const TEST_MANAGEMENT_IS_QUARANTINED = 'test.test_management.is_quarantined'
315
317
  const TEST_MANAGEMENT_ENABLED = 'test.test_management.enabled'
@@ -591,6 +593,8 @@ module.exports = {
591
593
  DD_TEST_IS_USER_PROVIDED_SERVICE,
592
594
  TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
593
595
  TEST_MANAGEMENT_IS_DISABLED,
596
+ TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION,
597
+ TEST_MANAGEMENT_NO_AUTO_RETRY,
594
598
  TEST_MANAGEMENT_IS_QUARANTINED,
595
599
  TEST_MANAGEMENT_ENABLED,
596
600
  TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
@@ -799,6 +803,8 @@ function getTestEnvironmentMetadata (testFramework, config, shouldSkipGitMetadat
799
803
  commitMessage,
800
804
  ciWorkspacePath,
801
805
  headCommitSha,
806
+ pullRequestBaseBranchSha: userProvidedGitMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA] ||
807
+ ciMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA],
802
808
  })
803
809
  }
804
810
 
@@ -2341,14 +2347,17 @@ function collectDynamicNameFromTraceSpan (span, newTestsWithDynamicNames) {
2341
2347
 
2342
2348
  function collectAttemptToFixExecutionFromTraceSpan (span, attemptToFixExecutions) {
2343
2349
  const meta = span.meta
2344
- if (meta?.[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] !== 'true') return
2350
+ if (meta?.[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] !== 'true' ||
2351
+ meta[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true') return
2345
2352
 
2346
2353
  recordAttemptToFixExecution(attemptToFixExecutions, {
2347
2354
  testSuite: meta[TEST_SUITE],
2348
2355
  testName: meta[TEST_NAME],
2349
2356
  status: meta[TEST_STATUS],
2350
- isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true',
2351
- isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true',
2357
+ isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true' &&
2358
+ meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
2359
+ isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true' &&
2360
+ meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
2352
2361
  })
2353
2362
  }
2354
2363
 
@@ -2366,9 +2375,12 @@ function collectTestManagementExecutionFromTraceSpan (span, executions) {
2366
2375
  testSuite: meta[TEST_SUITE],
2367
2376
  testName: meta[TEST_NAME],
2368
2377
  status: meta[TEST_STATUS],
2369
- isAttemptToFix: meta[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] === 'true',
2370
- isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true',
2371
- isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true',
2378
+ isAttemptToFix: meta[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] === 'true' &&
2379
+ meta[TEST_MANAGEMENT_NO_AUTO_RETRY] !== 'true',
2380
+ isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true' &&
2381
+ meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
2382
+ isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true' &&
2383
+ meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
2372
2384
  }, executions)
2373
2385
  }
2374
2386
 
@@ -2379,6 +2391,7 @@ function collectTestManagementExecutionFromTraceSpan (span, executions) {
2379
2391
  * @param {string} data - JSON-serialized traces from a worker
2380
2392
  * @param {{
2381
2393
  * newTestsWithDynamicNames?: Set<string>,
2394
+ * testAnnotations?: Map<string, { mustFail: boolean, noAutoRetry: boolean }>,
2382
2395
  * attemptToFixExecutions?: AttemptToFixExecutions,
2383
2396
  * testManagementExecutions?: TestManagementExecutions
2384
2397
  * }} summaries
@@ -2388,12 +2401,21 @@ function collectTestOptimizationSummariesFromTraces (data, summaries) {
2388
2401
  newTestsWithDynamicNames,
2389
2402
  attemptToFixExecutions,
2390
2403
  testManagementExecutions: executions = testManagementExecutions,
2404
+ testAnnotations,
2391
2405
  } = summaries
2392
2406
 
2393
2407
  try {
2394
2408
  const traces = JSON.parse(data)
2395
2409
  for (const trace of traces) {
2396
2410
  for (const span of trace) {
2411
+ if (testAnnotations && span.type === 'test' &&
2412
+ (span.meta?.[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] === 'true' ||
2413
+ span.meta?.[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true')) {
2414
+ testAnnotations.set(`${span.meta[TEST_SUITE]} › ${span.meta[TEST_NAME]}`, {
2415
+ mustFail: span.meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] === 'true',
2416
+ noAutoRetry: span.meta[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true',
2417
+ })
2418
+ }
2397
2419
  if (newTestsWithDynamicNames) {
2398
2420
  collectDynamicNameFromTraceSpan(span, newTestsWithDynamicNames)
2399
2421
  }
@@ -204,6 +204,22 @@ const web = {
204
204
  return context ? context.span : null
205
205
  },
206
206
 
207
+ /** @param {import('../../opentracing/span') | undefined} span */
208
+ rootFromSpan (span) {
209
+ if (!span) return
210
+
211
+ const started = span.context()._trace.started
212
+ while (span) {
213
+ const context = span.context()
214
+ if (context.getTag(SPAN_KIND) === SERVER && typeof context.getTag(HTTP_URL) === 'string') return span
215
+
216
+ const parentId = context._parentId
217
+ if (!parentId) return
218
+ span = started.find(parent => parent.context()._spanId === parentId)
219
+ }
220
+ return span
221
+ },
222
+
207
223
  // Return the active span.
208
224
  active (req) {
209
225
  const context = contexts.get(req)
@@ -321,20 +337,16 @@ const web = {
321
337
  const writeHead = res.writeHead
322
338
 
323
339
  return function (statusCode, statusMessage, headers) {
324
- // CORS preflight tagging only matters for OPTIONS requests. Skip the
325
- // getHeaders() spread + isOriginAllowed work entirely for the common
326
- // GET / POST / etc. case. Node's http module passes `req.method`
327
- // through unchanged, so all standard methods are uppercase; the
328
- // `toLowerCase` fallback covers any non-standard caller.
329
340
  if (req.method === 'OPTIONS' || req.method.toLowerCase() === 'options') {
330
- headers = typeof statusMessage === 'string' ? headers : statusMessage
331
- headers = { ...res.getHeaders(), ...headers }
332
-
333
- if (isOriginAllowed(req, headers)) {
334
- addAllowHeaders(req, res, headers)
341
+ const headerIndex = typeof statusMessage === 'string' || headers != null ? 2 : 1
342
+ const updatedHeaders = addAllowHeaders(req, res, arguments[headerIndex])
343
+ if (updatedHeaders) {
344
+ arguments[headerIndex] = updatedHeaders
345
+ const result = writeHead.apply(this, arguments)
346
+ if (context.config.headers.length > 0) context.responseHeaders = updatedHeaders
347
+ return result
335
348
  }
336
349
  }
337
-
338
350
  return writeHead.apply(this, arguments)
339
351
  }
340
352
  },
@@ -362,8 +374,28 @@ function normalizeHeadersCarrier (headers) {
362
374
  return carrier
363
375
  }
364
376
 
377
+ /**
378
+ * @param {import('node:http').IncomingMessage} req
379
+ * @param {import('node:http').ServerResponse | import('node:http2').Http2ServerResponse} res
380
+ * @param {ResponseHeaders} headers
381
+ */
365
382
  function addAllowHeaders (req, res, headers) {
366
- const allowHeaders = splitHeader(headers['access-control-allow-headers'])
383
+ if (!req.headers.origin || !req.headers['access-control-request-headers'] ||
384
+ res.headersSent || res.stream?.destroyed || res.stream?.closed) return
385
+
386
+ const originKey = findHeader(headers, 'access-control-allow-origin')
387
+ const allowOrigin = originKey === undefined
388
+ ? res.getHeader('access-control-allow-origin')
389
+ : getHeaderValue(headers, originKey)
390
+ if (allowOrigin !== '*' && allowOrigin !== req.headers.origin) return
391
+
392
+ const allowKey = findHeader(headers, 'access-control-allow-headers')
393
+ const existing = allowKey === undefined
394
+ ? res.getHeader('access-control-allow-headers')
395
+ : getHeaderValue(headers, allowKey)
396
+ if (allowKey !== undefined && existing == null) return
397
+
398
+ const allowHeaders = splitHeader(existing)
367
399
  const requestHeaders = splitHeader(req.headers['access-control-request-headers'])
368
400
  const contextHeaders = [
369
401
  'baggage',
@@ -384,19 +416,69 @@ function addAllowHeaders (req, res, headers) {
384
416
  }
385
417
 
386
418
  if (allowHeaders.length > 0) {
387
- res.setHeader('access-control-allow-headers', uniq(allowHeaders).join(','))
419
+ const value = uniq(allowHeaders).join(',')
420
+ if (headers) return setAllowHeaders(headers, allowKey, value)
421
+ res.setHeader('access-control-allow-headers', value)
388
422
  }
389
423
  }
390
424
 
391
- function isOriginAllowed (req, headers) {
392
- const origin = req.headers.origin
393
- const allowOrigin = headers['access-control-allow-origin']
425
+ /** @typedef {import('node:http').OutgoingHttpHeader} HeaderValue */
426
+ /** @typedef {import('node:http').OutgoingHttpHeaders | Array<HeaderValue | [string, HeaderValue]>} ResponseHeaders */
427
+
428
+ /**
429
+ * @param {ResponseHeaders} headers
430
+ * @param {string} name
431
+ */
432
+ function findHeader (headers, name) {
433
+ if (!headers) return
434
+ if (Array.isArray(headers)) {
435
+ const tuples = Array.isArray(headers[0])
436
+ for (let i = headers.length - (tuples ? 1 : 2); i >= 0; i -= tuples ? 1 : 2) {
437
+ const key = tuples ? headers[i][0] : headers[i]
438
+ if (typeof key === 'string' && key.toLowerCase() === name) return tuples ? i : i + 1
439
+ }
440
+ } else {
441
+ const keys = Object.keys(headers)
442
+ for (let i = keys.length - 1; i >= 0; i--) {
443
+ if (keys[i].toLowerCase() === name) return keys[i]
444
+ }
445
+ }
446
+ }
394
447
 
395
- return origin && (allowOrigin === '*' || allowOrigin === origin)
448
+ /**
449
+ * @param {ResponseHeaders} headers
450
+ * @param {string | number} key
451
+ */
452
+ function getHeaderValue (headers, key) {
453
+ return Array.isArray(headers) && Array.isArray(headers[0]) ? headers[key][1] : headers[key]
454
+ }
455
+
456
+ /**
457
+ * @param {ResponseHeaders} headers
458
+ * @param {string | number | undefined} key
459
+ * @param {string} value
460
+ */
461
+ function setAllowHeaders (headers, key, value) {
462
+ if (Array.isArray(headers)) {
463
+ const result = []
464
+ const tuples = Array.isArray(headers[0])
465
+ // Native writeHead ignores custom array iterators.
466
+ for (let i = 0; i < headers.length; i++) result.push(headers[i])
467
+ if (key !== undefined) {
468
+ result[key] = tuples ? [headers[key][0], value] : value
469
+ } else if (tuples) {
470
+ result.push(['access-control-allow-headers', value])
471
+ } else {
472
+ result.push('access-control-allow-headers', value)
473
+ }
474
+ return result
475
+ }
476
+ return { ...headers, [key ?? 'access-control-allow-headers']: value }
396
477
  }
397
478
 
398
479
  function splitHeader (str) {
399
- return typeof str === 'string' ? str.split(',').map((header) => header.trim()) : []
480
+ if (Array.isArray(str)) str = str.join(',')
481
+ return str === undefined ? [] : String(str).split(',').map((header) => header.trim())
400
482
  }
401
483
 
402
484
  function addRequestTags (context, spanType) {
@@ -527,10 +609,14 @@ function addRequestHeaders (context) {
527
609
  }
528
610
 
529
611
  function addResponseHeaders (context) {
530
- const { res, config, span, inferredProxySpan } = context
612
+ const { res, config, span, inferredProxySpan, responseHeaders } = context
531
613
 
532
614
  for (const [key, tag] of config.headers) {
533
- const resHeader = res.getHeader(key)
615
+ let resHeader = res.getHeader(key)
616
+ if (resHeader === undefined && responseHeaders) {
617
+ const headerKey = findHeader(responseHeaders, key)
618
+ if (headerKey !== undefined) resHeader = getHeaderValue(responseHeaders, headerKey)
619
+ }
534
620
  if (resHeader) {
535
621
  const tagName = tag || `${HTTP_RESPONSE_HEADERS}.${key}`
536
622
  span.setTag(tagName, resHeader)
@@ -15,7 +15,7 @@ const ENTRYPOINT_PATH = require.main?.filename || ''
15
15
  /**
16
16
  * Sanitize a process tag value
17
17
  *
18
- * @param {string} value
18
+ * @param {unknown} value
19
19
  */
20
20
  function sanitize (value) {
21
21
  return String(value)
@@ -78,7 +78,6 @@ function createProfilers (config, { asyncContextFrameEnabled, flushInterval, tag
78
78
  const profilers = []
79
79
  for (const name of selectProfilerTypes(config)) {
80
80
  switch (name) {
81
- case 'cpu':
82
81
  case 'wall':
83
82
  profilers.push(new WallProfiler(config, { asyncContextFrameEnabled, flushInterval }))
84
83
  break
@@ -112,7 +111,12 @@ function selectProfilerTypes ({
112
111
  // snapshots the space profile won't include memory taken by profiles created
113
112
  // before it in the sequence. That memory is ultimately transient and will be
114
113
  // released when all profiles are subsequently encoded.
115
- const profilers = new Set(DD_PROFILING_PROFILERS)
114
+ // 'cpu' is an alias of 'wall'. Normalizing it here keeps the settings below from adding a second
115
+ // wall profiler next to the alias.
116
+ const profilers = new Set()
117
+ for (const name of DD_PROFILING_PROFILERS) {
118
+ profilers.add(name === 'cpu' ? 'wall' : name)
119
+ }
116
120
 
117
121
  let spaceExplicitlyEnabled = false
118
122
  // Add/remove space depending on the value of DD_PROFILING_HEAP_ENABLED
@@ -133,7 +137,6 @@ function selectProfilerTypes ({
133
137
  profilers.add('wall')
134
138
  } else {
135
139
  profilers.delete('wall')
136
- profilers.delete('cpu') // remove alias too
137
140
  }
138
141
  }
139
142
 
@@ -117,6 +117,7 @@ function defineLazily (obj, property, getClass, ...args) {
117
117
  }
118
118
 
119
119
  class Tracer extends NoopProxy {
120
+ #aiguardConfigurationErrorLogged = false
120
121
  #openfeatureState = OPENFEATURE_STATE_NOOP
121
122
 
122
123
  /** @type {boolean} */
@@ -196,7 +197,10 @@ class Tracer extends NoopProxy {
196
197
  require('./heap_snapshots').start(config)
197
198
  }
198
199
 
199
- telemetry.start(config, this._pluginManager)
200
+ const telemetryLogOptions = config.isCiVisibility && config.telemetry.DD_INSTRUMENTATION_TELEMETRY_ENABLED
201
+ ? require('./ci-visibility/telemetry-logs')
202
+ : undefined
203
+ telemetry.start(config, this._pluginManager, telemetryLogOptions)
200
204
 
201
205
  if (config.dogstatsd && !config.DD_AGENTLESS_ENABLED && !isOfflineTestOptimizationValidation()) {
202
206
  // Custom Metrics
@@ -261,7 +265,7 @@ class Tracer extends NoopProxy {
261
265
 
262
266
  // Experimental: mirror the active trace ID, span ID and endpoint into
263
267
  // an OTEP-4947 thread-local context record an out-of-process eBPF
264
- // reader can consume.
268
+ // reader can consume. On by default when appsec is enabled.
265
269
  if (config.DD_TRACE_OTEL_CTX_ENABLED) {
266
270
  try {
267
271
  require('./otel-thread-ctx').start()
@@ -408,6 +412,13 @@ class Tracer extends NoopProxy {
408
412
  */
409
413
  #updateTracing (config) {
410
414
  if (config.DD_TRACE_ENABLED !== false) {
415
+ const aiguardEnabled = config.aiguard.DD_AI_GUARD_ENABLED === true &&
416
+ config.DD_API_KEY !== undefined &&
417
+ config.DD_APP_KEY !== undefined
418
+ if (config.aiguard.DD_AI_GUARD_ENABLED && !aiguardEnabled && !this.#aiguardConfigurationErrorLogged) {
419
+ log.error('AIGuard: missing api and/or app keys, use env DD_API_KEY and DD_APP_KEY')
420
+ this.#aiguardConfigurationErrorLogged = true
421
+ }
411
422
  if (config.appsec.DD_APPSEC_ENABLED) {
412
423
  this._modules.appsec.enable(config)
413
424
  }
@@ -424,12 +435,12 @@ class Tracer extends NoopProxy {
424
435
  lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config,
425
436
  () => this.openfeature)
426
437
 
427
- if (config.aiguard.DD_AI_GUARD_ENABLED) {
438
+ if (aiguardEnabled) {
428
439
  lazyProxy(this, 'aiguard', () => require('./aiguard/sdk'), this._tracer, config)
429
440
  }
430
441
  this._tracingInitialized = true
431
442
  }
432
- if (config.aiguard.DD_AI_GUARD_ENABLED) {
443
+ if (aiguardEnabled) {
433
444
  this._modules.aiguard.enable(this._tracer, config)
434
445
  }
435
446
  if (config.iast.DD_IAST_ENABLED) {