dd-trace 6.22.0 → 6.24.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.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/diagnose.js +4 -4
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/test-optimization-validation/approval-artifacts.js +2 -2
- package/ci/test-optimization-validation/approval.js +2 -2
- package/ci/test-optimization-validation/artifact-id.js +2 -3
- package/ci/test-optimization-validation/ci-package-scripts.js +1 -1
- package/ci/test-optimization-validation/cli.js +1 -1
- package/ci/test-optimization-validation/command-runner.js +2 -3
- package/ci/test-optimization-validation/executable.js +1 -1
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +1 -1
- package/ci/test-optimization-validation/literal-environment.js +2 -2
- package/ci/test-optimization-validation/manifest-scaffold.js +1 -1
- package/ci/test-optimization-validation/offline-fixtures.js +1 -1
- package/ci/test-optimization-validation/redaction.js +3 -3
- package/ci/test-optimization-validation/runner-contract.js +10 -10
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +1 -1
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -5
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -0
- package/index.d.ts +35 -5
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +23 -20
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +70 -7
- package/packages/datadog-instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/cucumber.js +64 -21
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/graphql.js +9 -3
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +27 -8
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/jest.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/vitest.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +332 -137
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +92 -13
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/nova-sonic/session.js +25 -16
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -26
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/stripe.js +23 -12
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -47
- package/packages/datadog-instrumentations/src/vitest-main.js +33 -3
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +5 -2
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +16 -6
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +277 -44
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -437
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +143 -1
- package/packages/dd-trace/src/aiguard/sdk.js +0 -11
- package/packages/dd-trace/src/appsec/iast/path-line.js +2 -1
- package/packages/dd-trace/src/appsec/stack_trace.js +3 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +3 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +9 -16
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +9 -16
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +9 -14
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +9 -16
- package/packages/dd-trace/src/config/defaults.js +4 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
- package/packages/dd-trace/src/config/index.js +140 -39
- package/packages/dd-trace/src/config/parsers.js +9 -1
- package/packages/dd-trace/src/config/supported-configurations.json +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +6 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +4 -6
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +16 -0
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +25 -6
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +4 -4
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/llmobs/agent-manifest.js +19 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +4 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +8 -4
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +9 -1
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +17 -5
- package/packages/dd-trace/src/llmobs/span_processor.js +222 -12
- package/packages/dd-trace/src/llmobs/tagger.js +21 -8
- package/packages/dd-trace/src/llmobs/util.js +10 -4
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/writer.js +7 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +64 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +18 -2
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +39 -13
- package/packages/dd-trace/src/openfeature/index.js +6 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +62 -27
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/openfeature/writers/util.js +4 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +18 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/tracer.js +9 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +47 -21
- package/packages/dd-trace/src/plugin_manager.js +1 -2
- package/packages/dd-trace/src/plugins/ci_plugin.js +4 -4
- package/packages/dd-trace/src/plugins/index.js +3 -0
- package/packages/dd-trace/src/plugins/tracing.js +1 -2
- package/packages/dd-trace/src/plugins/util/git.js +102 -40
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +2 -4
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -1
- package/packages/dd-trace/src/plugins/util/test.js +28 -6
- package/packages/dd-trace/src/plugins/util/web.js +106 -20
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/proxy.js +15 -4
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +21 -9
- package/packages/dd-trace/src/span_stats.js +32 -3
- package/packages/dd-trace/src/startup-log.js +2 -1
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/util.js +9 -5
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +8 -8
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/@opentelemetry/resources/LICENSE +0 -201
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const { performance } = require('node:perf_hooks')
|
|
4
4
|
|
|
5
|
+
const { getTestAnnotations } = require('../../../dd-trace/src/ci-visibility/test-annotations')
|
|
6
|
+
|
|
5
7
|
const { getEnvironmentVariable } = require('../../../dd-trace/src/config/helper')
|
|
6
8
|
const {
|
|
7
9
|
getEfdRetryCountForDuration,
|
|
@@ -43,6 +45,9 @@ const originalEfdFns = new WeakMap()
|
|
|
43
45
|
const originalFns = new WeakMap()
|
|
44
46
|
const originalPendingByTest = new WeakMap()
|
|
45
47
|
const originalRetriesByTest = new WeakMap()
|
|
48
|
+
let automaticRetryTests = new WeakSet()
|
|
49
|
+
let automaticRetryAttempts = new WeakMap()
|
|
50
|
+
let nativeRetryTests = new WeakSet()
|
|
46
51
|
const testToStartLine = new WeakMap()
|
|
47
52
|
const testFileToSuiteCtx = new Map()
|
|
48
53
|
const datadogRetryOriginals = new WeakMap()
|
|
@@ -130,6 +135,21 @@ function getAfterEachHooks (testOrHook) {
|
|
|
130
135
|
return hooks
|
|
131
136
|
}
|
|
132
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @param {{ file: string, fullTitle: () => string }} test
|
|
140
|
+
* @param {object} config
|
|
141
|
+
* @param {boolean} [config.isTestManagementTestsEnabled]
|
|
142
|
+
* @param {{ mocha?: { suites?: Record<string, {
|
|
143
|
+
* tests?: Record<string, { properties?: Record<string, boolean> }>
|
|
144
|
+
* }> } }} [config.testManagementTests]
|
|
145
|
+
*/
|
|
146
|
+
function getAssignedProperties (test, config) {
|
|
147
|
+
return config.isTestManagementTestsEnabled
|
|
148
|
+
? config.testManagementTests?.mocha?.suites
|
|
149
|
+
?.[getTestSuitePath(test.file, process.cwd())]?.tests?.[test.fullTitle()]?.properties
|
|
150
|
+
: undefined
|
|
151
|
+
}
|
|
152
|
+
|
|
133
153
|
function getTestProperties (test, testManagementTests) {
|
|
134
154
|
const testSuite = getTestSuitePath(test.file, process.cwd())
|
|
135
155
|
const testName = test.fullTitle()
|
|
@@ -137,7 +157,13 @@ function getTestProperties (test, testManagementTests) {
|
|
|
137
157
|
const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } =
|
|
138
158
|
testManagementTests?.mocha?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
|
|
139
159
|
|
|
140
|
-
|
|
160
|
+
const { mustFail, noAutoRetry } =
|
|
161
|
+
test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn)
|
|
162
|
+
return {
|
|
163
|
+
isAttemptToFix: isAttemptToFix && !noAutoRetry,
|
|
164
|
+
isDisabled: isDisabled && !mustFail,
|
|
165
|
+
isQuarantined: isQuarantined && !mustFail,
|
|
166
|
+
}
|
|
141
167
|
}
|
|
142
168
|
|
|
143
169
|
function isNewTest (test, knownTests) {
|
|
@@ -255,7 +281,8 @@ function isDatadogManagedRetryTest (test, config) {
|
|
|
255
281
|
* }} config
|
|
256
282
|
*/
|
|
257
283
|
function isEarlyFlakeDetectionTest (test, config) {
|
|
258
|
-
return !test.
|
|
284
|
+
return !getTestAnnotations(test.fn).noAutoRetry && !test._ddTestAnnotations?.noAutoRetry &&
|
|
285
|
+
!test._ddIsAttemptToFix &&
|
|
259
286
|
!test._ddIsDisabled &&
|
|
260
287
|
config.isEarlyFlakeDetectionEnabled &&
|
|
261
288
|
hasEfdRetries(config.earlyFlakeDetectionRetryPolicy) &&
|
|
@@ -278,6 +305,8 @@ function retryTest (test, numRetries, tags, retryPolicy) {
|
|
|
278
305
|
}
|
|
279
306
|
for (let retryIndex = 0; retryIndex < numRetries; retryIndex++) {
|
|
280
307
|
const clonedTest = test.clone()
|
|
308
|
+
clonedTest._ddTestAnnotations = test._ddTestAnnotations
|
|
309
|
+
clonedTest._ddAssignedProperties = test._ddAssignedProperties
|
|
281
310
|
disableMochaRetries(clonedTest)
|
|
282
311
|
datadogRetryOriginals.set(clonedTest, test)
|
|
283
312
|
suite.addTest(clonedTest)
|
|
@@ -346,6 +375,9 @@ function resetRunState (rootSuite) {
|
|
|
346
375
|
efdRetryCountByTestFullName.clear()
|
|
347
376
|
efdSlowAbortedTests.clear()
|
|
348
377
|
suiteHookFailureSuites.clear()
|
|
378
|
+
automaticRetryTests = new WeakSet()
|
|
379
|
+
automaticRetryAttempts = new WeakMap()
|
|
380
|
+
nativeRetryTests = new WeakSet()
|
|
349
381
|
dynamicAtrRetryCountByTest = new WeakMap()
|
|
350
382
|
attemptToFixExecutions.clear()
|
|
351
383
|
loggedAttemptToFixTests.clear()
|
|
@@ -372,6 +404,8 @@ function resetRunState (rootSuite) {
|
|
|
372
404
|
if (test._retriedTest) originalRetriesByTest.delete(test._retriedTest)
|
|
373
405
|
}
|
|
374
406
|
|
|
407
|
+
delete test._ddAssignedProperties
|
|
408
|
+
delete test._ddTestAnnotations
|
|
375
409
|
delete test._ddIsAttemptToFix
|
|
376
410
|
delete test._ddIsDisabled
|
|
377
411
|
delete test._ddIsQuarantined
|
|
@@ -423,7 +457,7 @@ function isMochaRetry (test) {
|
|
|
423
457
|
}
|
|
424
458
|
|
|
425
459
|
function getIsLastRetry (test) {
|
|
426
|
-
return test._currentRetry
|
|
460
|
+
return test._currentRetry >= test._retries
|
|
427
461
|
}
|
|
428
462
|
|
|
429
463
|
function getTestFullName (test) {
|
|
@@ -454,7 +488,7 @@ function recordRetryTrackedAttempt (test) {
|
|
|
454
488
|
if (isNew) {
|
|
455
489
|
recordTestAttempt(newTests, test)
|
|
456
490
|
}
|
|
457
|
-
if (!isAttemptToFix && (isNew || isModified)) {
|
|
491
|
+
if (!test._ddTestAnnotations?.noAutoRetry && !isAttemptToFix && (isNew || isModified)) {
|
|
458
492
|
recordTestAttempt(efdTests, test)
|
|
459
493
|
}
|
|
460
494
|
}
|
|
@@ -519,6 +553,8 @@ function suppressSyntheticTestLifecycle (test) {
|
|
|
519
553
|
function inheritDatadogPropertiesFromRetriedTest (test) {
|
|
520
554
|
const retriedTest = test._retriedTest
|
|
521
555
|
if (!retriedTest) return
|
|
556
|
+
test._ddTestAnnotations = retriedTest._ddTestAnnotations
|
|
557
|
+
test._ddAssignedProperties = retriedTest._ddAssignedProperties
|
|
522
558
|
|
|
523
559
|
if (retriedTest._ddIsDisabled) {
|
|
524
560
|
test._ddIsDisabled = true
|
|
@@ -534,6 +570,18 @@ function inheritDatadogPropertiesFromRetriedTest (test) {
|
|
|
534
570
|
|
|
535
571
|
function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
536
572
|
const Runnable = RunnablePackage.Runnable ?? RunnablePackage
|
|
573
|
+
// Mocha 12 can load its ESM class through require() without the ESM rewriter.
|
|
574
|
+
// Intercept the exported prototype to observe setters in both injection modes.
|
|
575
|
+
shimmer.wrap(Runnable.prototype, 'retries', retries => function () {
|
|
576
|
+
if (arguments.length && automaticRetryTests.delete(this)) {
|
|
577
|
+
const originalTest = this._retriedTest || this
|
|
578
|
+
// afterEach can change this runnable after Mocha has already copied its budget into a queued clone.
|
|
579
|
+
if (!automaticRetryAttempts.get(originalTest)?.has(this._currentRetry + 1)) {
|
|
580
|
+
nativeRetryTests.add(originalTest)
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return retries.apply(this, arguments)
|
|
584
|
+
})
|
|
537
585
|
shimmer.wrap(Runnable.prototype, 'run', run => function (...args) {
|
|
538
586
|
if (!testFinishCh.hasSubscribers) {
|
|
539
587
|
return run.apply(this, args)
|
|
@@ -559,11 +607,13 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
559
607
|
return onRunnableFinished.apply(this, arguments)
|
|
560
608
|
}
|
|
561
609
|
}
|
|
562
|
-
} else if (libraryConfig?.isFlakyTestRetriesEnabled
|
|
610
|
+
} else if (libraryConfig?.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
611
|
+
!nativeRetryTests.has(test._retriedTest || test)) {
|
|
563
612
|
if (!originalRetriesByTest.has(test)) {
|
|
564
613
|
const originalRetries = originalRetriesByTest.get(test._retriedTest) ?? test.retries()
|
|
565
614
|
originalRetriesByTest.set(test, originalRetries)
|
|
566
615
|
}
|
|
616
|
+
automaticRetryTests.delete(test)
|
|
567
617
|
if (libraryConfig.isDynamicAtrEnabled) {
|
|
568
618
|
// Dynamic ATR: set the max possible retries initially.
|
|
569
619
|
// The actual duration-based count is computed after the first attempt.
|
|
@@ -581,6 +631,7 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
581
631
|
} else {
|
|
582
632
|
test.retries(libraryConfig.flakyTestRetriesCount)
|
|
583
633
|
}
|
|
634
|
+
automaticRetryTests.add(test)
|
|
584
635
|
}
|
|
585
636
|
|
|
586
637
|
if (isTestHook || this.type === 'test') {
|
|
@@ -613,7 +664,7 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
613
664
|
return RunnablePackage
|
|
614
665
|
}
|
|
615
666
|
|
|
616
|
-
function getOnTestHandler (isMain) {
|
|
667
|
+
function getOnTestHandler (isMain, config = {}) {
|
|
617
668
|
return function (test) {
|
|
618
669
|
if (test._ddSuppressSyntheticTestLifecycle || hasHandledHookFailure(test)) return
|
|
619
670
|
|
|
@@ -624,6 +675,9 @@ function getOnTestHandler (isMain) {
|
|
|
624
675
|
restoreRunnableFunction(test)
|
|
625
676
|
|
|
626
677
|
inheritDatadogPropertiesFromRetriedTest(test)
|
|
678
|
+
// Mocha 5/6 clones lack _retriedTest, but retain the annotated callback.
|
|
679
|
+
test._ddTestAnnotations ||= test._ddDeclaredAnnotations || getTestAnnotations(test.fn)
|
|
680
|
+
test._ddAssignedProperties ||= getAssignedProperties(test, config)
|
|
627
681
|
|
|
628
682
|
if (isInFailedSuite(test.parent)) {
|
|
629
683
|
recordRetryTrackedAttempt(test)
|
|
@@ -654,6 +708,8 @@ function getOnTestHandler (isMain) {
|
|
|
654
708
|
}
|
|
655
709
|
|
|
656
710
|
const testInfo = {
|
|
711
|
+
assignedProperties: test._ddAssignedProperties,
|
|
712
|
+
testAnnotations: test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn),
|
|
657
713
|
testName: test.fullTitle(),
|
|
658
714
|
testSuiteAbsolutePath,
|
|
659
715
|
title,
|
|
@@ -666,6 +722,7 @@ function getOnTestHandler (isMain) {
|
|
|
666
722
|
|
|
667
723
|
testInfo.isNew = isNew
|
|
668
724
|
testInfo.isEfdRetry = isEfdRetry
|
|
725
|
+
testInfo.assignedProperties = test._ddAssignedProperties
|
|
669
726
|
testInfo.isAttemptToFix = isAttemptToFix
|
|
670
727
|
testInfo.isDisabled = isDisabled
|
|
671
728
|
testInfo.isQuarantined = isQuarantined
|
|
@@ -774,7 +831,7 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
774
831
|
const originalTest = test._retriedTest || test
|
|
775
832
|
if (
|
|
776
833
|
config.isDynamicAtrEnabled &&
|
|
777
|
-
config.isFlakyTestRetriesEnabled &&
|
|
834
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
778
835
|
!test._ddIsAttemptToFix &&
|
|
779
836
|
!test._ddIsEfdRetry &&
|
|
780
837
|
!dynamicAtrRetryCountByTest.has(originalTest) &&
|
|
@@ -803,7 +860,7 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
803
860
|
// Mocha aborts native retries on hook failure, even when the retry budget is not exhausted.
|
|
804
861
|
const isTerminalHookFailure = test._ddHookFailed && !isDatadogManagedRetryTest(test, config)
|
|
805
862
|
const isLastAtrAttempt = isTerminalHookFailure || getIsLastRetry(test) ||
|
|
806
|
-
(config.isFlakyTestRetriesEnabled && status === 'pass')
|
|
863
|
+
(config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry && status === 'pass')
|
|
807
864
|
|
|
808
865
|
// Needed for the getFinalStatus call. This is because EFD does NOT tag as
|
|
809
866
|
// EFD retry the first run of the test. It only tags as retries the clones
|
|
@@ -826,18 +883,20 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
826
883
|
}
|
|
827
884
|
|
|
828
885
|
// ATR: mark terminal attempts when every executed attempt failed.
|
|
829
|
-
if (config.isFlakyTestRetriesEnabled && !test.
|
|
886
|
+
if (config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
887
|
+
!test._ddIsAttemptToFix && !test._ddIsEfdRetry &&
|
|
830
888
|
isLastAtrAttempt && testStatuses.every(status => status === 'fail')) {
|
|
831
889
|
hasFailedAllRetries = true
|
|
832
890
|
}
|
|
833
891
|
|
|
834
892
|
const isAttemptToFixRetry = test._ddIsAttemptToFix && testStatuses.length > 1
|
|
835
|
-
const isAtrRetry = config.isFlakyTestRetriesEnabled &&
|
|
893
|
+
const isAtrRetry = config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
894
|
+
automaticRetryAttempts.get(test._retriedTest || test)?.has(test._currentRetry) &&
|
|
836
895
|
!test._ddIsAttemptToFix &&
|
|
837
896
|
!test._ddIsEfdRetry
|
|
838
897
|
const isFinalAttempt = isTerminalHookFailure || status !== 'fail' || test._currentRetry >= test._retries
|
|
839
898
|
|
|
840
|
-
const
|
|
899
|
+
const isFlakyTestRetriesEnabled = config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry
|
|
841
900
|
const { _ddIsAttemptToFix, _ddIsQuarantined, _ddIsDisabled } = test
|
|
842
901
|
|
|
843
902
|
const finalStatus = getFinalStatus({
|
|
@@ -1178,9 +1237,20 @@ function getOnFailHandler (isMain, config) {
|
|
|
1178
1237
|
|
|
1179
1238
|
function getOnTestRetryHandler (config) {
|
|
1180
1239
|
return function (test, err) {
|
|
1240
|
+
if (automaticRetryTests.has(test)) {
|
|
1241
|
+
// Mocha has already queued the clone; later budget changes cannot change its scheduling owner.
|
|
1242
|
+
const originalTest = test._retriedTest || test
|
|
1243
|
+
let attempts = automaticRetryAttempts.get(originalTest)
|
|
1244
|
+
if (!attempts) {
|
|
1245
|
+
attempts = new Set()
|
|
1246
|
+
automaticRetryAttempts.set(originalTest, attempts)
|
|
1247
|
+
}
|
|
1248
|
+
attempts.add(test._currentRetry + 1)
|
|
1249
|
+
}
|
|
1181
1250
|
const isFirstAttempt = test._currentRetry === 0
|
|
1182
1251
|
const isDynamicAtrTest = config.isDynamicAtrEnabled &&
|
|
1183
|
-
config.isFlakyTestRetriesEnabled &&
|
|
1252
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
1253
|
+
automaticRetryTests.has(test) &&
|
|
1184
1254
|
!test._ddIsAttemptToFix &&
|
|
1185
1255
|
!isEarlyFlakeDetectionTest(test, config)
|
|
1186
1256
|
if (isDynamicAtrTest && isFirstAttempt) {
|
|
@@ -1216,7 +1286,8 @@ function publishTestRetry (test, err, config) {
|
|
|
1216
1286
|
if (ctx) {
|
|
1217
1287
|
const willBeRetried = test._currentRetry < test._retries
|
|
1218
1288
|
const isAtrRetry = !isFirstAttempt &&
|
|
1219
|
-
config.isFlakyTestRetriesEnabled &&
|
|
1289
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
1290
|
+
automaticRetryAttempts.get(test._retriedTest || test)?.has(test._currentRetry) &&
|
|
1220
1291
|
!test._ddIsAttemptToFix &&
|
|
1221
1292
|
!test._ddIsEfdRetry
|
|
1222
1293
|
const promises = {}
|
|
@@ -1248,6 +1319,8 @@ function getOnPendingHandler () {
|
|
|
1248
1319
|
} = test
|
|
1249
1320
|
|
|
1250
1321
|
const testInfo = {
|
|
1322
|
+
assignedProperties: test._ddAssignedProperties,
|
|
1323
|
+
testAnnotations: test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn),
|
|
1251
1324
|
testName: test.fullTitle(),
|
|
1252
1325
|
testSuiteAbsolutePath,
|
|
1253
1326
|
title,
|
|
@@ -1274,6 +1347,12 @@ function getOnPendingHandler () {
|
|
|
1274
1347
|
// Hook to add retries to tests if Test Management or EFD is enabled
|
|
1275
1348
|
function getRunTestsWrapper (runTests, config) {
|
|
1276
1349
|
return function (suite) {
|
|
1350
|
+
for (const test of suite.tests) {
|
|
1351
|
+
test._ddTestAnnotations = test.fn
|
|
1352
|
+
? getTestAnnotations(originalFns.get(test.fn) || test.fn)
|
|
1353
|
+
: test._ddDeclaredAnnotations || getTestAnnotations()
|
|
1354
|
+
test._ddAssignedProperties = getAssignedProperties(test, config)
|
|
1355
|
+
}
|
|
1277
1356
|
if (config.isTestManagementTestsEnabled) {
|
|
1278
1357
|
suite.tests.forEach((test) => {
|
|
1279
1358
|
const { isAttemptToFix, isDisabled, isQuarantined } = getTestProperties(test, config.testManagementTests)
|
|
@@ -33,7 +33,7 @@ class Turn {
|
|
|
33
33
|
textEnd
|
|
34
34
|
completionId
|
|
35
35
|
metrics = { input_tokens: 0, output_tokens: 0, total_tokens: 0 }
|
|
36
|
-
|
|
36
|
+
missingModalityMetrics = new Set()
|
|
37
37
|
emitted = false
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -86,7 +86,9 @@ class SonicSession {
|
|
|
86
86
|
#sessionId = randomUUID()
|
|
87
87
|
#providerSessionId
|
|
88
88
|
#totals = { input_tokens: 0, output_tokens: 0 }
|
|
89
|
-
#
|
|
89
|
+
#modalityTotals = {
|
|
90
|
+
input_audio_tokens: 0, output_audio_tokens: 0, input_text_tokens: 0, output_text_tokens: 0,
|
|
91
|
+
}
|
|
90
92
|
|
|
91
93
|
/** @param {(descriptor: object) => void} emit */
|
|
92
94
|
constructor (emit) {
|
|
@@ -389,21 +391,28 @@ class SonicSession {
|
|
|
389
391
|
target.metrics[key] += delta
|
|
390
392
|
target.metrics.total_tokens += delta
|
|
391
393
|
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
394
|
+
// Each modality is a subset of the aggregate and has its own cumulative baseline.
|
|
395
|
+
// Missing text must not discard valid speech or charge a previous turn's gap.
|
|
396
|
+
let remaining = delta
|
|
397
|
+
for (const [modality, field] of [['audio', 'speechTokens'], ['text', 'textTokens']]) {
|
|
398
|
+
const modalityKey = `${direction}_${modality}_tokens`
|
|
399
|
+
const modalityTotal = data.details?.total?.[direction]?.[field]
|
|
400
|
+
const previous = this.#modalityTotals[modalityKey]
|
|
401
|
+
const valid = Number.isSafeInteger(modalityTotal) && modalityTotal >= 0 && modalityTotal <= total &&
|
|
402
|
+
(previous === undefined || modalityTotal >= previous)
|
|
403
|
+
const modalityDelta = valid && previous !== undefined ? modalityTotal - previous : undefined
|
|
404
|
+
this.#modalityTotals[modalityKey] = valid ? modalityTotal : delta ? undefined : previous
|
|
405
|
+
if (modalityDelta === undefined || modalityDelta > remaining) {
|
|
406
|
+
if (delta || modalityDelta > remaining) {
|
|
407
|
+
target.missingModalityMetrics.add(modalityKey)
|
|
408
|
+
delete target.metrics[modalityKey]
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
remaining -= modalityDelta
|
|
412
|
+
if (!target.missingModalityMetrics.has(modalityKey)) {
|
|
413
|
+
target.metrics[modalityKey] = (target.metrics[modalityKey] ?? 0) + modalityDelta
|
|
414
|
+
}
|
|
404
415
|
}
|
|
405
|
-
} else if (!target.missingAudioMetrics.has(audioKey)) {
|
|
406
|
-
target.metrics[audioKey] = (target.metrics[audioKey] ?? 0) + audioDelta
|
|
407
416
|
}
|
|
408
417
|
}
|
|
409
418
|
}
|
|
@@ -4,6 +4,7 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
4
4
|
const {
|
|
5
5
|
channel,
|
|
6
6
|
addHook,
|
|
7
|
+
AsyncResource,
|
|
7
8
|
} = require('./helpers/instrument')
|
|
8
9
|
|
|
9
10
|
const connectionAttributes = new WeakMap()
|
|
@@ -20,6 +21,36 @@ function finish (ctx) {
|
|
|
20
21
|
finishChannel.publish(ctx)
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/** @param {import('oracledb').Pool} pool */
|
|
25
|
+
function bindPoolRequestContexts (pool) {
|
|
26
|
+
const queue = pool._pendingRequestQueue
|
|
27
|
+
if (!(queue instanceof Set) || typeof pool.sessionCallback !== 'function') return
|
|
28
|
+
|
|
29
|
+
const contexts = new WeakMap()
|
|
30
|
+
// Each pool creates its own queue, so its insertion method needs a runtime wrapper.
|
|
31
|
+
shimmer.wrap(pool, '_processRequest',
|
|
32
|
+
/** @param {(request: object) => Promise<void>} processRequest */
|
|
33
|
+
processRequest => {
|
|
34
|
+
shimmer.wrap(queue, 'add',
|
|
35
|
+
/** @param {(request: object) => Set<object>} add */
|
|
36
|
+
add => /** @param {object} request */ function (request) {
|
|
37
|
+
if (startChannel.hasSubscribers) {
|
|
38
|
+
contexts.set(request, AsyncResource.bind(processRequest))
|
|
39
|
+
}
|
|
40
|
+
return add.apply(this, arguments)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return /** @param {object} request */ function (request) {
|
|
44
|
+
const processInContext = contexts.get(request)
|
|
45
|
+
if (processInContext !== undefined) {
|
|
46
|
+
contexts.delete(request)
|
|
47
|
+
return processInContext.apply(this, arguments)
|
|
48
|
+
}
|
|
49
|
+
return processRequest.apply(this, arguments)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
23
54
|
addHook({ name: 'oracledb', versions: ['>=5'], file: 'lib/oracledb.js' }, oracledb => {
|
|
24
55
|
shimmer.wrap(oracledb.Connection.prototype, 'execute', execute => {
|
|
25
56
|
return function wrappedExecute (dbQuery) {
|
|
@@ -134,6 +165,7 @@ addHook({ name: 'oracledb', versions: ['>=5'], file: 'lib/oracledb.js' }, oracle
|
|
|
134
165
|
arguments[1] = shimmer.wrapFunction(callback, callback => (err, pool) => {
|
|
135
166
|
if (pool) {
|
|
136
167
|
poolAttributes.set(pool, poolAttrs)
|
|
168
|
+
bindPoolRequestContexts(pool)
|
|
137
169
|
}
|
|
138
170
|
callback(err, pool)
|
|
139
171
|
})
|
|
@@ -142,6 +174,7 @@ addHook({ name: 'oracledb', versions: ['>=5'], file: 'lib/oracledb.js' }, oracle
|
|
|
142
174
|
} else {
|
|
143
175
|
return createPool.apply(this, arguments).then((pool) => {
|
|
144
176
|
poolAttributes.set(pool, poolAttrs)
|
|
177
|
+
bindPoolRequestContexts(pool)
|
|
145
178
|
return pool
|
|
146
179
|
})
|
|
147
180
|
}
|
|
@@ -286,7 +286,8 @@ function wrapQuery (query) {
|
|
|
286
286
|
const queryQueue = deperecated ? this._queryQueue : this.queryQueue
|
|
287
287
|
const activeQuery = deperecated ? this._activeQuery : this.activeQuery
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
// In pipeline mode, _sentQueryQueue contains submitted queries waiting behind activeQuery.
|
|
290
|
+
const newQuery = queryQueue.at(-1) || this._sentQueryQueue?.at(-1) || activeQuery
|
|
290
291
|
|
|
291
292
|
if (!newQuery) {
|
|
292
293
|
return retval
|