@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,37 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { performance } = require('node:perf_hooks')
|
|
4
|
+
|
|
3
5
|
const { createCoverageMap } = require('../../../vendor/dist/istanbul-lib-coverage')
|
|
4
6
|
const shimmer = require('../../datadog-shimmer')
|
|
5
7
|
const log = require('../../dd-trace/src/log')
|
|
6
8
|
const { getEnvironmentVariable } = require('../../dd-trace/src/config/helper')
|
|
7
9
|
const {
|
|
8
|
-
|
|
10
|
+
getCoveredFilesFromCoverage,
|
|
11
|
+
getExecutableFilesFromCoverage,
|
|
9
12
|
resetCoverage,
|
|
10
13
|
mergeCoverage,
|
|
11
14
|
fromCoverageMapToCoverage,
|
|
12
15
|
getTestSuitePath,
|
|
16
|
+
getRelativeCoverageFiles,
|
|
13
17
|
CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
|
|
14
18
|
getIsFaultyEarlyFlakeDetection,
|
|
19
|
+
getEfdRetryCount,
|
|
20
|
+
getMaxEfdRetryCount,
|
|
21
|
+
applySkippedCoverageToCoverage,
|
|
22
|
+
getTestCoverageLinesPercentage,
|
|
23
|
+
recordAttemptToFixExecution,
|
|
24
|
+
collectAttemptToFixExecutionsFromTraces,
|
|
25
|
+
logAttemptToFixTestExecution,
|
|
26
|
+
logTestOptimizationSummary,
|
|
27
|
+
getTestOptimizationRequestResults,
|
|
15
28
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
29
|
+
const { writeCoverageBackfillToCache } = require('../../dd-trace/src/ci-visibility/test-optimization-cache')
|
|
16
30
|
const satisfies = require('../../../vendor/dist/semifies')
|
|
17
31
|
const { addHook, channel } = require('./helpers/instrument')
|
|
18
32
|
|
|
33
|
+
const cucumberWorkerThreadsPatchModule = require.resolve('./cucumber-worker-threads')
|
|
34
|
+
|
|
19
35
|
const testStartCh = channel('ci:cucumber:test:start')
|
|
20
36
|
const testRetryCh = channel('ci:cucumber:test:retry')
|
|
21
37
|
const testFinishCh = channel('ci:cucumber:test:finish') // used for test steps too
|
|
@@ -44,6 +60,8 @@ const itrSkippedSuitesCh = channel('ci:cucumber:itr:skipped-suites')
|
|
|
44
60
|
|
|
45
61
|
const getCodeCoverageCh = channel('ci:nyc:get-coverage')
|
|
46
62
|
|
|
63
|
+
const DD_EFD_RETRY_COUNT_MESSAGE = '_ddEfdRetryCount'
|
|
64
|
+
|
|
47
65
|
const isMarkedAsUnskippable = (pickle) => {
|
|
48
66
|
return pickle.tags.some(tag => tag.name === '@datadog:unskippable')
|
|
49
67
|
}
|
|
@@ -53,28 +71,41 @@ const originalCoverageMap = createCoverageMap()
|
|
|
53
71
|
|
|
54
72
|
// TODO: remove in a later major version
|
|
55
73
|
const patched = new WeakSet()
|
|
74
|
+
const patchedCucumberWorkers = new WeakSet()
|
|
56
75
|
|
|
57
76
|
const lastStatusByPickleId = new Map()
|
|
58
77
|
/** For ATR: statuses keyed by stable scenario id (uri:name) so retries accumulate correctly */
|
|
59
78
|
const atrStatusesByScenarioKey = new Map()
|
|
60
79
|
const numRetriesByPickleId = new Map()
|
|
80
|
+
const efdRetryCountByPickleId = new Map()
|
|
81
|
+
const efdSlowAbortedPickleIds = new Set()
|
|
82
|
+
const finishedParallelSuites = new Set()
|
|
61
83
|
const numAttemptToCtx = new Map()
|
|
62
84
|
const newTestsByTestFullname = new Map()
|
|
85
|
+
const attemptToFixTestsByTestFullname = new Map()
|
|
63
86
|
const modifiedTestsByPickleId = new Map()
|
|
87
|
+
const runnerToRetryState = new WeakMap()
|
|
64
88
|
// Pickle IDs for tests that are genuinely new (not in known tests list).
|
|
65
89
|
const newTestPickleIds = new Set()
|
|
90
|
+
const attemptToFixExecutions = new Map()
|
|
91
|
+
const loggedAttemptToFixTests = new Set()
|
|
66
92
|
|
|
67
93
|
let eventDataCollector = null
|
|
68
94
|
let pickleByFile = {}
|
|
69
95
|
const pickleResultByFile = {}
|
|
70
96
|
|
|
71
97
|
let skippableSuites = []
|
|
98
|
+
let skippableSuitesCoverage = {}
|
|
99
|
+
let skippedSuitesCoverage = {}
|
|
72
100
|
let itrCorrelationId = ''
|
|
73
101
|
let isForcedToRun = false
|
|
74
102
|
let isUnskippable = false
|
|
103
|
+
let isItrEnabled = false
|
|
75
104
|
let isSuitesSkippingEnabled = false
|
|
105
|
+
let isCoverageReportUploadEnabled = false
|
|
76
106
|
let isEarlyFlakeDetectionEnabled = false
|
|
77
107
|
let earlyFlakeDetectionNumRetries = 0
|
|
108
|
+
let earlyFlakeDetectionSlowTestRetries = {}
|
|
78
109
|
let earlyFlakeDetectionFaultyThreshold = 0
|
|
79
110
|
let isEarlyFlakeDetectionFaulty = false
|
|
80
111
|
let isFlakyTestRetriesEnabled = false
|
|
@@ -88,11 +119,55 @@ let numTestRetries = 0
|
|
|
88
119
|
let knownTests = {}
|
|
89
120
|
let skippedSuites = []
|
|
90
121
|
let isSuitesSkipped = false
|
|
122
|
+
let repositoryRoot
|
|
91
123
|
|
|
92
124
|
function isValidKnownTests (receivedKnownTests) {
|
|
93
125
|
return !!receivedKnownTests.cucumber
|
|
94
126
|
}
|
|
95
127
|
|
|
128
|
+
function hasSkippableSuitesCoverage () {
|
|
129
|
+
return skippableSuitesCoverage &&
|
|
130
|
+
typeof skippableSuitesCoverage === 'object' &&
|
|
131
|
+
Object.keys(skippableSuitesCoverage).length > 0
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isTiaCoverageBackfillEnabled () {
|
|
135
|
+
return isItrEnabled && isCoverageReportUploadEnabled
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getCoverageRootDir () {
|
|
139
|
+
return repositoryRoot || process.cwd()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function shouldReportCodeCoverageLinesPct (hasBackfilledCoverage) {
|
|
143
|
+
return !isSuitesSkipped || hasBackfilledCoverage
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getSkippedSuitesCoverageForRun () {
|
|
147
|
+
return isSuitesSkipped && isTiaCoverageBackfillEnabled() && hasSkippableSuitesCoverage()
|
|
148
|
+
? skippableSuitesCoverage
|
|
149
|
+
: {}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function applySkippedCoverageToCucumberCoverageMap () {
|
|
153
|
+
if (!isTiaCoverageBackfillEnabled()) return false
|
|
154
|
+
return applySkippedCoverageToCoverage(originalCoverageMap, skippedSuitesCoverage, getCoverageRootDir())
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getCucumberTestSessionCoverageFiles () {
|
|
158
|
+
return getRelativeCoverageFiles(getExecutableFilesFromCoverage(originalCoverageMap), getCoverageRootDir())
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function resetSuiteSkippingRunState () {
|
|
162
|
+
skippableSuites = []
|
|
163
|
+
skippableSuitesCoverage = {}
|
|
164
|
+
skippedSuitesCoverage = {}
|
|
165
|
+
skippedSuites = []
|
|
166
|
+
isSuitesSkipped = false
|
|
167
|
+
repositoryRoot = undefined
|
|
168
|
+
writeCoverageBackfillToCache({})
|
|
169
|
+
}
|
|
170
|
+
|
|
96
171
|
function getSuiteStatusFromTestStatuses (testStatuses) {
|
|
97
172
|
if (testStatuses.includes('fail')) {
|
|
98
173
|
return 'fail'
|
|
@@ -103,6 +178,316 @@ function getSuiteStatusFromTestStatuses (testStatuses) {
|
|
|
103
178
|
return 'pass'
|
|
104
179
|
}
|
|
105
180
|
|
|
181
|
+
function getConfiguredEfdRetryCount () {
|
|
182
|
+
const maxSlowTestRetryCount = getMaxEfdRetryCount(earlyFlakeDetectionSlowTestRetries)
|
|
183
|
+
return maxSlowTestRetryCount ?? earlyFlakeDetectionNumRetries
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function publishWorkerEfdRetryCount (pickle, retryCount) {
|
|
187
|
+
const message = {
|
|
188
|
+
[DD_EFD_RETRY_COUNT_MESSAGE]: {
|
|
189
|
+
pickleId: pickle.id,
|
|
190
|
+
retryCount,
|
|
191
|
+
testFileAbsolutePath: pickle.uri,
|
|
192
|
+
testName: pickle.name,
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (typeof process.send === 'function') {
|
|
197
|
+
try {
|
|
198
|
+
process.send(message)
|
|
199
|
+
} catch {
|
|
200
|
+
// ignore IPC errors
|
|
201
|
+
}
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
const { isMainThread, parentPort } = require('node:worker_threads')
|
|
207
|
+
if (isMainThread || !parentPort) return
|
|
208
|
+
|
|
209
|
+
parentPort.postMessage(message)
|
|
210
|
+
} catch {
|
|
211
|
+
// ignore IPC errors
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function configureParallelWorkerWorldParameters (options) {
|
|
216
|
+
options.worldParameters ??= {}
|
|
217
|
+
|
|
218
|
+
if (isKnownTestsEnabled && isValidKnownTests(knownTests)) {
|
|
219
|
+
options.worldParameters._ddIsKnownTestsEnabled = true
|
|
220
|
+
options.worldParameters._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
221
|
+
options.worldParameters._ddKnownTests = knownTests
|
|
222
|
+
options.worldParameters._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
223
|
+
options.worldParameters._ddEarlyFlakeDetectionSlowTestRetries = earlyFlakeDetectionSlowTestRetries
|
|
224
|
+
} else {
|
|
225
|
+
isEarlyFlakeDetectionEnabled = false
|
|
226
|
+
isKnownTestsEnabled = false
|
|
227
|
+
options.worldParameters._ddIsEarlyFlakeDetectionEnabled = false
|
|
228
|
+
options.worldParameters._ddIsKnownTestsEnabled = false
|
|
229
|
+
options.worldParameters._ddEarlyFlakeDetectionNumRetries = 0
|
|
230
|
+
options.worldParameters._ddEarlyFlakeDetectionSlowTestRetries = {}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (isImpactedTestsEnabled) {
|
|
234
|
+
options.worldParameters._ddImpactedTestsEnabled = isImpactedTestsEnabled
|
|
235
|
+
options.worldParameters._ddModifiedFiles = modifiedFiles
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
options.worldParameters._ddIsFlakyTestRetriesEnabled = isFlakyTestRetriesEnabled
|
|
239
|
+
options.worldParameters._ddNumTestRetries = numTestRetries
|
|
240
|
+
|
|
241
|
+
if (isTestManagementTestsEnabled) {
|
|
242
|
+
options.worldParameters._ddIsTestManagementTestsEnabled = true
|
|
243
|
+
options.worldParameters._ddTestManagementTests = testManagementTests
|
|
244
|
+
options.worldParameters._ddTestManagementAttemptToFixRetries = testManagementAttemptToFixRetries
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function readParallelWorkerWorldParameters (options) {
|
|
249
|
+
const worldParameters = options?.worldParameters
|
|
250
|
+
if (!worldParameters) return
|
|
251
|
+
|
|
252
|
+
isKnownTestsEnabled = !!worldParameters._ddIsKnownTestsEnabled
|
|
253
|
+
if (isKnownTestsEnabled) {
|
|
254
|
+
knownTests = worldParameters._ddKnownTests
|
|
255
|
+
// if for whatever reason the worker does not receive valid known tests, we disable EFD and known tests
|
|
256
|
+
if (!isValidKnownTests(knownTests)) {
|
|
257
|
+
isKnownTestsEnabled = false
|
|
258
|
+
knownTests = {}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
isEarlyFlakeDetectionEnabled = !!worldParameters._ddIsEarlyFlakeDetectionEnabled
|
|
262
|
+
if (isEarlyFlakeDetectionEnabled) {
|
|
263
|
+
earlyFlakeDetectionNumRetries = worldParameters._ddEarlyFlakeDetectionNumRetries
|
|
264
|
+
earlyFlakeDetectionSlowTestRetries = worldParameters._ddEarlyFlakeDetectionSlowTestRetries ?? {}
|
|
265
|
+
}
|
|
266
|
+
isImpactedTestsEnabled = !!worldParameters._ddImpactedTestsEnabled
|
|
267
|
+
if (isImpactedTestsEnabled) {
|
|
268
|
+
modifiedFiles = worldParameters._ddModifiedFiles
|
|
269
|
+
}
|
|
270
|
+
isFlakyTestRetriesEnabled = !!worldParameters._ddIsFlakyTestRetriesEnabled
|
|
271
|
+
numTestRetries = worldParameters._ddNumTestRetries ?? 0
|
|
272
|
+
isTestManagementTestsEnabled = !!worldParameters._ddIsTestManagementTestsEnabled
|
|
273
|
+
if (isTestManagementTestsEnabled) {
|
|
274
|
+
testManagementTests = worldParameters._ddTestManagementTests
|
|
275
|
+
testManagementAttemptToFixRetries = worldParameters._ddTestManagementAttemptToFixRetries
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function handleDdWorkerMessage (message) {
|
|
280
|
+
if (Array.isArray(message)) {
|
|
281
|
+
const [messageCode, payload] = message
|
|
282
|
+
if (messageCode === CUCUMBER_WORKER_TRACE_PAYLOAD_CODE) {
|
|
283
|
+
collectAttemptToFixExecutionsFromTraces(payload, attemptToFixExecutions)
|
|
284
|
+
workerReportTraceCh.publish(payload)
|
|
285
|
+
return true
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (message?.[DD_EFD_RETRY_COUNT_MESSAGE]) {
|
|
290
|
+
handleEfdRetryCountMessage(message[DD_EFD_RETRY_COUNT_MESSAGE])
|
|
291
|
+
return true
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return false
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function onCucumberWorkerThreadMessage (message) {
|
|
298
|
+
if (!testSuiteFinishCh.hasSubscribers) return
|
|
299
|
+
|
|
300
|
+
handleDdWorkerMessage(message)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function registerWorkerThreadMessageHandlers (workers) {
|
|
304
|
+
if (!workers) return
|
|
305
|
+
|
|
306
|
+
for (const worker of workers) {
|
|
307
|
+
worker.workerThread.on('message', onCucumberWorkerThreadMessage)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function registerWorkerThreadPatchModule (supportCodeLibrary) {
|
|
312
|
+
const requireModules = supportCodeLibrary?.originalCoordinates?.requireModules
|
|
313
|
+
if (!Array.isArray(requireModules) || requireModules.includes(cucumberWorkerThreadsPatchModule)) return
|
|
314
|
+
|
|
315
|
+
requireModules.unshift(cucumberWorkerThreadsPatchModule)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function getRunningAssembledTestCase (adapter, worker) {
|
|
319
|
+
const command = adapter.running?.get(worker)
|
|
320
|
+
return command?.assembledTestCase
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function maybeStartParallelSuite (pickle) {
|
|
324
|
+
if (!pickle) return
|
|
325
|
+
|
|
326
|
+
const testFileAbsolutePath = pickle.uri
|
|
327
|
+
if (pickleResultByFile[testFileAbsolutePath]) return
|
|
328
|
+
|
|
329
|
+
pickleResultByFile[testFileAbsolutePath] = []
|
|
330
|
+
testSuiteStartCh.publish({
|
|
331
|
+
testFileAbsolutePath,
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function handleParallelTestCaseFinished (pickle, worstTestStepResult) {
|
|
336
|
+
const { status } = getStatusFromResultLatest(worstTestStepResult)
|
|
337
|
+
let isNew = false
|
|
338
|
+
|
|
339
|
+
if (isKnownTestsEnabled) {
|
|
340
|
+
isNew = isNewTest(pickle.uri, pickle.name)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const testFileAbsolutePath = pickle.uri
|
|
344
|
+
const finished = pickleResultByFile[testFileAbsolutePath] || (pickleResultByFile[testFileAbsolutePath] = [])
|
|
345
|
+
|
|
346
|
+
if (isEarlyFlakeDetectionEnabled && isNew) {
|
|
347
|
+
const testFullname = `${pickle.uri}:${pickle.name}`
|
|
348
|
+
let testStatuses = newTestsByTestFullname.get(testFullname)
|
|
349
|
+
if (testStatuses) {
|
|
350
|
+
testStatuses.push(status)
|
|
351
|
+
} else {
|
|
352
|
+
testStatuses = [status]
|
|
353
|
+
newTestsByTestFullname.set(testFullname, testStatuses)
|
|
354
|
+
}
|
|
355
|
+
let efdRetryCount = efdRetryCountByPickleId.get(pickle.id)
|
|
356
|
+
if (efdRetryCount === undefined) {
|
|
357
|
+
efdRetryCount = status === 'skip'
|
|
358
|
+
? 0
|
|
359
|
+
: getConfiguredEfdRetryCount()
|
|
360
|
+
efdRetryCountByPickleId.set(pickle.id, efdRetryCount)
|
|
361
|
+
if (efdRetryCount === 0 && status !== 'skip') {
|
|
362
|
+
efdSlowAbortedPickleIds.add(pickle.id)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
maybeRecordFinalParallelEfdStatus({ pickleId: pickle.id, testFileAbsolutePath, testFullname })
|
|
366
|
+
} else if (
|
|
367
|
+
isTestManagementTestsEnabled &&
|
|
368
|
+
getTestProperties(getTestSuitePath(testFileAbsolutePath, process.cwd()), pickle.name).attemptToFix
|
|
369
|
+
) {
|
|
370
|
+
const testFullname = `${pickle.uri}:${pickle.name}`
|
|
371
|
+
let testStatuses = attemptToFixTestsByTestFullname.get(testFullname)
|
|
372
|
+
if (testStatuses) {
|
|
373
|
+
testStatuses.push(status)
|
|
374
|
+
} else {
|
|
375
|
+
testStatuses = [status]
|
|
376
|
+
attemptToFixTestsByTestFullname.set(testFullname, testStatuses)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (status === 'skip' || testStatuses.length === testManagementAttemptToFixRetries + 1) {
|
|
380
|
+
finished.push(getTestStatusFromAttemptToFixExecutions(testStatuses))
|
|
381
|
+
attemptToFixTestsByTestFullname.delete(testFullname)
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
// TODO: can we get error message?
|
|
385
|
+
finished.push(status)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
finishParallelSuiteIfDone(testFileAbsolutePath)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function getWrappedHandleWorkerThreadEvent (handleEventFromWorker) {
|
|
392
|
+
return function (worker, event) {
|
|
393
|
+
if (!testSuiteFinishCh.hasSubscribers) {
|
|
394
|
+
return handleEventFromWorker.apply(this, arguments)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (handleDdWorkerMessage(event)) return
|
|
398
|
+
|
|
399
|
+
const envelope = event?.type === 'ENVELOPE' && event.envelope
|
|
400
|
+
if (!envelope) {
|
|
401
|
+
return handleEventFromWorker.apply(this, arguments)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const assembledTestCase = getRunningAssembledTestCase(this, worker)
|
|
405
|
+
|
|
406
|
+
if (envelope.testCaseStarted) {
|
|
407
|
+
maybeStartParallelSuite(assembledTestCase?.pickle)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const result = handleEventFromWorker.apply(this, arguments)
|
|
411
|
+
|
|
412
|
+
if (envelope.testCaseFinished && assembledTestCase?.pickle && eventDataCollector) {
|
|
413
|
+
const worstTestStepResult =
|
|
414
|
+
eventDataCollector.getTestCaseAttempt(envelope.testCaseFinished.testCaseStartedId).worstTestStepResult
|
|
415
|
+
handleParallelTestCaseFinished(assembledTestCase.pickle, worstTestStepResult)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return result
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function getWrappedWorkerThreadsSetup (setup) {
|
|
423
|
+
return async function () {
|
|
424
|
+
if (testSuiteFinishCh.hasSubscribers) {
|
|
425
|
+
configureParallelWorkerWorldParameters(this.options)
|
|
426
|
+
registerWorkerThreadPatchModule(this.supportCodeLibrary)
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const result = await setup.apply(this, arguments)
|
|
430
|
+
|
|
431
|
+
if (testSuiteFinishCh.hasSubscribers) {
|
|
432
|
+
registerWorkerThreadMessageHandlers(this.workers)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return result
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function getWrappedWorkerThreadsTeardown (teardown) {
|
|
440
|
+
return function () {
|
|
441
|
+
if (testSuiteFinishCh.hasSubscribers && this.workers) {
|
|
442
|
+
for (const worker of this.workers) {
|
|
443
|
+
worker.workerThread.removeListener('message', onCucumberWorkerThreadMessage)
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return teardown.apply(this, arguments)
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function finishParallelSuiteIfDone (testFileAbsolutePath) {
|
|
452
|
+
const finished = pickleResultByFile[testFileAbsolutePath]
|
|
453
|
+
const expectedPickles = pickleByFile[testFileAbsolutePath]
|
|
454
|
+
|
|
455
|
+
if (!finished || !expectedPickles || finished.length !== expectedPickles.length) return
|
|
456
|
+
if (finishedParallelSuites.has(testFileAbsolutePath)) return
|
|
457
|
+
|
|
458
|
+
finishedParallelSuites.add(testFileAbsolutePath)
|
|
459
|
+
testSuiteFinishCh.publish({
|
|
460
|
+
status: getSuiteStatusFromTestStatuses(finished),
|
|
461
|
+
testSuitePath: getTestSuitePath(testFileAbsolutePath, process.cwd()),
|
|
462
|
+
})
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function maybeRecordFinalParallelEfdStatus ({ pickleId, testFileAbsolutePath, testFullname }) {
|
|
466
|
+
const efdRetryCount = efdRetryCountByPickleId.get(pickleId)
|
|
467
|
+
const testStatuses = newTestsByTestFullname.get(testFullname)
|
|
468
|
+
const finished = pickleResultByFile[testFileAbsolutePath]
|
|
469
|
+
|
|
470
|
+
if (efdRetryCount === undefined || !testStatuses || !finished) return
|
|
471
|
+
if (testStatuses.length !== efdRetryCount + 1) return
|
|
472
|
+
|
|
473
|
+
finished.push(getTestStatusFromRetries(testStatuses))
|
|
474
|
+
newTestsByTestFullname.delete(testFullname)
|
|
475
|
+
finishParallelSuiteIfDone(testFileAbsolutePath)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function handleEfdRetryCountMessage (message) {
|
|
479
|
+
const { pickleId, retryCount, testFileAbsolutePath, testName } = message
|
|
480
|
+
|
|
481
|
+
if (!pickleId || typeof retryCount !== 'number' || !testFileAbsolutePath || !testName) return
|
|
482
|
+
|
|
483
|
+
efdRetryCountByPickleId.set(pickleId, retryCount)
|
|
484
|
+
maybeRecordFinalParallelEfdStatus({
|
|
485
|
+
pickleId,
|
|
486
|
+
testFileAbsolutePath,
|
|
487
|
+
testFullname: `${testFileAbsolutePath}:${testName}`,
|
|
488
|
+
})
|
|
489
|
+
}
|
|
490
|
+
|
|
106
491
|
function getStatusFromResult (result) {
|
|
107
492
|
if (result.status === 1) {
|
|
108
493
|
return { status: 'pass' }
|
|
@@ -154,6 +539,16 @@ function getTestStatusFromRetries (testStatuses) {
|
|
|
154
539
|
return 'pass'
|
|
155
540
|
}
|
|
156
541
|
|
|
542
|
+
function getTestStatusFromAttemptToFixExecutions (testStatuses) {
|
|
543
|
+
if (testStatuses.every(status => status === 'pass')) {
|
|
544
|
+
return 'pass'
|
|
545
|
+
}
|
|
546
|
+
if (testStatuses.every(status => status === 'skip')) {
|
|
547
|
+
return 'skip'
|
|
548
|
+
}
|
|
549
|
+
return 'fail'
|
|
550
|
+
}
|
|
551
|
+
|
|
157
552
|
function getErrorFromCucumberResult (cucumberResult) {
|
|
158
553
|
if (!cucumberResult.message) {
|
|
159
554
|
return
|
|
@@ -235,19 +630,132 @@ function getPickleByFile (runtimeOrCoodinator) {
|
|
|
235
630
|
}, {})
|
|
236
631
|
}
|
|
237
632
|
|
|
633
|
+
function getFinalStatus ({
|
|
634
|
+
status,
|
|
635
|
+
hasFailedAllRetries,
|
|
636
|
+
isLastAtrRetry,
|
|
637
|
+
isLastEfdRetry,
|
|
638
|
+
isLastAttemptToFix,
|
|
639
|
+
hasPassedAllRetries,
|
|
640
|
+
isQuarantined,
|
|
641
|
+
isDisabled,
|
|
642
|
+
}) {
|
|
643
|
+
// Note that intermediate executions DO NOT report a final status tag
|
|
644
|
+
|
|
645
|
+
// If the test is quarantined or disabled, its final status is skip unless attempt-to-fix takes precedence.
|
|
646
|
+
if (status === 'skip' || (!isLastAttemptToFix && (isQuarantined || isDisabled))) {
|
|
647
|
+
return 'skip'
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// When no retry feature is active, every execution is final
|
|
651
|
+
if (!isLastAtrRetry && !isLastEfdRetry && !isLastAttemptToFix) {
|
|
652
|
+
return status
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// ATR and EFD: pass unless every attempt failed
|
|
656
|
+
if (isLastAtrRetry || isLastEfdRetry) {
|
|
657
|
+
return hasFailedAllRetries ? 'fail' : 'pass'
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// Branch for ATF (We need to check hasPassedAllRetries)
|
|
661
|
+
if (isLastAttemptToFix) {
|
|
662
|
+
return hasPassedAllRetries ? 'pass' : 'fail'
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
async function handleRetriedAttempt (runner, state) {
|
|
667
|
+
const { promises } = state
|
|
668
|
+
if (promises.hitBreakpointPromise) {
|
|
669
|
+
await promises.hitBreakpointPromise
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const setProbePromise = publishRetriedAttempt(runner, state)
|
|
673
|
+
if (setProbePromise) {
|
|
674
|
+
await setProbePromise
|
|
675
|
+
promises.setProbePromise = undefined
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
startRetriedAttempt(state)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function handleRetriedAttemptFromEnvelope (runner, state) {
|
|
682
|
+
publishRetriedAttempt(runner, state)
|
|
683
|
+
startRetriedAttempt(state)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function publishRetriedAttempt (runner, state) {
|
|
687
|
+
const { promises } = state
|
|
688
|
+
let error
|
|
689
|
+
try {
|
|
690
|
+
const cucumberResult = runner.getWorstStepResult()
|
|
691
|
+
error = getErrorFromCucumberResult(cucumberResult)
|
|
692
|
+
} catch {
|
|
693
|
+
// ignore error
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const currentAttempt = state.numAttempt
|
|
697
|
+
const nextAttempt = currentAttempt + 1
|
|
698
|
+
const failedAttemptCtx = numAttemptToCtx.get(currentAttempt)
|
|
699
|
+
const isFirstAttempt = currentAttempt === 0
|
|
700
|
+
const isAtrRetry = !isFirstAttempt && isFlakyTestRetriesEnabled
|
|
701
|
+
|
|
702
|
+
// ATR: record this attempt as failed so when run().finally runs (after retry) we have all statuses
|
|
703
|
+
if (isFlakyTestRetriesEnabled) {
|
|
704
|
+
const nameForKey = runner.pickle.name.replace(/\s*\(attempt \d+(?:, retried)?\)\s*$/, '')
|
|
705
|
+
const atrKey = `${runner.pickle.uri}:${nameForKey}`
|
|
706
|
+
if (atrStatusesByScenarioKey.has(atrKey)) {
|
|
707
|
+
atrStatusesByScenarioKey.get(atrKey).push('fail')
|
|
708
|
+
} else {
|
|
709
|
+
atrStatusesByScenarioKey.set(atrKey, ['fail'])
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// the current span will be finished and a new one will be created
|
|
714
|
+
testRetryCh.publish({
|
|
715
|
+
isFirstAttempt,
|
|
716
|
+
error,
|
|
717
|
+
isAtrRetry,
|
|
718
|
+
promises,
|
|
719
|
+
canWaitForDi: state.testStartPayload.canWaitForDi,
|
|
720
|
+
...failedAttemptCtx.currentStore,
|
|
721
|
+
})
|
|
722
|
+
|
|
723
|
+
state.numAttempt = nextAttempt
|
|
724
|
+
return promises.setProbePromise
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function startRetriedAttempt (state) {
|
|
728
|
+
const { promises, testStartPayload } = state
|
|
729
|
+
const newCtx = { ...testStartPayload, promises }
|
|
730
|
+
numAttemptToCtx.set(state.numAttempt, newCtx)
|
|
731
|
+
|
|
732
|
+
testStartCh.runStores(newCtx, () => {})
|
|
733
|
+
}
|
|
734
|
+
|
|
238
735
|
function wrapRun (pl, isLatestVersion, version) {
|
|
239
736
|
if (patched.has(pl)) return
|
|
240
737
|
|
|
241
738
|
patched.add(pl)
|
|
242
739
|
|
|
243
|
-
|
|
740
|
+
const canAwaitRetries = typeof pl.prototype.runAttempt === 'function'
|
|
741
|
+
if (canAwaitRetries) {
|
|
742
|
+
shimmer.wrap(pl.prototype, 'runAttempt', runAttempt => async function (...args) {
|
|
743
|
+
const willBeRetried = await runAttempt.apply(this, args)
|
|
744
|
+
const state = runnerToRetryState.get(this)
|
|
745
|
+
if (willBeRetried && state) {
|
|
746
|
+
await handleRetriedAttempt(this, state)
|
|
747
|
+
}
|
|
748
|
+
return willBeRetried
|
|
749
|
+
})
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
shimmer.wrap(pl.prototype, 'run', run => function (...args) {
|
|
244
753
|
if (!testFinishCh.hasSubscribers) {
|
|
245
|
-
return run.apply(this,
|
|
754
|
+
return run.apply(this, args)
|
|
246
755
|
}
|
|
247
756
|
|
|
248
|
-
let numAttempt = 0
|
|
249
|
-
|
|
250
757
|
const testFileAbsolutePath = this.pickle.uri
|
|
758
|
+
const testSuitePath = getTestSuitePath(testFileAbsolutePath, process.cwd())
|
|
251
759
|
|
|
252
760
|
const testSourceLine = this.gherkinDocument?.feature?.location?.line
|
|
253
761
|
|
|
@@ -256,60 +764,45 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
256
764
|
testFileAbsolutePath,
|
|
257
765
|
testSourceLine,
|
|
258
766
|
isParallel: !!getEnvironmentVariable('CUCUMBER_WORKER_ID'),
|
|
767
|
+
// Older Cucumber runners do not expose an awaited retry boundary. Failed Test Replay
|
|
768
|
+
// intentionally skips DI setup there instead of bringing back the synchronous wait.
|
|
769
|
+
canWaitForDi: canAwaitRetries,
|
|
259
770
|
}
|
|
260
771
|
const ctx = testStartPayload
|
|
261
|
-
numAttemptToCtx.set(numAttempt, ctx)
|
|
262
|
-
testStartCh.runStores(ctx, () => {})
|
|
263
772
|
const promises = {}
|
|
773
|
+
const state = { numAttempt: 0, promises, testStartPayload }
|
|
774
|
+
numAttemptToCtx.set(state.numAttempt, ctx)
|
|
775
|
+
runnerToRetryState.set(this, state)
|
|
776
|
+
if (isTestManagementTestsEnabled && getTestProperties(testSuitePath, this.pickle.name).attemptToFix) {
|
|
777
|
+
logAttemptToFixTestExecution(testSuitePath, this.pickle.name, loggedAttemptToFixTests)
|
|
778
|
+
}
|
|
779
|
+
testStartCh.runStores(ctx, () => {})
|
|
264
780
|
try {
|
|
265
|
-
|
|
781
|
+
const onEnvelope = (testCase) => {
|
|
782
|
+
if (canAwaitRetries) return
|
|
783
|
+
|
|
266
784
|
// Only supported from >=8.0.0
|
|
267
785
|
if (testCase?.testCaseFinished) {
|
|
268
786
|
const { testCaseFinished: { willBeRetried } } = testCase
|
|
269
787
|
if (willBeRetried) { // test case failed and will be retried
|
|
270
|
-
|
|
271
|
-
try {
|
|
272
|
-
const cucumberResult = this.getWorstStepResult()
|
|
273
|
-
error = getErrorFromCucumberResult(cucumberResult)
|
|
274
|
-
} catch {
|
|
275
|
-
// ignore error
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const failedAttemptCtx = numAttemptToCtx.get(numAttempt)
|
|
279
|
-
const isFirstAttempt = numAttempt++ === 0
|
|
280
|
-
const isAtrRetry = !isFirstAttempt && isFlakyTestRetriesEnabled
|
|
281
|
-
|
|
282
|
-
// ATR: record this attempt as failed so when run().finally runs (after retry) we have all statuses
|
|
283
|
-
if (isFlakyTestRetriesEnabled && isAtrRetry === false) {
|
|
284
|
-
const nameForKey = this.pickle.name.replace(/\s*\(attempt \d+(?:, retried)?\)\s*$/, '')
|
|
285
|
-
const atrKey = `${this.pickle.uri}:${nameForKey}`
|
|
286
|
-
if (atrStatusesByScenarioKey.has(atrKey)) {
|
|
287
|
-
atrStatusesByScenarioKey.get(atrKey).push('fail')
|
|
288
|
-
} else {
|
|
289
|
-
atrStatusesByScenarioKey.set(atrKey, ['fail'])
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (promises.hitBreakpointPromise) {
|
|
294
|
-
await promises.hitBreakpointPromise
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// the current span will be finished and a new one will be created
|
|
298
|
-
testRetryCh.publish({ isFirstAttempt, error, isAtrRetry, ...failedAttemptCtx.currentStore })
|
|
299
|
-
|
|
300
|
-
const newCtx = { ...testStartPayload, promises }
|
|
301
|
-
numAttemptToCtx.set(numAttempt, newCtx)
|
|
302
|
-
|
|
303
|
-
testStartCh.runStores(newCtx, () => {})
|
|
788
|
+
handleRetriedAttemptFromEnvelope(this, state)
|
|
304
789
|
}
|
|
305
790
|
}
|
|
306
|
-
}
|
|
791
|
+
}
|
|
792
|
+
if (!canAwaitRetries) {
|
|
793
|
+
this.eventBroadcaster.on('envelope', onEnvelope)
|
|
794
|
+
}
|
|
307
795
|
let promise
|
|
796
|
+
const executionStart = performance.now()
|
|
308
797
|
|
|
309
798
|
testFnCh.runStores(ctx, () => {
|
|
310
|
-
promise = run.apply(this,
|
|
799
|
+
promise = run.apply(this, args)
|
|
311
800
|
})
|
|
312
801
|
promise.finally(async () => {
|
|
802
|
+
if (!canAwaitRetries) {
|
|
803
|
+
this.eventBroadcaster.removeListener('envelope', onEnvelope)
|
|
804
|
+
}
|
|
805
|
+
runnerToRetryState.delete(this)
|
|
313
806
|
const result = this.getWorstStepResult()
|
|
314
807
|
const { status, skipReason } = isLatestVersion
|
|
315
808
|
? getStatusFromResultLatest(result)
|
|
@@ -368,15 +861,31 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
368
861
|
isEfdRetry = numRetries > 0
|
|
369
862
|
}
|
|
370
863
|
|
|
864
|
+
if (
|
|
865
|
+
isEarlyFlakeDetectionEnabled &&
|
|
866
|
+
status !== 'skip' &&
|
|
867
|
+
(isNew || isModified) &&
|
|
868
|
+
!isEfdRetry &&
|
|
869
|
+
!efdRetryCountByPickleId.has(this.pickle.id)
|
|
870
|
+
) {
|
|
871
|
+
const retryCount = getEfdRetryCount(performance.now() - executionStart, earlyFlakeDetectionSlowTestRetries)
|
|
872
|
+
efdRetryCountByPickleId.set(this.pickle.id, retryCount)
|
|
873
|
+
if (retryCount === 0) {
|
|
874
|
+
efdSlowAbortedPickleIds.add(this.pickle.id)
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
const efdRetryCount = efdRetryCountByPickleId.get(this.pickle.id) ?? earlyFlakeDetectionNumRetries
|
|
879
|
+
|
|
371
880
|
// Check if all EFD retries failed
|
|
372
881
|
if (isEfdRetry && (isNew || isModified)) {
|
|
373
882
|
const statuses = lastStatusByPickleId.get(this.pickle.id)
|
|
374
|
-
if (statuses.length ===
|
|
883
|
+
if (statuses.length === efdRetryCount + 1) {
|
|
375
884
|
const { fail } = statuses.reduce((acc, status) => {
|
|
376
885
|
acc[status]++
|
|
377
886
|
return acc
|
|
378
887
|
}, { pass: 0, fail: 0 })
|
|
379
|
-
if (fail ===
|
|
888
|
+
if (fail === efdRetryCount + 1) {
|
|
380
889
|
hasFailedAllRetries = true
|
|
381
890
|
}
|
|
382
891
|
}
|
|
@@ -401,20 +910,55 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
401
910
|
}
|
|
402
911
|
}
|
|
403
912
|
|
|
404
|
-
const attemptCtx = numAttemptToCtx.get(numAttempt)
|
|
913
|
+
const attemptCtx = numAttemptToCtx.get(state.numAttempt)
|
|
405
914
|
|
|
406
915
|
const error = getErrorFromCucumberResult(result)
|
|
407
916
|
|
|
917
|
+
if (isAttemptToFix) {
|
|
918
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
919
|
+
testSuite: testSuitePath,
|
|
920
|
+
testName: this.pickle.name,
|
|
921
|
+
status,
|
|
922
|
+
isDisabled,
|
|
923
|
+
isQuarantined,
|
|
924
|
+
})
|
|
925
|
+
}
|
|
926
|
+
|
|
408
927
|
if (promises.hitBreakpointPromise) {
|
|
409
928
|
await promises.hitBreakpointPromise
|
|
410
929
|
}
|
|
930
|
+
|
|
931
|
+
// Notice that ATR is handled using cucumber native retries features.
|
|
932
|
+
// Therefore, if we reach this point, we are certain that it's the last ATR execution
|
|
933
|
+
const isLastAtrRetry = isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry && numTestRetries > 0
|
|
934
|
+
|
|
935
|
+
const statuses = lastStatusByPickleId.get(this.pickle.id)
|
|
936
|
+
const isLastEfdRetry = isEfdRetry && statuses?.length === efdRetryCount + 1
|
|
937
|
+
const isLastAttemptToFixRetry = isAttemptToFix && statuses?.length === testManagementAttemptToFixRetries + 1
|
|
938
|
+
|
|
939
|
+
// Intermediate (non-last EFD or ATF retries) executions do not report a final status
|
|
940
|
+
const isIntermediateExecution = (isEfdRetry && !isLastEfdRetry) || (isAttemptToFix && !isLastAttemptToFixRetry)
|
|
941
|
+
|
|
942
|
+
const finalStatus = isIntermediateExecution
|
|
943
|
+
? undefined
|
|
944
|
+
: getFinalStatus({
|
|
945
|
+
status,
|
|
946
|
+
hasFailedAllRetries,
|
|
947
|
+
isLastAtrRetry,
|
|
948
|
+
isLastEfdRetry,
|
|
949
|
+
isLastAttemptToFix: isLastAttemptToFixRetry,
|
|
950
|
+
hasPassedAllRetries,
|
|
951
|
+
isQuarantined,
|
|
952
|
+
isDisabled,
|
|
953
|
+
})
|
|
954
|
+
|
|
411
955
|
testFinishCh.publish({
|
|
412
956
|
status,
|
|
413
957
|
skipReason,
|
|
414
958
|
error,
|
|
415
959
|
isNew,
|
|
416
960
|
isEfdRetry,
|
|
417
|
-
isFlakyRetry: numAttempt > 0,
|
|
961
|
+
isFlakyRetry: state.numAttempt > 0,
|
|
418
962
|
isAttemptToFix,
|
|
419
963
|
isAttemptToFixRetry,
|
|
420
964
|
hasFailedAllRetries,
|
|
@@ -423,7 +967,9 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
423
967
|
isDisabled,
|
|
424
968
|
isQuarantined,
|
|
425
969
|
isModified,
|
|
970
|
+
earlyFlakeAbortReason: efdSlowAbortedPickleIds.has(this.pickle.id) ? 'slow' : undefined,
|
|
426
971
|
...attemptCtx.currentStore,
|
|
972
|
+
finalStatus,
|
|
427
973
|
})
|
|
428
974
|
})
|
|
429
975
|
return promise
|
|
@@ -434,11 +980,11 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
434
980
|
})
|
|
435
981
|
}
|
|
436
982
|
})
|
|
437
|
-
shimmer.wrap(pl.prototype, 'runStep', runStep => function () {
|
|
983
|
+
shimmer.wrap(pl.prototype, 'runStep', runStep => function (...args) {
|
|
438
984
|
if (!testFinishCh.hasSubscribers) {
|
|
439
|
-
return runStep.apply(this,
|
|
985
|
+
return runStep.apply(this, args)
|
|
440
986
|
}
|
|
441
|
-
const testStep =
|
|
987
|
+
const testStep = args[0]
|
|
442
988
|
let resource
|
|
443
989
|
|
|
444
990
|
if (isLatestVersion) {
|
|
@@ -450,7 +996,7 @@ function wrapRun (pl, isLatestVersion, version) {
|
|
|
450
996
|
const ctx = { resource }
|
|
451
997
|
return testStepStartCh.runStores(ctx, () => {
|
|
452
998
|
try {
|
|
453
|
-
const promise = runStep.apply(this,
|
|
999
|
+
const promise = runStep.apply(this, args)
|
|
454
1000
|
|
|
455
1001
|
promise.then((result) => {
|
|
456
1002
|
const finalResult = satisfies(version, '>=12.0.0') ? result.result : result
|
|
@@ -490,7 +1036,9 @@ function testCaseHook (TestCaseRunner, version) {
|
|
|
490
1036
|
// Valid for old and new cucumber versions
|
|
491
1037
|
function getCucumberOptions (adapterOrCoordinator) {
|
|
492
1038
|
if (adapterOrCoordinator.adapter) {
|
|
493
|
-
return adapterOrCoordinator.adapter.worker?.options ||
|
|
1039
|
+
return adapterOrCoordinator.adapter.worker?.options ||
|
|
1040
|
+
adapterOrCoordinator.adapter.executor?.options ||
|
|
1041
|
+
adapterOrCoordinator.adapter.options
|
|
494
1042
|
}
|
|
495
1043
|
return adapterOrCoordinator.options
|
|
496
1044
|
}
|
|
@@ -500,6 +1048,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
500
1048
|
if (!libraryConfigurationCh.hasSubscribers) {
|
|
501
1049
|
return start.apply(this, arguments)
|
|
502
1050
|
}
|
|
1051
|
+
resetSuiteSkippingRunState()
|
|
503
1052
|
const options = getCucumberOptions(this)
|
|
504
1053
|
|
|
505
1054
|
if (!isParallel && this.adapter?.options) {
|
|
@@ -509,10 +1058,14 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
509
1058
|
|
|
510
1059
|
const configurationResponse = await getChannelPromise(libraryConfigurationCh, frameworkVersion)
|
|
511
1060
|
|
|
1061
|
+
repositoryRoot = configurationResponse.repositoryRoot
|
|
1062
|
+
isItrEnabled = configurationResponse.libraryConfig?.isItrEnabled
|
|
512
1063
|
isEarlyFlakeDetectionEnabled = configurationResponse.libraryConfig?.isEarlyFlakeDetectionEnabled
|
|
513
1064
|
earlyFlakeDetectionNumRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionNumRetries
|
|
1065
|
+
earlyFlakeDetectionSlowTestRetries = configurationResponse.libraryConfig?.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
514
1066
|
earlyFlakeDetectionFaultyThreshold = configurationResponse.libraryConfig?.earlyFlakeDetectionFaultyThreshold
|
|
515
|
-
isSuitesSkippingEnabled = configurationResponse.libraryConfig?.isSuitesSkippingEnabled
|
|
1067
|
+
isSuitesSkippingEnabled = isItrEnabled && configurationResponse.libraryConfig?.isSuitesSkippingEnabled
|
|
1068
|
+
isCoverageReportUploadEnabled = configurationResponse.libraryConfig?.isCoverageReportUploadEnabled
|
|
516
1069
|
isFlakyTestRetriesEnabled = configurationResponse.libraryConfig?.isFlakyTestRetriesEnabled
|
|
517
1070
|
const configRetryCount = configurationResponse.libraryConfig?.flakyTestRetriesCount
|
|
518
1071
|
numTestRetries = (typeof configRetryCount === 'number' && configRetryCount > 0) ? configRetryCount : 0
|
|
@@ -521,21 +1074,35 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
521
1074
|
testManagementAttemptToFixRetries = configurationResponse.libraryConfig?.testManagementAttemptToFixRetries
|
|
522
1075
|
isImpactedTestsEnabled = configurationResponse.libraryConfig?.isImpactedTestsEnabled
|
|
523
1076
|
|
|
1077
|
+
const {
|
|
1078
|
+
knownTestsResponse,
|
|
1079
|
+
testManagementTestsResponse,
|
|
1080
|
+
skippableSuitesResponse,
|
|
1081
|
+
} = await getTestOptimizationRequestResults({
|
|
1082
|
+
isKnownTestsEnabled,
|
|
1083
|
+
isTestManagementTestsEnabled,
|
|
1084
|
+
isSuitesSkippingEnabled,
|
|
1085
|
+
getKnownTests: () => getChannelPromise(knownTestsCh),
|
|
1086
|
+
getTestManagementTests: () => getChannelPromise(testManagementTestsCh),
|
|
1087
|
+
getSkippableSuites: () => getChannelPromise(skippableSuitesCh),
|
|
1088
|
+
})
|
|
1089
|
+
|
|
524
1090
|
if (isKnownTestsEnabled) {
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
1091
|
+
const currentKnownTestsResponse = knownTestsResponse || await getChannelPromise(knownTestsCh)
|
|
1092
|
+
if (currentKnownTestsResponse.err) {
|
|
527
1093
|
isEarlyFlakeDetectionEnabled = false
|
|
528
1094
|
isKnownTestsEnabled = false
|
|
529
1095
|
} else {
|
|
530
|
-
knownTests =
|
|
1096
|
+
knownTests = currentKnownTestsResponse.knownTests
|
|
531
1097
|
}
|
|
532
1098
|
}
|
|
533
1099
|
|
|
534
1100
|
if (isSuitesSkippingEnabled) {
|
|
535
|
-
const skippableResponse = await getChannelPromise(skippableSuitesCh)
|
|
1101
|
+
const skippableResponse = skippableSuitesResponse || await getChannelPromise(skippableSuitesCh)
|
|
536
1102
|
|
|
537
1103
|
errorSkippableRequest = skippableResponse.err
|
|
538
|
-
skippableSuites = skippableResponse.skippableSuites
|
|
1104
|
+
skippableSuites = skippableResponse.skippableSuites ?? []
|
|
1105
|
+
skippableSuitesCoverage = skippableResponse.skippableSuitesCoverage ?? {}
|
|
539
1106
|
|
|
540
1107
|
if (!errorSkippableRequest) {
|
|
541
1108
|
const filteredPickles = isCoordinator
|
|
@@ -556,6 +1123,8 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
556
1123
|
}
|
|
557
1124
|
|
|
558
1125
|
skippedSuites = [...filteredPickles.skippedSuites]
|
|
1126
|
+
skippedSuitesCoverage = getSkippedSuitesCoverageForRun()
|
|
1127
|
+
writeCoverageBackfillToCache(skippedSuitesCoverage, getCoverageRootDir())
|
|
559
1128
|
itrCorrelationId = skippableResponse.itrCorrelationId
|
|
560
1129
|
}
|
|
561
1130
|
}
|
|
@@ -576,11 +1145,12 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
576
1145
|
}
|
|
577
1146
|
|
|
578
1147
|
if (isTestManagementTestsEnabled) {
|
|
579
|
-
const
|
|
580
|
-
|
|
1148
|
+
const currentTestManagementTestsResponse =
|
|
1149
|
+
testManagementTestsResponse || await getChannelPromise(testManagementTestsCh)
|
|
1150
|
+
if (currentTestManagementTestsResponse.err) {
|
|
581
1151
|
isTestManagementTestsEnabled = false
|
|
582
1152
|
} else {
|
|
583
|
-
testManagementTests =
|
|
1153
|
+
testManagementTests = currentTestManagementTestsResponse.testManagementTests
|
|
584
1154
|
}
|
|
585
1155
|
}
|
|
586
1156
|
|
|
@@ -599,13 +1169,19 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
599
1169
|
}
|
|
600
1170
|
|
|
601
1171
|
atrStatusesByScenarioKey.clear()
|
|
1172
|
+
attemptToFixTestsByTestFullname.clear()
|
|
1173
|
+
efdRetryCountByPickleId.clear()
|
|
1174
|
+
efdSlowAbortedPickleIds.clear()
|
|
1175
|
+
finishedParallelSuites.clear()
|
|
1176
|
+
newTestsByTestFullname.clear()
|
|
602
1177
|
sessionStartCh.publish({ command, frameworkVersion })
|
|
603
1178
|
|
|
604
1179
|
if (!errorSkippableRequest && skippedSuites.length) {
|
|
605
1180
|
itrSkippedSuitesCh.publish({ skippedSuites, frameworkVersion })
|
|
606
1181
|
}
|
|
607
1182
|
|
|
608
|
-
const
|
|
1183
|
+
const result = await start.apply(this, arguments)
|
|
1184
|
+
const success = satisfies(frameworkVersion, '>=13.1.0') ? result.success : result
|
|
609
1185
|
|
|
610
1186
|
let untestedCoverage
|
|
611
1187
|
if (getCodeCoverageCh.hasSubscribers) {
|
|
@@ -613,13 +1189,25 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
613
1189
|
}
|
|
614
1190
|
|
|
615
1191
|
let testCodeCoverageLinesTotal
|
|
1192
|
+
let testSessionCoverageFiles
|
|
616
1193
|
|
|
617
|
-
if (global.__coverage__) {
|
|
1194
|
+
if (global.__coverage__ || untestedCoverage) {
|
|
618
1195
|
try {
|
|
1196
|
+
let hasBackfilledCoverage = false
|
|
619
1197
|
if (untestedCoverage) {
|
|
620
1198
|
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
621
1199
|
}
|
|
622
|
-
|
|
1200
|
+
hasBackfilledCoverage = applySkippedCoverageToCucumberCoverageMap()
|
|
1201
|
+
if (shouldReportCodeCoverageLinesPct(hasBackfilledCoverage)) {
|
|
1202
|
+
testCodeCoverageLinesTotal = getTestCoverageLinesPercentage(
|
|
1203
|
+
originalCoverageMap,
|
|
1204
|
+
undefined,
|
|
1205
|
+
getCoverageRootDir()
|
|
1206
|
+
)
|
|
1207
|
+
}
|
|
1208
|
+
if (isTiaCoverageBackfillEnabled()) {
|
|
1209
|
+
testSessionCoverageFiles = getCucumberTestSessionCoverageFiles()
|
|
1210
|
+
}
|
|
623
1211
|
} catch {
|
|
624
1212
|
// ignore errors
|
|
625
1213
|
}
|
|
@@ -631,6 +1219,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
631
1219
|
status: success ? 'pass' : 'fail',
|
|
632
1220
|
isSuitesSkipped,
|
|
633
1221
|
testCodeCoverageLinesTotal,
|
|
1222
|
+
testSessionCoverageFiles,
|
|
634
1223
|
numSkippedSuites: skippedSuites.length,
|
|
635
1224
|
hasUnskippableSuites: isUnskippable,
|
|
636
1225
|
hasForcedToRunSuites: isForcedToRun,
|
|
@@ -639,8 +1228,10 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
639
1228
|
isTestManagementTestsEnabled,
|
|
640
1229
|
isParallel,
|
|
641
1230
|
})
|
|
1231
|
+
logTestOptimizationSummary({ attemptToFixExecutions })
|
|
1232
|
+
loggedAttemptToFixTests.clear()
|
|
642
1233
|
eventDataCollector = null
|
|
643
|
-
return
|
|
1234
|
+
return result
|
|
644
1235
|
}
|
|
645
1236
|
}
|
|
646
1237
|
|
|
@@ -651,6 +1242,9 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
651
1242
|
if (!testSuiteFinishCh.hasSubscribers) {
|
|
652
1243
|
return runTestCaseFunction.apply(this, arguments)
|
|
653
1244
|
}
|
|
1245
|
+
if (isWorker) {
|
|
1246
|
+
readParallelWorkerWorldParameters(this.options)
|
|
1247
|
+
}
|
|
654
1248
|
const pickle = isNewerCucumberVersion
|
|
655
1249
|
? arguments[0].pickle
|
|
656
1250
|
: this.eventDataCollector.getPickle(arguments[0])
|
|
@@ -720,8 +1314,15 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
720
1314
|
numRetriesByPickleId.set(pickle.id, 0)
|
|
721
1315
|
}
|
|
722
1316
|
}
|
|
1317
|
+
const originalRetry = this.options.retry
|
|
1318
|
+
const isManagedRetry = isAttemptToFix || (isEarlyFlakeDetectionEnabled && (isNew || isModified))
|
|
1319
|
+
if (isManagedRetry) {
|
|
1320
|
+
this.options.retry = 0
|
|
1321
|
+
}
|
|
723
1322
|
// TODO: for >=11 we could use `runTestCaseResult` instead of accumulating results in `lastStatusByPickleId`
|
|
1323
|
+
const firstExecutionStart = performance.now()
|
|
724
1324
|
let runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
1325
|
+
const firstExecutionDurationMs = performance.now() - firstExecutionStart
|
|
725
1326
|
|
|
726
1327
|
// Restore dryRun so it doesn't affect subsequent tests in the same worker
|
|
727
1328
|
this.options.dryRun = originalDryRun
|
|
@@ -740,7 +1341,18 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
740
1341
|
|
|
741
1342
|
// If it's a new test and it hasn't been skipped, we run it again
|
|
742
1343
|
if (isEarlyFlakeDetectionEnabled && lastTestStatus !== 'skip' && (isNew || isModified)) {
|
|
743
|
-
|
|
1344
|
+
let efdRetryCount = efdRetryCountByPickleId.get(pickle.id)
|
|
1345
|
+
if (efdRetryCount === undefined) {
|
|
1346
|
+
efdRetryCount = getEfdRetryCount(firstExecutionDurationMs, earlyFlakeDetectionSlowTestRetries)
|
|
1347
|
+
efdRetryCountByPickleId.set(pickle.id, efdRetryCount)
|
|
1348
|
+
if (efdRetryCount === 0) {
|
|
1349
|
+
efdSlowAbortedPickleIds.add(pickle.id)
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
if (isWorker) {
|
|
1353
|
+
publishWorkerEfdRetryCount(pickle, efdRetryCount)
|
|
1354
|
+
}
|
|
1355
|
+
for (let retryIndex = 0; retryIndex < efdRetryCount; retryIndex++) {
|
|
744
1356
|
numRetriesByPickleId.set(pickle.id, retryIndex + 1)
|
|
745
1357
|
// eslint-disable-next-line no-await-in-loop
|
|
746
1358
|
runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
@@ -749,6 +1361,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
749
1361
|
let testStatus = lastTestStatus
|
|
750
1362
|
let shouldBePassedByEFD = false
|
|
751
1363
|
let shouldBePassedByTestManagement = false
|
|
1364
|
+
let shouldBeFailedByAttemptToFix = false
|
|
752
1365
|
if ((isNew || isModified) && isEarlyFlakeDetectionEnabled) {
|
|
753
1366
|
/**
|
|
754
1367
|
* If Early Flake Detection (EFD) is enabled the logic is as follows:
|
|
@@ -765,7 +1378,15 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
765
1378
|
}
|
|
766
1379
|
}
|
|
767
1380
|
|
|
768
|
-
if (
|
|
1381
|
+
if (isAttemptToFix && testStatuses.length === testManagementAttemptToFixRetries + 1) {
|
|
1382
|
+
testStatus = getTestStatusFromAttemptToFixExecutions(testStatuses)
|
|
1383
|
+
if (testStatus === 'fail') {
|
|
1384
|
+
this.success = false
|
|
1385
|
+
shouldBeFailedByAttemptToFix = true
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
if (isTestManagementTestsEnabled && !isAttemptToFix && (isDisabled || isQuarantined)) {
|
|
769
1390
|
this.success = true
|
|
770
1391
|
shouldBePassedByTestManagement = true
|
|
771
1392
|
}
|
|
@@ -781,7 +1402,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
781
1402
|
// last test in suite
|
|
782
1403
|
const testSuiteStatus = getSuiteStatusFromTestStatuses(pickleResultByFile[testFileAbsolutePath])
|
|
783
1404
|
if (global.__coverage__) {
|
|
784
|
-
const coverageFiles =
|
|
1405
|
+
const coverageFiles = getCoveredFilesFromCoverage(global.__coverage__)
|
|
785
1406
|
|
|
786
1407
|
testSuiteCodeCoverageCh.publish({
|
|
787
1408
|
coverageFiles,
|
|
@@ -797,33 +1418,44 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
797
1418
|
testSuiteFinishCh.publish({ status: testSuiteStatus, testSuitePath })
|
|
798
1419
|
}
|
|
799
1420
|
|
|
1421
|
+
this.options.retry = originalRetry
|
|
1422
|
+
|
|
800
1423
|
if (isNewerCucumberVersion && isEarlyFlakeDetectionEnabled && (isNew || isModified)) {
|
|
801
1424
|
return shouldBePassedByEFD
|
|
802
1425
|
}
|
|
803
1426
|
|
|
804
|
-
if (isNewerCucumberVersion && isTestManagementTestsEnabled && (isQuarantined || isDisabled)) {
|
|
1427
|
+
if (isNewerCucumberVersion && isTestManagementTestsEnabled && !isAttemptToFix && (isQuarantined || isDisabled)) {
|
|
805
1428
|
return shouldBePassedByTestManagement
|
|
806
1429
|
}
|
|
807
1430
|
|
|
1431
|
+
if (isNewerCucumberVersion && isAttemptToFix && shouldBeFailedByAttemptToFix) {
|
|
1432
|
+
return false
|
|
1433
|
+
}
|
|
1434
|
+
|
|
808
1435
|
return runTestCaseResult
|
|
809
1436
|
}
|
|
810
1437
|
}
|
|
811
1438
|
|
|
1439
|
+
function patchCucumberWorkerRunTestCase (runtimeExecutorPackage, isWorker) {
|
|
1440
|
+
const runtimeExecutorPrototype =
|
|
1441
|
+
runtimeExecutorPackage?.Worker?.prototype || runtimeExecutorPackage?.Executor?.prototype
|
|
1442
|
+
if (!runtimeExecutorPrototype || patchedCucumberWorkers.has(runtimeExecutorPrototype)) return
|
|
1443
|
+
|
|
1444
|
+
patchedCucumberWorkers.add(runtimeExecutorPrototype)
|
|
1445
|
+
shimmer.wrap(
|
|
1446
|
+
runtimeExecutorPrototype,
|
|
1447
|
+
'runTestCase',
|
|
1448
|
+
runTestCase => getWrappedRunTestCase(runTestCase, true, isWorker)
|
|
1449
|
+
)
|
|
1450
|
+
}
|
|
1451
|
+
|
|
812
1452
|
function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion) {
|
|
813
1453
|
return function (worker, message) {
|
|
814
1454
|
if (!testSuiteFinishCh.hasSubscribers) {
|
|
815
1455
|
return parseWorkerMessageFunction.apply(this, arguments)
|
|
816
1456
|
}
|
|
817
|
-
// If
|
|
818
|
-
|
|
819
|
-
// TODO: identify the message better
|
|
820
|
-
if (Array.isArray(message)) {
|
|
821
|
-
const [messageCode, payload] = message
|
|
822
|
-
if (messageCode === CUCUMBER_WORKER_TRACE_PAYLOAD_CODE) {
|
|
823
|
-
workerReportTraceCh.publish(payload)
|
|
824
|
-
return
|
|
825
|
-
}
|
|
826
|
-
}
|
|
1457
|
+
// If it's a dd-trace message, stop cucumber processing or cucumber will throw an error.
|
|
1458
|
+
if (handleDdWorkerMessage(message)) return
|
|
827
1459
|
|
|
828
1460
|
const envelope = isNewVersion ? message.envelope : message.jsonEnvelope
|
|
829
1461
|
|
|
@@ -840,6 +1472,7 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
840
1472
|
return parseWorkerMessageFunction.apply(this, arguments)
|
|
841
1473
|
}
|
|
842
1474
|
}
|
|
1475
|
+
if (handleDdWorkerMessage(parsed)) return
|
|
843
1476
|
let pickle
|
|
844
1477
|
|
|
845
1478
|
if (parsed.testCaseStarted) {
|
|
@@ -849,15 +1482,7 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
849
1482
|
const { pickleId } = this.eventDataCollector.testCaseMap[parsed.testCaseStarted.testCaseId]
|
|
850
1483
|
pickle = this.eventDataCollector.getPickle(pickleId)
|
|
851
1484
|
}
|
|
852
|
-
|
|
853
|
-
const testFileAbsolutePath = pickle.uri
|
|
854
|
-
// First test in suite
|
|
855
|
-
if (!pickleResultByFile[testFileAbsolutePath]) {
|
|
856
|
-
pickleResultByFile[testFileAbsolutePath] = []
|
|
857
|
-
testSuiteStartCh.publish({
|
|
858
|
-
testFileAbsolutePath,
|
|
859
|
-
})
|
|
860
|
-
}
|
|
1485
|
+
maybeStartParallelSuite(pickle)
|
|
861
1486
|
}
|
|
862
1487
|
|
|
863
1488
|
const parseWorkerResponse = parseWorkerMessageFunction.apply(this, arguments)
|
|
@@ -875,49 +1500,15 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
875
1500
|
pickle = testCase.pickle
|
|
876
1501
|
}
|
|
877
1502
|
|
|
878
|
-
|
|
879
|
-
let isNew = false
|
|
880
|
-
|
|
881
|
-
if (isKnownTestsEnabled) {
|
|
882
|
-
isNew = isNewTest(pickle.uri, pickle.name)
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
const testFileAbsolutePath = pickle.uri
|
|
886
|
-
const finished = pickleResultByFile[testFileAbsolutePath]
|
|
887
|
-
|
|
888
|
-
if (isEarlyFlakeDetectionEnabled && isNew) {
|
|
889
|
-
const testFullname = `${pickle.uri}:${pickle.name}`
|
|
890
|
-
let testStatuses = newTestsByTestFullname.get(testFullname)
|
|
891
|
-
if (testStatuses) {
|
|
892
|
-
testStatuses.push(status)
|
|
893
|
-
} else {
|
|
894
|
-
testStatuses = [status]
|
|
895
|
-
newTestsByTestFullname.set(testFullname, testStatuses)
|
|
896
|
-
}
|
|
897
|
-
// We have finished all retries
|
|
898
|
-
if (testStatuses.length === earlyFlakeDetectionNumRetries + 1) {
|
|
899
|
-
const newTestFinalStatus = getTestStatusFromRetries(testStatuses)
|
|
900
|
-
// we only push to `finished` if the retries have finished
|
|
901
|
-
finished.push(newTestFinalStatus)
|
|
902
|
-
}
|
|
903
|
-
} else {
|
|
904
|
-
// TODO: can we get error message?
|
|
905
|
-
const finished = pickleResultByFile[testFileAbsolutePath]
|
|
906
|
-
finished.push(status)
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
if (finished.length === pickleByFile[testFileAbsolutePath].length) {
|
|
910
|
-
testSuiteFinishCh.publish({
|
|
911
|
-
status: getSuiteStatusFromTestStatuses(finished),
|
|
912
|
-
testSuitePath: getTestSuitePath(testFileAbsolutePath, process.cwd()),
|
|
913
|
-
})
|
|
914
|
-
}
|
|
1503
|
+
handleParallelTestCaseFinished(pickle, worstTestStepResult)
|
|
915
1504
|
}
|
|
916
1505
|
|
|
917
1506
|
return parseWorkerResponse
|
|
918
1507
|
}
|
|
919
1508
|
}
|
|
920
1509
|
|
|
1510
|
+
module.exports.patchCucumberWorkerRunTestCase = patchCucumberWorkerRunTestCase
|
|
1511
|
+
|
|
921
1512
|
// Test start / finish for older versions. The only hook executed in workers when in parallel mode
|
|
922
1513
|
addHook({
|
|
923
1514
|
name: '@cucumber/cucumber',
|
|
@@ -984,19 +1575,25 @@ addHook({
|
|
|
984
1575
|
// `getWrappedRunTestCase` does two things:
|
|
985
1576
|
// - generates suite start and finish events in the main process,
|
|
986
1577
|
// - handles EFD in both the main process and the worker process.
|
|
1578
|
+
// Shimmer is required because this wrapper may invoke the original test case multiple times and mutate runtime options.
|
|
987
1579
|
addHook({
|
|
988
1580
|
name: '@cucumber/cucumber',
|
|
989
|
-
versions: ['>=11.0.0'],
|
|
1581
|
+
versions: ['>=11.0.0 <13.2.0'],
|
|
990
1582
|
file: 'lib/runtime/worker.js',
|
|
991
1583
|
}, (workerPackage) => {
|
|
992
|
-
|
|
993
|
-
workerPackage.Worker.prototype,
|
|
994
|
-
'runTestCase',
|
|
995
|
-
runTestCase => getWrappedRunTestCase(runTestCase, true, !!getEnvironmentVariable('CUCUMBER_WORKER_ID'))
|
|
996
|
-
)
|
|
1584
|
+
patchCucumberWorkerRunTestCase(workerPackage, !!getEnvironmentVariable('CUCUMBER_WORKER_ID'))
|
|
997
1585
|
return workerPackage
|
|
998
1586
|
})
|
|
999
1587
|
|
|
1588
|
+
addHook({
|
|
1589
|
+
name: '@cucumber/cucumber',
|
|
1590
|
+
versions: ['>=13.2.0'],
|
|
1591
|
+
file: 'lib/runtime/executor.js',
|
|
1592
|
+
}, (executorPackage) => {
|
|
1593
|
+
patchCucumberWorkerRunTestCase(executorPackage, !!getEnvironmentVariable('CUCUMBER_WORKER_ID'))
|
|
1594
|
+
return executorPackage
|
|
1595
|
+
})
|
|
1596
|
+
|
|
1000
1597
|
// `getWrappedStart` generates session start and finish events
|
|
1001
1598
|
addHook({
|
|
1002
1599
|
name: '@cucumber/cucumber',
|
|
@@ -1017,9 +1614,9 @@ addHook({
|
|
|
1017
1614
|
versions: ['>=11.0.0'],
|
|
1018
1615
|
file: 'lib/formatter/helpers/event_data_collector.js',
|
|
1019
1616
|
}, (eventDataCollectorPackage) => {
|
|
1020
|
-
shimmer.wrap(eventDataCollectorPackage.default.prototype, 'parseEnvelope', parseEnvelope => function () {
|
|
1617
|
+
shimmer.wrap(eventDataCollectorPackage.default.prototype, 'parseEnvelope', parseEnvelope => function (...args) {
|
|
1021
1618
|
eventDataCollector = this
|
|
1022
|
-
return parseEnvelope.apply(this,
|
|
1619
|
+
return parseEnvelope.apply(this, args)
|
|
1023
1620
|
})
|
|
1024
1621
|
return eventDataCollectorPackage
|
|
1025
1622
|
})
|
|
@@ -1029,7 +1626,7 @@ addHook({
|
|
|
1029
1626
|
// In `startWorker` we pass early flake detection info to the worker.
|
|
1030
1627
|
addHook({
|
|
1031
1628
|
name: '@cucumber/cucumber',
|
|
1032
|
-
versions: ['>=11.0.0'],
|
|
1629
|
+
versions: ['>=11.0.0 <13.0.0'],
|
|
1033
1630
|
file: 'lib/runtime/parallel/adapter.js',
|
|
1034
1631
|
}, (adapterPackage) => {
|
|
1035
1632
|
shimmer.wrap(
|
|
@@ -1038,45 +1635,44 @@ addHook({
|
|
|
1038
1635
|
parseWorkerMessage => getWrappedParseWorkerMessage(parseWorkerMessage, true)
|
|
1039
1636
|
)
|
|
1040
1637
|
// EFD in parallel mode only supported in >=11.0.0
|
|
1041
|
-
shimmer.wrap(adapterPackage.ChildProcessAdapter.prototype, 'startWorker', startWorker => function () {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
1045
|
-
this.options.worldParameters._ddKnownTests = knownTests
|
|
1046
|
-
this.options.worldParameters._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
1047
|
-
} else {
|
|
1048
|
-
isEarlyFlakeDetectionEnabled = false
|
|
1049
|
-
isKnownTestsEnabled = false
|
|
1050
|
-
this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled = false
|
|
1051
|
-
this.options.worldParameters._ddIsKnownTestsEnabled = false
|
|
1052
|
-
this.options.worldParameters._ddEarlyFlakeDetectionNumRetries = 0
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
if (isImpactedTestsEnabled) {
|
|
1056
|
-
this.options.worldParameters._ddImpactedTestsEnabled = isImpactedTestsEnabled
|
|
1057
|
-
this.options.worldParameters._ddModifiedFiles = modifiedFiles
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
this.options.worldParameters._ddIsFlakyTestRetriesEnabled = isFlakyTestRetriesEnabled
|
|
1061
|
-
this.options.worldParameters._ddNumTestRetries = numTestRetries
|
|
1062
|
-
|
|
1063
|
-
if (isTestManagementTestsEnabled) {
|
|
1064
|
-
this.options.worldParameters._ddIsTestManagementTestsEnabled = true
|
|
1065
|
-
this.options.worldParameters._ddTestManagementTests = testManagementTests
|
|
1066
|
-
this.options.worldParameters._ddTestManagementAttemptToFixRetries = testManagementAttemptToFixRetries
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
return startWorker.apply(this, arguments)
|
|
1638
|
+
shimmer.wrap(adapterPackage.ChildProcessAdapter.prototype, 'startWorker', startWorker => function (...args) {
|
|
1639
|
+
configureParallelWorkerWorldParameters(this.options)
|
|
1640
|
+
return startWorker.apply(this, args)
|
|
1070
1641
|
})
|
|
1071
1642
|
return adapterPackage
|
|
1072
1643
|
})
|
|
1073
1644
|
|
|
1645
|
+
// Only executed in parallel mode for >=13, in the main process.
|
|
1646
|
+
// Cucumber v13 uses worker_threads and receives worker events via MessagePort.
|
|
1647
|
+
addHook({
|
|
1648
|
+
name: '@cucumber/cucumber',
|
|
1649
|
+
versions: ['>=13.0.0'],
|
|
1650
|
+
file: 'lib/runtime/parallel/adapter.js',
|
|
1651
|
+
}, (adapterPackage) => {
|
|
1652
|
+
shimmer.wrap(
|
|
1653
|
+
adapterPackage.WorkerThreadsAdapter.prototype,
|
|
1654
|
+
'setup',
|
|
1655
|
+
setup => getWrappedWorkerThreadsSetup(setup)
|
|
1656
|
+
)
|
|
1657
|
+
shimmer.wrap(
|
|
1658
|
+
adapterPackage.WorkerThreadsAdapter.prototype,
|
|
1659
|
+
'handleEventFromWorker',
|
|
1660
|
+
handleEventFromWorker => getWrappedHandleWorkerThreadEvent(handleEventFromWorker)
|
|
1661
|
+
)
|
|
1662
|
+
shimmer.wrap(
|
|
1663
|
+
adapterPackage.WorkerThreadsAdapter.prototype,
|
|
1664
|
+
'teardown',
|
|
1665
|
+
teardown => getWrappedWorkerThreadsTeardown(teardown)
|
|
1666
|
+
)
|
|
1667
|
+
return adapterPackage
|
|
1668
|
+
})
|
|
1669
|
+
|
|
1074
1670
|
// Hook executed in the worker process when in parallel mode.
|
|
1075
1671
|
// In this hook we read the information passed in `worldParameters` and make it available for
|
|
1076
1672
|
// `getWrappedRunTestCase`.
|
|
1077
1673
|
addHook({
|
|
1078
1674
|
name: '@cucumber/cucumber',
|
|
1079
|
-
versions: ['>=11.0.0'],
|
|
1675
|
+
versions: ['>=11.0.0 <13.0.0'],
|
|
1080
1676
|
file: 'lib/runtime/parallel/worker.js',
|
|
1081
1677
|
}, (workerPackage) => {
|
|
1082
1678
|
shimmer.wrap(
|
|
@@ -1084,30 +1680,7 @@ addHook({
|
|
|
1084
1680
|
'initialize',
|
|
1085
1681
|
initialize => async function () {
|
|
1086
1682
|
await initialize.apply(this, arguments)
|
|
1087
|
-
|
|
1088
|
-
if (isKnownTestsEnabled) {
|
|
1089
|
-
knownTests = this.options.worldParameters._ddKnownTests
|
|
1090
|
-
// if for whatever reason the worker does not receive valid known tests, we disable EFD and known tests
|
|
1091
|
-
if (!isValidKnownTests(knownTests)) {
|
|
1092
|
-
isKnownTestsEnabled = false
|
|
1093
|
-
knownTests = {}
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
isEarlyFlakeDetectionEnabled = !!this.options.worldParameters._ddIsEarlyFlakeDetectionEnabled
|
|
1097
|
-
if (isEarlyFlakeDetectionEnabled) {
|
|
1098
|
-
earlyFlakeDetectionNumRetries = this.options.worldParameters._ddEarlyFlakeDetectionNumRetries
|
|
1099
|
-
}
|
|
1100
|
-
isImpactedTestsEnabled = !!this.options.worldParameters._ddImpactedTestsEnabled
|
|
1101
|
-
if (isImpactedTestsEnabled) {
|
|
1102
|
-
modifiedFiles = this.options.worldParameters._ddModifiedFiles
|
|
1103
|
-
}
|
|
1104
|
-
isFlakyTestRetriesEnabled = !!this.options.worldParameters._ddIsFlakyTestRetriesEnabled
|
|
1105
|
-
numTestRetries = this.options.worldParameters._ddNumTestRetries ?? 0
|
|
1106
|
-
isTestManagementTestsEnabled = !!this.options.worldParameters._ddIsTestManagementTestsEnabled
|
|
1107
|
-
if (isTestManagementTestsEnabled) {
|
|
1108
|
-
testManagementTests = this.options.worldParameters._ddTestManagementTests
|
|
1109
|
-
testManagementAttemptToFixRetries = this.options.worldParameters._ddTestManagementAttemptToFixRetries
|
|
1110
|
-
}
|
|
1683
|
+
readParallelWorkerWorldParameters(this.options)
|
|
1111
1684
|
}
|
|
1112
1685
|
)
|
|
1113
1686
|
return workerPackage
|