@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,15 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const { performance } = require('node:perf_hooks')
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
getTestSuitePath,
|
|
7
|
+
DYNAMIC_NAME_RE,
|
|
8
|
+
getEfdRetryCount,
|
|
9
|
+
getMaxEfdRetryCount,
|
|
10
|
+
recordAttemptToFixExecution,
|
|
11
|
+
logAttemptToFixTestExecution,
|
|
12
|
+
} = require('../../../dd-trace/src/plugins/util/test')
|
|
7
13
|
const { channel } = require('../helpers/instrument')
|
|
8
14
|
const shimmer = require('../../../datadog-shimmer')
|
|
9
15
|
|
|
10
16
|
// test channels
|
|
11
17
|
const testStartCh = channel('ci:mocha:test:start')
|
|
12
18
|
const testFinishCh = channel('ci:mocha:test:finish')
|
|
19
|
+
const testDiWaitCh = channel('ci:mocha:test:di:wait')
|
|
13
20
|
// after a test has failed, we'll publish to this channel
|
|
14
21
|
const testRetryCh = channel('ci:mocha:test:retry')
|
|
15
22
|
const errorCh = channel('ci:mocha:test:error')
|
|
@@ -19,17 +26,27 @@ const isModifiedCh = channel('ci:mocha:test:is-modified')
|
|
|
19
26
|
// suite channels
|
|
20
27
|
const testSuiteErrorCh = channel('ci:mocha:test-suite:error')
|
|
21
28
|
|
|
22
|
-
const BREAKPOINT_HIT_GRACE_PERIOD_MS = 200
|
|
23
29
|
const testToContext = new WeakMap()
|
|
24
30
|
const originalFns = new WeakMap()
|
|
25
31
|
const testToStartLine = new WeakMap()
|
|
26
32
|
const testFileToSuiteCtx = new Map()
|
|
27
33
|
const wrappedFunctions = new WeakSet()
|
|
28
34
|
const newTests = {}
|
|
35
|
+
const efdTests = {}
|
|
29
36
|
const newTestsWithDynamicNames = new Set()
|
|
30
37
|
const testsAttemptToFix = new Set()
|
|
31
38
|
const testsQuarantined = new Set()
|
|
32
39
|
const testsStatuses = new Map()
|
|
40
|
+
const efdRetryCountByTestFullName = new Map()
|
|
41
|
+
const efdSlowAbortedTests = new Set()
|
|
42
|
+
const attemptToFixExecutions = new Map()
|
|
43
|
+
|
|
44
|
+
function waitForHitProbe () {
|
|
45
|
+
const promises = {}
|
|
46
|
+
testDiWaitCh.publish({ promises })
|
|
47
|
+
return promises.hitBreakpointPromise
|
|
48
|
+
}
|
|
49
|
+
const loggedAttemptToFixTests = new Set()
|
|
33
50
|
|
|
34
51
|
function getAfterEachHooks (testOrHook) {
|
|
35
52
|
const hooks = []
|
|
@@ -63,11 +80,129 @@ function isNewTest (test, knownTests) {
|
|
|
63
80
|
return !testsForSuite.includes(testName)
|
|
64
81
|
}
|
|
65
82
|
|
|
66
|
-
function
|
|
83
|
+
function setEfdRetryCountForTest (test, duration, slowTestRetries) {
|
|
84
|
+
const testName = getTestFullName(test)
|
|
85
|
+
if (efdRetryCountByTestFullName.has(testName)) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
const retryCount = getEfdRetryCount(duration, slowTestRetries || {})
|
|
89
|
+
efdRetryCountByTestFullName.set(testName, retryCount)
|
|
90
|
+
if (retryCount === 0) {
|
|
91
|
+
efdSlowAbortedTests.add(testName)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function wrapOriginalEfdTest (test, slowTestRetries) {
|
|
96
|
+
if (test._ddEfdDurationWrapped || typeof test.fn !== 'function') {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
test._ddEfdDurationWrapped = true
|
|
100
|
+
const originalFn = test.fn
|
|
101
|
+
test.fn = shimmer.wrapFunction(originalFn, originalFn => function () {
|
|
102
|
+
const start = performance.now()
|
|
103
|
+
const recordDuration = () => {
|
|
104
|
+
setEfdRetryCountForTest(test, performance.now() - start, slowTestRetries)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (originalFn.length > 0) {
|
|
108
|
+
const args = Array.prototype.slice.call(arguments)
|
|
109
|
+
args[0] = shimmer.wrapFunction(args[0], done => function (...args) {
|
|
110
|
+
recordDuration()
|
|
111
|
+
return done.apply(this, args)
|
|
112
|
+
})
|
|
113
|
+
return originalFn.apply(this, args)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const result = originalFn.apply(this, arguments)
|
|
118
|
+
if (result?.then) {
|
|
119
|
+
return result.then(value => {
|
|
120
|
+
recordDuration()
|
|
121
|
+
return value
|
|
122
|
+
}, error => {
|
|
123
|
+
recordDuration()
|
|
124
|
+
throw error
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
recordDuration()
|
|
128
|
+
return result
|
|
129
|
+
} catch (error) {
|
|
130
|
+
recordDuration()
|
|
131
|
+
throw error
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Disables Mocha's native retry mechanism for Datadog-managed clone retries.
|
|
138
|
+
* @param {{ retries?: (count: number) => void }} test
|
|
139
|
+
* @returns {void}
|
|
140
|
+
*/
|
|
141
|
+
function disableMochaRetries (test) {
|
|
142
|
+
if (typeof test.retries === 'function') {
|
|
143
|
+
test.retries(0)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Checks whether a runnable belongs to a Datadog-managed clone retry feature.
|
|
149
|
+
* @param {{
|
|
150
|
+
* _ddIsAttemptToFix?: boolean,
|
|
151
|
+
* _ddIsEfdRetry?: boolean,
|
|
152
|
+
* _ddIsModified?: boolean,
|
|
153
|
+
* _ddIsNew?: boolean
|
|
154
|
+
* }} test
|
|
155
|
+
* @param {{ isEarlyFlakeDetectionEnabled?: boolean }} config
|
|
156
|
+
* @returns {boolean}
|
|
157
|
+
*/
|
|
158
|
+
function isDatadogManagedRetryTest (test, config) {
|
|
159
|
+
return test._ddIsAttemptToFix ||
|
|
160
|
+
test._ddIsEfdRetry ||
|
|
161
|
+
(config.isEarlyFlakeDetectionEnabled && (test._ddIsNew || test._ddIsModified))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Checks whether a runnable belongs to an Early Flake Detection execution.
|
|
166
|
+
* @param {{
|
|
167
|
+
* _ddIsAttemptToFix?: boolean,
|
|
168
|
+
* _ddIsEfdRetry?: boolean,
|
|
169
|
+
* _ddIsModified?: boolean,
|
|
170
|
+
* _ddIsNew?: boolean
|
|
171
|
+
* }} test
|
|
172
|
+
* @param {{ isEarlyFlakeDetectionEnabled?: boolean }} config
|
|
173
|
+
* @returns {boolean}
|
|
174
|
+
*/
|
|
175
|
+
function isEarlyFlakeDetectionTest (test, config) {
|
|
176
|
+
return !test._ddIsAttemptToFix &&
|
|
177
|
+
config.isEarlyFlakeDetectionEnabled &&
|
|
178
|
+
(test._ddIsEfdRetry || test._ddIsNew || test._ddIsModified)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function retryTest (test, numRetries, tags, slowTestRetries) {
|
|
67
182
|
const suite = test.parent
|
|
183
|
+
const isEfdRetry = tags.includes('_ddIsEfdRetry')
|
|
184
|
+
disableMochaRetries(test)
|
|
185
|
+
if (isEfdRetry) {
|
|
186
|
+
wrapOriginalEfdTest(test, slowTestRetries)
|
|
187
|
+
}
|
|
68
188
|
for (let retryIndex = 0; retryIndex < numRetries; retryIndex++) {
|
|
69
189
|
const clonedTest = test.clone()
|
|
190
|
+
disableMochaRetries(clonedTest)
|
|
70
191
|
suite.addTest(clonedTest)
|
|
192
|
+
if (isEfdRetry) {
|
|
193
|
+
clonedTest._ddEfdRetryIndex = retryIndex + 1
|
|
194
|
+
const originalFn = clonedTest.fn
|
|
195
|
+
if (typeof originalFn === 'function') {
|
|
196
|
+
clonedTest.fn = shimmer.wrapFunction(originalFn, originalFn => function (...args) {
|
|
197
|
+
const efdRetryCount = efdRetryCountByTestFullName.get(getTestFullName(clonedTest))
|
|
198
|
+
if (efdRetryCount !== undefined && clonedTest._ddEfdRetryIndex > efdRetryCount) {
|
|
199
|
+
clonedTest._ddShouldSkipEfdRetry = true
|
|
200
|
+
this.skip()
|
|
201
|
+
}
|
|
202
|
+
return originalFn.apply(this, args)
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
}
|
|
71
206
|
for (const tag of tags) {
|
|
72
207
|
if (tag) {
|
|
73
208
|
clonedTest[tag] = true
|
|
@@ -76,6 +211,14 @@ function retryTest (test, numRetries, tags) {
|
|
|
76
211
|
}
|
|
77
212
|
}
|
|
78
213
|
|
|
214
|
+
function getConfiguredEfdRetryCount (config) {
|
|
215
|
+
const { earlyFlakeDetectionSlowTestRetries } = config
|
|
216
|
+
if (!earlyFlakeDetectionSlowTestRetries || !Object.keys(earlyFlakeDetectionSlowTestRetries).length) {
|
|
217
|
+
return config.earlyFlakeDetectionNumRetries
|
|
218
|
+
}
|
|
219
|
+
return getMaxEfdRetryCount(earlyFlakeDetectionSlowTestRetries)
|
|
220
|
+
}
|
|
221
|
+
|
|
79
222
|
function getSuitesByTestFile (root) {
|
|
80
223
|
const suitesByTestFile = {}
|
|
81
224
|
function getSuites (suite) {
|
|
@@ -86,7 +229,6 @@ function getSuitesByTestFile (root) {
|
|
|
86
229
|
suitesByTestFile[suite.file] = [suite]
|
|
87
230
|
}
|
|
88
231
|
}
|
|
89
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
90
232
|
suite.suites.forEach(suite => {
|
|
91
233
|
getSuites(suite)
|
|
92
234
|
})
|
|
@@ -113,6 +255,21 @@ function getTestFullName (test) {
|
|
|
113
255
|
return `mocha.${getTestSuitePath(test.file, process.cwd())}.${test.fullTitle()}`
|
|
114
256
|
}
|
|
115
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Records every attempt for a test grouped by its full test name.
|
|
260
|
+
* @param {Record<string, Array<{ file: string, fullTitle: () => string }>>} testsByFullName
|
|
261
|
+
* @param {{ file: string, fullTitle: () => string }} test
|
|
262
|
+
* @returns {void}
|
|
263
|
+
*/
|
|
264
|
+
function recordTestAttempt (testsByFullName, test) {
|
|
265
|
+
const testFullName = getTestFullName(test)
|
|
266
|
+
if (testsByFullName[testFullName]) {
|
|
267
|
+
testsByFullName[testFullName].push(test)
|
|
268
|
+
} else {
|
|
269
|
+
testsByFullName[testFullName] = [test]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
116
273
|
function getTestStatus (test) {
|
|
117
274
|
if (test.isPending()) {
|
|
118
275
|
return 'skip'
|
|
@@ -130,8 +287,7 @@ function getTestToContextKey (test) {
|
|
|
130
287
|
if (!wrappedFunctions.has(test.fn)) {
|
|
131
288
|
return test.fn
|
|
132
289
|
}
|
|
133
|
-
|
|
134
|
-
return originalFn
|
|
290
|
+
return originalFns.get(test.fn)
|
|
135
291
|
}
|
|
136
292
|
|
|
137
293
|
function getTestContext (test) {
|
|
@@ -139,13 +295,37 @@ function getTestContext (test) {
|
|
|
139
295
|
return testToContext.get(key)
|
|
140
296
|
}
|
|
141
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Copies Test Management metadata from Mocha's original runnable to its native retry clone.
|
|
300
|
+
* @param {{
|
|
301
|
+
* _retriedTest?: {
|
|
302
|
+
* _ddIsDisabled?: boolean,
|
|
303
|
+
* _ddIsQuarantined?: boolean
|
|
304
|
+
* },
|
|
305
|
+
* _ddIsDisabled?: boolean,
|
|
306
|
+
* _ddIsQuarantined?: boolean
|
|
307
|
+
* }} test
|
|
308
|
+
*/
|
|
309
|
+
function inheritDatadogPropertiesFromRetriedTest (test) {
|
|
310
|
+
const retriedTest = test._retriedTest
|
|
311
|
+
if (!retriedTest) return
|
|
312
|
+
|
|
313
|
+
if (retriedTest._ddIsDisabled) {
|
|
314
|
+
test._ddIsDisabled = true
|
|
315
|
+
}
|
|
316
|
+
if (retriedTest._ddIsQuarantined) {
|
|
317
|
+
test._ddIsQuarantined = true
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (test._ddIsQuarantined && !test._ddIsAttemptToFix) {
|
|
321
|
+
testsQuarantined.add(test)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
142
325
|
function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
143
|
-
shimmer.wrap(RunnablePackage.prototype, 'run', run => function () {
|
|
326
|
+
shimmer.wrap(RunnablePackage.prototype, 'run', run => function (...args) {
|
|
144
327
|
if (!testFinishCh.hasSubscribers) {
|
|
145
|
-
return run.apply(this,
|
|
146
|
-
}
|
|
147
|
-
if (libraryConfig?.isFlakyTestRetriesEnabled) {
|
|
148
|
-
this.retries(libraryConfig?.flakyTestRetriesCount)
|
|
328
|
+
return run.apply(this, args)
|
|
149
329
|
}
|
|
150
330
|
// The reason why the wrapping logic is here is because we need to cover
|
|
151
331
|
// `afterEach` and `beforeEach` hooks as well.
|
|
@@ -154,6 +334,7 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
154
334
|
const isAfterEach = this.parent._afterEach.includes(this)
|
|
155
335
|
|
|
156
336
|
const isTestHook = isBeforeEach || isAfterEach
|
|
337
|
+
const test = isTestHook ? this.ctx.currentTest : this
|
|
157
338
|
|
|
158
339
|
// we restore the original user defined function
|
|
159
340
|
if (wrappedFunctions.has(this.fn)) {
|
|
@@ -162,14 +343,26 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
162
343
|
wrappedFunctions.delete(this.fn)
|
|
163
344
|
}
|
|
164
345
|
|
|
346
|
+
if (isDatadogManagedRetryTest(test, libraryConfig)) {
|
|
347
|
+
disableMochaRetries(this)
|
|
348
|
+
if (typeof args[0] === 'function') {
|
|
349
|
+
const onRunnableFinished = args[0]
|
|
350
|
+
args[0] = function () {
|
|
351
|
+
disableMochaRetries(test)
|
|
352
|
+
return onRunnableFinished.apply(this, arguments)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} else if (libraryConfig?.isFlakyTestRetriesEnabled) {
|
|
356
|
+
this.retries(libraryConfig.flakyTestRetriesCount)
|
|
357
|
+
}
|
|
358
|
+
|
|
165
359
|
if (isTestHook || this.type === 'test') {
|
|
166
|
-
const test = isTestHook ? this.ctx.currentTest : this
|
|
167
360
|
const ctx = getTestContext(test)
|
|
168
361
|
|
|
169
362
|
if (ctx) {
|
|
170
363
|
// we bind the test fn to the correct context
|
|
171
|
-
const newFn = shimmer.wrapFunction(this.fn, originalFn => function () {
|
|
172
|
-
return testFnCh.runStores(ctx, () => originalFn.apply(this,
|
|
364
|
+
const newFn = shimmer.wrapFunction(this.fn, originalFn => function (...args) {
|
|
365
|
+
return testFnCh.runStores(ctx, () => originalFn.apply(this, args))
|
|
173
366
|
})
|
|
174
367
|
|
|
175
368
|
// we store the original function, not to lose it
|
|
@@ -180,7 +373,7 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
180
373
|
}
|
|
181
374
|
}
|
|
182
375
|
|
|
183
|
-
return run.apply(this,
|
|
376
|
+
return run.apply(this, args)
|
|
184
377
|
})
|
|
185
378
|
return RunnablePackage
|
|
186
379
|
}
|
|
@@ -197,6 +390,8 @@ function getOnTestHandler (isMain) {
|
|
|
197
390
|
wrappedFunctions.delete(test.fn)
|
|
198
391
|
}
|
|
199
392
|
|
|
393
|
+
inheritDatadogPropertiesFromRetriedTest(test)
|
|
394
|
+
|
|
200
395
|
const {
|
|
201
396
|
file: testSuiteAbsolutePath,
|
|
202
397
|
title,
|
|
@@ -208,6 +403,17 @@ function getOnTestHandler (isMain) {
|
|
|
208
403
|
_ddIsModified: isModified,
|
|
209
404
|
} = test
|
|
210
405
|
|
|
406
|
+
test._ddStartTime = performance.now()
|
|
407
|
+
|
|
408
|
+
if (isEfdRetry) {
|
|
409
|
+
const efdRetryCount = efdRetryCountByTestFullName.get(getTestFullName(test))
|
|
410
|
+
if (efdRetryCount !== undefined && test._ddEfdRetryIndex > efdRetryCount) {
|
|
411
|
+
test.pending = true
|
|
412
|
+
test._ddShouldSkipEfdRetry = true
|
|
413
|
+
return
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
211
417
|
const testInfo = {
|
|
212
418
|
testName: test.fullTitle(),
|
|
213
419
|
testSuiteAbsolutePath,
|
|
@@ -229,14 +435,19 @@ function getOnTestHandler (isMain) {
|
|
|
229
435
|
if (testInfo.hasDynamicName) {
|
|
230
436
|
newTestsWithDynamicNames.add(`${getTestSuitePath(test.file, process.cwd())} › ${test.fullTitle()}`)
|
|
231
437
|
}
|
|
438
|
+
if (isAttemptToFix) {
|
|
439
|
+
logAttemptToFixTestExecution(
|
|
440
|
+
getTestSuitePath(test.file, process.cwd()),
|
|
441
|
+
test.fullTitle(),
|
|
442
|
+
loggedAttemptToFixTests
|
|
443
|
+
)
|
|
444
|
+
}
|
|
232
445
|
// We want to store the result of the new tests
|
|
233
446
|
if (isNew) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
newTests[testFullName] = [test]
|
|
239
|
-
}
|
|
447
|
+
recordTestAttempt(newTests, test)
|
|
448
|
+
}
|
|
449
|
+
if (!isAttemptToFix && (isNew || isModified)) {
|
|
450
|
+
recordTestAttempt(efdTests, test)
|
|
240
451
|
}
|
|
241
452
|
|
|
242
453
|
if (!isAttemptToFix && isDisabled) {
|
|
@@ -259,14 +470,25 @@ function getFinalStatus ({
|
|
|
259
470
|
isAttemptToFix,
|
|
260
471
|
isLastAttemptToFix,
|
|
261
472
|
attemptToFixPassed,
|
|
473
|
+
hasPassedAnyEfdAttempt,
|
|
262
474
|
isQuarantined,
|
|
263
475
|
isDisabled,
|
|
476
|
+
isFinalAttempt,
|
|
264
477
|
}) {
|
|
265
478
|
// Note that intermediate executions DO NOT report a final status tag
|
|
266
479
|
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
480
|
+
// Intermediate executions must not carry a final status, regardless of quarantine/disabled state
|
|
481
|
+
const isExternalIntermediateExecution = !isEfdRetry && !isAttemptToFix && !isFinalAttempt
|
|
482
|
+
const isIntermediateExecution =
|
|
483
|
+
(isEfdRetry && !isLastEfdRetry) ||
|
|
484
|
+
(isAttemptToFix && !isLastAttemptToFix) ||
|
|
485
|
+
isExternalIntermediateExecution
|
|
486
|
+
if (isIntermediateExecution) {
|
|
487
|
+
return
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// If the test is quarantined or disabled, its final status is skip unless attempt-to-fix takes precedence.
|
|
491
|
+
if (!isAttemptToFix && (isQuarantined || isDisabled)) {
|
|
270
492
|
return 'skip'
|
|
271
493
|
}
|
|
272
494
|
|
|
@@ -280,123 +502,166 @@ function getFinalStatus ({
|
|
|
280
502
|
return hasFailedAllRetries ? 'fail' : 'pass'
|
|
281
503
|
}
|
|
282
504
|
if (isEfdRetry && isLastEfdRetry) {
|
|
283
|
-
return
|
|
505
|
+
return hasPassedAnyEfdAttempt ? 'pass' : 'fail'
|
|
284
506
|
}
|
|
285
507
|
if (isAttemptToFix && isLastAttemptToFix) {
|
|
286
508
|
return attemptToFixPassed ? 'pass' : 'fail'
|
|
287
509
|
}
|
|
288
510
|
}
|
|
289
511
|
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
let hasFailedAllRetries = false
|
|
306
|
-
let attemptToFixPassed = false
|
|
307
|
-
let attemptToFixFailed = false
|
|
308
|
-
|
|
309
|
-
const testName = getTestFullName(test)
|
|
512
|
+
function getTestFinishInfo (test, status, config, error) {
|
|
513
|
+
let hasFailedAllRetries = false
|
|
514
|
+
let attemptToFixPassed = false
|
|
515
|
+
let attemptToFixFailed = false
|
|
516
|
+
|
|
517
|
+
const testName = getTestFullName(test)
|
|
518
|
+
if (
|
|
519
|
+
isEarlyFlakeDetectionTest(test, config) &&
|
|
520
|
+
!test._ddIsEfdRetry &&
|
|
521
|
+
!efdRetryCountByTestFullName.has(testName)
|
|
522
|
+
) {
|
|
523
|
+
const duration = test.duration > 0 ? test.duration : performance.now() - test._ddStartTime
|
|
524
|
+
setEfdRetryCountForTest(test, duration, config.earlyFlakeDetectionSlowTestRetries)
|
|
525
|
+
}
|
|
310
526
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
527
|
+
if (testsStatuses.get(testName)) {
|
|
528
|
+
testsStatuses.get(testName).push(status)
|
|
529
|
+
} else {
|
|
530
|
+
testsStatuses.set(testName, [status])
|
|
531
|
+
}
|
|
532
|
+
const testStatuses = testsStatuses.get(testName)
|
|
317
533
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
534
|
+
const isLastAttempt = testStatuses.length === config.testManagementAttemptToFixRetries + 1
|
|
535
|
+
const efdRetryCount = efdRetryCountByTestFullName.get(testName) ?? getConfiguredEfdRetryCount(config)
|
|
536
|
+
const isLastEfdRetry = testStatuses.length === efdRetryCount + 1
|
|
537
|
+
const isLastAtrAttempt = getIsLastRetry(test) || (config.isFlakyTestRetriesEnabled && status === 'pass')
|
|
321
538
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
539
|
+
// Needed for the getFinalStatus call. This is because EFD does NOT tag as
|
|
540
|
+
// EFD retry the first run of the test. It only tags as retries the clones
|
|
541
|
+
const isEfdRetry = isEarlyFlakeDetectionTest(test, config)
|
|
325
542
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
if (testStatuses.every(status => status === 'fail')) {
|
|
331
|
-
hasFailedAllRetries = true
|
|
332
|
-
} else if (testStatuses.every(status => status === 'pass')) {
|
|
333
|
-
attemptToFixPassed = true
|
|
334
|
-
}
|
|
543
|
+
if (test._ddIsAttemptToFix && isLastAttempt) {
|
|
544
|
+
if (testStatuses.includes('fail')) {
|
|
545
|
+
attemptToFixFailed = true
|
|
335
546
|
}
|
|
336
|
-
|
|
337
|
-
if (test._ddIsEfdRetry && isLastEfdRetry &&
|
|
338
|
-
testStatuses.every(status => status === 'fail')) {
|
|
547
|
+
if (testStatuses.every(status => status === 'fail')) {
|
|
339
548
|
hasFailedAllRetries = true
|
|
549
|
+
} else if (testStatuses.every(status => status === 'pass')) {
|
|
550
|
+
attemptToFixPassed = true
|
|
340
551
|
}
|
|
552
|
+
}
|
|
341
553
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
554
|
+
if (test._ddIsEfdRetry && efdRetryCount > 0 && isLastEfdRetry &&
|
|
555
|
+
testStatuses.every(status => status === 'fail')) {
|
|
556
|
+
hasFailedAllRetries = true
|
|
557
|
+
}
|
|
347
558
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
559
|
+
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
560
|
+
if (config.isFlakyTestRetriesEnabled && !test._ddIsAttemptToFix && !test._ddIsEfdRetry &&
|
|
561
|
+
getIsLastRetry(test) && testStatuses.every(status => status === 'fail')) {
|
|
562
|
+
hasFailedAllRetries = true
|
|
563
|
+
}
|
|
352
564
|
|
|
353
|
-
|
|
354
|
-
|
|
565
|
+
const isAttemptToFixRetry = test._ddIsAttemptToFix && testStatuses.length > 1
|
|
566
|
+
const isAtrRetry = config.isFlakyTestRetriesEnabled &&
|
|
567
|
+
!test._ddIsAttemptToFix &&
|
|
568
|
+
!test._ddIsEfdRetry
|
|
569
|
+
const isFinalAttempt = status !== 'fail' || test._currentRetry >= test._retries
|
|
570
|
+
|
|
571
|
+
const { isFlakyTestRetriesEnabled } = config
|
|
572
|
+
const { _ddIsAttemptToFix, _ddIsQuarantined, _ddIsDisabled } = test
|
|
573
|
+
|
|
574
|
+
const finalStatus = getFinalStatus({
|
|
575
|
+
status,
|
|
576
|
+
hasFailedAllRetries,
|
|
577
|
+
isFlakyTestRetriesEnabled,
|
|
578
|
+
isLastAtrAttempt,
|
|
579
|
+
isEfdRetry,
|
|
580
|
+
isLastEfdRetry,
|
|
581
|
+
isAttemptToFix: _ddIsAttemptToFix,
|
|
582
|
+
isLastAttemptToFix: isLastAttempt,
|
|
583
|
+
attemptToFixPassed,
|
|
584
|
+
hasPassedAnyEfdAttempt: testStatuses.includes('pass'),
|
|
585
|
+
isQuarantined: _ddIsQuarantined,
|
|
586
|
+
isDisabled: _ddIsDisabled,
|
|
587
|
+
isFinalAttempt,
|
|
588
|
+
})
|
|
355
589
|
|
|
356
|
-
|
|
590
|
+
if (_ddIsAttemptToFix) {
|
|
591
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
592
|
+
testSuite: getTestSuitePath(test.file, process.cwd()),
|
|
593
|
+
testName: test.fullTitle(),
|
|
357
594
|
status,
|
|
358
|
-
hasFailedAllRetries,
|
|
359
|
-
isFlakyTestRetriesEnabled,
|
|
360
|
-
isLastAtrAttempt,
|
|
361
|
-
isEfdRetry,
|
|
362
|
-
isLastEfdRetry,
|
|
363
|
-
isAttemptToFix: _ddIsAttemptToFix,
|
|
364
|
-
isLastAttemptToFix: isLastAttempt,
|
|
365
|
-
attemptToFixPassed,
|
|
366
|
-
isQuarantined: _ddIsQuarantined,
|
|
367
595
|
isDisabled: _ddIsDisabled,
|
|
596
|
+
isQuarantined: _ddIsQuarantined,
|
|
368
597
|
})
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return {
|
|
601
|
+
hasFailedAllRetries,
|
|
602
|
+
attemptToFixPassed,
|
|
603
|
+
attemptToFixFailed,
|
|
604
|
+
isAttemptToFixRetry,
|
|
605
|
+
isAtrRetry,
|
|
606
|
+
finalStatus,
|
|
607
|
+
earlyFlakeAbortReason: efdSlowAbortedTests.has(testName) ? 'slow' : undefined,
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function getOnTestEndHandler (config, finalAttemptHandlers) {
|
|
612
|
+
return async function (test) {
|
|
613
|
+
if (test._ddShouldSkipEfdRetry) {
|
|
614
|
+
return
|
|
615
|
+
}
|
|
616
|
+
const ctx = getTestContext(test)
|
|
617
|
+
const status = getTestStatus(test)
|
|
618
|
+
const shouldFinishTest = ctx && (!getAfterEachHooks(test).length || (test._ddIsDisabled && !test._ddIsAttemptToFix))
|
|
619
|
+
let testFinishInfo
|
|
620
|
+
let isFinalAttempt = false
|
|
369
621
|
|
|
370
622
|
// If there are afterEach to be run, we don't finish the test yet.
|
|
371
623
|
// Disabled tests (marked pending by us) are finished immediately without waiting for afterEach hooks.
|
|
372
624
|
// In older mocha versions, pending tests don't run afterEach hooks, so we can't rely on
|
|
373
625
|
// getOnHookEndHandler to finish the test. This mirrors Jest's approach where the skip handler
|
|
374
626
|
// directly sets finalStatus without waiting for hooks
|
|
375
|
-
if (ctx &&
|
|
627
|
+
if (!ctx && test.isPending()) {
|
|
628
|
+
test._ddIsFinalAttempt = true
|
|
629
|
+
isFinalAttempt = true
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (shouldFinishTest) {
|
|
633
|
+
testFinishInfo = getTestFinishInfo(test, status, config, ctx.err || test.err)
|
|
634
|
+
if (testFinishInfo.finalStatus !== undefined) {
|
|
635
|
+
test._ddIsFinalAttempt = true
|
|
636
|
+
isFinalAttempt = true
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (isFinalAttempt) {
|
|
641
|
+
finalAttemptHandlers?.onStart?.(test)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (test._retriedTest?._ddShouldWaitForHitProbe) {
|
|
645
|
+
await waitForHitProbe()
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (shouldFinishTest) {
|
|
376
649
|
testFinishCh.publish({
|
|
377
650
|
status,
|
|
378
651
|
hasBeenRetried: isMochaRetry(test),
|
|
379
652
|
isLastRetry: getIsLastRetry(test),
|
|
380
|
-
|
|
381
|
-
attemptToFixPassed,
|
|
382
|
-
attemptToFixFailed,
|
|
383
|
-
isAttemptToFixRetry,
|
|
384
|
-
isAtrRetry,
|
|
653
|
+
...testFinishInfo,
|
|
385
654
|
...ctx.currentStore,
|
|
386
|
-
finalStatus,
|
|
387
655
|
})
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
ctx.attemptToFixFailed = attemptToFixFailed
|
|
393
|
-
ctx.isAttemptToFixRetry = isAttemptToFixRetry
|
|
394
|
-
ctx.isAtrRetry = isAtrRetry
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (isFinalAttempt) {
|
|
659
|
+
finalAttemptHandlers?.onFinish?.(test)
|
|
395
660
|
}
|
|
396
661
|
}
|
|
397
662
|
}
|
|
398
663
|
|
|
399
|
-
function getOnHookEndHandler () {
|
|
664
|
+
function getOnHookEndHandler (config, finalAttemptHandlers) {
|
|
400
665
|
return function (hook) {
|
|
401
666
|
const test = hook.ctx.currentTest
|
|
402
667
|
const afterEachHooks = getAfterEachHooks(hook)
|
|
@@ -407,26 +672,121 @@ function getOnHookEndHandler () {
|
|
|
407
672
|
const ctx = getTestContext(test)
|
|
408
673
|
// Disabled tests are already finished in getOnTestEndHandler,
|
|
409
674
|
// skip to avoid double-publishing
|
|
410
|
-
if (ctx && !test._ddIsDisabled) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
675
|
+
if (ctx && (!test._ddIsDisabled || test._ddIsAttemptToFix)) {
|
|
676
|
+
const testFinishInfo = getTestFinishInfo(test, status, config, ctx.err || test.err)
|
|
677
|
+
const isFinalAttempt = testFinishInfo.finalStatus !== undefined
|
|
678
|
+
const publishTestFinish = () => {
|
|
679
|
+
testFinishCh.publish({
|
|
680
|
+
status,
|
|
681
|
+
hasBeenRetried: isMochaRetry(test),
|
|
682
|
+
isLastRetry: getIsLastRetry(test),
|
|
683
|
+
...testFinishInfo,
|
|
684
|
+
...ctx.currentStore,
|
|
685
|
+
})
|
|
686
|
+
if (isFinalAttempt) {
|
|
687
|
+
test._ddIsFinalAttempt = true
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (test._retriedTest?._ddShouldWaitForHitProbe) {
|
|
691
|
+
if (isFinalAttempt) {
|
|
692
|
+
finalAttemptHandlers?.onStart?.(test)
|
|
693
|
+
}
|
|
694
|
+
test._ddDeferredHookEnd = {
|
|
695
|
+
waitForHitProbePromise: waitForHitProbe(),
|
|
696
|
+
publishTestFinish,
|
|
697
|
+
onFinish: isFinalAttempt ? () => finalAttemptHandlers?.onFinish?.(test) : undefined,
|
|
698
|
+
}
|
|
699
|
+
return
|
|
700
|
+
}
|
|
701
|
+
publishTestFinish()
|
|
423
702
|
}
|
|
424
703
|
}
|
|
425
704
|
}
|
|
426
705
|
}
|
|
427
706
|
}
|
|
428
707
|
|
|
429
|
-
function
|
|
708
|
+
function finishDeferredHookEnd (test) {
|
|
709
|
+
const deferredHookEnd = test?._ddDeferredHookEnd
|
|
710
|
+
if (!deferredHookEnd) return
|
|
711
|
+
|
|
712
|
+
const finish = () => {
|
|
713
|
+
try {
|
|
714
|
+
return deferredHookEnd.publishTestFinish()
|
|
715
|
+
} finally {
|
|
716
|
+
deferredHookEnd.onFinish?.()
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
delete test._ddDeferredHookEnd
|
|
721
|
+
if (!deferredHookEnd.waitForHitProbePromise) return finish()
|
|
722
|
+
|
|
723
|
+
return deferredHookEnd.waitForHitProbePromise.then(
|
|
724
|
+
finish,
|
|
725
|
+
finish
|
|
726
|
+
)
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Runs a Failed Test Replay hookUp callback after pending DI operations that must happen first.
|
|
731
|
+
*
|
|
732
|
+
* @param {(...args: unknown[]) => unknown} fn - Original hookUp completion callback.
|
|
733
|
+
* @param {object} test - Mocha test currently owning the hook.
|
|
734
|
+
* @param {Promise<void>|undefined} failedTestReplayPromise - Pending Failed Test Replay wait, if any.
|
|
735
|
+
* @param {unknown} hookThis - Callback receiver.
|
|
736
|
+
* @param {IArguments} args - Arguments passed by Mocha.
|
|
737
|
+
* @returns {unknown}
|
|
738
|
+
*/
|
|
739
|
+
function runFailedTestReplayHookUpCallback (fn, test, failedTestReplayPromise, hookThis, args) {
|
|
740
|
+
const continueAfterProbe = () => {
|
|
741
|
+
const deferredHookEndPromise = finishDeferredHookEnd(test)
|
|
742
|
+
if (deferredHookEndPromise) {
|
|
743
|
+
return deferredHookEndPromise.then(() => fn.apply(hookThis, args), () => fn.apply(hookThis, args))
|
|
744
|
+
}
|
|
745
|
+
return fn.apply(hookThis, args)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (failedTestReplayPromise) {
|
|
749
|
+
return failedTestReplayPromise.then(continueAfterProbe, continueAfterProbe)
|
|
750
|
+
}
|
|
751
|
+
return continueAfterProbe()
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Wraps Mocha's hookUp completion callback so retries wait for DI before continuing.
|
|
756
|
+
*
|
|
757
|
+
* @param {(...args: unknown[]) => unknown} fn - Original hookUp completion callback.
|
|
758
|
+
* @param {object} test - Mocha test currently owning the hook.
|
|
759
|
+
* @param {Promise<void>|undefined} failedTestReplayPromise - Pending Failed Test Replay wait, if any.
|
|
760
|
+
* @returns {(...args: unknown[]) => unknown}
|
|
761
|
+
*/
|
|
762
|
+
function wrapFailedTestReplayHookUpCallback (fn, test, failedTestReplayPromise) {
|
|
763
|
+
return shimmer.wrapCallback(fn, fn => function () {
|
|
764
|
+
return runFailedTestReplayHookUpCallback(fn, test, failedTestReplayPromise, this, arguments)
|
|
765
|
+
})
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const patchedFailedTestReplayHookUp = new WeakSet()
|
|
769
|
+
|
|
770
|
+
function patchFailedTestReplayHookUp (Runner) {
|
|
771
|
+
if (patchedFailedTestReplayHookUp.has(Runner)) return
|
|
772
|
+
|
|
773
|
+
patchedFailedTestReplayHookUp.add(Runner)
|
|
774
|
+
shimmer.wrap(Runner.prototype, 'hookUp', hookUp => function (name, fn) {
|
|
775
|
+
const test = name === 'afterEach' && this.test
|
|
776
|
+
if (!test) {
|
|
777
|
+
return hookUp.apply(this, arguments)
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const failedTestReplayPromise = test._ddFailedTestReplayPromise
|
|
781
|
+
if (failedTestReplayPromise) {
|
|
782
|
+
delete test._ddFailedTestReplayPromise
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return hookUp.call(this, name, wrapFailedTestReplayHookUpCallback(fn, test, failedTestReplayPromise))
|
|
786
|
+
})
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function getOnFailHandler (isMain, config) {
|
|
430
790
|
return function (testOrHook, err) {
|
|
431
791
|
const testFile = testOrHook.file
|
|
432
792
|
let test = testOrHook
|
|
@@ -443,15 +803,26 @@ function getOnFailHandler (isMain) {
|
|
|
443
803
|
err.message = `${testOrHook.fullTitle()}: ${err.message}`
|
|
444
804
|
testContext.err = err
|
|
445
805
|
errorCh.runStores(testContext, () => {})
|
|
446
|
-
|
|
447
|
-
//
|
|
448
|
-
//
|
|
449
|
-
|
|
806
|
+
const testFinishInfo = getTestFinishInfo(test, 'fail', config, err)
|
|
807
|
+
// ATR never retries hook failures: this.retries(N) is set in runnableWrapper
|
|
808
|
+
// which only runs when the test function executes — hooks bypass that path,
|
|
809
|
+
// so _retries stays at -1 and getIsLastRetry returns false, leaving finalStatus
|
|
810
|
+
// undefined. We must also mark the attempt final when no clone-based retry
|
|
811
|
+
// mechanism (EFD original, EFD clone, ATF) has queued further attempts.
|
|
812
|
+
const noCloneRetries = !test._ddIsEfdRetry &&
|
|
813
|
+
!((test._ddIsNew || test._ddIsModified) && config.isEarlyFlakeDetectionEnabled) &&
|
|
814
|
+
!test._ddIsAttemptToFix
|
|
815
|
+
if (testFinishInfo.finalStatus !== undefined || noCloneRetries) {
|
|
816
|
+
test._ddIsFinalAttempt = true
|
|
817
|
+
}
|
|
818
|
+
// test.state is never set to 'failed' for hook failures (Mocha marks the hook,
|
|
819
|
+
// not the test). Flag it so finishRootSuiteForFile can compute the correct status.
|
|
820
|
+
test._ddHookFailed = true
|
|
450
821
|
testFinishCh.publish({
|
|
451
822
|
status: 'fail',
|
|
452
823
|
hasBeenRetried: isMochaRetry(test),
|
|
824
|
+
...testFinishInfo,
|
|
453
825
|
...testContext.currentStore,
|
|
454
|
-
finalStatus: isSkippedByManagement ? 'skip' : 'fail',
|
|
455
826
|
})
|
|
456
827
|
} else {
|
|
457
828
|
testContext.err = err
|
|
@@ -485,7 +856,24 @@ function getOnTestRetryHandler (config) {
|
|
|
485
856
|
config.isFlakyTestRetriesEnabled &&
|
|
486
857
|
!test._ddIsAttemptToFix &&
|
|
487
858
|
!test._ddIsEfdRetry
|
|
488
|
-
|
|
859
|
+
const promises = {}
|
|
860
|
+
testRetryCh.publish({
|
|
861
|
+
isFirstAttempt,
|
|
862
|
+
err,
|
|
863
|
+
willBeRetried,
|
|
864
|
+
test,
|
|
865
|
+
isAtrRetry,
|
|
866
|
+
promises,
|
|
867
|
+
...ctx.currentStore,
|
|
868
|
+
})
|
|
869
|
+
if (promises.setProbePromise && promises.finishTestPromise) {
|
|
870
|
+
test._ddFailedTestReplayPromise = Promise.all([
|
|
871
|
+
promises.setProbePromise,
|
|
872
|
+
promises.finishTestPromise,
|
|
873
|
+
]).then(() => {})
|
|
874
|
+
} else if (promises.setProbePromise || promises.finishTestPromise) {
|
|
875
|
+
test._ddFailedTestReplayPromise = promises.setProbePromise || promises.finishTestPromise
|
|
876
|
+
}
|
|
489
877
|
}
|
|
490
878
|
const key = getTestToContextKey(test)
|
|
491
879
|
testToContext.delete(key)
|
|
@@ -494,6 +882,9 @@ function getOnTestRetryHandler (config) {
|
|
|
494
882
|
|
|
495
883
|
function getOnPendingHandler () {
|
|
496
884
|
return function (test) {
|
|
885
|
+
if (test._ddShouldSkipEfdRetry) {
|
|
886
|
+
return
|
|
887
|
+
}
|
|
497
888
|
const testStartLine = testToStartLine.get(test)
|
|
498
889
|
const {
|
|
499
890
|
file: testSuiteAbsolutePath,
|
|
@@ -528,7 +919,6 @@ function getOnPendingHandler () {
|
|
|
528
919
|
function getRunTestsWrapper (runTests, config) {
|
|
529
920
|
return function (suite) {
|
|
530
921
|
if (config.isTestManagementTestsEnabled) {
|
|
531
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
532
922
|
suite.tests.forEach((test) => {
|
|
533
923
|
const { isAttemptToFix, isDisabled, isQuarantined } = getTestProperties(test, config.testManagementTests)
|
|
534
924
|
if (isAttemptToFix && !test.isPending()) {
|
|
@@ -552,7 +942,6 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
552
942
|
}
|
|
553
943
|
|
|
554
944
|
if (config.isImpactedTestsEnabled) {
|
|
555
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
556
945
|
suite.tests.forEach((test) => {
|
|
557
946
|
isModifiedCh.publish({
|
|
558
947
|
modifiedFiles: config.modifiedFiles,
|
|
@@ -563,8 +952,9 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
563
952
|
if (!test.isPending() && !test._ddIsAttemptToFix && config.isEarlyFlakeDetectionEnabled) {
|
|
564
953
|
retryTest(
|
|
565
954
|
test,
|
|
566
|
-
config
|
|
567
|
-
['_ddIsModified', '_ddIsEfdRetry']
|
|
955
|
+
getConfiguredEfdRetryCount(config),
|
|
956
|
+
['_ddIsModified', '_ddIsEfdRetry'],
|
|
957
|
+
config.earlyFlakeDetectionSlowTestRetries
|
|
568
958
|
)
|
|
569
959
|
}
|
|
570
960
|
}
|
|
@@ -575,15 +965,15 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
575
965
|
|
|
576
966
|
if (config.isKnownTestsEnabled) {
|
|
577
967
|
// by the time we reach `this.on('test')`, it is too late. We need to add retries here
|
|
578
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
579
968
|
suite.tests.forEach((test) => {
|
|
580
969
|
if (!test.isPending() && isNewTest(test, config.knownTests)) {
|
|
581
970
|
test._ddIsNew = true
|
|
582
971
|
if (config.isEarlyFlakeDetectionEnabled && !test._ddIsAttemptToFix && !test._ddIsModified) {
|
|
583
972
|
retryTest(
|
|
584
973
|
test,
|
|
585
|
-
config
|
|
586
|
-
['_ddIsNew', '_ddIsEfdRetry']
|
|
974
|
+
getConfiguredEfdRetryCount(config),
|
|
975
|
+
['_ddIsNew', '_ddIsEfdRetry'],
|
|
976
|
+
config.earlyFlakeDetectionSlowTestRetries
|
|
587
977
|
)
|
|
588
978
|
}
|
|
589
979
|
}
|
|
@@ -610,13 +1000,19 @@ module.exports = {
|
|
|
610
1000
|
getOnTestEndHandler,
|
|
611
1001
|
getOnTestRetryHandler,
|
|
612
1002
|
getOnHookEndHandler,
|
|
1003
|
+
finishDeferredHookEnd,
|
|
1004
|
+
wrapFailedTestReplayHookUpCallback,
|
|
1005
|
+
patchFailedTestReplayHookUp,
|
|
613
1006
|
getOnFailHandler,
|
|
614
1007
|
getOnPendingHandler,
|
|
615
1008
|
testFileToSuiteCtx,
|
|
616
1009
|
getRunTestsWrapper,
|
|
617
1010
|
newTests,
|
|
1011
|
+
efdTests,
|
|
618
1012
|
newTestsWithDynamicNames,
|
|
619
1013
|
testsQuarantined,
|
|
620
1014
|
testsAttemptToFix,
|
|
621
1015
|
testsStatuses,
|
|
1016
|
+
attemptToFixExecutions,
|
|
1017
|
+
loggedAttemptToFixTests,
|
|
622
1018
|
}
|