dd-trace 5.122.0 → 5.124.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 +144 -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
@@ -358,6 +358,16 @@ declare namespace tracer {
358
358
  links?: { context: SpanContext, attributes?: Object }[]
359
359
  }
360
360
 
361
+ export interface Exception {
362
+ message: string;
363
+ name?: string;
364
+ stack?: string;
365
+ }
366
+
367
+ export type SpanEventAttributeValue =
368
+ string | number | boolean | Array<string> | Array<number> | Array<boolean>;
369
+ export type SpanEventAttributes = Record<string, SpanEventAttributeValue>;
370
+
361
371
  /**
362
372
  * Span represents a logical unit of work as part of a broader Trace.
363
373
  * Examples of span might include remote procedure calls or a in-process
@@ -368,6 +378,14 @@ declare namespace tracer {
368
378
  export interface Span extends opentracing.Span {
369
379
  context (): SpanContext;
370
380
 
381
+ /**
382
+ * Records an exception as a span event without marking the span as failed.
383
+ *
384
+ * @param exception The exception to record.
385
+ * @param attributes Additional attributes for the exception event.
386
+ */
387
+ recordException (exception: Exception, attributes?: SpanEventAttributes): void;
388
+
371
389
  /**
372
390
  * Causally links another span to the current span
373
391
  *
@@ -859,6 +877,13 @@ declare namespace tracer {
859
877
  * Programmatic configuration takes precedence over the environment variables listed above.
860
878
  */
861
879
  maxMessagesLength?: number,
880
+ /**
881
+ * Whether AI Guard applies backend-provided sensitive-data redaction replacements.
882
+ * @default true
883
+ * @env DD_AI_GUARD_REDACTION_ENABLED
884
+ * Programmatic configuration takes precedence over the environment variables listed above.
885
+ */
886
+ redactionEnabled?: boolean,
862
887
  /**
863
888
  * Max size of the content property set in the meta-struct
864
889
  * @env DD_AI_GUARD_MAX_CONTENT_SIZE
@@ -1818,6 +1843,25 @@ declare namespace tracer {
1818
1843
  };
1819
1844
  }
1820
1845
 
1846
+ /**
1847
+ * A structured content part in an AI Guard message.
1848
+ */
1849
+ export interface ContentPart {
1850
+ type: string;
1851
+ text?: string;
1852
+ image_url?: { url: string };
1853
+ }
1854
+
1855
+ /**
1856
+ * A conversational message whose content is represented by structured parts.
1857
+ */
1858
+ export interface ContentPartsMessage {
1859
+ role: string;
1860
+ content: ContentPart[];
1861
+ tool_call_id?: string;
1862
+ tool_calls?: ToolCall[];
1863
+ }
1864
+
1821
1865
  /**
1822
1866
  * A standard conversational message exchanged with a Large Language Model (LLM).
1823
1867
  */
@@ -1889,10 +1933,25 @@ declare namespace tracer {
1889
1933
 
1890
1934
  export type Message =
1891
1935
  | TextMessage
1936
+ | ContentPartsMessage
1892
1937
  | AssistantTextMessage
1893
1938
  | AssistantToolCallMessage
1894
1939
  | ToolMessage;
1895
1940
 
1941
+ /**
1942
+ * A sensitive data replacement the AI Guard service determined for the evaluated conversation.
1943
+ */
1944
+ export interface RedactionReplacement {
1945
+ /**
1946
+ * Location of the replaced value within the evaluated conversation (e.g. `messages[0].content`).
1947
+ */
1948
+ path: string;
1949
+ /**
1950
+ * The value that replaces the sensitive data found at `path`.
1951
+ */
1952
+ replacement: string;
1953
+ }
1954
+
1896
1955
  /**
1897
1956
  * The result returned by AI Guard after evaluating a conversation.
1898
1957
  */
@@ -1920,6 +1979,16 @@ declare namespace tracer {
1920
1979
  * Sensitive Data Scanner findings from the evaluation.
1921
1980
  */
1922
1981
  sds: Object[];
1982
+ /**
1983
+ * The evaluated conversation, redacted when required by the AI Guard service.
1984
+ * This may contain sensitive data when redaction is disabled or no replacement was applied.
1985
+ */
1986
+ messages: Message[];
1987
+ /**
1988
+ * The replacements the AI Guard service determined for the evaluated conversation, reported whether or not
1989
+ * the tracer applied them. Empty when the service determined no replacement.
1990
+ */
1991
+ redactionReplacements: RedactionReplacement[];
1923
1992
  }
1924
1993
 
1925
1994
  /**
@@ -2317,7 +2386,7 @@ declare namespace tracer {
2317
2386
  * This plugin automatically instruments the
2318
2387
  * [Vercel AI SDK](https://ai-sdk.dev/docs/introduction) module.
2319
2388
  */
2320
- interface ai extends Instrumentation {}
2389
+ interface ai extends Instrumentation, LLMObsIntegration {}
2321
2390
 
2322
2391
  /**
2323
2392
  * This plugin automatically instruments the
@@ -2335,13 +2404,13 @@ declare namespace tracer {
2335
2404
  * This plugin automatically instruments the
2336
2405
  * [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) module.
2337
2406
  */
2338
- interface claude_agent_sdk extends Instrumentation {}
2407
+ interface claude_agent_sdk extends Instrumentation, LLMObsIntegration {}
2339
2408
 
2340
2409
  /**
2341
2410
  * This plugin automatically instruments the
2342
2411
  * [anthropic](https://www.npmjs.com/package/@anthropic-ai/sdk) module.
2343
2412
  */
2344
- interface anthropic extends Instrumentation {}
2413
+ interface anthropic extends Instrumentation, LLMObsIntegration {}
2345
2414
 
2346
2415
  /**
2347
2416
  * Currently this plugin automatically instruments
@@ -2402,7 +2471,7 @@ declare namespace tracer {
2402
2471
  * This plugin automatically instruments the
2403
2472
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
2404
2473
  */
2405
- interface aws_sdk extends Instrumentation {
2474
+ interface aws_sdk extends Instrumentation, LLMObsIntegration {
2406
2475
  /**
2407
2476
  * The service name to be used for this plugin. When a function is used it is called with the AWS
2408
2477
  * request parameters (e.g. `{ TableName }` for DynamoDB, `{ Bucket }` for S3) and its return value
@@ -2637,13 +2706,13 @@ declare namespace tracer {
2637
2706
  * This plugin automatically instruments the
2638
2707
  * [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
2639
2708
  */
2640
- interface google_cloud_vertexai extends Integration {}
2709
+ interface google_cloud_vertexai extends Integration, LLMObsIntegration {}
2641
2710
 
2642
2711
  /**
2643
2712
  * This plugin automatically instruments the
2644
2713
  * [@google-genai](https://github.com/googleapis/js-genai) module.
2645
2714
  */
2646
- interface google_genai extends Integration {}
2715
+ interface google_genai extends Integration, LLMObsIntegration {}
2647
2716
 
2648
2717
  /** @hidden */
2649
2718
  interface ExecutionArgs {
@@ -3001,7 +3070,7 @@ declare namespace tracer {
3001
3070
  * This plugin automatically instruments the
3002
3071
  * [langgraph](https://github.com/npmjs/package/langgraph) library.
3003
3072
  */
3004
- interface langgraph extends Instrumentation {}
3073
+ interface langgraph extends Instrumentation, LLMObsIntegration {}
3005
3074
 
3006
3075
  /**
3007
3076
  * This plugin automatically instruments the
@@ -3161,13 +3230,13 @@ declare namespace tracer {
3161
3230
  * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
3162
3231
  * in the agent.
3163
3232
  */
3164
- interface openai extends Instrumentation {}
3233
+ interface openai extends Instrumentation, LLMObsIntegration {}
3165
3234
 
3166
3235
  /**
3167
3236
  * This plugin automatically instruments the
3168
3237
  * [@openai/agents](https://www.npmjs.com/package/@openai/agents) library.
3169
3238
  */
3170
- interface openai_agents extends Instrumentation {}
3239
+ interface openai_agents extends Instrumentation, LLMObsIntegration {}
3171
3240
 
3172
3241
  /**
3173
3242
  * This plugin automatically instruments the
@@ -3816,7 +3885,7 @@ declare namespace tracer {
3816
3885
  *
3817
3886
  * @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 })`.
3818
3887
  */
3819
- enable (options: LLMObsEnableOptions): void,
3888
+ enable (options: LLMObsRuntimeEnableOptions): void,
3820
3889
 
3821
3890
  /**
3822
3891
  * Disable LLM Observability tracing.
@@ -3995,20 +4064,35 @@ declare namespace tracer {
3995
4064
  metadata?: Array<Record<string, any>>
3996
4065
  ) => any | Promise<any>
3997
4066
 
4067
+ interface DatasetRecord {
4068
+ id: string | null
4069
+ input: JSONType
4070
+ expectedOutput: JSONType
4071
+ metadata: Record<string, JSONType>
4072
+ tags: string[]
4073
+ }
4074
+
4075
+ interface DatasetRecordNew {
4076
+ id?: string
4077
+ inputData: JSONType
4078
+ expectedOutput?: JSONType
4079
+ metadata?: Record<string, JSONType>
4080
+ tags?: string[]
4081
+ }
4082
+
3998
4083
  interface CreateDatasetOptions {
4084
+ /** Override the configured project for this dataset. */
4085
+ projectName?: string
3999
4086
  description?: string
4000
- records?: Array<{
4001
- id?: string,
4002
- inputData: JSONType,
4003
- expectedOutput?: JSONType,
4004
- metadata?: Record<string, JSONType>
4005
- }>
4087
+ records?: DatasetRecordNew[]
4006
4088
  }
4007
4089
 
4008
4090
  interface ExperimentOptions {
4009
4091
  name: string
4010
4092
  dataset: Dataset
4011
4093
  task: ExperimentTask
4094
+ /** Override the configured project for this experiment. */
4095
+ projectName?: string
4012
4096
  /** Evaluators keyed by metric label, or named functions. */
4013
4097
  evaluators?: Record<string, ExperimentEvaluator> | ExperimentEvaluator[]
4014
4098
  /** Summary evaluators keyed by metric label, or named functions. */
@@ -4016,6 +4100,8 @@ declare namespace tracer {
4016
4100
  description?: string
4017
4101
  config?: Record<string, JSONType>
4018
4102
  tags?: Record<string, string>
4103
+ /** Number of full experiment runs to execute. Default 1. */
4104
+ runs?: number
4019
4105
  }
4020
4106
 
4021
4107
  interface ExperimentRunOptions {
@@ -4025,15 +4111,21 @@ declare namespace tracer {
4025
4111
  retryDelay?: (attempt: number) => number
4026
4112
  /** Reject on the first task/evaluator error instead of capturing it. Default false. */
4027
4113
  throwOnErrors?: boolean
4114
+ /** Maximum number of task/evaluator executions to process concurrently. Default 10. */
4115
+ concurrency?: number
4028
4116
  }
4029
4117
 
4030
4118
  interface PullDatasetOptions {
4119
+ /** Override the configured project for this dataset pull. */
4120
+ projectName?: string
4031
4121
  /** Dataset version to pull. Defaults to latest. */
4032
4122
  version?: number
4033
4123
  /** Wait until at least this many records are readable (absorbs write lag). */
4034
4124
  expectedRecordCount?: number
4035
4125
  /** Maximum total time to wait, in ms. Default 30000. */
4036
4126
  maxWaitMs?: number
4127
+ /** Filter records by these tags. */
4128
+ tags?: string[]
4037
4129
  }
4038
4130
 
4039
4131
  interface ExperimentResultRow {
@@ -4054,17 +4146,21 @@ declare namespace tracer {
4054
4146
 
4055
4147
  interface ExperimentRun {
4056
4148
  runId: string
4149
+ /** 1-based run iteration. */
4057
4150
  runIteration: number
4151
+ /** Whether this run had a task, row-evaluator, or summary-evaluator error. */
4152
+ hasError: boolean
4058
4153
  rows: ExperimentResultRow[]
4059
4154
  summaryEvaluations: Record<string, { value: any, error: string | null }>
4060
4155
  }
4061
4156
 
4062
4157
  interface ExperimentResult {
4063
4158
  experimentId: string
4159
+ /** Rows from the first run, kept as a compatibility alias. */
4064
4160
  rows: ExperimentResultRow[]
4065
- /** Single-run summary evaluator results. */
4161
+ /** Summary evaluator results from the first run, kept as a compatibility alias. */
4066
4162
  summaryEvaluations: Record<string, { value: any, error: string | null }>
4067
- /** Experiment runs. P0 Node experiments currently return one run. */
4163
+ /** All experiment runs. */
4068
4164
  runs: ExperimentRun[]
4069
4165
  /** Dashboard URL for the experiment. */
4070
4166
  url: string
@@ -4151,7 +4247,14 @@ declare namespace tracer {
4151
4247
  }
4152
4248
 
4153
4249
  interface Dataset {
4154
- addRecord (input: JSONType, expectedOutput?: JSONType, metadata?: Record<string, JSONType>): Dataset
4250
+ addRecord (
4251
+ input: JSONType,
4252
+ expectedOutput?: JSONType,
4253
+ metadata?: Record<string, JSONType>,
4254
+ tags?: string[]
4255
+ ): Dataset
4256
+ /** Add multiple records to the dataset. */
4257
+ addRecords (records: DatasetRecordNew[]): Dataset
4155
4258
  /** Update fields on an existing dataset record. */
4156
4259
  update (index: number, fields: {
4157
4260
  input?: JSONType
@@ -4160,20 +4263,25 @@ declare namespace tracer {
4160
4263
  }): Dataset
4161
4264
  /** Delete an existing dataset record. */
4162
4265
  delete (index: number): Dataset
4266
+ /** Add tags to a dataset record. */
4267
+ addTags (index: number, tags: string[]): Dataset
4268
+ /** Remove tags from a dataset record. */
4269
+ removeTags (index: number, tags: string[]): Dataset
4270
+ /** Replace all tags on a dataset record. */
4271
+ replaceTags (index: number, tags: string[]): Dataset
4163
4272
  /** Creates the dataset remotely if needed and pushes any unpushed records. */
4164
4273
  push (): Promise<DatasetPushResult>
4165
4274
  name (): string
4166
4275
  description (): string
4167
4276
  id (): string | null
4168
4277
  projectId (): string | null
4278
+ /** Project associated with the client used to create or pull this dataset. */
4279
+ projectName (): string | null | undefined
4169
4280
  version (): number | null
4170
4281
  latestVersion (): number | null
4171
- records (): Array<{
4172
- id: string | null,
4173
- input: JSONType,
4174
- expectedOutput: JSONType,
4175
- metadata: Record<string, JSONType>
4176
- }>
4282
+ records (): DatasetRecord[]
4283
+ /** Return the tags used to filter this dataset. */
4284
+ filterTags (): string[]
4177
4285
  /** Dashboard URL for the dataset, or null until pushed. */
4178
4286
  url (): string | null
4179
4287
  }
@@ -4689,6 +4797,13 @@ declare namespace tracer {
4689
4797
  * Options for enabling LLM Observability tracing.
4690
4798
  */
4691
4799
  interface LLMObsEnableOptions {
4800
+ /**
4801
+ * The name of the LLM Observability project used for experiments.
4802
+ * @env DD_LLMOBS_PROJECT_NAME
4803
+ * Programmatic configuration takes precedence over the environment variables listed above.
4804
+ */
4805
+ projectName?: string,
4806
+
4692
4807
  /**
4693
4808
  * The name of your ML application.
4694
4809
  * @env DD_LLMOBS_ML_APP
@@ -4712,6 +4827,10 @@ declare namespace tracer {
4712
4827
  */
4713
4828
  sampleRate?: number,
4714
4829
  }
4830
+
4831
+ /** Options accepted by the deprecated runtime `llmobs.enable()` method. */
4832
+ type LLMObsRuntimeEnableOptions = Omit<LLMObsEnableOptions, 'projectName'>
4833
+
4715
4834
  /** @hidden */
4716
4835
  type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
4717
4836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.122.0",
3
+ "version": "5.124.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,