dd-trace 6.0.0-pre-b4d004d → 6.0.0-pre-0bb1f17

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 (85) hide show
  1. package/LICENSE-3rdparty.csv +1 -0
  2. package/index.d.ts +18 -26
  3. package/initialize.mjs +10 -10
  4. package/package.json +10 -7
  5. package/packages/datadog-core/src/storage.js +4 -4
  6. package/packages/datadog-esbuild/src/utils.js +5 -1
  7. package/packages/datadog-instrumentations/src/aws-sdk.js +9 -2
  8. package/packages/datadog-instrumentations/src/azure-service-bus.js +43 -36
  9. package/packages/datadog-instrumentations/src/helpers/hook.js +1 -0
  10. package/packages/datadog-instrumentations/src/helpers/instrument.js +2 -1
  11. package/packages/datadog-instrumentations/src/jest.js +1 -4
  12. package/packages/datadog-instrumentations/src/playwright.js +20 -0
  13. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +3 -2
  14. package/packages/datadog-plugin-azure-service-bus/src/producer.js +14 -5
  15. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
  16. package/packages/datadog-plugin-cypress/src/support.js +73 -31
  17. package/packages/datadog-plugin-jest/src/index.js +1 -6
  18. package/packages/datadog-plugin-jest/src/util.js +46 -15
  19. package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -1
  20. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -1
  21. package/packages/datadog-plugin-openai/src/stream-helpers.js +1 -1
  22. package/packages/datadog-shimmer/src/shimmer.js +2 -2
  23. package/packages/dd-trace/src/aiguard/sdk.js +12 -5
  24. package/packages/dd-trace/src/appsec/telemetry/index.js +1 -31
  25. package/packages/dd-trace/src/baggage.js +11 -0
  26. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +1 -1
  27. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
  28. package/packages/dd-trace/src/config.js +61 -6
  29. package/packages/dd-trace/src/config_defaults.js +13 -2
  30. package/packages/dd-trace/src/datastreams/encoding.js +23 -6
  31. package/packages/dd-trace/src/datastreams/pathway.js +39 -0
  32. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +11 -2
  33. package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
  34. package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -0
  35. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -5
  36. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  37. package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
  38. package/packages/dd-trace/src/debugger/devtools_client/session.js +11 -1
  39. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +65 -14
  40. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +44 -9
  41. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +39 -23
  42. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +2 -1
  43. package/packages/dd-trace/src/debugger/devtools_client/state.js +6 -1
  44. package/packages/dd-trace/src/debugger/index.js +1 -1
  45. package/packages/dd-trace/src/encode/0.4.js +3 -3
  46. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +2 -2
  47. package/packages/dd-trace/src/exporters/agent/writer.js +6 -13
  48. package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -2
  49. package/packages/dd-trace/src/llmobs/index.js +5 -5
  50. package/packages/dd-trace/src/llmobs/noop.js +6 -0
  51. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +1 -0
  52. package/packages/dd-trace/src/llmobs/plugins/openai.js +41 -35
  53. package/packages/dd-trace/src/llmobs/sdk.js +5 -1
  54. package/packages/dd-trace/src/llmobs/span_processor.js +5 -5
  55. package/packages/dd-trace/src/llmobs/tagger.js +31 -17
  56. package/packages/dd-trace/src/msgpack/chunk.js +2 -2
  57. package/packages/dd-trace/src/msgpack/encoder.js +2 -3
  58. package/packages/dd-trace/src/msgpack/index.js +2 -2
  59. package/packages/dd-trace/src/openfeature/flagging_provider.js +5 -3
  60. package/packages/dd-trace/src/opentelemetry/logs/index.js +3 -3
  61. package/packages/dd-trace/src/opentelemetry/logs/logger.js +13 -7
  62. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +6 -4
  63. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -17
  64. package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
  65. package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
  66. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
  67. package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
  68. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
  69. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
  70. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
  71. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +532 -0
  72. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
  73. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +36 -22
  74. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
  75. package/packages/dd-trace/src/plugins/database.js +1 -0
  76. package/packages/dd-trace/src/plugins/plugin.js +7 -9
  77. package/packages/dd-trace/src/profiling/exporter_cli.js +7 -6
  78. package/packages/dd-trace/src/proxy.js +5 -0
  79. package/packages/dd-trace/src/remote_config/index.js +11 -1
  80. package/packages/dd-trace/src/require-package-json.js +1 -1
  81. package/packages/dd-trace/src/service-naming/index.js +31 -4
  82. package/packages/dd-trace/src/span_processor.js +9 -9
  83. package/packages/dd-trace/src/supported-configurations.json +9 -0
  84. package/packages/dd-trace/src/telemetry/telemetry.js +11 -2
  85. /package/packages/dd-trace/src/{format.js → span_format.js} +0 -0
@@ -56,6 +56,7 @@ dev,chai,MIT,Copyright 2017 Chai.js Assertion Library
56
56
  dev,eslint,MIT,Copyright JS Foundation and other contributors https://js.foundation
57
57
  dev,eslint-plugin-cypress,MIT,Copyright (c) 2019 Cypress.io
58
58
  dev,eslint-plugin-import,MIT,Copyright 2015 Ben Mosher
59
+ dev,eslint-plugin-jsdoc,BSD-3-Clause,Copyright Gajus Kuizinas
59
60
  dev,eslint-plugin-mocha,MIT,Copyright 2014 Mathias Schreck
60
61
  dev,eslint-plugin-n,MIT,Copyright 2015 Toru Nagashima
61
62
  dev,eslint-plugin-promise,ISC,jden and other contributors
package/index.d.ts CHANGED
@@ -541,6 +541,12 @@ declare namespace tracer {
541
541
  eventLoop?: boolean
542
542
  }
543
543
 
544
+ /**
545
+ * Whether to add an auto-generated `runtime-id` tag to metrics.
546
+ * @default false
547
+ */
548
+ runtimeMetricsRuntimeId?: boolean
549
+
544
550
  /**
545
551
  * Custom function for DNS lookups when sending requests to the agent.
546
552
  * @default dns.lookup()
@@ -577,13 +583,6 @@ declare namespace tracer {
577
583
  */
578
584
  experimental?: {
579
585
  b3?: boolean
580
- traceparent?: boolean
581
-
582
- /**
583
- * Whether to add an auto-generated `runtime-id` tag to metrics.
584
- * @default false
585
- */
586
- runtimeId?: boolean
587
586
 
588
587
  /**
589
588
  * Whether to write traces to log output or agentless, rather than send to an agent
@@ -654,6 +653,13 @@ declare namespace tracer {
654
653
  * @default false
655
654
  */
656
655
  enabled?: boolean
656
+ /**
657
+ * Timeout in milliseconds for OpenFeature provider initialization.
658
+ * If configuration is not received within this time, initialization fails.
659
+ *
660
+ * @default 30000
661
+ */
662
+ initializationTimeoutMs?: number
657
663
  }
658
664
  };
659
665
 
@@ -680,13 +686,6 @@ declare namespace tracer {
680
686
  */
681
687
  tags?: { [key: string]: any };
682
688
 
683
- /**
684
- * Specifies which scope implementation to use. The default is to use the best
685
- * implementation for the runtime. Only change this if you know what you are
686
- * doing.
687
- */
688
- scope?: 'async_hooks' | 'async_local_storage' | 'async_resource' | 'sync' | 'noop'
689
-
690
689
  /**
691
690
  * Whether to report the hostname of the service host. This is used when the agent is deployed on a different host and cannot determine the hostname automatically.
692
691
  * @default false
@@ -699,13 +698,6 @@ declare namespace tracer {
699
698
  */
700
699
  logLevel?: 'error' | 'debug'
701
700
 
702
- /**
703
- * If false, require a parent in order to trace.
704
- * @default true
705
- * @deprecated since version 4.0
706
- */
707
- orphanable?: boolean
708
-
709
701
  /**
710
702
  * Enables DBM to APM link using tag injection.
711
703
  * @default 'disabled'
@@ -912,7 +904,7 @@ declare namespace tracer {
912
904
  /**
913
905
  * The selection and priority order of context propagation injection and extraction mechanisms.
914
906
  */
915
- propagationStyle?: string[] | PropagationStyle
907
+ tracePropagationStyle?: string[] | PropagationStyle
916
908
 
917
909
  /**
918
910
  * Cloud payload report as tags
@@ -3011,15 +3003,15 @@ declare namespace tracer {
3011
3003
  label: string,
3012
3004
 
3013
3005
  /**
3014
- * The type of evaluation metric, one of 'categorical' or 'score'
3006
+ * The type of evaluation metric, one of 'categorical', 'score', or 'boolean'
3015
3007
  */
3016
- metricType: 'categorical' | 'score',
3008
+ metricType: 'categorical' | 'score' | 'boolean',
3017
3009
 
3018
3010
  /**
3019
3011
  * The value of the evaluation metric.
3020
- * Must be string for 'categorical' metrics and number for 'score' metrics.
3012
+ * Must be string for 'categorical' metrics, number for 'score' metrics, and boolean for 'boolean' metrics.
3021
3013
  */
3022
- value: string | number,
3014
+ value: string | number | boolean,
3023
3015
 
3024
3016
  /**
3025
3017
  * An object of string key-value pairs to tag the evaluation metric with.
package/initialize.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * This file serves one of two purposes, depending on how it's used.
3
- *
4
- * If used with --import, it will import init.js and register the loader hook.
5
- * If used with --loader, it will act as the loader hook, except that it will
6
- * also import init.js inside the source code of the entrypoint file.
7
- *
8
- * The result is that no matter how this file is used, so long as it's with
9
- * one of the two flags, the tracer will always be initialized, and the loader
10
- * hook will always be active for ESM support.
11
- */
2
+ * This file serves one of two purposes, depending on how it's used.
3
+ *
4
+ * If used with --import, it will import init.js and register the loader hook.
5
+ * If used with --loader, it will act as the loader hook, except that it will
6
+ * also import init.js inside the source code of the entrypoint file.
7
+ *
8
+ * The result is that no matter how this file is used, so long as it's with
9
+ * one of the two flags, the tracer will always be initialized, and the loader
10
+ * hook will always be active for ESM support.
11
+ */
12
12
 
13
13
  /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.0.0-pre-b4d004d",
3
+ "version": "6.0.0-pre-0bb1f17",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -46,6 +46,8 @@
46
46
  "test:llmobs:sdk:ci": "nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:sdk",
47
47
  "test:llmobs:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/llmobs/plugins/@($(echo $PLUGINS))/*.spec.js\"",
48
48
  "test:llmobs:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:plugins",
49
+ "test:openfeature": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/openfeature/*.spec.js\"",
50
+ "test:openfeature:ci": "nyc --no-clean --include \"packages/dd-trace/src/openfeature/**/*.js\" -- npm run test:openfeature",
49
51
  "test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/@($(echo ${SPEC:-'*'})).spec.js\"",
50
52
  "test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
51
53
  "test:plugins:ci:flaky": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins -- --bail --retries 2",
@@ -65,7 +67,7 @@
65
67
  "test:integration:playwright": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/playwright/*.spec.js\"",
66
68
  "test:integration:selenium": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/selenium/*.spec.js\"",
67
69
  "test:integration:vitest": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/vitest/*.spec.js\"",
68
- "test:integration:testopt": "mocha --timeout 90000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/ci-visibility/*.spec.js\"",
70
+ "test:integration:testopt": "mocha --timeout 120000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/ci-visibility/*.spec.js\"",
69
71
  "test:integration:profiler": "mocha --timeout 180000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/profiler/*.spec.js\"",
70
72
  "test:integration:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
71
73
  "test:unit:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
@@ -123,9 +125,9 @@
123
125
  "dependencies": {
124
126
  "@datadog/libdatadog": "0.7.0",
125
127
  "@datadog/native-appsec": "10.3.0",
126
- "@datadog/native-iast-taint-tracking": "4.0.0",
128
+ "@datadog/native-iast-taint-tracking": "4.1.0",
127
129
  "@datadog/native-metrics": "3.1.1",
128
- "@datadog/openfeature-node-server": "0.1.0-preview.15",
130
+ "@datadog/openfeature-node-server": "^0.2.0",
129
131
  "@datadog/pprof": "5.12.0",
130
132
  "@datadog/sketches-js": "2.1.1",
131
133
  "@datadog/wasm-js-rewriter": "5.0.1",
@@ -165,21 +167,22 @@
165
167
  "@eslint/js": "^9.39.0",
166
168
  "@msgpack/msgpack": "^3.1.2",
167
169
  "@openfeature/core": "^1.9.0",
168
- "@openfeature/server-sdk": "^1.20.0",
170
+ "@openfeature/server-sdk": "~1.20.0",
169
171
  "@stylistic/eslint-plugin": "^5.5.0",
170
172
  "@types/chai": "^4.3.16",
171
173
  "@types/mocha": "^10.0.10",
172
174
  "@types/node": "^18.19.106",
173
- "@types/sinon": "^17.0.4",
175
+ "@types/sinon": "^21.0.0",
174
176
  "@types/tap": "^15.0.12",
175
177
  "axios": "^1.12.2",
176
178
  "benchmark": "^2.1.4",
177
179
  "body-parser": "^2.2.0",
178
- "bun": "1.3.2",
180
+ "bun": "1.3.3",
179
181
  "chai": "^4.5.0",
180
182
  "eslint": "^9.39.0",
181
183
  "eslint-plugin-cypress": "^5.2.0",
182
184
  "eslint-plugin-import": "^2.32.0",
185
+ "eslint-plugin-jsdoc": "^61.1.12",
183
186
  "eslint-plugin-mocha": "^11.2.0",
184
187
  "eslint-plugin-n": "^17.23.1",
185
188
  "eslint-plugin-promise": "^7.2.1",
@@ -15,7 +15,7 @@ const { AsyncLocalStorage } = require('async_hooks')
15
15
  class DatadogStorage extends AsyncLocalStorage {
16
16
  /**
17
17
  *
18
- * @param store {Store}
18
+ * @param {Store} [store]
19
19
  * @override
20
20
  */
21
21
  enterWith (store) {
@@ -47,7 +47,7 @@ class DatadogStorage extends AsyncLocalStorage {
47
47
  * retrieved through `getHandle()` can also be passed in to be used as the
48
48
  * key. This is useful if you've stashed a handle somewhere and want to
49
49
  * retrieve the store with it.
50
- * @param {{}} [handle]
50
+ * @param {object} [handle]
51
51
  * @returns {Store | undefined}
52
52
  * @override
53
53
  */
@@ -87,7 +87,7 @@ class DatadogStorage extends AsyncLocalStorage {
87
87
 
88
88
  /**
89
89
  * This is the map from handles to real stores, used in the class above.
90
- * @type {WeakMap<WeakKey, Store>}
90
+ * @type {WeakMap<WeakKey, Store|undefined>}
91
91
  */
92
92
  const stores = new WeakMap()
93
93
 
@@ -101,7 +101,7 @@ const storages = Object.create(null)
101
101
 
102
102
  /**
103
103
  *
104
- * @param namespace {string} the namespace to use
104
+ * @param {string} namespace The namespace to use
105
105
  * @returns {DatadogStorage}
106
106
  */
107
107
  function storage (namespace) {
@@ -65,7 +65,11 @@ function getSource (url, { format }) {
65
65
  /**
66
66
  * Generates the pieces of code for the proxy module before the path
67
67
  *
68
- * @param {Object} moduleData { path, internal, context, excludeDefault }
68
+ * @param {object} moduleData
69
+ * @param {string} moduleData.path
70
+ * @param {boolean} moduleData.internal
71
+ * @param {object} moduleData.context
72
+ * @param {boolean} moduleData.excludeDefault
69
73
  * @returns {Promise<Map>}
70
74
  */
71
75
  async function processModule ({ path, internal, context, excludeDefault }) {
@@ -34,10 +34,11 @@ function wrapRequest (send) {
34
34
  }
35
35
  }
36
36
 
37
- function wrapDeserialize (deserialize, channelSuffix) {
37
+ function wrapDeserialize (deserialize, channelSuffix, responseIndex = 0) {
38
38
  const headersCh = channel(`apm:aws:response:deserialize:${channelSuffix}`)
39
39
 
40
- return function (response) {
40
+ return function () {
41
+ const response = arguments[responseIndex]
41
42
  if (headersCh.hasSubscribers) {
42
43
  headersCh.publish({ headers: response.headers })
43
44
  }
@@ -66,6 +67,12 @@ function wrapSmithySend (send) {
66
67
 
67
68
  if (typeof command.deserialize === 'function') {
68
69
  shimmer.wrap(command, 'deserialize', deserialize => wrapDeserialize(deserialize, channelSuffix))
70
+ } else if (this.config?.protocol?.deserializeResponse) {
71
+ shimmer.wrap(
72
+ this.config.protocol,
73
+ 'deserializeResponse',
74
+ deserializeResponse => wrapDeserialize(deserializeResponse, channelSuffix, 2)
75
+ )
69
76
  }
70
77
 
71
78
  const ctx = {
@@ -8,57 +8,64 @@ const shimmer = require('../../datadog-shimmer')
8
8
  const dc = require('dc-polyfill')
9
9
 
10
10
  const producerCh = dc.tracingChannel('apm:azure-service-bus:send')
11
+ const isItDefault = new WeakSet()
11
12
 
12
- addHook({ name: '@azure/service-bus', versions: ['>=7.9.2'], patchDefault: false }, (obj) => {
13
+ addHook({ name: '@azure/service-bus', versions: ['>=7.9.2'] }, (obj) => {
13
14
  const ServiceBusClient = obj.ServiceBusClient
14
- let didItShim = false
15
15
  shimmer.wrap(ServiceBusClient.prototype, 'createSender',
16
16
  createSender => function (queueOrTopicName) {
17
17
  const sender = createSender.apply(this, arguments)
18
- if (didItShim) return sender
19
18
  const senderPrototype = sender.constructor.prototype
20
19
  const senderSenderPrototype = sender._sender.constructor.prototype
21
- shimmer.wrap(senderPrototype, 'scheduleMessages', scheduleMessages =>
22
- function (msg, scheduledEnqueueTimeUtc) {
23
- const functionName = scheduleMessages.name
20
+
21
+ if (!isItDefault.has(senderPrototype)) {
22
+ isItDefault.add(senderPrototype)
23
+
24
+ shimmer.wrap(senderPrototype, 'scheduleMessages', scheduleMessages =>
25
+ function (msg, scheduledEnqueueTimeUtc) {
26
+ const functionName = scheduleMessages.name
27
+ const config = this._context.config
28
+ const entityPath = this._entityPath
29
+ return producerCh.tracePromise(
30
+ scheduleMessages,
31
+ { config, entityPath, functionName, msg, scheduledEnqueueTimeUtc },
32
+ this, ...arguments
33
+ )
34
+ })
35
+
36
+ shimmer.wrap(senderPrototype, 'createMessageBatch', createMessageBatch => async function () {
37
+ const batch = await createMessageBatch.apply(this, arguments)
38
+ shimmer.wrap(batch, 'tryAddMessage', tryAddMessage => function (msg) {
39
+ const functionName = tryAddMessage.name
40
+ const config = this._context.config
41
+ return producerCh.tracePromise(
42
+ tryAddMessage, { config, functionName, batch, msg }, this, ...arguments)
43
+ })
44
+ return batch
45
+ })
46
+ }
47
+
48
+ if (!isItDefault.has(senderSenderPrototype)) {
49
+ isItDefault.add(senderSenderPrototype)
50
+
51
+ shimmer.wrap(senderSenderPrototype, 'send', send => function (msg) {
52
+ const functionName = send.name
24
53
  const config = this._context.config
25
- const entityPath = this._entityPath
54
+ const entityPath = this.entityPath
26
55
  return producerCh.tracePromise(
27
- scheduleMessages,
28
- { config, entityPath, functionName, msg, scheduledEnqueueTimeUtc },
29
- this, ...arguments
56
+ send, { config, entityPath, functionName, msg }, this, ...arguments
30
57
  )
31
58
  })
32
59
 
33
- shimmer.wrap(senderPrototype, 'createMessageBatch', createMessageBatch => async function () {
34
- const batch = await createMessageBatch.apply(this, arguments)
35
- shimmer.wrap(batch.constructor.prototype, 'tryAddMessage', tryAddMessage => function (msg) {
36
- const functionName = tryAddMessage.name
60
+ shimmer.wrap(senderSenderPrototype, 'sendBatch', sendBatch => function (msg) {
61
+ const functionName = sendBatch.name
37
62
  const config = this._context.config
63
+ const entityPath = this.entityPath
38
64
  return producerCh.tracePromise(
39
- tryAddMessage, { config, functionName, batch, msg }, this, ...arguments)
65
+ sendBatch, { config, entityPath, functionName, msg }, this, ...arguments
66
+ )
40
67
  })
41
- return batch
42
- })
43
-
44
- shimmer.wrap(senderSenderPrototype, 'send', send => function (msg) {
45
- const functionName = send.name
46
- const config = this._context.config
47
- const entityPath = this.entityPath
48
- return producerCh.tracePromise(
49
- send, { config, entityPath, functionName, msg }, this, ...arguments
50
- )
51
- })
52
-
53
- shimmer.wrap(senderSenderPrototype, 'sendBatch', sendBatch => function (msg) {
54
- const functionName = sendBatch.name
55
- const config = this._context.config
56
- const entityPath = this.entityPath
57
- return producerCh.tracePromise(
58
- sendBatch, { config, entityPath, functionName, msg }, this, ...arguments
59
- )
60
- })
61
- didItShim = true
68
+ }
62
69
  return sender
63
70
  })
64
71
  return obj
@@ -8,6 +8,7 @@ const ritm = require('../../../dd-trace/src/ritm')
8
8
  * In practice, `modules` is always an array with a single entry.
9
9
  *
10
10
  * @param {string[]} modules list of modules to hook into
11
+ * @param {object} hookOptions hook options
11
12
  * @param {Function} onrequire callback to be executed upon encountering module
12
13
  */
13
14
  function Hook (modules, hookOptions, onrequire) {
@@ -28,7 +28,8 @@ exports.tracingChannel = function (name) {
28
28
  * @param {string[]} args.versions array of semver range strings
29
29
  * @param {string} [args.file='index.js'] path to file within package to instrument
30
30
  * @param {string} [args.filePattern] pattern to match files within package to instrument
31
- * @param Function hook
31
+ * @param {boolean} [args.patchDefault] whether to patch the default export
32
+ * @param {(moduleExports: unknown, version: string) => unknown} hook
32
33
  */
33
34
  exports.addHook = function addHook ({ name, versions, file, filePattern, patchDefault }, hook) {
34
35
  if (typeof name === 'string') {
@@ -1110,7 +1110,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
1110
1110
  * Child processes do not each request ITR configuration, so the jest's parent process
1111
1111
  * needs to pass them the configuration. This is done via _ddTestCodeCoverageEnabled, which
1112
1112
  * controls whether coverage is reported.
1113
- */
1113
+ */
1114
1114
  if (environment.testEnvironmentOptions?._ddTestCodeCoverageEnabled) {
1115
1115
  const root = environment.repositoryRoot || environment.rootDir
1116
1116
 
@@ -1345,9 +1345,6 @@ addHook({
1345
1345
  }
1346
1346
  }
1347
1347
  return returnedValue
1348
- } catch (error) {
1349
- testSuiteErrorCh.publish({ error, testSuiteAbsolutePath: this._testPath })
1350
- throw error
1351
1348
  } finally {
1352
1349
  // Restore original prepareStackTrace
1353
1350
  Error.prepareStackTrace = originalPrepareStackTrace
@@ -481,6 +481,15 @@ function dispatcherRunWrapper (run) {
481
481
 
482
482
  function dispatcherRunWrapperNew (run) {
483
483
  return function (testGroups) {
484
+ // Filter out disabled tests from testGroups before they get scheduled
485
+ if (isTestManagementTestsEnabled) {
486
+ testGroups.forEach(group => {
487
+ group.tests = group.tests.filter(test => !test._ddIsDisabled)
488
+ })
489
+ // Remove empty groups
490
+ testGroups = testGroups.filter(group => group.tests.length > 0)
491
+ }
492
+
484
493
  if (!this._allTests) {
485
494
  // Removed in https://github.com/microsoft/playwright/commit/1e52c37b254a441cccf332520f60225a5acc14c7
486
495
  // Not available from >=1.44.0
@@ -893,6 +902,9 @@ addHook({
893
902
  if (testProperties.disabled) {
894
903
  test._ddIsDisabled = true
895
904
  test.expectedStatus = 'skipped'
905
+ // setting test.expectedStatus to 'skipped' does not work for every case,
906
+ // so we need to filter out disabled tests in dispatcherRunWrapperNew,
907
+ // so they don't get to the workers
896
908
  continue
897
909
  }
898
910
  if (testProperties.quarantined) {
@@ -1270,6 +1282,10 @@ function generateSummaryWrapper (generateSummary) {
1270
1282
  const {
1271
1283
  _requireFile: testSuiteAbsolutePath,
1272
1284
  location: { line: testSourceLine },
1285
+ _ddIsNew: isNew,
1286
+ _ddIsDisabled: isDisabled,
1287
+ _ddIsModified: isModified,
1288
+ _ddIsQuarantined: isQuarantined
1273
1289
  } = test
1274
1290
  const browserName = getBrowserNameFromProjects(sessionProjects, test)
1275
1291
 
@@ -1278,6 +1294,10 @@ function generateSummaryWrapper (generateSummary) {
1278
1294
  testSuiteAbsolutePath,
1279
1295
  testSourceLine,
1280
1296
  browserName,
1297
+ isNew,
1298
+ isDisabled,
1299
+ isModified,
1300
+ isQuarantined
1281
1301
  })
1282
1302
  }
1283
1303
  }
@@ -27,8 +27,9 @@ const PROVIDER = {
27
27
  * Coerce the chunks into a single response body.
28
28
  *
29
29
  * @param {Array<{ chunk: { bytes: Buffer } }>} chunks
30
- * @param {string} provider
31
- * @returns {Object}
30
+ * @param {string} modelProvider
31
+ * @param {string} modelName
32
+ * @returns {Generation | Record<never, never>}
32
33
  */
33
34
  function extractTextAndResponseReasonFromStream (chunks, modelProvider, modelName) {
34
35
  const modelProviderUpper = modelProvider.toUpperCase()
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
4
4
  const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
5
+ const spanContexts = new WeakMap()
5
6
 
6
7
  class AzureServiceBusProducerPlugin extends ProducerPlugin {
7
8
  static get id () { return 'azure-service-bus' }
@@ -36,7 +37,12 @@ class AzureServiceBusProducerPlugin extends ProducerPlugin {
36
37
  }
37
38
 
38
39
  if (batchLinksAreEnabled()) {
39
- ctx.batch._spanContexts.push(span.context())
40
+ const spanContext = spanContexts.get(ctx.batch)
41
+ if (spanContext) {
42
+ spanContext.push(span.context())
43
+ } else {
44
+ spanContexts.set(ctx.batch, [span.context()])
45
+ }
40
46
  injectTraceContext(this.tracer, span, ctx.msg)
41
47
  }
42
48
  }
@@ -47,9 +53,12 @@ class AzureServiceBusProducerPlugin extends ProducerPlugin {
47
53
  if (isBatch) {
48
54
  span.setTag('messaging.batch.message_count', messages.count)
49
55
  if (batchLinksAreEnabled()) {
50
- messages._spanContexts.forEach(spanContext => {
51
- span.addLink(spanContext)
52
- })
56
+ const contexts = spanContexts.get(messages)
57
+ if (contexts) {
58
+ for (const spanContext of contexts) {
59
+ span.addLink(spanContext)
60
+ }
61
+ }
53
62
  }
54
63
  } else if (Array.isArray(messages)) {
55
64
  span.setTag('messaging.batch.message_count', messages.length)
@@ -64,7 +73,7 @@ class AzureServiceBusProducerPlugin extends ProducerPlugin {
64
73
  }
65
74
 
66
75
  asyncEnd (ctx) {
67
- super.finish()
76
+ super.finish(ctx)
68
77
  }
69
78
  }
70
79
 
@@ -133,6 +133,14 @@ function getCypressCommand (details) {
133
133
  return `${TEST_FRAMEWORK_NAME} ${details.specPattern || ''}`
134
134
  }
135
135
 
136
+ function getIsTestIsolationEnabled (cypressConfig) {
137
+ if (!cypressConfig) {
138
+ // If we can't read testIsolation config parameter, we default to allowing retries
139
+ return true
140
+ }
141
+ return cypressConfig.testIsolation === undefined ? true : cypressConfig.testIsolation
142
+ }
143
+
136
144
  function getLibraryConfiguration (tracer, testConfiguration) {
137
145
  return new Promise(resolve => {
138
146
  if (!tracer._tracer._exporter?.getLibraryConfiguration) {
@@ -296,6 +304,12 @@ class CypressPlugin {
296
304
  this.tracer = tracer
297
305
  this.cypressConfig = cypressConfig
298
306
 
307
+ this.isTestIsolationEnabled = getIsTestIsolationEnabled(cypressConfig)
308
+
309
+ if (!this.isTestIsolationEnabled) {
310
+ log.warn('Test isolation is disabled, retries will not be enabled')
311
+ }
312
+
299
313
  // we have to do it here because the tracer is not initialized in the constructor
300
314
  this.testEnvironmentMetadata[DD_TEST_IS_USER_PROVIDED_SERVICE] =
301
315
  tracer._tracer._config.isServiceUserProvided ? 'true' : 'false'
@@ -324,7 +338,7 @@ class CypressPlugin {
324
338
  this.isEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
325
339
  this.earlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
326
340
  this.isKnownTestsEnabled = isKnownTestsEnabled
327
- if (isFlakyTestRetriesEnabled) {
341
+ if (isFlakyTestRetriesEnabled && this.isTestIsolationEnabled) {
328
342
  this.isFlakyTestRetriesEnabled = true
329
343
  this.cypressConfig.retries.runMode = flakyTestRetriesCount
330
344
  }
@@ -467,6 +481,7 @@ class CypressPlugin {
467
481
  // We need to make sure that the plugin is initialized before running the tests
468
482
  // This is for the case where the user has not returned the promise from the init function
469
483
  await this.libraryConfigurationPromise
484
+
470
485
  this.command = getCypressCommand(details)
471
486
  this.frameworkVersion = getCypressVersion(details)
472
487
  this.rootDir = getRootDir(details)
@@ -801,7 +816,8 @@ class CypressPlugin {
801
816
  testManagementTests: this.getTestSuiteProperties(testSuite),
802
817
  isImpactedTestsEnabled: this.isImpactedTestsEnabled,
803
818
  isModifiedTest: this.getIsTestModified(testSuiteAbsolutePath),
804
- repositoryRoot: this.repositoryRoot
819
+ repositoryRoot: this.repositoryRoot,
820
+ isTestIsolationEnabled: this.isTestIsolationEnabled
805
821
  }
806
822
 
807
823
  if (this.testSuiteSpan) {
@@ -962,6 +978,11 @@ class CypressPlugin {
962
978
  this.activeTestSpan.addTags(tags)
963
979
  }
964
980
  return null
981
+ },
982
+ 'dd:log': (message) => {
983
+ // eslint-disable-next-line no-console
984
+ console.log(`[datadog] ${message}`)
985
+ return null
965
986
  }
966
987
  }
967
988
  }