dd-trace 6.11.0 → 6.13.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 (139) hide show
  1. package/LICENSE-3rdparty.csv +5 -0
  2. package/ci/test-optimization-validation/framework-adapters/cypress.js +9 -11
  3. package/ci/test-optimization-validation/scenarios/ci-wiring.js +5 -4
  4. package/index.d.ts +143 -25
  5. package/package.json +26 -25
  6. package/packages/datadog-instrumentations/src/bunyan.js +4 -2
  7. package/packages/datadog-instrumentations/src/cucumber.js +4 -4
  8. package/packages/datadog-instrumentations/src/helpers/bunyan.js +12 -3
  9. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +1 -0
  10. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +28 -0
  11. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +1 -0
  12. package/packages/datadog-instrumentations/src/jest.js +140 -18
  13. package/packages/datadog-instrumentations/src/mariadb-bundle.js +1597 -0
  14. package/packages/datadog-instrumentations/src/mariadb.js +7 -0
  15. package/packages/datadog-instrumentations/src/mocha/utils.js +5 -2
  16. package/packages/datadog-instrumentations/src/pino.js +15 -4
  17. package/packages/datadog-instrumentations/src/playwright-reporter.js +149 -1
  18. package/packages/datadog-instrumentations/src/playwright.js +67 -53
  19. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +13 -12
  20. package/packages/datadog-instrumentations/src/vitest-worker.js +11 -0
  21. package/packages/datadog-instrumentations/src/webdriverio.js +26 -0
  22. package/packages/datadog-instrumentations/src/winston.js +6 -3
  23. package/packages/datadog-plugin-cypress/src/support.js +1 -0
  24. package/packages/datadog-plugin-http/src/client.js +2 -15
  25. package/packages/datadog-plugin-http2/src/client.js +2 -15
  26. package/packages/datadog-plugin-openai-agents/src/integration.js +15 -11
  27. package/packages/datadog-plugin-playwright/src/index.js +13 -1
  28. package/packages/datadog-plugin-undici/src/index.js +2 -15
  29. package/packages/dd-trace/src/aiguard/evaluation.js +94 -20
  30. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +2 -3
  31. package/packages/dd-trace/src/aiguard/messages/anthropic.js +21 -9
  32. package/packages/dd-trace/src/aiguard/noop.js +9 -1
  33. package/packages/dd-trace/src/aiguard/redaction.js +183 -0
  34. package/packages/dd-trace/src/aiguard/sdk.js +7 -2
  35. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  36. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +10 -9
  37. package/packages/dd-trace/src/appsec/reporter.js +2 -0
  38. package/packages/dd-trace/src/appsec/rule_manager.js +2 -0
  39. package/packages/dd-trace/src/appsec/telemetry/index.js +13 -0
  40. package/packages/dd-trace/src/appsec/telemetry/rasp.js +16 -0
  41. package/packages/dd-trace/src/appsec/telemetry/waf.js +24 -0
  42. package/packages/dd-trace/src/carrier.js +107 -48
  43. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +5 -5
  44. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +2 -0
  45. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +5 -3
  46. package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +51 -26
  47. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +4 -2
  48. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +5 -11
  49. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +6 -4
  50. package/packages/dd-trace/src/ci-visibility/final-flush.js +20 -0
  51. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +5 -3
  52. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +196 -29
  53. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -2
  54. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +4 -2
  55. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +4 -2
  56. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +5 -5
  57. package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
  58. package/packages/dd-trace/src/config/index.js +2 -1
  59. package/packages/dd-trace/src/config/supported-configurations.json +27 -0
  60. package/packages/dd-trace/src/debugger/constants.js +1 -0
  61. package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
  62. package/packages/dd-trace/src/debugger/devtools_client/index.js +3 -10
  63. package/packages/dd-trace/src/debugger/devtools_client/send.js +4 -3
  64. package/packages/dd-trace/src/debugger/index.js +4 -2
  65. package/packages/dd-trace/src/debugger/inspect-segment.js +154 -0
  66. package/packages/dd-trace/src/dogstatsd.js +45 -18
  67. package/packages/dd-trace/src/encode/agentless-json.js +5 -4
  68. package/packages/dd-trace/src/evp_proxy/constants.js +8 -0
  69. package/packages/dd-trace/src/evp_proxy/direct.js +64 -0
  70. package/packages/dd-trace/src/evp_proxy/discovery.js +133 -0
  71. package/packages/dd-trace/src/evp_proxy/path.js +22 -0
  72. package/packages/dd-trace/src/exporters/agent/index.js +22 -2
  73. package/packages/dd-trace/src/exporters/agent/writer.js +4 -4
  74. package/packages/dd-trace/src/exporters/common/request.js +5 -2
  75. package/packages/dd-trace/src/exporters/common/writer.js +24 -2
  76. package/packages/dd-trace/src/exporters/span-stats/index.js +23 -4
  77. package/packages/dd-trace/src/external-logger/src/index.js +4 -3
  78. package/packages/dd-trace/src/flush.js +102 -0
  79. package/packages/dd-trace/src/llmobs/experiments/client.js +10 -2
  80. package/packages/dd-trace/src/llmobs/experiments/dataset.js +301 -14
  81. package/packages/dd-trace/src/llmobs/experiments/experiment.js +440 -112
  82. package/packages/dd-trace/src/llmobs/experiments/index.js +68 -44
  83. package/packages/dd-trace/src/llmobs/experiments/noop.js +103 -12
  84. package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
  85. package/packages/dd-trace/src/llmobs/experiments/util.js +81 -4
  86. package/packages/dd-trace/src/llmobs/index.js +80 -17
  87. package/packages/dd-trace/src/llmobs/noop.js +2 -1
  88. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +8 -4
  89. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +6 -3
  90. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +13 -6
  91. package/packages/dd-trace/src/llmobs/plugins/openai-agents/utils.js +5 -7
  92. package/packages/dd-trace/src/llmobs/writers/base.js +60 -24
  93. package/packages/dd-trace/src/noop/span.js +5 -0
  94. package/packages/dd-trace/src/openfeature/constants/constants.js +0 -18
  95. package/packages/dd-trace/src/openfeature/index.js +7 -4
  96. package/packages/dd-trace/src/openfeature/writers/base.js +153 -11
  97. package/packages/dd-trace/src/openfeature/writers/exposures.js +70 -15
  98. package/packages/dd-trace/src/openfeature/writers/util.js +97 -15
  99. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +45 -3
  100. package/packages/dd-trace/src/opentelemetry/logs/index.js +4 -1
  101. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +7 -4
  102. package/packages/dd-trace/src/opentelemetry/metrics/index.js +3 -1
  103. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +8 -0
  104. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +4 -2
  105. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -2
  106. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +25 -5
  107. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +61 -25
  108. package/packages/dd-trace/src/opentelemetry/tracer.js +26 -2
  109. package/packages/dd-trace/src/opentracing/propagation/text_map.js +429 -352
  110. package/packages/dd-trace/src/opentracing/span.js +28 -0
  111. package/packages/dd-trace/src/otel-thread-ctx.js +23 -5
  112. package/packages/dd-trace/src/plugin_manager.js +2 -0
  113. package/packages/dd-trace/src/plugins/util/status-validator.js +98 -0
  114. package/packages/dd-trace/src/plugins/util/test.js +74 -21
  115. package/packages/dd-trace/src/plugins/util/web.js +2 -65
  116. package/packages/dd-trace/src/profiling/oom.js +4 -3
  117. package/packages/dd-trace/src/profiling/profiler.js +7 -0
  118. package/packages/dd-trace/src/profiling/profilers/events.js +3 -3
  119. package/packages/dd-trace/src/profiling/profilers/wall.js +14 -14
  120. package/packages/dd-trace/src/proxy.js +36 -8
  121. package/packages/dd-trace/src/runtime_metrics/index.js +5 -0
  122. package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +5 -0
  123. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +17 -6
  124. package/packages/dd-trace/src/serverless/telemetry-delivery-tracker.js +55 -0
  125. package/packages/dd-trace/src/serverless/vercel.js +122 -0
  126. package/packages/dd-trace/src/serverless.js +37 -20
  127. package/packages/dd-trace/src/span_stats.js +40 -3
  128. package/packages/dd-trace/src/telemetry/metrics.js +62 -8
  129. package/packages/dd-trace/src/telemetry/send-data.js +1 -0
  130. package/packages/dd-trace/src/tracer.js +22 -0
  131. package/packages/dd-trace/src/web-tags-cache.js +67 -13
  132. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  133. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  134. package/vendor/dist/https-proxy-agent/LICENSE +22 -0
  135. package/vendor/dist/https-proxy-agent/index.js +4 -0
  136. package/vendor/dist/protobufjs/index.js +1 -1
  137. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  138. package/vendor/dist/proxy-from-env/LICENSE +20 -0
  139. package/vendor/dist/proxy-from-env/index.js +1 -0
@@ -44,18 +44,21 @@
44
44
  "@oxc-project/types","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
45
45
  "@tybys/wasm-util","https://github.com/toyobayashi/wasm-util","['MIT']","['toyobayashi']"
46
46
  "@types/estree","https://github.com/DefinitelyTyped/DefinitelyTyped","['MIT']","['DefinitelyTyped']"
47
+ "agent-base","https://github.com/TooTallNate/proxy-agents","['MIT']","['Nathan Rajlich']"
47
48
  "argparse","https://github.com/nodeca/argparse","['Python-2.0']","['nodeca']"
48
49
  "astring","https://github.com/davidbonnet/astring","['MIT']","['David Bonnet']"
49
50
  "cjs-module-lexer","https://github.com/nodejs/cjs-module-lexer","['MIT']","['Guy Bedford']"
50
51
  "crypto-randomuuid","npm:crypto-randomuuid","['MIT']","['Stephen Belanger']"
51
52
  "dc-polyfill","https://github.com/DataDog/dc-polyfill","['MIT']","['Thomas Hunter II']"
52
53
  "dd-trace","https://github.com/DataDog/dd-trace-js","['(Apache-2.0 OR BSD-3-Clause)']","['Datadog Inc. <info@datadoghq.com>']"
54
+ "debug","https://github.com/debug-js/debug","['MIT']","['Josh Junon']"
53
55
  "detect-newline","https://github.com/sindresorhus/detect-newline","['MIT']","['Sindre Sorhus']"
54
56
  "es-module-lexer","https://github.com/guybedford/es-module-lexer","['MIT']","['Guy Bedford']"
55
57
  "escape-string-regexp","https://github.com/sindresorhus/escape-string-regexp","['MIT']","['Sindre Sorhus']"
56
58
  "esquery","https://github.com/estools/esquery","['BSD-3-Clause']","['Joel Feenstra']"
57
59
  "estraverse","https://github.com/estools/estraverse","['BSD-2-Clause']","['estools']"
58
60
  "fast-fifo","https://github.com/mafintosh/fast-fifo","['MIT']","['Mathias Buus']"
61
+ "https-proxy-agent","https://github.com/TooTallNate/proxy-agents","['MIT']","['Nathan Rajlich']"
59
62
  "import-in-the-middle","https://github.com/nodejs/import-in-the-middle","['Apache-2.0']","['Bryan English']"
60
63
  "istanbul-lib-coverage","https://github.com/istanbuljs/istanbuljs","['BSD-3-Clause']","['Krishnan Anantheswaran']"
61
64
  "jest-docblock","https://github.com/jestjs/jest","['MIT']","['jestjs']"
@@ -68,6 +71,7 @@
68
71
  "lru-cache","https://github.com/isaacs/node-lru-cache","['ISC']","['Isaac Z. Schlueter']"
69
72
  "meriyah","https://github.com/meriyah/meriyah","['ISC']","['Kenny F.']"
70
73
  "module-details-from-path","https://github.com/watson/module-details-from-path","['MIT']","['Thomas Watson']"
74
+ "ms","https://github.com/vercel/ms","['MIT']","['vercel']"
71
75
  "mutexify","https://github.com/mafintosh/mutexify","['MIT']","['Mathias Buus']"
72
76
  "node-addon-api","https://github.com/nodejs/node-addon-api","['MIT']","['nodejs']"
73
77
  "node-gyp-build","https://github.com/prebuild/node-gyp-build","['MIT']","['Mathias Buus']"
@@ -75,6 +79,7 @@
75
79
  "oxc-parser","https://github.com/oxc-project/oxc","['MIT']","['Boshen and oxc contributors']"
76
80
  "pprof-format","https://github.com/DataDog/pprof-format","['MIT']","['Datadog Inc.']"
77
81
  "protobufjs","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
82
+ "proxy-from-env","https://github.com/Rob--W/proxy-from-env","['MIT']","['Rob Wu']"
78
83
  "queue-tick","https://github.com/mafintosh/queue-tick","['MIT']","['Mathias Buus']"
79
84
  "retry","https://github.com/tim-kos/node-retry","['MIT']","['Tim Koschützki']"
80
85
  "rfdc","https://github.com/davidmarkclements/rfdc","['MIT']","['David Mark Clements']"
@@ -40,20 +40,18 @@ function getTestExtension (filename) {
40
40
  * @returns {string} canonical generated Cypress source
41
41
  */
42
42
  function getGeneratedTestContent ({ scenarioId, testName }) {
43
- const lines = []
43
+ let content = ''
44
44
  if (scenarioId === 'atr-fail-once') {
45
- lines.push('let attempt = 0', '')
45
+ content = 'let attempt = 0\n\n'
46
46
  }
47
- lines.push(
48
- "describe('dd-test-optimization-validation', () => {",
49
- ` it(${JSON.stringify(testName)}, () => {`,
50
- scenarioId === 'atr-fail-once'
51
- ? ' expect(attempt++).to.equal(1)'
52
- : ' expect(true).to.equal(true)',
53
- ' })',
47
+ content += "describe('dd-test-optimization-validation', () => {\n" +
48
+ ` it(${JSON.stringify(testName)}, () => {\n` +
49
+ (scenarioId === 'atr-fail-once'
50
+ ? ' expect(attempt++).to.equal(1)\n'
51
+ : ' expect(true).to.equal(true)\n') +
52
+ ' })\n' +
54
53
  '})'
55
- )
56
- return lines.join('\n')
54
+ return content
57
55
  }
58
56
 
59
57
  /**
@@ -184,12 +184,13 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
184
184
  }
185
185
 
186
186
  if (resolution.status !== 'confirmed') {
187
- const visibleFacts = []
187
+ let visibleFacts = ''
188
188
  if (initialization.status === 'missing') {
189
- visibleFacts.push('The selected job has no visible dd-trace/ci/init preload.')
189
+ visibleFacts = 'The selected job has no visible dd-trace/ci/init preload.'
190
190
  }
191
191
  if (ciFacts.transport.status === 'missing') {
192
- visibleFacts.push('The recorded review found no visible Datadog Agent or agentless reporting transport.')
192
+ if (visibleFacts) visibleFacts += ' '
193
+ visibleFacts += 'The recorded review found no visible Datadog Agent or agentless reporting transport.'
193
194
  }
194
195
  const recommendation = /working directory/i.test(resolution.reason)
195
196
  ? 'Keep the CI job\'s actual working directory. Resolve the repository-root wrapper to the selected test ' +
@@ -199,7 +200,7 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
199
200
  return getIncomplete(
200
201
  framework,
201
202
  'The CI audit remains incomplete because the selected command could not be resolved to the ' +
202
- `${framework.framework} runner: ${resolution.reason}. ${visibleFacts.join(' ')}`.trim(),
203
+ `${framework.framework} runner: ${resolution.reason}. ${visibleFacts}`.trim(),
203
204
  {
204
205
  ...evidence,
205
206
  recommendation,
package/index.d.ts CHANGED
@@ -356,6 +356,16 @@ declare namespace tracer {
356
356
  links?: { context: SpanContext, attributes?: Object }[]
357
357
  }
358
358
 
359
+ export interface Exception {
360
+ message: string;
361
+ name?: string;
362
+ stack?: string;
363
+ }
364
+
365
+ export type SpanEventAttributeValue =
366
+ string | number | boolean | Array<string> | Array<number> | Array<boolean>;
367
+ export type SpanEventAttributes = Record<string, SpanEventAttributeValue>;
368
+
359
369
  /**
360
370
  * Span represents a logical unit of work as part of a broader Trace.
361
371
  * Examples of span might include remote procedure calls or a in-process
@@ -366,6 +376,14 @@ declare namespace tracer {
366
376
  export interface Span extends opentracing.Span {
367
377
  context (): SpanContext;
368
378
 
379
+ /**
380
+ * Records an exception as a span event without marking the span as failed.
381
+ *
382
+ * @param exception The exception to record.
383
+ * @param attributes Additional attributes for the exception event.
384
+ */
385
+ recordException (exception: Exception, attributes?: SpanEventAttributes): void;
386
+
369
387
  /**
370
388
  * Adds a single link to the span.
371
389
  *
@@ -789,6 +807,13 @@ declare namespace tracer {
789
807
  * Programmatic configuration takes precedence over the environment variables listed above.
790
808
  */
791
809
  maxMessagesLength?: number,
810
+ /**
811
+ * Whether AI Guard applies backend-provided sensitive-data redaction replacements.
812
+ * @default true
813
+ * @env DD_AI_GUARD_REDACTION_ENABLED
814
+ * Programmatic configuration takes precedence over the environment variables listed above.
815
+ */
816
+ redactionEnabled?: boolean,
792
817
  /**
793
818
  * Max size of the content property set in the meta-struct
794
819
  * @env DD_AI_GUARD_MAX_CONTENT_SIZE
@@ -1706,6 +1731,25 @@ declare namespace tracer {
1706
1731
  };
1707
1732
  }
1708
1733
 
1734
+ /**
1735
+ * A structured content part in an AI Guard message.
1736
+ */
1737
+ export interface ContentPart {
1738
+ type: string;
1739
+ text?: string;
1740
+ image_url?: { url: string };
1741
+ }
1742
+
1743
+ /**
1744
+ * A conversational message whose content is represented by structured parts.
1745
+ */
1746
+ export interface ContentPartsMessage {
1747
+ role: string;
1748
+ content: ContentPart[];
1749
+ tool_call_id?: string;
1750
+ tool_calls?: ToolCall[];
1751
+ }
1752
+
1709
1753
  /**
1710
1754
  * A standard conversational message exchanged with a Large Language Model (LLM).
1711
1755
  */
@@ -1777,10 +1821,25 @@ declare namespace tracer {
1777
1821
 
1778
1822
  export type Message =
1779
1823
  | TextMessage
1824
+ | ContentPartsMessage
1780
1825
  | AssistantTextMessage
1781
1826
  | AssistantToolCallMessage
1782
1827
  | ToolMessage;
1783
1828
 
1829
+ /**
1830
+ * A sensitive data replacement the AI Guard service determined for the evaluated conversation.
1831
+ */
1832
+ export interface RedactionReplacement {
1833
+ /**
1834
+ * Location of the replaced value within the evaluated conversation (e.g. `messages[0].content`).
1835
+ */
1836
+ path: string;
1837
+ /**
1838
+ * The value that replaces the sensitive data found at `path`.
1839
+ */
1840
+ replacement: string;
1841
+ }
1842
+
1784
1843
  /**
1785
1844
  * The result returned by AI Guard after evaluating a conversation.
1786
1845
  */
@@ -1808,6 +1867,16 @@ declare namespace tracer {
1808
1867
  * Sensitive Data Scanner findings from the evaluation.
1809
1868
  */
1810
1869
  sds: Object[];
1870
+ /**
1871
+ * The evaluated conversation, redacted when required by the AI Guard service.
1872
+ * This may contain sensitive data when redaction is disabled or no replacement was applied.
1873
+ */
1874
+ messages: Message[];
1875
+ /**
1876
+ * The replacements the AI Guard service determined for the evaluated conversation, reported whether or not
1877
+ * the tracer applied them. Empty when the service determined no replacement.
1878
+ */
1879
+ redactionReplacements: RedactionReplacement[];
1811
1880
  }
1812
1881
 
1813
1882
  /**
@@ -2189,7 +2258,7 @@ declare namespace tracer {
2189
2258
  * This plugin automatically instruments the
2190
2259
  * [Vercel AI SDK](https://ai-sdk.dev/docs/introduction) module.
2191
2260
  */
2192
- interface ai extends Instrumentation {}
2261
+ interface ai extends Instrumentation, LLMObsIntegration {}
2193
2262
 
2194
2263
  /**
2195
2264
  * This plugin automatically instruments the
@@ -2207,13 +2276,13 @@ declare namespace tracer {
2207
2276
  * This plugin automatically instruments the
2208
2277
  * [anthropic](https://www.npmjs.com/package/@anthropic-ai/sdk) module.
2209
2278
  */
2210
- interface anthropic extends Instrumentation {}
2279
+ interface anthropic extends Instrumentation, LLMObsIntegration {}
2211
2280
 
2212
2281
  /**
2213
2282
  * This plugin automatically instruments the
2214
2283
  * [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) module.
2215
2284
  */
2216
- interface claude_agent_sdk extends Instrumentation {}
2285
+ interface claude_agent_sdk extends Instrumentation, LLMObsIntegration {}
2217
2286
 
2218
2287
  /**
2219
2288
  * Currently this plugin automatically instruments
@@ -2274,7 +2343,7 @@ declare namespace tracer {
2274
2343
  * This plugin automatically instruments the
2275
2344
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
2276
2345
  */
2277
- interface aws_sdk extends Instrumentation {
2346
+ interface aws_sdk extends Instrumentation, LLMObsIntegration {
2278
2347
  /**
2279
2348
  * The service name to be used for this plugin. When a function is used it is called with the AWS
2280
2349
  * request parameters (e.g. `{ TableName }` for DynamoDB, `{ Bucket }` for S3) and its return value
@@ -2503,13 +2572,13 @@ declare namespace tracer {
2503
2572
  * This plugin automatically instruments the
2504
2573
  * [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
2505
2574
  */
2506
- interface google_cloud_vertexai extends Integration {}
2575
+ interface google_cloud_vertexai extends Integration, LLMObsIntegration {}
2507
2576
 
2508
2577
  /**
2509
2578
  * This plugin automatically instruments the
2510
2579
  * [@google-genai](https://github.com/googleapis/js-genai) module.
2511
2580
  */
2512
- interface google_genai extends Integration {}
2581
+ interface google_genai extends Integration, LLMObsIntegration {}
2513
2582
 
2514
2583
  /** @hidden */
2515
2584
  interface ExecutionArgs {
@@ -2831,7 +2900,7 @@ declare namespace tracer {
2831
2900
  * This plugin automatically instruments the
2832
2901
  * [langgraph](https://github.com/npmjs/package/langgraph) library.
2833
2902
  */
2834
- interface langgraph extends Instrumentation {}
2903
+ interface langgraph extends Instrumentation, LLMObsIntegration {}
2835
2904
 
2836
2905
  /**
2837
2906
  * This plugin automatically instruments the
@@ -2991,13 +3060,13 @@ declare namespace tracer {
2991
3060
  * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
2992
3061
  * in the agent.
2993
3062
  */
2994
- interface openai extends Instrumentation {}
3063
+ interface openai extends Instrumentation, LLMObsIntegration {}
2995
3064
 
2996
3065
  /**
2997
3066
  * This plugin automatically instruments the
2998
3067
  * [@openai/agents](https://www.npmjs.com/package/@openai/agents) library.
2999
3068
  */
3000
- interface openai_agents extends Instrumentation {}
3069
+ interface openai_agents extends Instrumentation, LLMObsIntegration {}
3001
3070
 
3002
3071
  /**
3003
3072
  * This plugin automatically instruments the
@@ -3610,7 +3679,7 @@ declare namespace tracer {
3610
3679
  *
3611
3680
  * @deprecated Enabling LLM Observability via `llmobs.enable()` is deprecated and will be removed in dd-trace@7.0.0. Please instantiate LLM Observability via DD_LLMOBS_ENABLED or `tracer.init({ llmobs: ...options })`.
3612
3681
  */
3613
- enable (options: LLMObsEnableOptions): void,
3682
+ enable (options: LLMObsRuntimeEnableOptions): void,
3614
3683
 
3615
3684
  /**
3616
3685
  * Disable LLM Observability tracing.
@@ -3798,20 +3867,35 @@ declare namespace tracer {
3798
3867
  metadata?: Array<Record<string, any>>
3799
3868
  ) => any | Promise<any>
3800
3869
 
3870
+ interface DatasetRecord {
3871
+ id: string | null
3872
+ input: JSONType
3873
+ expectedOutput: JSONType
3874
+ metadata: Record<string, JSONType>
3875
+ tags: string[]
3876
+ }
3877
+
3878
+ interface DatasetRecordNew {
3879
+ id?: string
3880
+ inputData: JSONType
3881
+ expectedOutput?: JSONType
3882
+ metadata?: Record<string, JSONType>
3883
+ tags?: string[]
3884
+ }
3885
+
3801
3886
  interface CreateDatasetOptions {
3887
+ /** Override the configured project for this dataset. */
3888
+ projectName?: string
3802
3889
  description?: string
3803
- records?: Array<{
3804
- id?: string,
3805
- inputData: JSONType,
3806
- expectedOutput?: JSONType,
3807
- metadata?: Record<string, JSONType>
3808
- }>
3890
+ records?: DatasetRecordNew[]
3809
3891
  }
3810
3892
 
3811
3893
  interface ExperimentOptions {
3812
3894
  name: string
3813
3895
  dataset: Dataset
3814
3896
  task: ExperimentTask
3897
+ /** Override the configured project for this experiment. */
3898
+ projectName?: string
3815
3899
  /** Evaluators keyed by metric label, or named functions. */
3816
3900
  evaluators?: Record<string, ExperimentEvaluator> | ExperimentEvaluator[]
3817
3901
  /** Summary evaluators keyed by metric label, or named functions. */
@@ -3819,6 +3903,8 @@ declare namespace tracer {
3819
3903
  description?: string
3820
3904
  config?: Record<string, JSONType>
3821
3905
  tags?: Record<string, string>
3906
+ /** Number of full experiment runs to execute. Default 1. */
3907
+ runs?: number
3822
3908
  }
3823
3909
 
3824
3910
  interface ExperimentRunOptions {
@@ -3828,15 +3914,21 @@ declare namespace tracer {
3828
3914
  retryDelay?: (attempt: number) => number
3829
3915
  /** Reject on the first task/evaluator error instead of capturing it. Default false. */
3830
3916
  throwOnErrors?: boolean
3917
+ /** Maximum number of task/evaluator executions to process concurrently. Default 10. */
3918
+ concurrency?: number
3831
3919
  }
3832
3920
 
3833
3921
  interface PullDatasetOptions {
3922
+ /** Override the configured project for this dataset pull. */
3923
+ projectName?: string
3834
3924
  /** Dataset version to pull. Defaults to latest. */
3835
3925
  version?: number
3836
3926
  /** Wait until at least this many records are readable (absorbs write lag). */
3837
3927
  expectedRecordCount?: number
3838
3928
  /** Maximum total time to wait, in ms. Default 30000. */
3839
3929
  maxWaitMs?: number
3930
+ /** Filter records by these tags. */
3931
+ tags?: string[]
3840
3932
  }
3841
3933
 
3842
3934
  interface ExperimentResultRow {
@@ -3857,17 +3949,21 @@ declare namespace tracer {
3857
3949
 
3858
3950
  interface ExperimentRun {
3859
3951
  runId: string
3952
+ /** 1-based run iteration. */
3860
3953
  runIteration: number
3954
+ /** Whether this run had a task, row-evaluator, or summary-evaluator error. */
3955
+ hasError: boolean
3861
3956
  rows: ExperimentResultRow[]
3862
3957
  summaryEvaluations: Record<string, { value: any, error: string | null }>
3863
3958
  }
3864
3959
 
3865
3960
  interface ExperimentResult {
3866
3961
  experimentId: string
3962
+ /** Rows from the first run, kept as a compatibility alias. */
3867
3963
  rows: ExperimentResultRow[]
3868
- /** Single-run summary evaluator results. */
3964
+ /** Summary evaluator results from the first run, kept as a compatibility alias. */
3869
3965
  summaryEvaluations: Record<string, { value: any, error: string | null }>
3870
- /** Experiment runs. P0 Node experiments currently return one run. */
3966
+ /** All experiment runs. */
3871
3967
  runs: ExperimentRun[]
3872
3968
  /** Dashboard URL for the experiment. */
3873
3969
  url: string
@@ -3954,7 +4050,14 @@ declare namespace tracer {
3954
4050
  }
3955
4051
 
3956
4052
  interface Dataset {
3957
- addRecord (input: JSONType, expectedOutput?: JSONType, metadata?: Record<string, JSONType>): Dataset
4053
+ addRecord (
4054
+ input: JSONType,
4055
+ expectedOutput?: JSONType,
4056
+ metadata?: Record<string, JSONType>,
4057
+ tags?: string[]
4058
+ ): Dataset
4059
+ /** Add multiple records to the dataset. */
4060
+ addRecords (records: DatasetRecordNew[]): Dataset
3958
4061
  /** Update fields on an existing dataset record. */
3959
4062
  update (index: number, fields: {
3960
4063
  input?: JSONType
@@ -3963,20 +4066,25 @@ declare namespace tracer {
3963
4066
  }): Dataset
3964
4067
  /** Delete an existing dataset record. */
3965
4068
  delete (index: number): Dataset
4069
+ /** Add tags to a dataset record. */
4070
+ addTags (index: number, tags: string[]): Dataset
4071
+ /** Remove tags from a dataset record. */
4072
+ removeTags (index: number, tags: string[]): Dataset
4073
+ /** Replace all tags on a dataset record. */
4074
+ replaceTags (index: number, tags: string[]): Dataset
3966
4075
  /** Creates the dataset remotely if needed and pushes any unpushed records. */
3967
4076
  push (): Promise<DatasetPushResult>
3968
4077
  name (): string
3969
4078
  description (): string
3970
4079
  id (): string | null
3971
4080
  projectId (): string | null
4081
+ /** Project associated with the client used to create or pull this dataset. */
4082
+ projectName (): string | null | undefined
3972
4083
  version (): number | null
3973
4084
  latestVersion (): number | null
3974
- records (): Array<{
3975
- id: string | null,
3976
- input: JSONType,
3977
- expectedOutput: JSONType,
3978
- metadata: Record<string, JSONType>
3979
- }>
4085
+ records (): DatasetRecord[]
4086
+ /** Return the tags used to filter this dataset. */
4087
+ filterTags (): string[]
3980
4088
  /** Dashboard URL for the dataset, or null until pushed. */
3981
4089
  url (): string | null
3982
4090
  }
@@ -4490,6 +4598,13 @@ declare namespace tracer {
4490
4598
  * Options for enabling LLM Observability tracing.
4491
4599
  */
4492
4600
  interface LLMObsEnableOptions {
4601
+ /**
4602
+ * The name of the LLM Observability project used for experiments.
4603
+ * @env DD_LLMOBS_PROJECT_NAME
4604
+ * Programmatic configuration takes precedence over the environment variables listed above.
4605
+ */
4606
+ projectName?: string,
4607
+
4493
4608
  /**
4494
4609
  * The name of your ML application.
4495
4610
  * @env DD_LLMOBS_ML_APP
@@ -4514,6 +4629,9 @@ declare namespace tracer {
4514
4629
  sampleRate?: number,
4515
4630
  }
4516
4631
 
4632
+ /** Options accepted by the deprecated runtime `llmobs.enable()` method. */
4633
+ type LLMObsRuntimeEnableOptions = Omit<LLMObsEnableOptions, 'projectName'>
4634
+
4517
4635
  /** @hidden */
4518
4636
  type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
4519
4637
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.11.0",
3
+ "version": "6.13.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -57,13 +57,14 @@
57
57
  "test:core:ci": "node scripts/c8-ci.js test:core",
58
58
  "test:code-origin": "mocha \"packages/datadog-code-origin/test/**/*.spec.js\"",
59
59
  "test:code-origin:ci": "node scripts/c8-ci.js test:code-origin",
60
+ "test:evp_proxy": "mocha \"packages/dd-trace/test/evp_proxy/**/*.spec.js\"",
60
61
  "test:lambda": "mocha \"packages/dd-trace/test/lambda/**/*.spec.js\"",
61
62
  "test:lambda:ci": "node scripts/c8-ci.js test:lambda",
62
63
  "test:llmobs:sdk": "mocha --exclude \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\" \"packages/dd-trace/test/llmobs/**/*.spec.js\"",
63
64
  "test:llmobs:sdk:ci": "node scripts/c8-ci.js test:llmobs:sdk",
64
65
  "test:llmobs:plugins": "mocha \"packages/dd-trace/test/llmobs/plugins/@(${PLUGINS})/*.spec.js\"",
65
66
  "test:llmobs:plugins:ci": "yarn services && node scripts/c8-ci.js test:llmobs:plugins",
66
- "test:openfeature": "mocha \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
67
+ "test:openfeature": "mocha \"packages/dd-trace/test/evp_proxy/**/*.spec.js\" \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
67
68
  "test:openfeature:ci": "node scripts/c8-ci.js test:openfeature",
68
69
  "test:plugins": "node --expose-gc ./node_modules/mocha/bin/mocha.js --fail-zero \"packages/datadog-plugin-@(${PLUGINS})/test/**/${SPEC:-*}*.spec.js\"",
69
70
  "test:plugins:ci": "yarn services && node scripts/c8-ci.js test:plugins",
@@ -114,7 +115,7 @@
114
115
  "test:integration:plugins:coverage": "yarn services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
115
116
  "test:unit:plugins": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\" \"packages/datadog-plugin-@(${PLUGINS})/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/*.spec.js\"",
116
117
  "test:release": "mocha \"scripts/release/**/*.spec.js\"",
117
- "test:scripts": "mocha \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
118
+ "test:scripts": "mocha \"benchmark/e2e-test-optimization/*.spec.js\" \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
118
119
  "test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
119
120
  "test:shimmer:ci": "node scripts/c8-ci.js test:shimmer",
120
121
  "verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
@@ -183,11 +184,11 @@
183
184
  },
184
185
  "optionalDependencies": {
185
186
  "@datadog/libdatadog": "0.12.1",
186
- "@datadog/native-appsec": "11.0.1",
187
- "@datadog/native-iast-taint-tracking": "4.2.0",
188
- "@datadog/native-metrics": "3.1.2",
189
- "@datadog/pprof": "5.18.0",
190
- "@datadog/wasm-js-rewriter": "5.0.3",
187
+ "@datadog/native-appsec": "11.0.2",
188
+ "@datadog/native-iast-taint-tracking": "4.2.1",
189
+ "@datadog/native-metrics": "4.0.0",
190
+ "@datadog/pprof": "5.18.1",
191
+ "@datadog/wasm-js-rewriter": "5.0.4",
191
192
  "@opentelemetry/api": ">=1.0.0 <1.10.0",
192
193
  "@opentelemetry/api-logs": "<1.0.0",
193
194
  "oxc-parser": "^0.132.0"
@@ -196,58 +197,58 @@
196
197
  "@actions/core": "^3.0.1",
197
198
  "@actions/github": "^9.1.1",
198
199
  "@babel/helpers": "^8.0.0",
199
- "@eslint/eslintrc": "^3.3.5",
200
+ "@eslint/eslintrc": "^3.3.6",
200
201
  "@eslint/js": "^10.0.1",
201
202
  "@eslint/plugin-kit": "^0.7.2",
202
- "@datadog/openfeature-node-server": "2.1.0",
203
+ "@datadog/openfeature-node-server": "2.2.0",
203
204
  "@msgpack/msgpack": "^3.1.3",
204
- "@openfeature/core": "^1.11.0",
205
- "@openfeature/server-sdk": "~1.22.0",
205
+ "@openfeature/core": "^1.12.0",
206
+ "@openfeature/server-sdk": "~1.23.0",
206
207
  "@stylistic/eslint-plugin": "^5.10.0",
207
208
  "@types/mocha": "^10.0.10",
208
209
  "@types/node": "^18.19.106",
209
210
  "@types/sinon": "^22.0.0",
210
- "@vercel/nft": "^1.10.2",
211
+ "@vercel/nft": "^1.11.0",
211
212
  "@yarnpkg/lockfile": "^1.1.0",
212
- "axios": "^1.18.1",
213
+ "axios": "^1.19.0",
213
214
  "benchmark": "^2.1.4",
214
215
  "body-parser": "^2.3.0",
215
- "bun": "1.3.14",
216
+ "bun": "1.4.0",
216
217
  "c8": "^12.0.0",
217
218
  "codeowners-audit": "^2.9.0",
218
- "eslint": "^10.5.0",
219
- "eslint-plugin-cypress": "^6.4.2",
219
+ "eslint": "^10.8.1",
220
+ "eslint-plugin-cypress": "^7.0.0",
220
221
  "eslint-plugin-import-x": "^4.16.2",
221
- "eslint-plugin-jsdoc": "^63.0.12",
222
+ "eslint-plugin-jsdoc": "^64.2.1",
222
223
  "eslint-plugin-mocha": "^11.3.0",
223
- "eslint-plugin-n": "^18.2.1",
224
+ "eslint-plugin-n": "^18.3.0",
224
225
  "eslint-plugin-promise": "^7.3.0",
225
226
  "eslint-plugin-sonarjs": "^4.2.0",
226
227
  "eslint-plugin-unicorn": "^73.0.0",
227
228
  "express": "^5.1.0",
228
229
  "glob": "^10.4.5",
229
- "globals": "^17.7.0",
230
+ "globals": "^17.11.0",
230
231
  "graphql": "*",
231
232
  "husky": "^9.1.7",
232
233
  "istanbul-lib-report": "^3.0.0",
233
234
  "istanbul-reports": "^3.0.2",
234
235
  "jsonc-parser": "^3.3.1",
235
236
  "jszip": "^3.10.1",
236
- "minimatch": "^10.2.5",
237
- "mocha": "^11.7.6",
237
+ "minimatch": "^10.2.6",
238
+ "mocha": "^11.8.0",
238
239
  "mocha-junit-reporter": "^2.2.1",
239
240
  "mocha-multi-reporters": "^1.5.1",
240
241
  "multer": "^2.2.0",
241
- "nock": "^14.0.16",
242
+ "nock": "^14.0.17",
242
243
  "node-preload": "^0.2.1",
243
244
  "nyc": "^18.0.0",
244
245
  "octokit": "^5.0.3",
245
- "p-limit": "^7.2.0",
246
+ "p-limit": "^7.3.1",
246
247
  "proxyquire": "^2.1.3",
247
248
  "retry": "^0.13.1",
248
249
  "semifies": "^1.0.0",
249
250
  "semver": "^7.8.5",
250
- "sinon": "^22.0.0",
251
+ "sinon": "^22.1.0",
251
252
  "source-map-support": "^0.5.21",
252
253
  "test-exclude": "^8.0.0",
253
254
  "tiktoken": "^1.0.21",
@@ -1,9 +1,11 @@
1
1
  'use strict'
2
2
 
3
3
  const wrapLogger = require('./helpers/bunyan')
4
- const { addHook } = require('./helpers/instrument')
4
+ const { addHook, channel } = require('./helpers/instrument')
5
+
6
+ const logSubmissionCh = channel('ci:log-submission:log')
5
7
 
6
8
  addHook({ name: 'bunyan', versions: ['>=1'] }, Logger => {
7
- wrapLogger(Logger, 'bunyan')
9
+ wrapLogger(Logger, 'bunyan', logSubmissionCh)
8
10
  return Logger
9
11
  })
@@ -1482,14 +1482,14 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
1482
1482
 
1483
1483
  this.options.retry = originalRetry
1484
1484
 
1485
- if (isNewerCucumberVersion && shouldRunEarlyFlakeDetection() && (isNew || isModified)) {
1486
- return shouldBePassedByEFD
1487
- }
1488
-
1489
1485
  if (isNewerCucumberVersion && isTestManagementTestsEnabled && !isAttemptToFix && (isQuarantined || isDisabled)) {
1490
1486
  return shouldBePassedByTestManagement
1491
1487
  }
1492
1488
 
1489
+ if (isNewerCucumberVersion && shouldRunEarlyFlakeDetection() && (isNew || isModified)) {
1490
+ return shouldBePassedByEFD
1491
+ }
1492
+
1493
1493
  if (isNewerCucumberVersion && isAttemptToFix && shouldBeFailedByAttemptToFix) {
1494
1494
  return false
1495
1495
  }
@@ -6,17 +6,26 @@ const { channel } = require('./instrument')
6
6
  /**
7
7
  * @param {{ prototype: object }} Logger
8
8
  * @param {string} id
9
+ * @param {import('node:diagnostics_channel').Channel} [logSubmissionCh]
9
10
  */
10
- module.exports = function wrapLogger (Logger, id) {
11
+ module.exports = function wrapLogger (Logger, id, logSubmissionCh) {
11
12
  const logCh = channel(`apm:${id}:log`)
13
+ // The record must be replaceable before Bunyan emits it, while the serialized line is only available afterward.
14
+ // This before-and-after contract requires the existing runtime wrapper rather than an Orchestrion subscriber.
12
15
  shimmer.wrap(Logger.prototype, '_emit', emit => {
13
16
  return function wrappedEmit (rec) {
14
17
  if (logCh.hasSubscribers) {
15
18
  const payload = { message: rec }
16
19
  logCh.publish(payload)
17
- arguments[0] = payload.message
20
+ rec = arguments[0] = payload.message
18
21
  }
19
- return emit.apply(this, arguments)
22
+
23
+ // Reuse Bunyan's cycle-safe serialization instead of serializing the record again.
24
+ const line = emit.apply(this, arguments)
25
+ if (logSubmissionCh?.hasSubscribers && logCh.hasSubscribers && !arguments[1]) {
26
+ logSubmissionCh.publish({ source: id, message: line ?? rec })
27
+ }
28
+ return line
20
29
  }
21
30
  })
22
31
  }
@@ -621,6 +621,7 @@ module.exports = {
621
621
  clearPoolWaitTime,
622
622
  dispatchesAcquireSynchronously,
623
623
  isPoolQueryAcquire,
624
+ reportPoolAcquireError,
624
625
  runOutsidePoolQueryAcquire,
625
626
  runPoolAcquireError,
626
627
  runWithPoolWait,