@depup/dd-trace 5.97.0-depup.0 → 6.5.0-depup.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 +89 -104
- package/README.electron.md +7 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/ci/diagnose.js +2100 -0
- package/ci/init.js +46 -5
- package/ci/runbook.md +198 -0
- package/ci/test-optimization-validation/approval-artifacts.js +143 -0
- package/ci/test-optimization-validation/approval.js +299 -0
- package/ci/test-optimization-validation/artifact-id.js +20 -0
- package/ci/test-optimization-validation/bounded-json.js +121 -0
- package/ci/test-optimization-validation/ci-command-candidate.js +83 -0
- package/ci/test-optimization-validation/ci-discovery.js +181 -0
- package/ci/test-optimization-validation/ci-remediation.js +210 -0
- package/ci/test-optimization-validation/cli.js +903 -0
- package/ci/test-optimization-validation/command-blocker.js +81 -0
- package/ci/test-optimization-validation/command-output-policy.js +206 -0
- package/ci/test-optimization-validation/command-runner.js +707 -0
- package/ci/test-optimization-validation/command-suitability.js +471 -0
- package/ci/test-optimization-validation/executable-approval.js +48 -0
- package/ci/test-optimization-validation/executable.js +480 -0
- package/ci/test-optimization-validation/generated-file-policy.js +63 -0
- package/ci/test-optimization-validation/generated-files.js +351 -0
- package/ci/test-optimization-validation/generated-verifier.js +196 -0
- package/ci/test-optimization-validation/init-probe-preload.js +163 -0
- package/ci/test-optimization-validation/init-probe.js +246 -0
- package/ci/test-optimization-validation/late-initialization.js +63 -0
- package/ci/test-optimization-validation/local-command.js +163 -0
- package/ci/test-optimization-validation/manifest-loader.js +133 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +738 -0
- package/ci/test-optimization-validation/manifest-schema.js +862 -0
- package/ci/test-optimization-validation/offline-fixtures.js +327 -0
- package/ci/test-optimization-validation/offline-output.js +406 -0
- package/ci/test-optimization-validation/payload-normalizer.js +72 -0
- package/ci/test-optimization-validation/plan-writer.js +1120 -0
- package/ci/test-optimization-validation/preflight-runner.js +114 -0
- package/ci/test-optimization-validation/redaction.js +331 -0
- package/ci/test-optimization-validation/report-writer.js +1508 -0
- package/ci/test-optimization-validation/safe-files.js +203 -0
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +159 -0
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +657 -0
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +780 -0
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +141 -0
- package/ci/test-optimization-validation/scenarios/helpers.js +539 -0
- package/ci/test-optimization-validation/scenarios/test-management.js +218 -0
- package/ci/test-optimization-validation/setup-runner.js +97 -0
- package/ci/test-optimization-validation/static-diagnosis.js +159 -0
- package/ci/test-optimization-validation/test-output.js +129 -0
- package/ci/test-optimization-validation-manifest.schema.json +1 -0
- package/ci/validate-test-optimization.js +3 -0
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +2 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +436 -252
- package/index.electron.js +3 -0
- package/init.js +18 -0
- package/initialize.mjs +10 -9
- package/loader-hook.mjs +170 -53
- package/openfeature.d.ts +1 -0
- package/openfeature.js +4 -0
- package/package.json +118 -80
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +137 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +16 -16
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +25 -0
- package/packages/datadog-instrumentations/src/cucumber.js +762 -189
- package/packages/datadog-instrumentations/src/cypress-config.js +547 -93
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +166 -87
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +31 -7
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +111 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1809 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -120
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -135
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +82 -8
- package/packages/datadog-instrumentations/src/mongoose.js +46 -37
- package/packages/datadog-instrumentations/src/mquery.js +7 -7
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +68 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -8
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1229 -356
- package/packages/datadog-instrumentations/src/process.js +3 -0
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +253 -87
- package/packages/datadog-instrumentations/src/selenium.js +53 -28
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1590 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +9 -8
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +80 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-aws-sdk/src/util.js +2 -2
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +47 -29
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +929 -98
- package/packages/datadog-plugin-cypress/src/index.js +109 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +272 -51
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +748 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +54 -8
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +7 -4
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +195 -72
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +55 -44
- package/packages/datadog-plugin-selenium/src/index.js +5 -36
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +5 -2
- package/packages/datadog-plugin-ws/src/producer.js +4 -1
- package/packages/datadog-plugin-ws/src/receiver.js +4 -2
- package/packages/datadog-plugin-ws/src/server.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +148 -55
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +3 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +19 -7
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +123 -33
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +160 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +288 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +84 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +369 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +60 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +188 -27
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +110 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +10 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/rum.js +7 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +9 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +256 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +451 -0
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +90 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +692 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +140 -33
- package/packages/dd-trace/src/config/index.js +127 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +460 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +5 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/client-library-headers.js +21 -0
- package/packages/dd-trace/src/exporters/common/request.js +93 -44
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +48 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +29 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/experiments/client.js +113 -0
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +154 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +283 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +152 -0
- package/packages/dd-trace/src/llmobs/experiments/noop.js +30 -0
- package/packages/dd-trace/src/llmobs/experiments/result.js +34 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +380 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +4 -29
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +8 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +68 -64
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +43 -0
- package/packages/dd-trace/src/llmobs/sdk.js +73 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +197 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +33 -2
- package/packages/dd-trace/src/llmobs/util.js +234 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +322 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +90 -0
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +32 -16
- package/packages/dd-trace/src/openfeature/index.js +0 -2
- package/packages/dd-trace/src/openfeature/noop.js +41 -64
- package/packages/dd-trace/src/openfeature/register.js +35 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -14
- package/packages/dd-trace/src/openfeature/require-provider.js +18 -0
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +10 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +64 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +407 -91
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +6 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +29 -5
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +950 -69
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +128 -37
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +18 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +0 -36
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +22 -22
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +57 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { createCoverageMap } = require('../../../../vendor/dist/istanbul-lib-coverage')
|
|
4
|
+
const satisfies = require('../../../../vendor/dist/semifies')
|
|
5
|
+
const { DD_MAJOR } = require('../../../../version')
|
|
4
6
|
const { addHook, channel } = require('../helpers/instrument')
|
|
5
7
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
8
|
const { isMarkedAsUnskippable } = require('../../../datadog-plugin-jest/src/util')
|
|
9
|
+
const { writeCoverageBackfillToCache } = require('../../../dd-trace/src/ci-visibility/test-optimization-cache')
|
|
7
10
|
const log = require('../../../dd-trace/src/log')
|
|
8
11
|
const { getEnvironmentVariable } = require('../../../dd-trace/src/config/helper')
|
|
9
12
|
const {
|
|
10
13
|
getTestSuitePath,
|
|
11
14
|
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
|
|
12
15
|
fromCoverageMapToCoverage,
|
|
13
|
-
|
|
16
|
+
getCoveredFilesFromCoverage,
|
|
17
|
+
getExecutableFilesFromCoverage,
|
|
18
|
+
applySkippedCoverageToCoverage,
|
|
14
19
|
mergeCoverage,
|
|
15
20
|
resetCoverage,
|
|
16
21
|
getIsFaultyEarlyFlakeDetection,
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
getRelativeCoverageFiles,
|
|
23
|
+
getTestCoverageLinesPercentage,
|
|
24
|
+
collectTestOptimizationSummariesFromTraces,
|
|
25
|
+
logTestOptimizationSummary,
|
|
26
|
+
getTestOptimizationRequestResults,
|
|
27
|
+
isModifiedTest,
|
|
19
28
|
} = require('../../../dd-trace/src/plugins/util/test')
|
|
20
29
|
|
|
21
30
|
const {
|
|
@@ -27,26 +36,33 @@ const {
|
|
|
27
36
|
getOnTestEndHandler,
|
|
28
37
|
getOnTestRetryHandler,
|
|
29
38
|
getOnHookEndHandler,
|
|
39
|
+
patchFailedTestReplayHookUp,
|
|
30
40
|
getOnFailHandler,
|
|
31
41
|
getOnPendingHandler,
|
|
32
42
|
testFileToSuiteCtx,
|
|
33
43
|
newTests,
|
|
44
|
+
efdTests,
|
|
34
45
|
testsQuarantined,
|
|
35
46
|
getTestFullName,
|
|
36
47
|
getRunTestsWrapper,
|
|
37
|
-
testsAttemptToFix,
|
|
38
|
-
testsStatuses,
|
|
39
48
|
newTestsWithDynamicNames,
|
|
49
|
+
attemptToFixExecutions,
|
|
50
|
+
loggedAttemptToFixTests,
|
|
40
51
|
} = require('./utils')
|
|
41
52
|
|
|
42
53
|
require('./common')
|
|
43
54
|
|
|
55
|
+
const MINIMUM_MOCHA_VERSION = DD_MAJOR >= 6 ? '>=8.0.0' : '>=5.2.0'
|
|
56
|
+
|
|
44
57
|
const patched = new WeakSet()
|
|
58
|
+
let hasWarnedDeprecatedMochaVersion = false
|
|
45
59
|
|
|
46
60
|
const unskippableSuites = []
|
|
47
61
|
let suitesToSkip = []
|
|
48
62
|
let isSuitesSkipped = false
|
|
49
63
|
let skippedSuites = []
|
|
64
|
+
let skippableSuitesCoverage = {}
|
|
65
|
+
let skippedSuitesCoverage = {}
|
|
50
66
|
let itrCorrelationId = ''
|
|
51
67
|
let isForcedToRun = false
|
|
52
68
|
const config = {}
|
|
@@ -79,6 +95,20 @@ const itrSkippedSuitesCh = channel('ci:mocha:itr:skipped-suites')
|
|
|
79
95
|
|
|
80
96
|
const getCodeCoverageCh = channel('ci:nyc:get-coverage')
|
|
81
97
|
|
|
98
|
+
function warnDeprecatedMochaVersion (frameworkVersion) {
|
|
99
|
+
if (DD_MAJOR >= 6 || hasWarnedDeprecatedMochaVersion || !frameworkVersion ||
|
|
100
|
+
!satisfies(frameworkVersion, '<8.0.0')) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
hasWarnedDeprecatedMochaVersion = true
|
|
105
|
+
// eslint-disable-next-line no-console
|
|
106
|
+
console.warn(
|
|
107
|
+
'dd-trace support for Mocha<8.0.0 is deprecated and will be removed in dd-trace v6. ' +
|
|
108
|
+
'Please upgrade Mocha to >=8.0.0.'
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
// Tests from workers do not come with `isFailed` method
|
|
83
113
|
function isTestFailed (test) {
|
|
84
114
|
if (test.isFailed) {
|
|
@@ -90,10 +120,56 @@ function isTestFailed (test) {
|
|
|
90
120
|
return false
|
|
91
121
|
}
|
|
92
122
|
|
|
123
|
+
function getRootSuiteStatus (rootTests) {
|
|
124
|
+
let status = 'pass'
|
|
125
|
+
if (rootTests.every(t => t.isPending())) {
|
|
126
|
+
status = 'skip'
|
|
127
|
+
} else {
|
|
128
|
+
for (const test of rootTests) {
|
|
129
|
+
if (test.state === 'failed' || test.timedOut || test._ddHookFailed) {
|
|
130
|
+
status = 'fail'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return status
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function haveRootTestsFinished (rootTests) {
|
|
138
|
+
for (const test of rootTests) {
|
|
139
|
+
if (!test.isPending() && !test.state && !test.timedOut && !test._ddHookFailed) {
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getSuitePath (suite) {
|
|
147
|
+
return getTestSuitePath(suite.file, process.cwd())
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getSuitesToSkip (originalSuites) {
|
|
151
|
+
return getSuitesToSkipFromPaths(originalSuites.map(getSuitePath))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getSuitesToSkipFromPaths (localSuites) {
|
|
155
|
+
const localSuitesSet = new Set(localSuites)
|
|
156
|
+
const suitesToSkipForRun = []
|
|
157
|
+
|
|
158
|
+
for (const suite of suitesToSkip) {
|
|
159
|
+
if (localSuitesSet.has(suite)) {
|
|
160
|
+
suitesToSkipForRun.push(suite)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return suitesToSkipForRun
|
|
165
|
+
}
|
|
166
|
+
|
|
93
167
|
function getFilteredSuites (originalSuites) {
|
|
168
|
+
const suitesToSkipForRun = getSuitesToSkip(originalSuites)
|
|
169
|
+
|
|
94
170
|
return originalSuites.reduce((acc, suite) => {
|
|
95
|
-
const testPath =
|
|
96
|
-
const shouldSkip =
|
|
171
|
+
const testPath = getSuitePath(suite)
|
|
172
|
+
const shouldSkip = suitesToSkipForRun.includes(testPath)
|
|
97
173
|
const isUnskippable = unskippableSuites.includes(suite.file)
|
|
98
174
|
if (shouldSkip && !isUnskippable) {
|
|
99
175
|
acc.skippedSuites.add(testPath)
|
|
@@ -101,7 +177,67 @@ function getFilteredSuites (originalSuites) {
|
|
|
101
177
|
acc.suitesToRun.push(suite)
|
|
102
178
|
}
|
|
103
179
|
return acc
|
|
104
|
-
}, { suitesToRun: [], skippedSuites: new Set() })
|
|
180
|
+
}, { suitesToRun: [], skippedSuites: new Set(), suitesToSkipForRun })
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function hasSkippableSuitesCoverage () {
|
|
184
|
+
return skippableSuitesCoverage &&
|
|
185
|
+
typeof skippableSuitesCoverage === 'object' &&
|
|
186
|
+
Object.keys(skippableSuitesCoverage).length > 0
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isTiaCoverageBackfillEnabled () {
|
|
190
|
+
return config.isItrEnabled && config.isCoverageReportUploadEnabled
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function getCoverageRootDir () {
|
|
194
|
+
return config.repositoryRoot || process.cwd()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Recomputes whether a parallel worker result belongs to a modified suite.
|
|
199
|
+
*
|
|
200
|
+
* In parallel mode, `_ddIsModified` is set on Mocha Test objects inside the worker.
|
|
201
|
+
* The main process receives `Test.prototype.serialize()` output for test events,
|
|
202
|
+
* and that fixed serialization drops custom properties. We still need modified-test
|
|
203
|
+
* bookkeeping in the main process for EFD failure suppression, so infer it again
|
|
204
|
+
* from the suite path.
|
|
205
|
+
*
|
|
206
|
+
* @param {string} testSuiteAbsolutePath
|
|
207
|
+
* @returns {boolean}
|
|
208
|
+
*/
|
|
209
|
+
function isModifiedTestSuite (testSuiteAbsolutePath) {
|
|
210
|
+
const testPath = getTestSuitePath(testSuiteAbsolutePath, getCoverageRootDir())
|
|
211
|
+
return isModifiedTest(testPath, null, null, config.modifiedFiles, 'mocha')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function shouldReportCodeCoverageLinesPct (hasBackfilledCoverage) {
|
|
215
|
+
return !isSuitesSkipped || hasBackfilledCoverage
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getSkippedSuitesCoverageForRun () {
|
|
219
|
+
return isSuitesSkipped && isTiaCoverageBackfillEnabled() && hasSkippableSuitesCoverage()
|
|
220
|
+
? skippableSuitesCoverage
|
|
221
|
+
: {}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function applySkippedCoverageToMochaCoverageMap () {
|
|
225
|
+
if (!isTiaCoverageBackfillEnabled()) return false
|
|
226
|
+
return applySkippedCoverageToCoverage(originalCoverageMap, skippedSuitesCoverage, getCoverageRootDir())
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function getMochaTestSessionCoverageFiles () {
|
|
230
|
+
return getRelativeCoverageFiles(getExecutableFilesFromCoverage(originalCoverageMap), getCoverageRootDir())
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function resetSuiteSkippingRunState () {
|
|
234
|
+
isSuitesSkipped = false
|
|
235
|
+
skippedSuites = []
|
|
236
|
+
skippableSuitesCoverage = {}
|
|
237
|
+
skippedSuitesCoverage = {}
|
|
238
|
+
untestedCoverage = undefined
|
|
239
|
+
config.repositoryRoot = undefined
|
|
240
|
+
writeCoverageBackfillToCache({})
|
|
105
241
|
}
|
|
106
242
|
|
|
107
243
|
function getOnStartHandler (frameworkVersion) {
|
|
@@ -136,36 +272,28 @@ function getOnEndHandler (isParallel) {
|
|
|
136
272
|
* The rationale behind is the following: you may still be able to block your CI pipeline by gating
|
|
137
273
|
* on flakiness (the test will be considered flaky), but you may choose to unblock the pipeline too.
|
|
138
274
|
*/
|
|
139
|
-
for (const tests of Object.values(
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.failures -=
|
|
275
|
+
for (const tests of Object.values(efdTests)) {
|
|
276
|
+
const failingEfdTests = tests.filter(test => isTestFailed(test))
|
|
277
|
+
const areAllEfdTestsFailing = failingEfdTests.length === tests.length
|
|
278
|
+
const nonQuarantinedFailingEfdTests = failingEfdTests.filter(test => !testsQuarantined.has(test))
|
|
279
|
+
if (nonQuarantinedFailingEfdTests.length && !areAllEfdTestsFailing) {
|
|
280
|
+
this.stats.failures -= nonQuarantinedFailingEfdTests.length
|
|
281
|
+
this.failures -= nonQuarantinedFailingEfdTests.length
|
|
145
282
|
}
|
|
146
283
|
}
|
|
147
284
|
}
|
|
148
285
|
|
|
149
|
-
// We
|
|
150
|
-
//
|
|
286
|
+
// We subtract the errors from quarantined tests from the total number of failures.
|
|
287
|
+
// Attempt-to-fix tests ignore quarantine/disabled suppression and keep their framework result.
|
|
151
288
|
if (config.isTestManagementTestsEnabled) {
|
|
152
289
|
let numFailedQuarantinedTests = 0
|
|
153
|
-
let numFailedRetriedQuarantinedOrDisabledTests = 0
|
|
154
|
-
for (const test of testsAttemptToFix) {
|
|
155
|
-
const testName = getTestFullName(test)
|
|
156
|
-
const testProperties = getTestProperties(test, config.testManagementTests)
|
|
157
|
-
if (isTestFailed(test) && (testProperties.isQuarantined || testProperties.isDisabled)) {
|
|
158
|
-
const numFailedTests = testsStatuses.get(testName).filter(status => status === 'fail').length
|
|
159
|
-
numFailedRetriedQuarantinedOrDisabledTests += numFailedTests
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
290
|
for (const test of testsQuarantined) {
|
|
163
291
|
if (isTestFailed(test)) {
|
|
164
292
|
numFailedQuarantinedTests++
|
|
165
293
|
}
|
|
166
294
|
}
|
|
167
|
-
this.stats.failures -= numFailedQuarantinedTests
|
|
168
|
-
this.failures -= numFailedQuarantinedTests
|
|
295
|
+
this.stats.failures -= numFailedQuarantinedTests
|
|
296
|
+
this.failures -= numFailedQuarantinedTests
|
|
169
297
|
}
|
|
170
298
|
|
|
171
299
|
// Recompute status after EFD and quarantine adjustments have reduced failure counts
|
|
@@ -184,12 +312,24 @@ function getOnEndHandler (isParallel) {
|
|
|
184
312
|
testFileToSuiteCtx.clear()
|
|
185
313
|
|
|
186
314
|
let testCodeCoverageLinesTotal
|
|
187
|
-
|
|
315
|
+
let testSessionCoverageFiles
|
|
316
|
+
if (global.__coverage__ || untestedCoverage) {
|
|
188
317
|
try {
|
|
318
|
+
let hasBackfilledCoverage = false
|
|
189
319
|
if (untestedCoverage) {
|
|
190
320
|
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
191
321
|
}
|
|
192
|
-
|
|
322
|
+
hasBackfilledCoverage = applySkippedCoverageToMochaCoverageMap()
|
|
323
|
+
if (shouldReportCodeCoverageLinesPct(hasBackfilledCoverage)) {
|
|
324
|
+
testCodeCoverageLinesTotal = getTestCoverageLinesPercentage(
|
|
325
|
+
originalCoverageMap,
|
|
326
|
+
undefined,
|
|
327
|
+
getCoverageRootDir()
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
if (isTiaCoverageBackfillEnabled()) {
|
|
331
|
+
testSessionCoverageFiles = getMochaTestSessionCoverageFiles()
|
|
332
|
+
}
|
|
193
333
|
} catch {
|
|
194
334
|
// ignore errors
|
|
195
335
|
}
|
|
@@ -201,6 +341,7 @@ function getOnEndHandler (isParallel) {
|
|
|
201
341
|
status,
|
|
202
342
|
isSuitesSkipped,
|
|
203
343
|
testCodeCoverageLinesTotal,
|
|
344
|
+
testSessionCoverageFiles,
|
|
204
345
|
numSkippedSuites: skippedSuites.length,
|
|
205
346
|
hasForcedToRunSuites: isForcedToRun,
|
|
206
347
|
hasUnskippableSuites: !!unskippableSuites.length,
|
|
@@ -211,26 +352,74 @@ function getOnEndHandler (isParallel) {
|
|
|
211
352
|
isParallel,
|
|
212
353
|
})
|
|
213
354
|
|
|
214
|
-
|
|
355
|
+
logTestOptimizationSummary({ attemptToFixExecutions, newTestsWithDynamicNames })
|
|
356
|
+
loggedAttemptToFixTests.clear()
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function getRunStoresPromise (channelToPublishTo, ctx) {
|
|
361
|
+
return new Promise(resolve => {
|
|
362
|
+
channelToPublishTo.runStores({ ...ctx, onDone: resolve }, () => {})
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function applyKnownTestsResponse ({ err, knownTests }) {
|
|
367
|
+
if (err) {
|
|
368
|
+
config.knownTests = []
|
|
369
|
+
config.isEarlyFlakeDetectionEnabled = false
|
|
370
|
+
config.isKnownTestsEnabled = false
|
|
371
|
+
} else {
|
|
372
|
+
config.knownTests = knownTests
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function applyTestManagementTestsResponse ({ err, testManagementTests: receivedTestManagementTests }) {
|
|
377
|
+
if (err) {
|
|
378
|
+
config.testManagementTests = {}
|
|
379
|
+
config.isTestManagementTestsEnabled = false
|
|
380
|
+
config.testManagementAttemptToFixRetries = 0
|
|
381
|
+
} else {
|
|
382
|
+
config.testManagementTests = receivedTestManagementTests
|
|
215
383
|
}
|
|
216
384
|
}
|
|
217
385
|
|
|
218
|
-
function
|
|
386
|
+
function isFailedTestReplayEnabled () {
|
|
387
|
+
return config.isTestDynamicInstrumentationEnabled && config.isDiEnabled
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFinishRequest, localSuites) {
|
|
219
391
|
const ctx = {
|
|
220
392
|
isParallel,
|
|
221
393
|
frameworkVersion,
|
|
222
394
|
}
|
|
223
|
-
|
|
224
|
-
|
|
395
|
+
let skippableSuitesResponse
|
|
396
|
+
resetSuiteSkippingRunState()
|
|
397
|
+
|
|
398
|
+
const onReceivedSkippableSuites = ({
|
|
399
|
+
err,
|
|
400
|
+
skippableSuites,
|
|
401
|
+
itrCorrelationId: responseItrCorrelationId,
|
|
402
|
+
skippableSuitesCoverage: responseSkippableSuitesCoverage,
|
|
403
|
+
}) => {
|
|
225
404
|
if (err) {
|
|
226
405
|
suitesToSkip = []
|
|
406
|
+
skippableSuitesCoverage = {}
|
|
227
407
|
} else {
|
|
228
408
|
suitesToSkip = skippableSuites
|
|
229
409
|
itrCorrelationId = responseItrCorrelationId
|
|
410
|
+
skippableSuitesCoverage = responseSkippableSuitesCoverage || {}
|
|
230
411
|
}
|
|
412
|
+
if (localSuites) {
|
|
413
|
+
suitesToSkip = getSuitesToSkipFromPaths(localSuites)
|
|
414
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
415
|
+
onFinishRequest()
|
|
416
|
+
})
|
|
417
|
+
return
|
|
418
|
+
}
|
|
419
|
+
|
|
231
420
|
// We remove the suites that we skip through ITR
|
|
232
421
|
const filteredSuites = getFilteredSuites(runner.suite.suites)
|
|
233
|
-
const { suitesToRun } = filteredSuites
|
|
422
|
+
const { suitesToRun, suitesToSkipForRun } = filteredSuites
|
|
234
423
|
|
|
235
424
|
isSuitesSkipped = suitesToRun.length !== runner.suite.suites.length
|
|
236
425
|
|
|
@@ -239,12 +428,25 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
239
428
|
runner.suite.suites = suitesToRun
|
|
240
429
|
|
|
241
430
|
skippedSuites = [...filteredSuites.skippedSuites]
|
|
431
|
+
suitesToSkip = suitesToSkipForRun
|
|
432
|
+
skippedSuitesCoverage = getSkippedSuitesCoverageForRun()
|
|
433
|
+
writeCoverageBackfillToCache(skippedSuitesCoverage, getCoverageRootDir())
|
|
242
434
|
|
|
243
435
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
244
436
|
onFinishRequest()
|
|
245
437
|
})
|
|
246
438
|
}
|
|
247
439
|
|
|
440
|
+
const requestSkippableSuites = () => {
|
|
441
|
+
if (skippableSuitesResponse) {
|
|
442
|
+
onReceivedSkippableSuites(skippableSuitesResponse)
|
|
443
|
+
return
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
447
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
448
|
+
}
|
|
449
|
+
|
|
248
450
|
const onReceivedImpactedTests = ({ err, modifiedFiles: receivedModifiedFiles }) => {
|
|
249
451
|
if (err) {
|
|
250
452
|
config.modifiedFiles = []
|
|
@@ -253,8 +455,7 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
253
455
|
config.modifiedFiles = receivedModifiedFiles
|
|
254
456
|
}
|
|
255
457
|
if (config.isSuitesSkippingEnabled) {
|
|
256
|
-
|
|
257
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
458
|
+
requestSkippableSuites()
|
|
258
459
|
} else {
|
|
259
460
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
260
461
|
onFinishRequest()
|
|
@@ -262,20 +463,12 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
262
463
|
}
|
|
263
464
|
}
|
|
264
465
|
|
|
265
|
-
const
|
|
266
|
-
if (err) {
|
|
267
|
-
config.testManagementTests = {}
|
|
268
|
-
config.isTestManagementTestsEnabled = false
|
|
269
|
-
config.testManagementAttemptToFixRetries = 0
|
|
270
|
-
} else {
|
|
271
|
-
config.testManagementTests = receivedTestManagementTests
|
|
272
|
-
}
|
|
466
|
+
const continueAfterTestRequests = () => {
|
|
273
467
|
if (config.isImpactedTestsEnabled) {
|
|
274
468
|
ctx.onDone = onReceivedImpactedTests
|
|
275
469
|
modifiedFilesCh.runStores(ctx, () => {})
|
|
276
470
|
} else if (config.isSuitesSkippingEnabled) {
|
|
277
|
-
|
|
278
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
471
|
+
requestSkippableSuites()
|
|
279
472
|
} else {
|
|
280
473
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
281
474
|
onFinishRequest()
|
|
@@ -283,64 +476,54 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
283
476
|
}
|
|
284
477
|
}
|
|
285
478
|
|
|
286
|
-
const
|
|
287
|
-
if (err) {
|
|
288
|
-
config.knownTests = []
|
|
289
|
-
config.isEarlyFlakeDetectionEnabled = false
|
|
290
|
-
config.isKnownTestsEnabled = false
|
|
291
|
-
} else {
|
|
292
|
-
config.knownTests = knownTests
|
|
293
|
-
}
|
|
294
|
-
if (config.isTestManagementTestsEnabled) {
|
|
295
|
-
ctx.onDone = onReceivedTestManagementTests
|
|
296
|
-
testManagementTestsCh.runStores(ctx, () => {})
|
|
297
|
-
} else if (config.isImpactedTestsEnabled) {
|
|
298
|
-
ctx.onDone = onReceivedImpactedTests
|
|
299
|
-
modifiedFilesCh.runStores(ctx, () => {})
|
|
300
|
-
} else if (config.isSuitesSkippingEnabled) {
|
|
301
|
-
ctx.onDone = onReceivedSkippableSuites
|
|
302
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
303
|
-
} else {
|
|
304
|
-
mochaGlobalRunCh.runStores(ctx, () => {
|
|
305
|
-
onFinishRequest()
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const onReceivedConfiguration = ({ err, libraryConfig }) => {
|
|
479
|
+
const onReceivedConfiguration = ({ err, isTestDynamicInstrumentationEnabled, libraryConfig, repositoryRoot }) => {
|
|
311
480
|
if (err || !skippableSuitesCh.hasSubscribers || !knownTestsCh.hasSubscribers) {
|
|
312
481
|
return mochaGlobalRunCh.runStores(ctx, () => {
|
|
313
482
|
onFinishRequest()
|
|
314
483
|
})
|
|
315
484
|
}
|
|
485
|
+
config.repositoryRoot = repositoryRoot
|
|
316
486
|
config.isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
317
487
|
config.earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
488
|
+
config.earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
318
489
|
config.earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
319
490
|
config.isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
320
491
|
config.isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
321
492
|
config.testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
322
493
|
config.isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
323
|
-
config.
|
|
494
|
+
config.isItrEnabled = libraryConfig.isItrEnabled
|
|
495
|
+
config.isCodeCoverageEnabled = libraryConfig.isCodeCoverageEnabled
|
|
496
|
+
config.isCoverageReportUploadEnabled = libraryConfig.isCoverageReportUploadEnabled
|
|
497
|
+
config.isSuitesSkippingEnabled = config.isItrEnabled && libraryConfig.isSuitesSkippingEnabled
|
|
324
498
|
config.isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
325
499
|
config.flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
500
|
+
config.isDiEnabled = libraryConfig.isDiEnabled
|
|
501
|
+
config.isTestDynamicInstrumentationEnabled = isTestDynamicInstrumentationEnabled
|
|
502
|
+
|
|
503
|
+
getTestOptimizationRequestResults({
|
|
504
|
+
isKnownTestsEnabled: config.isKnownTestsEnabled,
|
|
505
|
+
isTestManagementTestsEnabled: config.isTestManagementTestsEnabled,
|
|
506
|
+
isSuitesSkippingEnabled: config.isSuitesSkippingEnabled,
|
|
507
|
+
getKnownTests: () => getRunStoresPromise(knownTestsCh, ctx),
|
|
508
|
+
getTestManagementTests: () => getRunStoresPromise(testManagementTestsCh, ctx),
|
|
509
|
+
getSkippableSuites: () => getRunStoresPromise(skippableSuitesCh, ctx),
|
|
510
|
+
}).then(requestResults => {
|
|
511
|
+
const {
|
|
512
|
+
knownTestsResponse,
|
|
513
|
+
testManagementTestsResponse,
|
|
514
|
+
skippableSuitesResponse: requestSkippableSuitesResponse,
|
|
515
|
+
} = requestResults
|
|
516
|
+
|
|
517
|
+
if (knownTestsResponse) {
|
|
518
|
+
applyKnownTestsResponse(knownTestsResponse)
|
|
519
|
+
}
|
|
520
|
+
if (testManagementTestsResponse) {
|
|
521
|
+
applyTestManagementTestsResponse(testManagementTestsResponse)
|
|
522
|
+
}
|
|
523
|
+
skippableSuitesResponse = requestSkippableSuitesResponse
|
|
326
524
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
knownTestsCh.runStores(ctx, () => {})
|
|
330
|
-
} else if (config.isTestManagementTestsEnabled) {
|
|
331
|
-
ctx.onDone = onReceivedTestManagementTests
|
|
332
|
-
testManagementTestsCh.runStores(ctx, () => {})
|
|
333
|
-
} else if (config.isImpactedTestsEnabled) {
|
|
334
|
-
ctx.onDone = onReceivedImpactedTests
|
|
335
|
-
modifiedFilesCh.runStores(ctx, () => {})
|
|
336
|
-
} else if (config.isSuitesSkippingEnabled) {
|
|
337
|
-
ctx.onDone = onReceivedSkippableSuites
|
|
338
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
339
|
-
} else {
|
|
340
|
-
mochaGlobalRunCh.runStores(ctx, () => {
|
|
341
|
-
onFinishRequest()
|
|
342
|
-
})
|
|
343
|
-
}
|
|
525
|
+
continueAfterTestRequests()
|
|
526
|
+
})
|
|
344
527
|
}
|
|
345
528
|
|
|
346
529
|
ctx.onDone = onReceivedConfiguration
|
|
@@ -353,22 +536,23 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
353
536
|
// It is called but skipped in parallel mode.
|
|
354
537
|
addHook({
|
|
355
538
|
name: 'mocha',
|
|
356
|
-
versions: [
|
|
539
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
357
540
|
file: 'lib/mocha.js',
|
|
358
541
|
}, (Mocha, frameworkVersion) => {
|
|
359
|
-
|
|
542
|
+
warnDeprecatedMochaVersion(frameworkVersion)
|
|
543
|
+
|
|
544
|
+
shimmer.wrap(Mocha.prototype, 'run', run => function (...args) {
|
|
360
545
|
// Workers do not need to request any data, just run the tests
|
|
361
546
|
if (!testFinishCh.hasSubscribers || getEnvironmentVariable('MOCHA_WORKER_ID') || this.options.parallel) {
|
|
362
|
-
return run.apply(this,
|
|
547
|
+
return run.apply(this, args)
|
|
363
548
|
}
|
|
364
549
|
|
|
365
550
|
// `options.delay` does not work in parallel mode, so we can't delay the execution this way
|
|
366
551
|
// This needs to be both here and in `runMocha` hook. Read the comment in `runMocha` hook for more info.
|
|
367
552
|
this.options.delay = true
|
|
368
553
|
|
|
369
|
-
const runner = run.apply(this,
|
|
554
|
+
const runner = run.apply(this, args)
|
|
370
555
|
|
|
371
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
372
556
|
this.files.forEach((path) => {
|
|
373
557
|
const isUnskippable = isMarkedAsUnskippable({ path })
|
|
374
558
|
if (isUnskippable) {
|
|
@@ -377,6 +561,9 @@ addHook({
|
|
|
377
561
|
})
|
|
378
562
|
|
|
379
563
|
getExecutionConfiguration(runner, false, frameworkVersion, () => {
|
|
564
|
+
if (isFailedTestReplayEnabled()) {
|
|
565
|
+
patchFailedTestReplayHookUp(runner.constructor)
|
|
566
|
+
}
|
|
380
567
|
if (config.isKnownTestsEnabled) {
|
|
381
568
|
const testSuites = this.files.map(file => getTestSuitePath(file, process.cwd()))
|
|
382
569
|
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
@@ -409,15 +596,15 @@ addHook({
|
|
|
409
596
|
|
|
410
597
|
addHook({
|
|
411
598
|
name: 'mocha',
|
|
412
|
-
versions: [
|
|
599
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
413
600
|
file: 'lib/cli/run-helpers.js',
|
|
414
601
|
}, (run) => {
|
|
415
602
|
// `runMocha` is an async function
|
|
416
|
-
shimmer.wrap(run, 'runMocha', runMocha => function () {
|
|
603
|
+
shimmer.wrap(run, 'runMocha', runMocha => function (...args) {
|
|
417
604
|
if (!testFinishCh.hasSubscribers) {
|
|
418
|
-
return runMocha.apply(this,
|
|
605
|
+
return runMocha.apply(this, args)
|
|
419
606
|
}
|
|
420
|
-
const mocha =
|
|
607
|
+
const mocha = args[0]
|
|
421
608
|
|
|
422
609
|
/**
|
|
423
610
|
* This attaches `run` to the global context, which we'll call after
|
|
@@ -431,7 +618,7 @@ addHook({
|
|
|
431
618
|
mocha.options.delay = true
|
|
432
619
|
}
|
|
433
620
|
|
|
434
|
-
return runMocha.apply(this,
|
|
621
|
+
return runMocha.apply(this, args)
|
|
435
622
|
})
|
|
436
623
|
return run
|
|
437
624
|
})
|
|
@@ -440,7 +627,7 @@ addHook({
|
|
|
440
627
|
// This hook is used to generate session, module, suite and test events
|
|
441
628
|
addHook({
|
|
442
629
|
name: 'mocha',
|
|
443
|
-
versions: [
|
|
630
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
444
631
|
file: 'lib/runner.js',
|
|
445
632
|
}, function (Runner, frameworkVersion) {
|
|
446
633
|
if (patched.has(Runner)) return Runner
|
|
@@ -449,32 +636,216 @@ addHook({
|
|
|
449
636
|
|
|
450
637
|
shimmer.wrap(Runner.prototype, 'runTests', runTests => getRunTestsWrapper(runTests, config))
|
|
451
638
|
|
|
452
|
-
shimmer.wrap(Runner.prototype, 'run', run => function () {
|
|
639
|
+
shimmer.wrap(Runner.prototype, 'run', run => function (...args) {
|
|
453
640
|
if (!testFinishCh.hasSubscribers) {
|
|
454
|
-
return run.apply(this,
|
|
641
|
+
return run.apply(this, args)
|
|
455
642
|
}
|
|
456
643
|
|
|
457
644
|
const { suitesByTestFile, numSuitesByTestFile } = getSuitesByTestFile(this.suite)
|
|
645
|
+
// Root-level tests (direct children of root, no describe wrapper) keyed by file.
|
|
646
|
+
// Populated during the root 'suite' event so the normal finish path can include them
|
|
647
|
+
// in mixed-file status calculation.
|
|
648
|
+
const rootTestsByFile = new Map()
|
|
649
|
+
// Counts how many original tests per pure-root file still need their final attempt.
|
|
650
|
+
// Hits zero when the last test's lifecycle completes, triggering the suite finish.
|
|
651
|
+
const rootPendingCountByFile = new Map()
|
|
652
|
+
const rootFinalizationPendingCountByFile = new Map()
|
|
653
|
+
const rootFallbackPendingFiles = new Set()
|
|
654
|
+
const rootFinalizationPendingTests = new WeakSet()
|
|
655
|
+
let pendingRootFinalizations = 0
|
|
656
|
+
let hasEnded = false
|
|
657
|
+
let hasFinishedRun = false
|
|
658
|
+
let endRunner
|
|
659
|
+
|
|
660
|
+
function updateRootTestForFinalAttempt (test) {
|
|
661
|
+
if (!test._retriedTest) return
|
|
662
|
+
|
|
663
|
+
const rootTests = rootTestsByFile.get(test.file)
|
|
664
|
+
if (!rootTests) return
|
|
665
|
+
|
|
666
|
+
const retriedTestIndex = rootTests.indexOf(test._retriedTest)
|
|
667
|
+
if (retriedTestIndex !== -1) {
|
|
668
|
+
rootTests[retriedTestIndex] = test
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function finishRunIfReady () {
|
|
673
|
+
if (hasFinishedRun) return
|
|
674
|
+
if (hasEnded && pendingRootFinalizations === 0) {
|
|
675
|
+
hasFinishedRun = true
|
|
676
|
+
onEnd.call(endRunner)
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function incrementPendingRootFinalization (test) {
|
|
681
|
+
if (!rootPendingCountByFile.has(test.file) || rootFinalizationPendingTests.has(test)) return
|
|
682
|
+
|
|
683
|
+
rootFinalizationPendingTests.add(test)
|
|
684
|
+
pendingRootFinalizations++
|
|
685
|
+
rootFinalizationPendingCountByFile.set(
|
|
686
|
+
test.file,
|
|
687
|
+
(rootFinalizationPendingCountByFile.get(test.file) || 0) + 1
|
|
688
|
+
)
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function decrementPendingRootFinalization (test) {
|
|
692
|
+
if (!rootFinalizationPendingTests.has(test)) return
|
|
693
|
+
|
|
694
|
+
rootFinalizationPendingTests.delete(test)
|
|
695
|
+
pendingRootFinalizations--
|
|
696
|
+
|
|
697
|
+
const remaining = rootFinalizationPendingCountByFile.get(test.file) - 1
|
|
698
|
+
if (remaining > 0) {
|
|
699
|
+
rootFinalizationPendingCountByFile.set(test.file, remaining)
|
|
700
|
+
} else {
|
|
701
|
+
rootFinalizationPendingCountByFile.delete(test.file)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (!rootFinalizationPendingCountByFile.has(test.file) && rootFallbackPendingFiles.delete(test.file)) {
|
|
705
|
+
finishRootSuiteFallbackForFile(test.file)
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
finishRunIfReady()
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function finishRootSuiteForFile (file) {
|
|
712
|
+
const remaining = rootPendingCountByFile.get(file) - 1
|
|
713
|
+
if (remaining > 0) {
|
|
714
|
+
rootPendingCountByFile.set(file, remaining)
|
|
715
|
+
return
|
|
716
|
+
}
|
|
717
|
+
rootPendingCountByFile.delete(file)
|
|
718
|
+
|
|
719
|
+
const ctx = testFileToSuiteCtx.get(file)
|
|
720
|
+
if (!ctx) {
|
|
721
|
+
log.warn('No ctx found for suite', file)
|
|
722
|
+
return
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const rootTests = rootTestsByFile.get(file) || []
|
|
726
|
+
const status = getRootSuiteStatus(rootTests)
|
|
727
|
+
|
|
728
|
+
if (global.__coverage__) {
|
|
729
|
+
const coverageFiles = getCoveredFilesFromCoverage(global.__coverage__)
|
|
730
|
+
testSuiteCodeCoverageCh.publish({ coverageFiles, suiteFile: file })
|
|
731
|
+
mergeCoverage(global.__coverage__, originalCoverageMap)
|
|
732
|
+
resetCoverage(global.__coverage__)
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function finishRootSuiteFallbackForFile (file) {
|
|
739
|
+
const ctx = testFileToSuiteCtx.get(file)
|
|
740
|
+
if (!ctx || !rootPendingCountByFile.has(file)) return
|
|
741
|
+
|
|
742
|
+
const rootTests = rootTestsByFile.get(file) || []
|
|
743
|
+
const status = haveRootTestsFinished(rootTests) ? getRootSuiteStatus(rootTests) : 'fail'
|
|
744
|
+
rootPendingCountByFile.delete(file)
|
|
745
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function finishRootSuiteAfterFinalAttempt (test) {
|
|
749
|
+
if (!test._ddIsFinalAttempt || !rootPendingCountByFile.has(test.file)) return
|
|
750
|
+
|
|
751
|
+
updateRootTestForFinalAttempt(test)
|
|
752
|
+
finishRootSuiteForFile(test.file)
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const onEnd = getOnEndHandler(false)
|
|
458
756
|
|
|
459
757
|
this.once('start', getOnStartHandler(frameworkVersion))
|
|
460
758
|
|
|
461
|
-
this.once('end',
|
|
759
|
+
this.once('end', function () {
|
|
760
|
+
hasEnded = true
|
|
761
|
+
endRunner = this
|
|
762
|
+
finishRunIfReady()
|
|
763
|
+
})
|
|
764
|
+
|
|
765
|
+
// The job of this listener is to
|
|
766
|
+
// initialize the suite span tag in correct order
|
|
767
|
+
// (that is suiteA -> testA ... -> suiteB -> testB
|
|
768
|
+
// instead of suiteA -> suiteB -> testA -> ... -> testB)
|
|
769
|
+
// when the suite has tests that are in the top level
|
|
770
|
+
// (no describe(...))
|
|
771
|
+
this.on('test', function (test) {
|
|
772
|
+
const ctx = testFileToSuiteCtx.get(test.file)
|
|
773
|
+
if (ctx?._pendingRootStart) {
|
|
774
|
+
ctx._pendingRootStart = false
|
|
775
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
776
|
+
}
|
|
777
|
+
})
|
|
462
778
|
|
|
463
779
|
this.on('test', getOnTestHandler(true))
|
|
464
780
|
|
|
465
|
-
this.on('test end', getOnTestEndHandler(config
|
|
781
|
+
this.on('test end', getOnTestEndHandler(config, {
|
|
782
|
+
onStart: incrementPendingRootFinalization,
|
|
783
|
+
onFinish: function (test) {
|
|
784
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
785
|
+
decrementPendingRootFinalization(test)
|
|
786
|
+
},
|
|
787
|
+
}))
|
|
466
788
|
|
|
467
789
|
this.on('retry', getOnTestRetryHandler(config))
|
|
468
790
|
|
|
469
791
|
// If the hook passes, 'hook end' will be emitted. Otherwise, 'fail' will be emitted
|
|
470
|
-
this.on('hook end', getOnHookEndHandler(
|
|
792
|
+
this.on('hook end', getOnHookEndHandler(config, {
|
|
793
|
+
onStart: incrementPendingRootFinalization,
|
|
794
|
+
onFinish: function (test) {
|
|
795
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
796
|
+
decrementPendingRootFinalization(test)
|
|
797
|
+
},
|
|
798
|
+
}))
|
|
799
|
+
|
|
800
|
+
this.on('hook end', function (hook) {
|
|
801
|
+
const test = hook.ctx?.currentTest
|
|
802
|
+
if (!test) return
|
|
803
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
804
|
+
})
|
|
805
|
+
|
|
806
|
+
this.on('fail', getOnFailHandler(true, config))
|
|
471
807
|
|
|
472
|
-
this.on('fail',
|
|
808
|
+
this.on('fail', function (testOrHook) {
|
|
809
|
+
if (testOrHook.type !== 'hook') return
|
|
810
|
+
const test = testOrHook.ctx?.currentTest
|
|
811
|
+
if (!test) return
|
|
812
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
813
|
+
})
|
|
473
814
|
|
|
474
815
|
this.on('pending', getOnPendingHandler())
|
|
475
816
|
|
|
476
817
|
this.on('suite', function (suite) {
|
|
477
818
|
if (suite.root || !suite.tests.length) {
|
|
819
|
+
// This branch can be triggered when we have top level it(...) inside test files.
|
|
820
|
+
// In that case, they all (even if they are from different files) are going to be
|
|
821
|
+
// children of the root suite.
|
|
822
|
+
// Note: We could have suites that contain top level it(...) and also it(...) nested
|
|
823
|
+
// inside describe(...) ("mixed case"). Duplication is avoided by the context guard
|
|
824
|
+
// below. Since 'suite' fires for root first, in the mixed case the ctx is created
|
|
825
|
+
// here and the describe-based handler finds it already set.
|
|
826
|
+
if (suite.root && suite.tests.length > 0) {
|
|
827
|
+
const files = new Set(suite.tests.map(test => test.file).filter(Boolean))
|
|
828
|
+
for (const file of files) {
|
|
829
|
+
const testsForFile = suite.tests.filter(t => t.file === file)
|
|
830
|
+
rootTestsByFile.set(file, testsForFile)
|
|
831
|
+
// Only track the countdown for pure root-level files.
|
|
832
|
+
// Mixed files are finished by the normal 'suite end' path.
|
|
833
|
+
if (!suitesByTestFile[file]) {
|
|
834
|
+
rootPendingCountByFile.set(file, testsForFile.length)
|
|
835
|
+
}
|
|
836
|
+
if (testFileToSuiteCtx.get(file)) continue
|
|
837
|
+
const isUnskippable = unskippableSuites.includes(file)
|
|
838
|
+
isForcedToRun = isUnskippable && suitesToSkip.includes(getTestSuitePath(file, process.cwd()))
|
|
839
|
+
const ctx = {
|
|
840
|
+
testSuiteAbsolutePath: file,
|
|
841
|
+
isUnskippable,
|
|
842
|
+
isForcedToRun,
|
|
843
|
+
itrCorrelationId,
|
|
844
|
+
_pendingRootStart: true, // Now the suite start fires lazily on the first test event for this file
|
|
845
|
+
}
|
|
846
|
+
testFileToSuiteCtx.set(file, ctx)
|
|
847
|
+
}
|
|
848
|
+
}
|
|
478
849
|
return
|
|
479
850
|
}
|
|
480
851
|
let ctx = testFileToSuiteCtx.get(suite.file)
|
|
@@ -494,6 +865,40 @@ addHook({
|
|
|
494
865
|
|
|
495
866
|
this.on('suite end', function (suite) {
|
|
496
867
|
if (suite.root) {
|
|
868
|
+
// Normal case: pure root-level files are finished by the 'test end' / 'hook end'
|
|
869
|
+
// listeners via finishRootSuiteForFile. Two edge cases remain here:
|
|
870
|
+
//
|
|
871
|
+
// 1. All-pending: no 'test' event fired, _pendingRootStart is still true.
|
|
872
|
+
// Start and immediately finish with 'skip'.
|
|
873
|
+
//
|
|
874
|
+
// 2. Aborted mid-run (e.g. a beforeEach hook failure): Mocha skips remaining
|
|
875
|
+
// tests and jumps straight to 'suite end'. rootPendingCountByFile still has
|
|
876
|
+
// a nonzero count for the file because the last tests never ran. Finish it
|
|
877
|
+
// as failed now.
|
|
878
|
+
//
|
|
879
|
+
// 3. Async finalization lagged behind Mocha's synchronous events (e.g. DI retry
|
|
880
|
+
// wait): all tests have Mocha terminal state, but the final-attempt callback
|
|
881
|
+
// did not run before root 'suite end'. Finish from the observed test states.
|
|
882
|
+
const processedFiles = new Set()
|
|
883
|
+
for (const test of suite.tests) {
|
|
884
|
+
if (!test.file || processedFiles.has(test.file)) continue
|
|
885
|
+
processedFiles.add(test.file)
|
|
886
|
+
if (suitesByTestFile[test.file]) continue // mixed: handled by normal path
|
|
887
|
+
const ctx = testFileToSuiteCtx.get(test.file)
|
|
888
|
+
if (!ctx) continue
|
|
889
|
+
if (ctx._pendingRootStart) {
|
|
890
|
+
ctx._pendingRootStart = false
|
|
891
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
892
|
+
testSuiteFinishCh.publish({ status: 'skip', ...ctx.currentStore }, () => {})
|
|
893
|
+
} else if (rootPendingCountByFile.has(test.file)) {
|
|
894
|
+
if (rootFinalizationPendingCountByFile.has(test.file)) {
|
|
895
|
+
rootFallbackPendingFiles.add(test.file)
|
|
896
|
+
continue
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
finishRootSuiteFallbackForFile(test.file)
|
|
900
|
+
}
|
|
901
|
+
}
|
|
497
902
|
return
|
|
498
903
|
}
|
|
499
904
|
const suitesInTestFile = suitesByTestFile[suite.file]
|
|
@@ -503,12 +908,12 @@ addHook({
|
|
|
503
908
|
return
|
|
504
909
|
}
|
|
505
910
|
|
|
911
|
+
const rootTests = rootTestsByFile.get(suite.file) || []
|
|
506
912
|
let status = 'pass'
|
|
507
|
-
if (suitesInTestFile.every(suite => suite.pending)) {
|
|
913
|
+
if (suitesInTestFile.every(suite => suite.pending) && rootTests.every(test => test.isPending())) {
|
|
508
914
|
status = 'skip'
|
|
509
915
|
} else {
|
|
510
916
|
// has to check every test in the test file
|
|
511
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
512
917
|
suitesInTestFile.forEach(suite => {
|
|
513
918
|
suite.eachTest(test => {
|
|
514
919
|
if (test.state === 'failed' || test.timedOut) {
|
|
@@ -516,10 +921,15 @@ addHook({
|
|
|
516
921
|
}
|
|
517
922
|
})
|
|
518
923
|
})
|
|
924
|
+
for (const test of rootTests) {
|
|
925
|
+
if (test.state === 'failed' || test.timedOut) {
|
|
926
|
+
status = 'fail'
|
|
927
|
+
}
|
|
928
|
+
}
|
|
519
929
|
}
|
|
520
930
|
|
|
521
931
|
if (global.__coverage__) {
|
|
522
|
-
const coverageFiles =
|
|
932
|
+
const coverageFiles = getCoveredFilesFromCoverage(global.__coverage__)
|
|
523
933
|
|
|
524
934
|
testSuiteCodeCoverageCh.publish({
|
|
525
935
|
coverageFiles,
|
|
@@ -539,7 +949,7 @@ addHook({
|
|
|
539
949
|
}
|
|
540
950
|
})
|
|
541
951
|
|
|
542
|
-
return run.apply(this,
|
|
952
|
+
return run.apply(this, args)
|
|
543
953
|
})
|
|
544
954
|
|
|
545
955
|
return Runner
|
|
@@ -549,7 +959,7 @@ addHook({
|
|
|
549
959
|
// Used to set the correct async resource to the test.
|
|
550
960
|
addHook({
|
|
551
961
|
name: 'mocha',
|
|
552
|
-
versions: [
|
|
962
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
553
963
|
file: 'lib/runnable.js',
|
|
554
964
|
}, (runnablePackage) => runnableWrapper(runnablePackage, config))
|
|
555
965
|
|
|
@@ -557,7 +967,10 @@ function onMessage (message) {
|
|
|
557
967
|
if (Array.isArray(message)) {
|
|
558
968
|
const [messageCode, payload] = message
|
|
559
969
|
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
560
|
-
|
|
970
|
+
collectTestOptimizationSummariesFromTraces(payload, {
|
|
971
|
+
newTestsWithDynamicNames,
|
|
972
|
+
attemptToFixExecutions,
|
|
973
|
+
})
|
|
561
974
|
workerReportTraceCh.publish(payload)
|
|
562
975
|
}
|
|
563
976
|
}
|
|
@@ -638,11 +1051,11 @@ addHook({
|
|
|
638
1051
|
}
|
|
639
1052
|
}
|
|
640
1053
|
|
|
1054
|
+
const localSuites = files.map(file => getTestSuitePath(file, process.cwd()))
|
|
641
1055
|
getExecutionConfiguration(this, true, frameworkVersion, () => {
|
|
642
1056
|
if (config.isKnownTestsEnabled) {
|
|
643
|
-
const testSuites = files.map(file => getTestSuitePath(file, process.cwd()))
|
|
644
1057
|
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
645
|
-
|
|
1058
|
+
localSuites,
|
|
646
1059
|
config.knownTests?.mocha || {},
|
|
647
1060
|
config.earlyFlakeDetectionFaultyThreshold
|
|
648
1061
|
)
|
|
@@ -667,11 +1080,13 @@ addHook({
|
|
|
667
1080
|
}
|
|
668
1081
|
isSuitesSkipped = skippedFiles.length > 0
|
|
669
1082
|
skippedSuites = skippedFiles
|
|
1083
|
+
skippedSuitesCoverage = getSkippedSuitesCoverageForRun()
|
|
1084
|
+
writeCoverageBackfillToCache(skippedSuitesCoverage, getCoverageRootDir())
|
|
670
1085
|
run.apply(this, [cb, { files: filteredFiles }])
|
|
671
1086
|
} else {
|
|
672
1087
|
run.apply(this, arguments)
|
|
673
1088
|
}
|
|
674
|
-
})
|
|
1089
|
+
}, localSuites)
|
|
675
1090
|
|
|
676
1091
|
return this
|
|
677
1092
|
})
|
|
@@ -692,9 +1107,10 @@ addHook({
|
|
|
692
1107
|
shimmer.wrap(BufferedWorkerPool.prototype, 'run', run => async function (testSuiteAbsolutePath, workerArgs) {
|
|
693
1108
|
if (!testFinishCh.hasSubscribers ||
|
|
694
1109
|
(!config.isKnownTestsEnabled &&
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
1110
|
+
!config.isTestManagementTestsEnabled &&
|
|
1111
|
+
!config.isImpactedTestsEnabled &&
|
|
1112
|
+
!config.isFlakyTestRetriesEnabled &&
|
|
1113
|
+
!isFailedTestReplayEnabled())) {
|
|
698
1114
|
return run.apply(this, arguments)
|
|
699
1115
|
}
|
|
700
1116
|
|
|
@@ -706,6 +1122,7 @@ addHook({
|
|
|
706
1122
|
if (config.knownTests?.mocha) {
|
|
707
1123
|
const testSuiteKnownTests = config.knownTests.mocha[testPath] || []
|
|
708
1124
|
newWorkerArgs._ddEfdNumRetries = config.earlyFlakeDetectionNumRetries
|
|
1125
|
+
newWorkerArgs._ddEfdSlowTestRetries = config.earlyFlakeDetectionSlowTestRetries
|
|
709
1126
|
newWorkerArgs._ddIsEfdEnabled = config.isEarlyFlakeDetectionEnabled
|
|
710
1127
|
newWorkerArgs._ddIsKnownTestsEnabled = true
|
|
711
1128
|
newWorkerArgs._ddKnownTests = {
|
|
@@ -744,6 +1161,10 @@ addHook({
|
|
|
744
1161
|
newWorkerArgs._ddFlakyTestRetriesCount = config.flakyTestRetriesCount
|
|
745
1162
|
}
|
|
746
1163
|
|
|
1164
|
+
if (isFailedTestReplayEnabled()) {
|
|
1165
|
+
newWorkerArgs._ddIsFailedTestReplayEnabled = true
|
|
1166
|
+
}
|
|
1167
|
+
|
|
747
1168
|
// We pass the known tests for the test file to the worker
|
|
748
1169
|
const testFileResult = await run.apply(
|
|
749
1170
|
this,
|
|
@@ -757,10 +1178,15 @@ addHook({
|
|
|
757
1178
|
.events
|
|
758
1179
|
.filter(event => event.eventName === 'test end')
|
|
759
1180
|
.map(event => event.data)
|
|
1181
|
+
const isModified = config.isImpactedTestsEnabled && isModifiedTestSuite(testSuiteAbsolutePath)
|
|
760
1182
|
|
|
761
1183
|
for (const test of tests) {
|
|
1184
|
+
const testProperties = getTestProperties(test, config.testManagementTests)
|
|
1185
|
+
const isAttemptToFix = config.isTestManagementTestsEnabled && testProperties.isAttemptToFix
|
|
1186
|
+
|
|
762
1187
|
// `newTests` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
763
|
-
|
|
1188
|
+
const isNew = config.isKnownTestsEnabled && isNewTest(test, config.knownTests)
|
|
1189
|
+
if (isNew) {
|
|
764
1190
|
const testFullName = getTestFullName(test)
|
|
765
1191
|
const tests = newTests[testFullName]
|
|
766
1192
|
|
|
@@ -770,8 +1196,19 @@ addHook({
|
|
|
770
1196
|
newTests[testFullName] = [test]
|
|
771
1197
|
}
|
|
772
1198
|
}
|
|
1199
|
+
// `efdTests` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
1200
|
+
if (!isAttemptToFix && (isNew || isModified)) {
|
|
1201
|
+
const testFullName = getTestFullName(test)
|
|
1202
|
+
const tests = efdTests[testFullName]
|
|
1203
|
+
|
|
1204
|
+
if (tests) {
|
|
1205
|
+
tests.push(test)
|
|
1206
|
+
} else {
|
|
1207
|
+
efdTests[testFullName] = [test]
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
773
1210
|
// `testsQuarantined` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
774
|
-
if (config.isTestManagementTestsEnabled &&
|
|
1211
|
+
if (config.isTestManagementTestsEnabled && testProperties.isQuarantined && !testProperties.isAttemptToFix) {
|
|
775
1212
|
testsQuarantined.add(test)
|
|
776
1213
|
}
|
|
777
1214
|
}
|