dd-trace 5.97.0 → 5.99.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 (175) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ext/tags.js +1 -0
  3. package/index.d.ts +35 -3
  4. package/package.json +48 -46
  5. package/packages/datadog-instrumentations/src/crypto.js +45 -0
  6. package/packages/datadog-instrumentations/src/cucumber.js +65 -3
  7. package/packages/datadog-instrumentations/src/cypress-config.js +153 -53
  8. package/packages/datadog-instrumentations/src/dns.js +24 -56
  9. package/packages/datadog-instrumentations/src/graphql.js +1 -1
  10. package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
  11. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +4 -1
  12. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
  13. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +10 -3
  14. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
  15. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +59 -0
  16. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +11 -2
  17. package/packages/datadog-instrumentations/src/jest.js +104 -12
  18. package/packages/datadog-instrumentations/src/mocha/utils.js +8 -0
  19. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -0
  20. package/packages/datadog-instrumentations/src/pino.js +4 -28
  21. package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
  22. package/packages/datadog-instrumentations/src/playwright.js +5 -17
  23. package/packages/datadog-instrumentations/src/redis.js +12 -6
  24. package/packages/datadog-instrumentations/src/stripe.js +38 -24
  25. package/packages/datadog-instrumentations/src/vitest.js +32 -4
  26. package/packages/datadog-instrumentations/src/zlib.js +29 -0
  27. package/packages/datadog-plugin-aws-sdk/src/base.js +2 -3
  28. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +1 -0
  29. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -0
  30. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -0
  31. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -0
  32. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -0
  34. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
  35. package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -9
  36. package/packages/datadog-plugin-cucumber/src/index.js +8 -2
  37. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +114 -6
  38. package/packages/datadog-plugin-cypress/src/index.js +59 -2
  39. package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
  40. package/packages/datadog-plugin-fs/src/index.js +1 -1
  41. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -1
  42. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +2 -7
  43. package/packages/datadog-plugin-http/src/client.js +1 -1
  44. package/packages/datadog-plugin-http/src/server.js +21 -13
  45. package/packages/datadog-plugin-http2/src/client.js +1 -1
  46. package/packages/datadog-plugin-http2/src/server.js +10 -2
  47. package/packages/datadog-plugin-jest/src/index.js +2 -2
  48. package/packages/datadog-plugin-mocha/src/index.js +1 -2
  49. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
  50. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +55 -0
  51. package/packages/datadog-plugin-mongodb-core/src/index.js +4 -9
  52. package/packages/datadog-plugin-mysql/src/index.js +1 -1
  53. package/packages/datadog-plugin-next/src/index.js +8 -2
  54. package/packages/datadog-plugin-pg/src/index.js +1 -1
  55. package/packages/datadog-plugin-playwright/src/index.js +2 -3
  56. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  57. package/packages/datadog-plugin-vitest/src/index.js +14 -6
  58. package/packages/datadog-plugin-ws/src/close.js +3 -1
  59. package/packages/datadog-plugin-ws/src/producer.js +2 -0
  60. package/packages/datadog-plugin-ws/src/receiver.js +2 -1
  61. package/packages/dd-trace/src/aiguard/channels.js +8 -0
  62. package/packages/dd-trace/src/aiguard/index.js +7 -3
  63. package/packages/dd-trace/src/aiguard/sdk.js +66 -22
  64. package/packages/dd-trace/src/aiguard/tags.js +1 -0
  65. package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
  66. package/packages/dd-trace/src/appsec/blocking.js +62 -34
  67. package/packages/dd-trace/src/appsec/graphql.js +6 -6
  68. package/packages/dd-trace/src/appsec/index.js +9 -11
  69. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
  70. package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
  71. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
  72. package/packages/dd-trace/src/appsec/rasp/ssrf.js +5 -6
  73. package/packages/dd-trace/src/appsec/recommended.json +2438 -13
  74. package/packages/dd-trace/src/appsec/reporter.js +6 -5
  75. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  76. package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
  77. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +6 -10
  78. package/packages/dd-trace/src/appsec/sdk/utils.js +4 -2
  79. package/packages/dd-trace/src/appsec/store.js +50 -0
  80. package/packages/dd-trace/src/appsec/waf/index.js +3 -5
  81. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -2
  82. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
  83. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
  84. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
  85. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
  86. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -2
  87. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
  88. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +3 -4
  89. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +6 -6
  90. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +2 -2
  91. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -2
  92. package/packages/dd-trace/src/config/config-types.d.ts +0 -4
  93. package/packages/dd-trace/src/config/defaults.js +10 -11
  94. package/packages/dd-trace/src/config/generated-config-types.d.ts +14 -8
  95. package/packages/dd-trace/src/config/index.js +49 -32
  96. package/packages/dd-trace/src/config/parsers.js +26 -9
  97. package/packages/dd-trace/src/config/supported-configurations.json +86 -33
  98. package/packages/dd-trace/src/constants.js +1 -0
  99. package/packages/dd-trace/src/debugger/config.js +2 -0
  100. package/packages/dd-trace/src/debugger/devtools_client/send.js +25 -5
  101. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
  102. package/packages/dd-trace/src/encode/0.4.js +11 -11
  103. package/packages/dd-trace/src/encode/span-stats.js +4 -1
  104. package/packages/dd-trace/src/exporters/agent/index.js +0 -1
  105. package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
  106. package/packages/dd-trace/src/exporters/agentless/writer.js +3 -3
  107. package/packages/dd-trace/src/exporters/common/util.js +2 -2
  108. package/packages/dd-trace/src/id.js +2 -0
  109. package/packages/dd-trace/src/index.js +2 -5
  110. package/packages/dd-trace/src/lambda/handler.js +1 -3
  111. package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +5 -63
  112. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +106 -0
  113. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
  114. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
  115. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
  116. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +0 -49
  117. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
  118. package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
  119. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -26
  120. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
  121. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
  122. package/packages/dd-trace/src/llmobs/sdk.js +2 -2
  123. package/packages/dd-trace/src/log/index.js +0 -10
  124. package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
  125. package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -0
  126. package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
  127. package/packages/dd-trace/src/opentelemetry/context_manager.js +6 -4
  128. package/packages/dd-trace/src/opentelemetry/logs/index.js +1 -1
  129. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
  130. package/packages/dd-trace/src/opentelemetry/metrics/index.js +1 -1
  131. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
  132. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -51
  133. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
  134. package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
  135. package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
  136. package/packages/dd-trace/src/opentelemetry/trace/index.js +70 -0
  137. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +74 -0
  138. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +342 -0
  139. package/packages/dd-trace/src/opentelemetry/tracer.js +9 -11
  140. package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -10
  141. package/packages/dd-trace/src/opentracing/span.js +1 -1
  142. package/packages/dd-trace/src/opentracing/tracer.js +17 -5
  143. package/packages/dd-trace/src/plugins/index.js +1 -0
  144. package/packages/dd-trace/src/plugins/log_plugin.js +3 -0
  145. package/packages/dd-trace/src/plugins/plugin.js +6 -11
  146. package/packages/dd-trace/src/plugins/storage.js +2 -2
  147. package/packages/dd-trace/src/plugins/tracing.js +22 -5
  148. package/packages/dd-trace/src/plugins/util/test.js +128 -5
  149. package/packages/dd-trace/src/plugins/util/url.js +2 -1
  150. package/packages/dd-trace/src/plugins/util/web.js +6 -88
  151. package/packages/dd-trace/src/profiling/profiler.js +34 -77
  152. package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
  153. package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
  154. package/packages/dd-trace/src/profiling/profilers/events.js +35 -0
  155. package/packages/dd-trace/src/proxy.js +3 -4
  156. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +17 -13
  157. package/packages/dd-trace/src/service-naming/index.js +1 -1
  158. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
  159. package/packages/dd-trace/src/service-naming/schemas/util.js +15 -1
  160. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +24 -1
  161. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
  162. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +21 -1
  163. package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
  164. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
  165. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +15 -1
  166. package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
  167. package/packages/dd-trace/src/span_processor.js +1 -2
  168. package/packages/dd-trace/src/span_stats.js +5 -1
  169. package/packages/dd-trace/src/tagger.js +2 -2
  170. package/packages/dd-trace/src/telemetry/send-data.js +5 -7
  171. package/vendor/dist/@apm-js-collab/code-transformer/index.js +28 -6
  172. package/vendor/dist/protobufjs/index.js +1 -1
  173. package/packages/dd-trace/src/log/utils.js +0 -16
  174. package/vendor/dist/ignore/LICENSE +0 -21
  175. package/vendor/dist/ignore/index.js +0 -1
@@ -68,7 +68,6 @@
68
68
  "esquery","https://github.com/estools/esquery","['BSD-3-Clause']","['Joel Feenstra']"
69
69
  "estraverse","https://github.com/estools/estraverse","['BSD-2-Clause']","['estools']"
70
70
  "fast-fifo","https://github.com/mafintosh/fast-fifo","['MIT']","['Mathias Buus']"
71
- "ignore","https://github.com/kaelzhang/node-ignore","['MIT']","['kael']"
72
71
  "import-in-the-middle","https://github.com/nodejs/import-in-the-middle","['Apache-2.0']","['Bryan English']"
73
72
  "istanbul-lib-coverage","https://github.com/istanbuljs/istanbuljs","['BSD-3-Clause']","['Krishnan Anantheswaran']"
74
73
  "jest-docblock","https://github.com/jestjs/jest","['MIT']","['jestjs']"
package/ext/tags.js CHANGED
@@ -25,6 +25,7 @@ const tags = {
25
25
  HTTP_RESPONSE_HEADERS: 'http.response.headers',
26
26
  HTTP_USERAGENT: 'http.useragent',
27
27
  HTTP_CLIENT_IP: 'http.client_ip',
28
+ NETWORK_CLIENT_IP: 'network.client.ip',
28
29
 
29
30
  // Messaging
30
31
 
package/index.d.ts CHANGED
@@ -272,6 +272,7 @@ interface Plugins {
272
272
  "memcached": tracer.plugins.memcached;
273
273
  "microgateway-core": tracer.plugins.microgateway_core;
274
274
  "mocha": tracer.plugins.mocha;
275
+ "modelcontextprotocol-sdk": tracer.plugins.modelcontextprotocol_sdk;
275
276
  "moleculer": tracer.plugins.moleculer;
276
277
  "mongodb-core": tracer.plugins.mongodb_core;
277
278
  "mongoose": tracer.plugins.mongoose;
@@ -665,7 +666,15 @@ declare namespace tracer {
665
666
  * @env DD_RUNTIME_METRICS_EVENT_LOOP_ENABLED
666
667
  * Programmatic configuration takes precedence over the environment variables listed above.
667
668
  */
668
- eventLoop?: boolean
669
+ eventLoop?: boolean,
670
+
671
+ /**
672
+ * Whether to use native metrics. When set to false, forces the JS implementation
673
+ * @default true
674
+ * @env DD_RUNTIME_METRICS_NATIVE
675
+ * Programmatic configuration takes precedence over the environment variables listed above.
676
+ */
677
+ native?: boolean
669
678
  }
670
679
 
671
680
  /**
@@ -795,7 +804,7 @@ declare namespace tracer {
795
804
  * Whether to request blocking mode when evaluating prompts via auto-instrumentation.
796
805
  * When `true`, AI Guard will block requests that violate security policies.
797
806
  * When `false`, AI Guard evaluates but never blocks (monitor-only mode).
798
- * @default false
807
+ * @default true
799
808
  * @env DD_AI_GUARD_BLOCK
800
809
  * Programmatic configuration takes precedence over the environment variables listed above.
801
810
  */
@@ -1847,6 +1856,10 @@ declare namespace tracer {
1847
1856
  * List of tags associated with the evaluation (e.g. indirect-prompt-injection)
1848
1857
  */
1849
1858
  tags: string[];
1859
+ /**
1860
+ * Dictionary of tag probabilities (e.g. { indirect-prompt-injection: 0.2, jailbreak-attempt: 0.8 })
1861
+ */
1862
+ tagProbabilities: { [key: string]: number }
1850
1863
  /**
1851
1864
  * Sensitive Data Scanner findings from the evaluation.
1852
1865
  */
@@ -1866,6 +1879,10 @@ declare namespace tracer {
1866
1879
  * List of tags associated with the evaluation (e.g. indirect-prompt-injection)
1867
1880
  */
1868
1881
  tags: string[];
1882
+ /**
1883
+ * Dictionary of tag probabilities (e.g. { indirect-prompt-injection: 0.2, jailbreak-attempt: 0.8 })
1884
+ */
1885
+ tagProbabilities: { [key: string]: number }
1869
1886
  /**
1870
1887
  * Sensitive Data Scanner findings from the evaluation.
1871
1888
  */
@@ -2832,11 +2849,18 @@ declare namespace tracer {
2832
2849
  * [mocha](https://mochajs.org/) module.
2833
2850
  */
2834
2851
  interface mocha extends Integration {}
2835
-
2852
+
2853
+ /**
2854
+ * This plugin automatically instruments the
2855
+ * [modelcontextprotocol-sdk](https://github.com/npmjs/package/@modelcontextprotocol/sdk) library.
2856
+ */
2857
+ interface modelcontextprotocol_sdk extends Instrumentation {}
2858
+
2836
2859
  /**
2837
2860
  * This plugin automatically instruments the
2838
2861
  * [moleculer](https://moleculer.services/) module.
2839
2862
  */
2863
+
2840
2864
  interface moleculer extends Moleculer {
2841
2865
  /**
2842
2866
  * Configuration for Moleculer clients. Set to false to disable client
@@ -3048,6 +3072,14 @@ declare namespace tracer {
3048
3072
  * @returns true to instrument the command, false to skip it
3049
3073
  */
3050
3074
  filter?: (command: string) => boolean;
3075
+
3076
+ /**
3077
+ * Whether to use a different service name for each Redis instance based
3078
+ * on the configured connection name of the client.
3079
+ *
3080
+ * @default false
3081
+ */
3082
+ splitByInstance?: boolean;
3051
3083
  }
3052
3084
 
3053
3085
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.97.0",
3
+ "version": "5.99.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -13,6 +13,8 @@
13
13
  "dependencies:dedupe": "yarn-deduplicate yarn.lock",
14
14
  "generate:config:types": "node scripts/generate-config-types.js",
15
15
  "verify:config:types": "node scripts/generate-config-types.js --check",
16
+ "generate:supported-integrations": "node scripts/generate-supported-integrations.js",
17
+ "verify:supported-integrations": "node scripts/generate-supported-integrations.js --check",
16
18
  "type:check": "tsc --noEmit -p tsconfig.dev.json",
17
19
  "type:doc:build": "cd docs && yarn && yarn build",
18
20
  "type:doc:test": "cd docs && yarn && yarn test",
@@ -24,58 +26,58 @@
24
26
  "release:proposal": "node scripts/release/proposal",
25
27
  "services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
26
28
  "test": "echo '\nError: The root \"npm test\" command is intentionally disabled.\n\nInstead, run specific test suites:\n - npm run test:trace:core\n - npm run test:appsec\n - etc.\n\nOr run individual test files:\n npx mocha path/to/test.spec.js\n\nSee CONTRIBUTING.md (Testing section) for more details.\n' && exit 1",
27
- "test:aiguard": "mocha packages/dd-trace/test/aiguard/**/*.spec.js",
28
- "test:aiguard:ci": "nyc -- npm run test:aiguard",
29
+ "test:aiguard": "mocha \"packages/dd-trace/test/aiguard/**/*.spec.js\"",
30
+ "test:aiguard:ci": "nyc --silent node init && nyc -- npm run test:aiguard",
29
31
  "test:appsec": "mocha --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" \"packages/dd-trace/test/appsec/**/*.spec.js\"",
30
- "test:appsec:ci": "nyc -- npm run test:appsec",
32
+ "test:appsec:ci": "nyc --silent node init && nyc -- npm run test:appsec",
31
33
  "test:appsec:plugins": "mocha \"packages/dd-trace/test/appsec/**/*.@(${PLUGINS}).plugin.spec.js\"",
32
- "test:appsec:plugins:ci": "yarn services && nyc -- npm run test:appsec:plugins",
33
- "test:debugger": "mocha packages/dd-trace/test/debugger/**/*.spec.js",
34
- "test:debugger:ci": "nyc -- npm run test:debugger",
34
+ "test:appsec:plugins:ci": "yarn services && nyc --silent node init && nyc -- npm run test:appsec:plugins",
35
+ "test:debugger": "mocha \"packages/dd-trace/test/debugger/**/*.spec.js\"",
36
+ "test:debugger:ci": "nyc --silent node init && nyc -- npm run test:debugger",
35
37
  "test:eslint-rules": "node eslint-rules/*.test.mjs",
36
38
  "test:trace:core": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/dd-trace/test/*.spec.js\" \"packages/dd-trace/test/{agent,ci-visibility,config,crashtracking,datastreams,encode,exporters,msgpack,opentelemetry,opentracing,payload-tagging,plugins,remote_config,service-naming,standalone,telemetry,external-logger}/**/*.spec.js\"",
37
- "test:trace:core:ci": "nyc -- npm run test:trace:core",
38
- "test:trace:guardrails": "mocha packages/dd-trace/test/guardrails/**/*.spec.js",
39
- "test:trace:guardrails:ci": "nyc -- npm run test:trace:guardrails",
40
- "test:esbuild": "mocha packages/datadog-esbuild/test/**/*.spec.js",
41
- "test:esbuild:ci": "nyc -- npm run test:esbuild",
42
- "test:webpack": "mocha packages/datadog-webpack/test/**/*.spec.js",
43
- "test:webpack:ci": "nyc -- npm run test:webpack",
39
+ "test:trace:core:ci": "nyc --silent node init && nyc -- npm run test:trace:core",
40
+ "test:trace:guardrails": "mocha \"packages/dd-trace/test/guardrails/**/*.spec.js\"",
41
+ "test:trace:guardrails:ci": "nyc --silent node init && nyc -- npm run test:trace:guardrails",
42
+ "test:esbuild": "mocha \"packages/datadog-esbuild/test/**/*.spec.js\"",
43
+ "test:esbuild:ci": "nyc --silent node init && nyc -- npm run test:esbuild",
44
+ "test:webpack": "mocha \"packages/datadog-webpack/test/**/*.spec.js\"",
45
+ "test:webpack:ci": "nyc --silent node init && nyc -- npm run test:webpack",
44
46
  "test:instrumentations": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\"",
45
- "test:instrumentations:ci": "yarn services && nyc -- npm run test:instrumentations",
46
- "test:instrumentations:misc": "mocha packages/datadog-instrumentations/test/*/**/*.spec.js",
47
- "test:instrumentations:misc:ci": "nyc -- npm run test:instrumentations:misc",
48
- "test:core": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- packages/datadog-core/test/**/*.spec.js",
49
- "test:core:ci": "nyc -- npm run test:core",
50
- "test:code-origin": "mocha packages/datadog-code-origin/test/**/*.spec.js",
51
- "test:code-origin:ci": "nyc -- npm run test:code-origin",
52
- "test:lambda": "mocha packages/dd-trace/test/lambda/**/*.spec.js",
53
- "test:lambda:ci": "nyc -- npm run test:lambda",
47
+ "test:instrumentations:ci": "yarn services && nyc --silent node init && nyc -- npm run test:instrumentations",
48
+ "test:instrumentations:misc": "mocha \"packages/datadog-instrumentations/test/*/**/*.spec.js\"",
49
+ "test:instrumentations:misc:ci": "nyc --silent node init && nyc -- npm run test:instrumentations:misc",
50
+ "test:core": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/datadog-core/test/**/*.spec.js\"",
51
+ "test:core:ci": "nyc --silent node init && nyc -- npm run test:core",
52
+ "test:code-origin": "mocha \"packages/datadog-code-origin/test/**/*.spec.js\"",
53
+ "test:code-origin:ci": "nyc --silent node init && nyc -- npm run test:code-origin",
54
+ "test:lambda": "mocha \"packages/dd-trace/test/lambda/**/*.spec.js\"",
55
+ "test:lambda:ci": "nyc --silent node init && nyc -- npm run test:lambda",
54
56
  "test:llmobs:sdk": "mocha --exclude \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\" \"packages/dd-trace/test/llmobs/**/*.spec.js\"",
55
- "test:llmobs:sdk:ci": "nyc -- npm run test:llmobs:sdk",
57
+ "test:llmobs:sdk:ci": "nyc --silent node init && nyc -- npm run test:llmobs:sdk",
56
58
  "test:llmobs:plugins": "mocha \"packages/dd-trace/test/llmobs/plugins/@(${PLUGINS})/*.spec.js\"",
57
- "test:llmobs:plugins:ci": "yarn services && nyc -- npm run test:llmobs:plugins",
58
- "test:openfeature": "mocha packages/dd-trace/test/openfeature/**/*.spec.js",
59
- "test:openfeature:ci": "nyc -- npm run test:openfeature",
59
+ "test:llmobs:plugins:ci": "yarn services && nyc --silent node init && nyc -- npm run test:llmobs:plugins",
60
+ "test:openfeature": "mocha \"packages/dd-trace/test/openfeature/**/*.spec.js\"",
61
+ "test:openfeature:ci": "nyc --silent node init && nyc -- npm run test:openfeature",
60
62
  "test:plugins": "node --expose-gc ./node_modules/mocha/bin/mocha.js \"packages/datadog-plugin-@(${PLUGINS})/test/**/${SPEC:-*}*.spec.js\"",
61
- "test:plugins:ci": "yarn services && nyc -- npm run test:plugins",
62
- "test:plugins:ci:flaky": "yarn services && nyc -- npm run test:plugins -- --bail --retries 2",
63
+ "test:plugins:ci": "yarn services && nyc --silent node init && nyc -- npm run test:plugins",
64
+ "test:plugins:ci:flaky": "yarn services && nyc --silent node init && nyc -- npm run test:plugins -- --bail --retries 2",
63
65
  "test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
64
- "test:profiler": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- packages/dd-trace/test/profiling/**/*.spec.js",
65
- "test:profiler:ci": "nyc -- npm run test:profiler",
66
+ "test:profiler": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/dd-trace/test/profiling/**/*.spec.js\"",
67
+ "test:profiler:ci": "nyc --silent node init && nyc -- npm run test:profiler",
66
68
  "test:integration": "mocha --timeout 60000 \"integration-tests/*.spec.js\"",
67
69
  "test:integration:aiguard": "mocha --timeout 60000 \"integration-tests/aiguard/*.spec.js\"",
68
70
  "test:integration:appsec": "mocha --timeout 60000 \"integration-tests/appsec/*.spec.js\"",
69
71
  "test:integration:bun": "mocha --timeout 60000 \"integration-tests/bun/*.spec.js\"",
70
72
  "test:integration:cucumber": "mocha --timeout 60000 \"integration-tests/cucumber/*.spec.js\"",
71
- "test:integration:cypress": "mocha --timeout 60000 \"integration-tests/cypress/*.spec.js\"",
73
+ "test:integration:cypress": "mocha --timeout 60000 \"integration-tests/cypress/${SPEC:-cypress-*}.spec.js\"",
72
74
  "test:integration:debugger": "mocha --timeout 60000 \"integration-tests/debugger/*.spec.js\"",
73
75
  "test:integration:esbuild": "mocha --timeout 60000 \"integration-tests/esbuild/*.spec.js\"",
74
76
  "test:integration:webpack": "mocha --timeout 60000 \"integration-tests/webpack/*.spec.js\"",
75
77
  "test:integration:openfeature": "mocha --timeout 60000 \"integration-tests/openfeature/*.spec.js\"",
76
78
  "test:integration:jest": "mocha --timeout 60000 \"integration-tests/jest/*.spec.js\"",
77
79
  "test:integration:mocha": "mocha --timeout 60000 \"integration-tests/mocha/*.spec.js\"",
78
- "test:integration:playwright": "mocha --timeout 60000 \"integration-tests/playwright/*.spec.js\"",
80
+ "test:integration:playwright": "mocha --timeout 60000 \"integration-tests/playwright/${SPEC:-playwright-*}.spec.js\"",
79
81
  "test:integration:selenium": "mocha --timeout 60000 \"integration-tests/selenium/*.spec.js\"",
80
82
  "test:integration:vitest": "mocha --timeout 60000 \"integration-tests/vitest/*.spec.js\"",
81
83
  "test:integration:testopt": "mocha --timeout 120000 \"integration-tests/ci-visibility/*.spec.js\"",
@@ -83,7 +85,7 @@
83
85
  "test:integration:plugins": "mocha \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/*.spec.js\"",
84
86
  "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\"",
85
87
  "test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
86
- "test:shimmer:ci": "nyc -- npm run test:shimmer",
88
+ "test:shimmer:ci": "nyc --silent node init && nyc -- npm run test:shimmer",
87
89
  "verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
88
90
  "verify-exercised-tests": "node scripts/verify-exercised-tests.js"
89
91
  },
@@ -153,28 +155,28 @@
153
155
  "@datadog/wasm-js-rewriter": "5.0.1",
154
156
  "@opentelemetry/api": ">=1.0.0 <1.10.0",
155
157
  "@opentelemetry/api-logs": "<1.0.0",
156
- "oxc-parser": "^0.121.0"
158
+ "oxc-parser": "^0.127.0"
157
159
  },
158
160
  "devDependencies": {
159
- "@actions/core": "^3.0.0",
160
- "@actions/github": "^9.0.0",
161
+ "@actions/core": "^3.0.1",
162
+ "@actions/github": "^9.1.1",
161
163
  "@babel/helpers": "^7.29.2",
162
164
  "@eslint/eslintrc": "^3.3.5",
163
165
  "@eslint/js": "^9.39.2",
164
166
  "@msgpack/msgpack": "^3.1.3",
165
- "@openfeature/core": "^1.8.1",
166
- "@openfeature/server-sdk": "~1.20.0",
167
+ "@openfeature/core": "^1.10.0",
168
+ "@openfeature/server-sdk": "~1.21.0",
167
169
  "@stylistic/eslint-plugin": "^5.10.0",
168
170
  "@types/mocha": "^10.0.10",
169
171
  "@types/node": "^18.19.106",
170
- "@types/sinon": "^21.0.0",
171
- "axios": "^1.15.0",
172
+ "@types/sinon": "^21.0.1",
173
+ "axios": "^1.15.2",
172
174
  "benchmark": "^2.1.4",
173
175
  "body-parser": "^2.2.2",
174
- "bun": "1.3.11",
176
+ "bun": "1.3.13",
175
177
  "codeowners-audit": "^2.9.0",
176
178
  "eslint": "^9.39.2",
177
- "eslint-plugin-cypress": "^6.2.2",
179
+ "eslint-plugin-cypress": "^6.3.1",
178
180
  "eslint-plugin-import": "^2.32.0",
179
181
  "eslint-plugin-jsdoc": "^62.9.0",
180
182
  "eslint-plugin-mocha": "^11.2.0",
@@ -200,10 +202,10 @@
200
202
  "retry": "^0.13.1",
201
203
  "semifies": "^1.0.0",
202
204
  "semver": "^7.7.2",
203
- "sinon": "^21.0.3",
205
+ "sinon": "^21.1.2",
204
206
  "tiktoken": "^1.0.21",
205
- "typescript": "^6.0.2",
206
- "workerpool": "^10.0.0",
207
+ "typescript": "^6.0.3",
208
+ "workerpool": "^10.0.2",
207
209
  "yaml": "^2.8.3",
208
210
  "yarn-deduplicate": "^6.0.2"
209
211
  }
@@ -5,6 +5,7 @@ const {
5
5
  channel,
6
6
  addHook,
7
7
  } = require('./helpers/instrument')
8
+ const { createCallbackInstrumentor } = require('./helpers/callback-instrumentor')
8
9
 
9
10
  const cryptoHashCh = channel('datadog:crypto:hashing:start')
10
11
  const cryptoCipherCh = channel('datadog:crypto:cipher:start')
@@ -12,9 +13,35 @@ const cryptoCipherCh = channel('datadog:crypto:cipher:start')
12
13
  const hashMethods = ['createHash', 'createHmac', 'createSign', 'createVerify', 'sign', 'verify']
13
14
  const cipherMethods = ['createCipheriv', 'createDecipheriv']
14
15
 
16
+ // Async crypto APIs that offload work to the libuv worker thread pool. The mapped sparse array
17
+ // names each callback-preceding argument position whose value should be captured on the context
18
+ // (string or number only). Unused positions are elided so iteration can skip them. Consumers of
19
+ // the context (e.g. the events profiler) read these fields as sample labels.
20
+ const asyncParamsByMethod = {
21
+ checkPrime: [],
22
+ generateKey: ['type'],
23
+ generateKeyPair: ['type'],
24
+ generatePrime: ['size'],
25
+ hkdf: ['digest', , , , 'keylen'], // eslint-disable-line no-sparse-arrays
26
+ pbkdf2: [, , 'iterations', 'keylen', 'digest'], // eslint-disable-line no-sparse-arrays
27
+ randomBytes: ['size'],
28
+ randomFill: [, 'offset', 'size'], // eslint-disable-line no-sparse-arrays
29
+ randomInt: [],
30
+ scrypt: [, , 'keylen'], // eslint-disable-line no-sparse-arrays
31
+ sign: ['algorithm'],
32
+ verify: ['algorithm'],
33
+ }
34
+
15
35
  addHook({ name: 'crypto' }, crypto => {
16
36
  shimmer.massWrap(crypto, hashMethods, wrapCryptoMethod(cryptoHashCh))
17
37
  shimmer.massWrap(crypto, cipherMethods, wrapCryptoMethod(cryptoCipherCh))
38
+
39
+ const instrument = createCallbackInstrumentor('apm:crypto:operation')
40
+ for (const [method, paramNames] of Object.entries(asyncParamsByMethod)) {
41
+ if (typeof crypto[method] === 'function') {
42
+ shimmer.wrap(crypto, method, instrument(buildAsyncContext(method, paramNames)))
43
+ }
44
+ }
18
45
  return crypto
19
46
  })
20
47
 
@@ -30,3 +57,21 @@ function wrapCryptoMethod (channel) {
30
57
  }
31
58
  return wrapMethod
32
59
  }
60
+
61
+ function buildAsyncContext (operation, paramNames) {
62
+ return function (_, args) {
63
+ const ctx = { operation }
64
+ const lastIndex = args.length - 1
65
+ // paramNames is a sparse array; for-in yields only populated slot indices, in ascending
66
+ // numeric order, so we can break once we pass the callback position.
67
+ for (const i in paramNames) {
68
+ if (i >= lastIndex) break
69
+ const name = paramNames[i]
70
+ const value = args[i]
71
+ if (typeof value === 'string' || typeof value === 'number') {
72
+ ctx[name] = value
73
+ }
74
+ }
75
+ return ctx
76
+ }
77
+ }
@@ -235,6 +235,40 @@ function getPickleByFile (runtimeOrCoodinator) {
235
235
  }, {})
236
236
  }
237
237
 
238
+ function getFinalStatus ({
239
+ status,
240
+ hasFailedAllRetries,
241
+ isLastAtrRetry,
242
+ isLastEfdRetry,
243
+ isLastAttemptToFix,
244
+ hasPassedAllRetries,
245
+ isQuarantined,
246
+ isDisabled,
247
+ }) {
248
+ // Note that intermediate executions DO NOT report a final status tag
249
+
250
+ // If the test is quarantined or disabled, regardless of its actual execution result or active retry features,
251
+ // the final status of its last execution should be reported as 'skip'.
252
+ if (isQuarantined || isDisabled || status === 'skip') {
253
+ return 'skip'
254
+ }
255
+
256
+ // When no retry feature is active, every execution is final
257
+ if (!isLastAtrRetry && !isLastEfdRetry && !isLastAttemptToFix) {
258
+ return status
259
+ }
260
+
261
+ // ATR and EFD: pass unless every attempt failed
262
+ if (isLastAtrRetry || isLastEfdRetry) {
263
+ return hasFailedAllRetries ? 'fail' : 'pass'
264
+ }
265
+
266
+ // Branch for ATF (We need to check hasPassedAllRetries)
267
+ if (isLastAttemptToFix) {
268
+ return hasPassedAllRetries ? 'pass' : 'fail'
269
+ }
270
+ }
271
+
238
272
  function wrapRun (pl, isLatestVersion, version) {
239
273
  if (patched.has(pl)) return
240
274
 
@@ -262,7 +296,7 @@ function wrapRun (pl, isLatestVersion, version) {
262
296
  testStartCh.runStores(ctx, () => {})
263
297
  const promises = {}
264
298
  try {
265
- this.eventBroadcaster.on('envelope', async (testCase) => {
299
+ const onEnvelope = async (testCase) => {
266
300
  // Only supported from >=8.0.0
267
301
  if (testCase?.testCaseFinished) {
268
302
  const { testCaseFinished: { willBeRetried } } = testCase
@@ -280,7 +314,7 @@ function wrapRun (pl, isLatestVersion, version) {
280
314
  const isAtrRetry = !isFirstAttempt && isFlakyTestRetriesEnabled
281
315
 
282
316
  // ATR: record this attempt as failed so when run().finally runs (after retry) we have all statuses
283
- if (isFlakyTestRetriesEnabled && isAtrRetry === false) {
317
+ if (isFlakyTestRetriesEnabled) {
284
318
  const nameForKey = this.pickle.name.replace(/\s*\(attempt \d+(?:, retried)?\)\s*$/, '')
285
319
  const atrKey = `${this.pickle.uri}:${nameForKey}`
286
320
  if (atrStatusesByScenarioKey.has(atrKey)) {
@@ -303,13 +337,15 @@ function wrapRun (pl, isLatestVersion, version) {
303
337
  testStartCh.runStores(newCtx, () => {})
304
338
  }
305
339
  }
306
- })
340
+ }
341
+ this.eventBroadcaster.on('envelope', onEnvelope)
307
342
  let promise
308
343
 
309
344
  testFnCh.runStores(ctx, () => {
310
345
  promise = run.apply(this, arguments)
311
346
  })
312
347
  promise.finally(async () => {
348
+ this.eventBroadcaster.removeListener('envelope', onEnvelope)
313
349
  const result = this.getWorstStepResult()
314
350
  const { status, skipReason } = isLatestVersion
315
351
  ? getStatusFromResultLatest(result)
@@ -408,6 +444,31 @@ function wrapRun (pl, isLatestVersion, version) {
408
444
  if (promises.hitBreakpointPromise) {
409
445
  await promises.hitBreakpointPromise
410
446
  }
447
+
448
+ // Notice that ATR is handled using cucumber native retries features.
449
+ // Therefore, if we reach this point, we are certain that it's the last ATR execution
450
+ const isLastAtrRetry = isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry && numTestRetries > 0
451
+
452
+ const statuses = lastStatusByPickleId.get(this.pickle.id)
453
+ const isLastEfdRetry = isEfdRetry && statuses?.length === earlyFlakeDetectionNumRetries + 1
454
+ const isLastAttemptToFixRetry = isAttemptToFix && statuses?.length === testManagementAttemptToFixRetries + 1
455
+
456
+ // Intermediate (non-last EFD or ATF retries) executions do not report a final status
457
+ const isIntermediateExecution = (isEfdRetry && !isLastEfdRetry) || (isAttemptToFix && !isLastAttemptToFixRetry)
458
+
459
+ const finalStatus = isIntermediateExecution
460
+ ? undefined
461
+ : getFinalStatus({
462
+ status,
463
+ hasFailedAllRetries,
464
+ isLastAtrRetry,
465
+ isLastEfdRetry,
466
+ isLastAttemptToFix: isLastAttemptToFixRetry,
467
+ hasPassedAllRetries,
468
+ isQuarantined,
469
+ isDisabled,
470
+ })
471
+
411
472
  testFinishCh.publish({
412
473
  status,
413
474
  skipReason,
@@ -424,6 +485,7 @@ function wrapRun (pl, isLatestVersion, version) {
424
485
  isQuarantined,
425
486
  isModified,
426
487
  ...attemptCtx.currentStore,
488
+ finalStatus,
427
489
  })
428
490
  })
429
491
  return promise