dd-trace 6.24.0 → 6.25.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/ci/init.js +2 -22
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/package.json +11 -9
- package/packages/datadog-esbuild/index.js +8 -55
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +18 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +22 -11
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +42 -2
- package/packages/dd-trace/src/config/index.js +17 -5
- package/packages/dd-trace/src/config/parsers.js +9 -0
- package/packages/dd-trace/src/config/supported-configurations.json +158 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +4 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +35 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +41 -10
- package/packages/dd-trace/src/plugins/index.js +6 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +75 -46
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +64 -39
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +33 -53
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { getCommandBlocker } = require('../command-blocker')
|
|
4
|
-
const { runCommand } = require('../command-runner')
|
|
5
|
-
const { eventsOfType } = require('../payload-normalizer')
|
|
6
|
-
const { getBasicCommand } = require('../runner-command')
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
basicEventEvidence,
|
|
10
|
-
error: scenarioError,
|
|
11
|
-
failWithDebugRerun,
|
|
12
|
-
frameworkOutDir,
|
|
13
|
-
hasAllBasicEventTypes,
|
|
14
|
-
inconclusive,
|
|
15
|
-
pass,
|
|
16
|
-
runInstrumentedCommand,
|
|
17
|
-
} = require('./helpers')
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Checks whether controlled initialization reports one real project test.
|
|
21
|
-
*
|
|
22
|
-
* @param {object} input scenario inputs
|
|
23
|
-
* @param {object} input.framework framework manifest entry
|
|
24
|
-
* @param {string} input.out validation output directory
|
|
25
|
-
* @param {object} input.options validator options
|
|
26
|
-
* @returns {Promise<object>} scenario result
|
|
27
|
-
*/
|
|
28
|
-
async function runBasicReporting ({ framework, out, options }) {
|
|
29
|
-
const scenarioName = 'basic-reporting'
|
|
30
|
-
const command = getBasicCommand(framework)
|
|
31
|
-
let outDir
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const run = await runInstrumentedCommand({
|
|
35
|
-
allowMissingInitialization: true,
|
|
36
|
-
command,
|
|
37
|
-
framework,
|
|
38
|
-
options,
|
|
39
|
-
out,
|
|
40
|
-
scenarioName,
|
|
41
|
-
})
|
|
42
|
-
outDir = run.outDir
|
|
43
|
-
const complete = hasAllBasicEventTypes(run.events)
|
|
44
|
-
const selector = getSelectorEvidence(framework, run.events)
|
|
45
|
-
const evidence = {
|
|
46
|
-
...basicEventEvidence(run.events),
|
|
47
|
-
commandExitCode: run.result.exitCode,
|
|
48
|
-
commandOutputSummary: summarizeTestOutput(run.result.stdout, run.result.stderr),
|
|
49
|
-
commandTimedOut: run.result.timedOut,
|
|
50
|
-
foundationalReportingEstablished: complete &&
|
|
51
|
-
run.offline.initialized &&
|
|
52
|
-
run.offline.inputs.settings?.status === 'loaded' &&
|
|
53
|
-
run.result.exitCode === 0 &&
|
|
54
|
-
!run.result.timedOut,
|
|
55
|
-
offlineExporterInitialized: run.offline.initialized,
|
|
56
|
-
preflight: summarizePreflight(framework.preflight),
|
|
57
|
-
reportingPath: complete ? 'validator-direct-runner' : 'none',
|
|
58
|
-
selector,
|
|
59
|
-
settingsLoadedFromCache: run.offline.inputs.settings?.status === 'loaded',
|
|
60
|
-
}
|
|
61
|
-
evidence.foundationalReportingEstablished &&= selector.verified
|
|
62
|
-
|
|
63
|
-
if (run.result.timedOut) {
|
|
64
|
-
return inconclusive(
|
|
65
|
-
framework,
|
|
66
|
-
scenarioName,
|
|
67
|
-
'The initialized direct test exceeded its approved timeout. Basic Reporting remains incomplete.',
|
|
68
|
-
{ ...evidence, commandFailure: classifyFailure(framework, run.result) },
|
|
69
|
-
outDir
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!selector.verified) {
|
|
74
|
-
return inconclusive(
|
|
75
|
-
framework,
|
|
76
|
-
scenarioName,
|
|
77
|
-
'The repository test wrapper ran, but captured events did not prove that it honored the approved ' +
|
|
78
|
-
'representative test file. Basic Reporting remains incomplete.',
|
|
79
|
-
{
|
|
80
|
-
...evidence,
|
|
81
|
-
recommendation: 'Use a repository wrapper that forwards the selected test file, or use a direct ' +
|
|
82
|
-
'framework runner whose selector can be bounded by the validator.',
|
|
83
|
-
},
|
|
84
|
-
outDir
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (evidence.foundationalReportingEstablished) {
|
|
89
|
-
return pass(
|
|
90
|
-
framework,
|
|
91
|
-
scenarioName,
|
|
92
|
-
'The direct test emitted session, module, suite, and test events.',
|
|
93
|
-
evidence,
|
|
94
|
-
outDir
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (framework.preflight?.observedTestCount === null && evidence.testEvents === 0) {
|
|
99
|
-
return inconclusive(
|
|
100
|
-
framework,
|
|
101
|
-
scenarioName,
|
|
102
|
-
'The clean runner exited successfully without a parseable test count, and the initialized run emitted no ' +
|
|
103
|
-
'test event. Basic Reporting remains incomplete because the validator cannot prove that a test executed.',
|
|
104
|
-
{
|
|
105
|
-
...evidence,
|
|
106
|
-
recommendation: 'Use a representative test command that reports an executed-test count, or inspect the ' +
|
|
107
|
-
'runner output and debug artifact before attributing the missing event to dd-trace.',
|
|
108
|
-
},
|
|
109
|
-
outDir
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!run.offline.initialized || !evidence.settingsLoadedFromCache) {
|
|
114
|
-
return failBasicWithDebugRerun({
|
|
115
|
-
command,
|
|
116
|
-
diagnosis: run.offline.initialized
|
|
117
|
-
? 'The clean test passed, but Test Optimization did not load the validator-owned offline settings.'
|
|
118
|
-
: 'The clean test passed, but the offline Test Optimization exporter did not initialize.',
|
|
119
|
-
evidence: {
|
|
120
|
-
...evidence,
|
|
121
|
-
possibleLibraryBug: true,
|
|
122
|
-
recommendation: 'Inspect the debug artifact for dd-trace initialization errors and report it with the ' +
|
|
123
|
-
'framework and dd-trace versions.',
|
|
124
|
-
},
|
|
125
|
-
framework,
|
|
126
|
-
options,
|
|
127
|
-
out,
|
|
128
|
-
outDir,
|
|
129
|
-
scenarioName,
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (run.result.exitCode !== 0) {
|
|
134
|
-
evidence.commandFailure = classifyFailure(framework, run.result, run.events)
|
|
135
|
-
const confirmation = await runCleanConfirmation({ command, framework, options, out })
|
|
136
|
-
evidence.cleanConfirmation = confirmation.evidence
|
|
137
|
-
if (!confirmation.evidence.matchesPreflight) {
|
|
138
|
-
return inconclusive(
|
|
139
|
-
framework,
|
|
140
|
-
scenarioName,
|
|
141
|
-
'The clean baseline changed between runs, so the initialized failure cannot be attributed to dd-trace.',
|
|
142
|
-
evidence,
|
|
143
|
-
outDir,
|
|
144
|
-
confirmation.artifacts
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
const result = await failBasicWithDebugRerun({
|
|
148
|
-
command,
|
|
149
|
-
diagnosis: complete
|
|
150
|
-
? `The test passed twice without Datadog but exited ${run.result.exitCode} when initialized, after ` +
|
|
151
|
-
'emitting ' +
|
|
152
|
-
'the complete event hierarchy. This is a possible dd-trace compatibility bug.'
|
|
153
|
-
: `The test passed twice without Datadog but exited ${run.result.exitCode} when initialized and did not ` +
|
|
154
|
-
'emit the complete event hierarchy. This is a possible dd-trace adapter or compatibility bug.',
|
|
155
|
-
evidence: {
|
|
156
|
-
...evidence,
|
|
157
|
-
possibleLibraryBug: true,
|
|
158
|
-
recommendation: 'Attach the debug run, clean confirmations, framework version, and dd-trace version to ' +
|
|
159
|
-
'the engineering investigation.',
|
|
160
|
-
},
|
|
161
|
-
framework,
|
|
162
|
-
options,
|
|
163
|
-
out,
|
|
164
|
-
outDir,
|
|
165
|
-
scenarioName,
|
|
166
|
-
})
|
|
167
|
-
result.artifacts.push(...confirmation.artifacts)
|
|
168
|
-
return result
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const missing = getMissingLevels(evidence)
|
|
172
|
-
return failBasicWithDebugRerun({
|
|
173
|
-
command,
|
|
174
|
-
diagnosis: 'The direct test passed cleanly and while initialized, but no complete Test Optimization event ' +
|
|
175
|
-
`hierarchy was captured. Missing levels: ${missing.join(', ')}. This is a possible dd-trace adapter bug.`,
|
|
176
|
-
evidence: {
|
|
177
|
-
...evidence,
|
|
178
|
-
missingEventLevels: missing,
|
|
179
|
-
possibleLibraryBug: true,
|
|
180
|
-
recommendation: 'Inspect the debug artifact for initialization and adapter errors. Include it with the ' +
|
|
181
|
-
'framework and dd-trace versions in an engineering investigation.',
|
|
182
|
-
},
|
|
183
|
-
framework,
|
|
184
|
-
options,
|
|
185
|
-
out,
|
|
186
|
-
outDir,
|
|
187
|
-
scenarioName,
|
|
188
|
-
})
|
|
189
|
-
} catch (error) {
|
|
190
|
-
const failure = scenarioError(framework, scenarioName, error, outDir || error?.artifactDirectory)
|
|
191
|
-
failure.diagnosis = `Basic Reporting could not complete: ${error?.message || error}`
|
|
192
|
-
failure.evidence.validationIncomplete = true
|
|
193
|
-
return failure
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async function failBasicWithDebugRerun (input) {
|
|
198
|
-
const result = await failWithDebugRerun(input)
|
|
199
|
-
const debug = result.evidence?.debugRerun
|
|
200
|
-
if (!isSuccessfulDebugRerun(debug, result.evidence?.selector)) return result
|
|
201
|
-
|
|
202
|
-
const initialDiagnosis = result.diagnosis
|
|
203
|
-
delete result.evidence.possibleLibraryBug
|
|
204
|
-
result.status = 'error'
|
|
205
|
-
result.diagnosis = 'The first initialized run failed, but the unchanged DD_TRACE_DEBUG=1 rerun exited cleanly ' +
|
|
206
|
-
'and emitted the complete event hierarchy. Basic Reporting is intermittent, so no library-bug conclusion ' +
|
|
207
|
-
'was reached.'
|
|
208
|
-
result.evidence.initialInstrumentedDiagnosis = initialDiagnosis
|
|
209
|
-
result.evidence.intermittentInstrumentedResult = true
|
|
210
|
-
result.evidence.recommendation = 'Repeat the approved initialized command without changing its test selection. ' +
|
|
211
|
-
'If the failure recurs, send both initialized runs and the clean confirmations to engineering.'
|
|
212
|
-
result.evidence.validationIncomplete = true
|
|
213
|
-
return result
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function isSuccessfulDebugRerun (debug, selector) {
|
|
217
|
-
return isDebugSelectorVerified(debug, selector) &&
|
|
218
|
-
debug?.ran === true &&
|
|
219
|
-
debug.commandExitCode === 0 &&
|
|
220
|
-
debug.commandTimedOut === false &&
|
|
221
|
-
debug.offlineExporterInitialized === true &&
|
|
222
|
-
debug.settingsLoadedFromCache === true &&
|
|
223
|
-
debug.testSessionEvents > 0 &&
|
|
224
|
-
debug.testModuleEvents > 0 &&
|
|
225
|
-
debug.testSuiteEvents > 0 &&
|
|
226
|
-
debug.testEvents > 0
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// A wrapper rerun is comparable only when events identify the approved representative and no other file.
|
|
230
|
-
function isDebugSelectorVerified (debug, selector) {
|
|
231
|
-
if (selector?.verified !== true) return false
|
|
232
|
-
if (selector.mode === 'bounded_direct_runner') return true
|
|
233
|
-
if (selector.mode !== 'instrumented_event_identity' ||
|
|
234
|
-
typeof selector.expectedTestFile !== 'string' ||
|
|
235
|
-
debug?.testEventsWithoutSourceFile !== 0 ||
|
|
236
|
-
debug?.testSourceFileCount !== 1 ||
|
|
237
|
-
debug?.testSourceFiles?.length !== 1) return false
|
|
238
|
-
return sourceFilesMatch(debug.testSourceFiles[0], selector.expectedTestFile)
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Repeats the direct clean command after an initialized-only failure.
|
|
243
|
-
*
|
|
244
|
-
* @param {object} input confirmation inputs
|
|
245
|
-
* @param {object} input.command direct command
|
|
246
|
-
* @param {object} input.framework framework entry
|
|
247
|
-
* @param {object} input.options validator options
|
|
248
|
-
* @param {string} input.out output root
|
|
249
|
-
* @returns {Promise<{artifacts: string[], evidence: object}>} confirmation evidence
|
|
250
|
-
*/
|
|
251
|
-
async function runCleanConfirmation ({ command, framework, options, out }) {
|
|
252
|
-
const outDir = frameworkOutDir(out, framework, 'basic-reporting-clean-confirmation')
|
|
253
|
-
const result = await runCommand(command, {
|
|
254
|
-
artifactRoot: out,
|
|
255
|
-
envMode: 'clean',
|
|
256
|
-
label: `${framework.id}:basic-reporting:clean-confirmation`,
|
|
257
|
-
outDir,
|
|
258
|
-
repositoryRoot: options.repositoryRoot,
|
|
259
|
-
requireExecutableApproval: options.requireExecutableApproval,
|
|
260
|
-
verbose: options.verbose,
|
|
261
|
-
})
|
|
262
|
-
return {
|
|
263
|
-
artifacts: Object.values(result.artifacts),
|
|
264
|
-
evidence: {
|
|
265
|
-
exitCode: result.exitCode,
|
|
266
|
-
matchesPreflight: !result.timedOut &&
|
|
267
|
-
framework.preflight?.exitCode === result.exitCode,
|
|
268
|
-
timedOut: result.timedOut,
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Returns a compact preflight summary.
|
|
275
|
-
*
|
|
276
|
-
* @param {object} preflight preflight evidence
|
|
277
|
-
* @returns {object} compact evidence
|
|
278
|
-
*/
|
|
279
|
-
function summarizePreflight (preflight = {}) {
|
|
280
|
-
return {
|
|
281
|
-
attempts: (preflight.attempts || []).map(attempt => ({
|
|
282
|
-
exitCode: attempt.exitCode,
|
|
283
|
-
observedTestCount: attempt.observedTestCount,
|
|
284
|
-
testFile: attempt.testFile,
|
|
285
|
-
timedOut: attempt.timedOut === true,
|
|
286
|
-
})),
|
|
287
|
-
durationMs: preflight.durationMs,
|
|
288
|
-
exitCode: preflight.exitCode,
|
|
289
|
-
observedTestCount: preflight.observedTestCount,
|
|
290
|
-
ran: preflight.ran === true,
|
|
291
|
-
selectedTestFile: preflight.selectedTestFile,
|
|
292
|
-
selectorVerification: preflight.selectorVerification,
|
|
293
|
-
timedOut: preflight.timedOut === true,
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Verifies repository wrapper scope from captured test source files.
|
|
299
|
-
*
|
|
300
|
-
* @param {object} framework framework manifest entry
|
|
301
|
-
* @param {object[]} events normalized captured events
|
|
302
|
-
* @returns {object} selector verification evidence
|
|
303
|
-
*/
|
|
304
|
-
function getSelectorEvidence (framework, events) {
|
|
305
|
-
const mode = framework.validation?.selectorScope
|
|
306
|
-
const expectedTestFile = framework.validation?.testFile
|
|
307
|
-
if (mode === 'bounded_direct_runner') {
|
|
308
|
-
return { mode, verified: true }
|
|
309
|
-
}
|
|
310
|
-
if (mode !== 'instrumented_event_identity') {
|
|
311
|
-
return { mode: mode || 'missing', verified: false }
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const tests = eventsOfType(events, 'test')
|
|
315
|
-
const sourceFiles = tests.map(test => test.testSourceFile).filter(Boolean)
|
|
316
|
-
const matchingTestEvents = sourceFiles.filter(filename => {
|
|
317
|
-
return sourceFilesMatch(filename, expectedTestFile)
|
|
318
|
-
}).length
|
|
319
|
-
const differentSourceFiles = [...new Set(sourceFiles.filter(filename => {
|
|
320
|
-
return !sourceFilesMatch(filename, expectedTestFile)
|
|
321
|
-
}))].slice(0, 5)
|
|
322
|
-
const testEventsWithoutSourceFile = tests.length - sourceFiles.length
|
|
323
|
-
|
|
324
|
-
return {
|
|
325
|
-
differentSourceFiles,
|
|
326
|
-
expectedTestFile,
|
|
327
|
-
matchingTestEvents,
|
|
328
|
-
mode,
|
|
329
|
-
testEventsWithoutSourceFile,
|
|
330
|
-
verified: matchingTestEvents > 0 &&
|
|
331
|
-
differentSourceFiles.length === 0 &&
|
|
332
|
-
testEventsWithoutSourceFile === 0,
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Compares absolute and repository-relative test source paths without filesystem access.
|
|
338
|
-
*
|
|
339
|
-
* @param {string} actual captured test source path
|
|
340
|
-
* @param {string} expected approved representative path
|
|
341
|
-
*/
|
|
342
|
-
function sourceFilesMatch (actual, expected) {
|
|
343
|
-
const normalizedActual = normalizeSourceFile(actual)
|
|
344
|
-
const normalizedExpected = normalizeSourceFile(expected)
|
|
345
|
-
if (!normalizedActual || !normalizedExpected) return false
|
|
346
|
-
if (normalizedActual === normalizedExpected) return true
|
|
347
|
-
if (!normalizedActual.includes('/') || !normalizedExpected.includes('/')) return false
|
|
348
|
-
return normalizedExpected.endsWith(`/${normalizedActual}`) ||
|
|
349
|
-
normalizedActual.endsWith(`/${normalizedExpected}`)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function normalizeSourceFile (filename) {
|
|
353
|
-
return String(filename || '')
|
|
354
|
-
.replace(/^file:\/\//, '')
|
|
355
|
-
.replaceAll('\\', '/')
|
|
356
|
-
.replace(/^\.\//, '')
|
|
357
|
-
.replaceAll(/\/+/g, '/')
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Classifies a direct command failure.
|
|
362
|
-
*
|
|
363
|
-
* @param {object} framework framework entry
|
|
364
|
-
* @param {object} result command result
|
|
365
|
-
* @param {object[]} [events] normalized captured events
|
|
366
|
-
* @returns {object|undefined} blocker
|
|
367
|
-
*/
|
|
368
|
-
function classifyFailure (framework, result, events = []) {
|
|
369
|
-
return getCommandBlocker(result, {
|
|
370
|
-
browserRequired: framework.browserRequired,
|
|
371
|
-
framework: framework.framework,
|
|
372
|
-
packageJson: framework.project?.packageJson,
|
|
373
|
-
testsRan: eventsOfType(events, 'test').length > 0,
|
|
374
|
-
})
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Returns missing Test Optimization hierarchy levels.
|
|
379
|
-
*
|
|
380
|
-
* @param {object} evidence event evidence
|
|
381
|
-
* @returns {string[]} missing levels
|
|
382
|
-
*/
|
|
383
|
-
function getMissingLevels (evidence) {
|
|
384
|
-
return [
|
|
385
|
-
['session', evidence.testSessionEvents],
|
|
386
|
-
['module', evidence.testModuleEvents],
|
|
387
|
-
['suite', evidence.testSuiteEvents],
|
|
388
|
-
['test', evidence.testEvents],
|
|
389
|
-
].filter(([, count]) => count < 1).map(([level]) => level)
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Extracts bounded useful test output lines.
|
|
394
|
-
*
|
|
395
|
-
* @param {string} [stdout] command stdout
|
|
396
|
-
* @param {string} [stderr] command stderr
|
|
397
|
-
* @returns {string[]} output summary
|
|
398
|
-
*/
|
|
399
|
-
function summarizeTestOutput (stdout = '', stderr = '') {
|
|
400
|
-
const lines = `${stdout}\n${stderr}`.split(/\r?\n/)
|
|
401
|
-
const interesting = lines.filter(line => {
|
|
402
|
-
return /\b(?:error|fail|pass|scenario|suite|test|timed out|warning)\b/i.test(line)
|
|
403
|
-
})
|
|
404
|
-
return [...new Set(interesting.map(line => line.trim()).filter(Boolean))].slice(-12)
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
module.exports = { runBasicReporting, summarizeTestOutput }
|