@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
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { performance } = require('node:perf_hooks')
|
|
4
|
+
|
|
5
|
+
const shimmer = require('../../datadog-shimmer')
|
|
6
|
+
const {
|
|
7
|
+
DYNAMIC_NAME_RE,
|
|
8
|
+
getEfdRetryCount,
|
|
9
|
+
recordAttemptToFixExecution,
|
|
10
|
+
logAttemptToFixTestExecution,
|
|
11
|
+
} = require('../../dd-trace/src/plugins/util/test')
|
|
12
|
+
const { addHook } = require('./helpers/instrument')
|
|
13
|
+
const {
|
|
14
|
+
testStartCh,
|
|
15
|
+
testFinishTimeCh,
|
|
16
|
+
testPassCh,
|
|
17
|
+
testErrorCh,
|
|
18
|
+
testDiWaitCh,
|
|
19
|
+
testSkipCh,
|
|
20
|
+
testFnCh,
|
|
21
|
+
testSuiteStartCh,
|
|
22
|
+
testSuiteFinishCh,
|
|
23
|
+
testSuiteErrorCh,
|
|
24
|
+
findExportByName,
|
|
25
|
+
getTestRunnerExport,
|
|
26
|
+
getTypeTasks,
|
|
27
|
+
getTestName,
|
|
28
|
+
getProvidedContext,
|
|
29
|
+
isFlakyTestRetriesEnabledForTask,
|
|
30
|
+
getVitestTestProperties,
|
|
31
|
+
} = require('./vitest-util')
|
|
32
|
+
|
|
33
|
+
const taskToCtx = new WeakMap()
|
|
34
|
+
const taskToTestProperties = new WeakMap()
|
|
35
|
+
const taskToStatuses = new WeakMap()
|
|
36
|
+
const taskToReportedErrorCount = new WeakMap()
|
|
37
|
+
const attemptToFixTaskToStatuses = new WeakMap()
|
|
38
|
+
const fileToHasConcurrentTests = new WeakMap()
|
|
39
|
+
const originalHookFns = new WeakMap()
|
|
40
|
+
const newTasks = new WeakSet()
|
|
41
|
+
const dynamicNameTasks = new WeakSet()
|
|
42
|
+
const disabledTasks = new WeakSet()
|
|
43
|
+
const quarantinedTasks = new WeakSet()
|
|
44
|
+
const attemptToFixTasks = new WeakSet()
|
|
45
|
+
const attemptToFixRetryTasks = new WeakSet()
|
|
46
|
+
const modifiedTasks = new WeakSet()
|
|
47
|
+
const efdRetryTasks = new WeakSet()
|
|
48
|
+
const efdDeterminedRetries = new WeakMap()
|
|
49
|
+
const efdSlowAbortedTasks = new WeakSet()
|
|
50
|
+
const efdExecutionStartByTask = new WeakMap()
|
|
51
|
+
const efdSkippedRetryResults = new WeakMap()
|
|
52
|
+
const attemptToFixExecutions = new Map()
|
|
53
|
+
const loggedAttemptToFixTests = new Set()
|
|
54
|
+
const switchedStatuses = new WeakSet()
|
|
55
|
+
let vitestGetFn = null
|
|
56
|
+
let vitestSetFn = null
|
|
57
|
+
let vitestGetHooks = null
|
|
58
|
+
|
|
59
|
+
function waitForHitProbe () {
|
|
60
|
+
const promises = {}
|
|
61
|
+
testDiWaitCh.publish({ promises })
|
|
62
|
+
return promises.hitBreakpointPromise
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getVitestTestStatus (test, retryCount) {
|
|
66
|
+
if (test.result.state !== 'fail' && (!test.repeats || (test.retry ?? 0) === retryCount)) {
|
|
67
|
+
return 'pass'
|
|
68
|
+
}
|
|
69
|
+
return 'fail'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getFinalAttemptToFixStatus (task, state, isSwitchedStatus, testCtx) {
|
|
73
|
+
if (isSwitchedStatus && attemptToFixTasks.has(task) && testCtx?.status) {
|
|
74
|
+
return testCtx.status
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return state === 'fail' ? 'fail' : 'pass'
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Return the normalized test suite path prepared by the main process for a Vitest task.
|
|
82
|
+
*
|
|
83
|
+
* @param {{ file: { filepath: string } }} task
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
function getTaskTestSuite (task) {
|
|
87
|
+
return taskToTestProperties.get(task)?.testSuite || task.file.filepath
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function recordFinalAttemptToFixExecution (task, status, providedContext) {
|
|
91
|
+
const statuses = attemptToFixTaskToStatuses.get(task)
|
|
92
|
+
if (statuses && statuses.length <= providedContext.testManagementAttemptToFixRetries) {
|
|
93
|
+
statuses.push(status)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
97
|
+
testSuite: getTaskTestSuite(task),
|
|
98
|
+
testName: getTestName(task),
|
|
99
|
+
status,
|
|
100
|
+
isDisabled: disabledTasks.has(task),
|
|
101
|
+
isQuarantined: quarantinedTasks.has(task),
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function disableFrameworkRetries (task) {
|
|
106
|
+
task.retry = 0
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getCurrentAttemptTestError (task, errors) {
|
|
110
|
+
if (!errors?.length) return
|
|
111
|
+
|
|
112
|
+
const previousErrorCount = taskToReportedErrorCount.get(task) ?? 0
|
|
113
|
+
const testError = errors[previousErrorCount] ?? errors[0]
|
|
114
|
+
taskToReportedErrorCount.set(task, errors.length)
|
|
115
|
+
return testError
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function wrapTestScopedFn (task, fn) {
|
|
119
|
+
return shimmer.wrapFunction(fn, fn => function (...args) {
|
|
120
|
+
return testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, args))
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function wrapBeforeEachCleanupResult (task, result) {
|
|
125
|
+
if (typeof result === 'function') {
|
|
126
|
+
return wrapTestScopedFn(task, result)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (result && typeof result.then === 'function') {
|
|
130
|
+
return result.then(cleanupFn => wrapBeforeEachCleanupResult(task, cleanupFn))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return result
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns whether a Vitest task tree includes any concurrent task.
|
|
138
|
+
*
|
|
139
|
+
* @param {Array<{ type?: string, concurrent?: boolean, tasks?: object[] }>|undefined} tasks
|
|
140
|
+
* @returns {boolean}
|
|
141
|
+
*/
|
|
142
|
+
function hasConcurrentTask (tasks) {
|
|
143
|
+
if (!tasks) return false
|
|
144
|
+
|
|
145
|
+
for (const task of tasks) {
|
|
146
|
+
if (task.concurrent === true) return true
|
|
147
|
+
if (hasConcurrentTask(task.tasks)) return true
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return false
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns whether a Vitest file includes any concurrent test.
|
|
155
|
+
*
|
|
156
|
+
* @param {{ tasks?: object[] }} file
|
|
157
|
+
* @returns {boolean}
|
|
158
|
+
*/
|
|
159
|
+
function hasConcurrentTests (file) {
|
|
160
|
+
const cached = fileToHasConcurrentTests.get(file)
|
|
161
|
+
if (cached !== undefined) return cached
|
|
162
|
+
|
|
163
|
+
const hasConcurrent = hasConcurrentTask(file.tasks)
|
|
164
|
+
fileToHasConcurrentTests.set(file, hasConcurrent)
|
|
165
|
+
return hasConcurrent
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Gets the task associated with a Vitest hook invocation.
|
|
170
|
+
*
|
|
171
|
+
* @param {unknown[]} args
|
|
172
|
+
* @param {object} fallbackTask
|
|
173
|
+
* @returns {object}
|
|
174
|
+
*/
|
|
175
|
+
function getTaskFromHookArgs (args, fallbackTask) {
|
|
176
|
+
return args[0]?.task || fallbackTask
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Wraps a Vitest hook so it runs inside the span context for the current test.
|
|
181
|
+
*
|
|
182
|
+
* @param {'beforeEach'|'afterEach'} hookType
|
|
183
|
+
* @param {Function} fn
|
|
184
|
+
* @param {object} fallbackTask
|
|
185
|
+
* @returns {Function}
|
|
186
|
+
*/
|
|
187
|
+
function wrapSuiteHookFn (hookType, fn, fallbackTask) {
|
|
188
|
+
return shimmer.wrapFunction(fn, fn => function (...args) {
|
|
189
|
+
const task = getTaskFromHookArgs(args, fallbackTask)
|
|
190
|
+
const result = testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, args))
|
|
191
|
+
|
|
192
|
+
if (hookType === 'beforeEach') {
|
|
193
|
+
return wrapBeforeEachCleanupResult(task, result)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return result
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function wrapVitestTestRunner (VitestTestRunner) {
|
|
201
|
+
// `onBeforeRunTask` is run before any repetition or attempt is run
|
|
202
|
+
// `onBeforeRunTask` is an async function
|
|
203
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeRunTask', onBeforeRunTask => function (task) {
|
|
204
|
+
const testName = getTestName(task)
|
|
205
|
+
|
|
206
|
+
const providedContext = getProvidedContext()
|
|
207
|
+
const {
|
|
208
|
+
isEarlyFlakeDetectionEnabled,
|
|
209
|
+
isKnownTestsEnabled,
|
|
210
|
+
numRepeats,
|
|
211
|
+
isTestManagementTestsEnabled,
|
|
212
|
+
testManagementAttemptToFixRetries,
|
|
213
|
+
isImpactedTestsEnabled,
|
|
214
|
+
} = providedContext
|
|
215
|
+
const testProperties = getVitestTestProperties(providedContext, task.file.filepath, testName)
|
|
216
|
+
taskToTestProperties.set(task, testProperties)
|
|
217
|
+
|
|
218
|
+
if (isTestManagementTestsEnabled) {
|
|
219
|
+
const {
|
|
220
|
+
isAttemptToFix,
|
|
221
|
+
isDisabled,
|
|
222
|
+
isQuarantined,
|
|
223
|
+
} = testProperties
|
|
224
|
+
if (isAttemptToFix) {
|
|
225
|
+
if (task.repeats !== testManagementAttemptToFixRetries) {
|
|
226
|
+
attemptToFixRetryTasks.add(task)
|
|
227
|
+
}
|
|
228
|
+
disableFrameworkRetries(task)
|
|
229
|
+
task.repeats = testManagementAttemptToFixRetries
|
|
230
|
+
attemptToFixTasks.add(task)
|
|
231
|
+
attemptToFixTaskToStatuses.set(task, [])
|
|
232
|
+
}
|
|
233
|
+
if (isQuarantined) {
|
|
234
|
+
quarantinedTasks.add(task)
|
|
235
|
+
}
|
|
236
|
+
if (isDisabled) {
|
|
237
|
+
disabledTasks.add(task)
|
|
238
|
+
if (!attemptToFixTasks.has(task)) {
|
|
239
|
+
// we only actually skip if the test is not being attempted to be fixed
|
|
240
|
+
task.mode = 'skip'
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (isImpactedTestsEnabled && testProperties.isModified) {
|
|
246
|
+
if (isEarlyFlakeDetectionEnabled) {
|
|
247
|
+
efdRetryTasks.add(task)
|
|
248
|
+
disableFrameworkRetries(task)
|
|
249
|
+
task.repeats = numRepeats
|
|
250
|
+
}
|
|
251
|
+
modifiedTasks.add(task)
|
|
252
|
+
taskToStatuses.set(task, [])
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (isKnownTestsEnabled && testProperties.isNew && !attemptToFixTasks.has(task)) {
|
|
256
|
+
if (isEarlyFlakeDetectionEnabled && !modifiedTasks.has(task)) {
|
|
257
|
+
efdRetryTasks.add(task)
|
|
258
|
+
disableFrameworkRetries(task)
|
|
259
|
+
task.repeats = numRepeats
|
|
260
|
+
}
|
|
261
|
+
newTasks.add(task)
|
|
262
|
+
taskToStatuses.set(task, [])
|
|
263
|
+
if (DYNAMIC_NAME_RE.test(testName)) {
|
|
264
|
+
dynamicNameTasks.add(task)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return onBeforeRunTask.apply(this, arguments)
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
// `onAfterRunTask` is run after all repetitions or attempts are run
|
|
272
|
+
// `onAfterRunTask` is an async function
|
|
273
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onAfterRunTask', onAfterRunTask => function (task) {
|
|
274
|
+
const { isEarlyFlakeDetectionEnabled, isTestManagementTestsEnabled } = getProvidedContext()
|
|
275
|
+
|
|
276
|
+
if (isTestManagementTestsEnabled) {
|
|
277
|
+
const isAttemptingToFix = attemptToFixTasks.has(task)
|
|
278
|
+
const isQuarantined = quarantinedTasks.has(task)
|
|
279
|
+
|
|
280
|
+
if (isAttemptingToFix) {
|
|
281
|
+
const statuses = attemptToFixTaskToStatuses.get(task)
|
|
282
|
+
if (task.result.state === 'pass' && statuses?.includes('fail')) {
|
|
283
|
+
switchedStatuses.add(task)
|
|
284
|
+
task.result.state = 'fail'
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (!isAttemptingToFix && isQuarantined) {
|
|
289
|
+
if (task.result.state === 'fail') {
|
|
290
|
+
switchedStatuses.add(task)
|
|
291
|
+
}
|
|
292
|
+
task.result.state = 'pass'
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (isEarlyFlakeDetectionEnabled && taskToStatuses.has(task) && !attemptToFixTasks.has(task)) {
|
|
297
|
+
const statuses = taskToStatuses.get(task)
|
|
298
|
+
// If the test has passed at least once, we consider it passed
|
|
299
|
+
if (statuses.includes('pass')) {
|
|
300
|
+
if (task.result.state === 'fail') {
|
|
301
|
+
switchedStatuses.add(task)
|
|
302
|
+
}
|
|
303
|
+
task.result.state = 'pass'
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return onAfterRunTask.apply(this, arguments)
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
// test start (only tests that are not marked as skip or todo)
|
|
311
|
+
// `onBeforeTryTask` is run for every repetition and attempt of the test
|
|
312
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeTryTask', onBeforeTryTask => async function (task, retryInfo) {
|
|
313
|
+
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
314
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
315
|
+
}
|
|
316
|
+
const testName = getTestName(task)
|
|
317
|
+
let isNew = false
|
|
318
|
+
const providedContext = getProvidedContext()
|
|
319
|
+
const {
|
|
320
|
+
isKnownTestsEnabled,
|
|
321
|
+
isEarlyFlakeDetectionEnabled,
|
|
322
|
+
isDiEnabled,
|
|
323
|
+
slowTestRetries,
|
|
324
|
+
} = providedContext
|
|
325
|
+
|
|
326
|
+
if (isKnownTestsEnabled) {
|
|
327
|
+
isNew = newTasks.has(task)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const { retry: numAttempt, repeats: numRepetition } = retryInfo
|
|
331
|
+
const isFailedTestReplayAllowed = !hasConcurrentTests(task.file)
|
|
332
|
+
const isEfdManagedTask = isEarlyFlakeDetectionEnabled && taskToStatuses.has(task) && !attemptToFixTasks.has(task)
|
|
333
|
+
|
|
334
|
+
if (isEfdManagedTask && numRepetition > 0 && !efdDeterminedRetries.has(task)) {
|
|
335
|
+
const previousExecutionStart = efdExecutionStartByTask.get(task)
|
|
336
|
+
const duration = previousExecutionStart === undefined
|
|
337
|
+
? task.result?.duration ?? 0
|
|
338
|
+
: performance.now() - previousExecutionStart
|
|
339
|
+
const retryCount = getEfdRetryCount(duration, slowTestRetries)
|
|
340
|
+
efdDeterminedRetries.set(task, retryCount)
|
|
341
|
+
task.repeats = retryCount
|
|
342
|
+
if (retryCount === 0) {
|
|
343
|
+
efdSlowAbortedTasks.add(task)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const efdRetryCount = efdDeterminedRetries.get(task)
|
|
348
|
+
if (isEfdManagedTask && efdRetryCount !== undefined && numRepetition > efdRetryCount) {
|
|
349
|
+
if (task.result) {
|
|
350
|
+
efdSkippedRetryResults.set(task, {
|
|
351
|
+
...task.result,
|
|
352
|
+
errors: task.result.errors?.slice(),
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
if (vitestSetFn) {
|
|
356
|
+
const noop = function () {}
|
|
357
|
+
noop.__ddTraceWrapped = true
|
|
358
|
+
vitestSetFn(task, noop)
|
|
359
|
+
}
|
|
360
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
361
|
+
}
|
|
362
|
+
if (isEfdManagedTask) {
|
|
363
|
+
efdExecutionStartByTask.set(task, performance.now())
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// We finish the previous test here because we know it has failed already
|
|
367
|
+
if (numAttempt > 0) {
|
|
368
|
+
const shouldWaitForHitProbe = isDiEnabled && isFailedTestReplayAllowed && numAttempt > 1
|
|
369
|
+
if (shouldWaitForHitProbe) {
|
|
370
|
+
await waitForHitProbe()
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const promises = {}
|
|
374
|
+
const shouldSetProbe = isDiEnabled && isFailedTestReplayAllowed && numAttempt === 1
|
|
375
|
+
const ctx = taskToCtx.get(task)
|
|
376
|
+
const testError = getCurrentAttemptTestError(task, task.result?.errors)
|
|
377
|
+
if (ctx) {
|
|
378
|
+
testErrorCh.publish({
|
|
379
|
+
error: testError,
|
|
380
|
+
shouldSetProbe,
|
|
381
|
+
shouldWaitForHitProbe,
|
|
382
|
+
promises,
|
|
383
|
+
...ctx.currentStore,
|
|
384
|
+
})
|
|
385
|
+
// We wait for the probe to be set
|
|
386
|
+
if (promises.setProbePromise) {
|
|
387
|
+
await promises.setProbePromise
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const lastExecutionStatus = task.result.state
|
|
393
|
+
const isAtf = attemptToFixTasks.has(task)
|
|
394
|
+
const shouldTrackStatuses = isEarlyFlakeDetectionEnabled || isAtf
|
|
395
|
+
const shouldFlipStatus = isEarlyFlakeDetectionEnabled || isAtf
|
|
396
|
+
const statuses = isAtf ? attemptToFixTaskToStatuses.get(task) : taskToStatuses.get(task)
|
|
397
|
+
|
|
398
|
+
// These clauses handle task.repeats, whether EFD is enabled or not
|
|
399
|
+
// The only thing that EFD does is to forcefully pass the test if it has passed at least once
|
|
400
|
+
if (numRepetition > 0 && numRepetition < task.repeats) { // it may or may have not failed
|
|
401
|
+
// Here we finish the earlier iteration,
|
|
402
|
+
// as long as it's not the _last_ iteration (which will be finished normally)
|
|
403
|
+
|
|
404
|
+
const ctx = taskToCtx.get(task)
|
|
405
|
+
if (ctx) {
|
|
406
|
+
if (lastExecutionStatus === 'fail') {
|
|
407
|
+
const testError = getCurrentAttemptTestError(task, task.result?.errors)
|
|
408
|
+
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
409
|
+
} else {
|
|
410
|
+
testPassCh.publish({ task, ...ctx.currentStore })
|
|
411
|
+
}
|
|
412
|
+
if (shouldTrackStatuses && statuses) {
|
|
413
|
+
statuses.push(lastExecutionStatus)
|
|
414
|
+
}
|
|
415
|
+
if (shouldFlipStatus) {
|
|
416
|
+
// If we don't "reset" the result.state to "pass", once a repetition fails,
|
|
417
|
+
// vitest will always consider the test as failed, so we can't read the actual status
|
|
418
|
+
// This means that we change vitest's behavior:
|
|
419
|
+
// if the last attempt passes, vitest would consider the test as failed
|
|
420
|
+
// but after this change, it will consider the test as passed
|
|
421
|
+
task.result.state = 'pass'
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} else if (numRepetition === task.repeats) {
|
|
425
|
+
if (shouldTrackStatuses && statuses) {
|
|
426
|
+
statuses.push(lastExecutionStatus)
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const ctx = taskToCtx.get(task)
|
|
430
|
+
if (lastExecutionStatus === 'fail') {
|
|
431
|
+
const testError = getCurrentAttemptTestError(task, task.result?.errors)
|
|
432
|
+
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
433
|
+
} else {
|
|
434
|
+
testPassCh.publish({ task, ...ctx.currentStore })
|
|
435
|
+
}
|
|
436
|
+
if (shouldFlipStatus) {
|
|
437
|
+
task.result.state = 'pass'
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const isRetryReasonAtr = numAttempt > 0 &&
|
|
442
|
+
isFlakyTestRetriesEnabledForTask(providedContext, task) &&
|
|
443
|
+
!attemptToFixRetryTasks.has(task) &&
|
|
444
|
+
!efdRetryTasks.has(task)
|
|
445
|
+
|
|
446
|
+
const ctx = {
|
|
447
|
+
testName,
|
|
448
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
449
|
+
isRetry: numAttempt > 0 || numRepetition > 0,
|
|
450
|
+
isRetryReasonEfd: efdRetryTasks.has(task),
|
|
451
|
+
isRetryReasonAttemptToFix: attemptToFixRetryTasks.has(task) && numRepetition > 0,
|
|
452
|
+
isNew,
|
|
453
|
+
hasDynamicName: dynamicNameTasks.has(task),
|
|
454
|
+
mightHitProbe: isDiEnabled && isFailedTestReplayAllowed && numAttempt > 0,
|
|
455
|
+
isAttemptToFix: attemptToFixTasks.has(task),
|
|
456
|
+
isDisabled: disabledTasks.has(task),
|
|
457
|
+
isQuarantined: quarantinedTasks.has(task),
|
|
458
|
+
isRetryReasonAtr,
|
|
459
|
+
isModified: modifiedTasks.has(task),
|
|
460
|
+
}
|
|
461
|
+
taskToCtx.set(task, ctx)
|
|
462
|
+
|
|
463
|
+
if (attemptToFixTasks.has(task)) {
|
|
464
|
+
logAttemptToFixTestExecution(
|
|
465
|
+
getTaskTestSuite(task),
|
|
466
|
+
testName,
|
|
467
|
+
loggedAttemptToFixTests
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
testStartCh.runStores(ctx, () => {})
|
|
472
|
+
|
|
473
|
+
// Wrap the test function so it runs inside the test span context.
|
|
474
|
+
// Without this, HTTP requests during test execution become orphaned root spans.
|
|
475
|
+
if (vitestGetFn && vitestSetFn) {
|
|
476
|
+
const originalFn = vitestGetFn(task)
|
|
477
|
+
if (originalFn && !originalFn.__ddTraceWrapped) {
|
|
478
|
+
const wrappedFn = wrapTestScopedFn(task, originalFn)
|
|
479
|
+
wrappedFn.__ddTraceWrapped = true
|
|
480
|
+
vitestSetFn(task, wrappedFn)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Wrap beforeEach/afterEach hooks so they also run inside the test span context.
|
|
485
|
+
// In vitest 4+, hooks are in a WeakMap accessed via getHooks(). In older versions, they're on suite.hooks.
|
|
486
|
+
let currentSuite = task.suite
|
|
487
|
+
while (currentSuite) {
|
|
488
|
+
const hooks = vitestGetHooks ? vitestGetHooks(currentSuite) : currentSuite.hooks
|
|
489
|
+
if (hooks) {
|
|
490
|
+
for (const hookType of ['beforeEach', 'afterEach']) {
|
|
491
|
+
const hookArray = hooks[hookType]
|
|
492
|
+
if (!hookArray) continue
|
|
493
|
+
for (let i = 0; i < hookArray.length; i++) {
|
|
494
|
+
const currentFn = hookArray[i]
|
|
495
|
+
if (originalHookFns.has(currentFn)) continue
|
|
496
|
+
const wrappedFn = wrapSuiteHookFn(hookType, currentFn, task)
|
|
497
|
+
originalHookFns.set(wrappedFn, currentFn)
|
|
498
|
+
hookArray[i] = wrappedFn
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
currentSuite = currentSuite.suite
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
// test finish (only passed tests)
|
|
509
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onAfterTryTask', onAfterTryTask =>
|
|
510
|
+
async function (task, retryInfo) {
|
|
511
|
+
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
512
|
+
return onAfterTryTask.apply(this, arguments)
|
|
513
|
+
}
|
|
514
|
+
const result = await onAfterTryTask.apply(this, arguments)
|
|
515
|
+
|
|
516
|
+
const {
|
|
517
|
+
isEarlyFlakeDetectionEnabled,
|
|
518
|
+
testManagementAttemptToFixRetries,
|
|
519
|
+
slowTestRetries,
|
|
520
|
+
} = getProvidedContext()
|
|
521
|
+
|
|
522
|
+
const status = getVitestTestStatus(task, retryInfo.retry)
|
|
523
|
+
const ctx = taskToCtx.get(task)
|
|
524
|
+
|
|
525
|
+
const { isDiEnabled } = getProvidedContext()
|
|
526
|
+
const isFailedTestReplayAllowed = !hasConcurrentTests(task.file)
|
|
527
|
+
|
|
528
|
+
if (efdSkippedRetryResults.has(task)) {
|
|
529
|
+
task.result = efdSkippedRetryResults.get(task)
|
|
530
|
+
efdSkippedRetryResults.delete(task)
|
|
531
|
+
return result
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (isDiEnabled && isFailedTestReplayAllowed && retryInfo.retry > 1) {
|
|
535
|
+
await waitForHitProbe()
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (
|
|
539
|
+
isEarlyFlakeDetectionEnabled &&
|
|
540
|
+
(retryInfo.repeats ?? 0) === 0 &&
|
|
541
|
+
taskToStatuses.has(task) &&
|
|
542
|
+
!attemptToFixTasks.has(task) &&
|
|
543
|
+
!efdDeterminedRetries.has(task)
|
|
544
|
+
) {
|
|
545
|
+
const executionStart = efdExecutionStartByTask.get(task)
|
|
546
|
+
const duration = executionStart === undefined ? task.result?.duration ?? 0 : performance.now() - executionStart
|
|
547
|
+
const retryCount = getEfdRetryCount(duration, slowTestRetries)
|
|
548
|
+
efdDeterminedRetries.set(task, retryCount)
|
|
549
|
+
task.repeats = retryCount
|
|
550
|
+
if (retryCount === 0) {
|
|
551
|
+
efdSlowAbortedTasks.add(task)
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let attemptToFixPassed = false
|
|
556
|
+
let attemptToFixFailed = false
|
|
557
|
+
if (attemptToFixTasks.has(task)) {
|
|
558
|
+
const statuses = attemptToFixTaskToStatuses.get(task)
|
|
559
|
+
if (statuses.length === testManagementAttemptToFixRetries) {
|
|
560
|
+
if (status === 'pass' && statuses.every(status => status === 'pass')) {
|
|
561
|
+
attemptToFixPassed = true
|
|
562
|
+
} else if (status === 'fail' || statuses.includes('fail')) {
|
|
563
|
+
attemptToFixFailed = true
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (ctx) {
|
|
569
|
+
// We don't finish here because the test might fail in a later hook (afterEach)
|
|
570
|
+
ctx.status = status
|
|
571
|
+
ctx.task = task
|
|
572
|
+
ctx.attemptToFixPassed = attemptToFixPassed
|
|
573
|
+
ctx.attemptToFixFailed = attemptToFixFailed
|
|
574
|
+
testFinishTimeCh.runStores(ctx, () => {})
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return result
|
|
578
|
+
})
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function captureRunnerFunctions (pkg) {
|
|
582
|
+
if (vitestGetFn) return
|
|
583
|
+
const getFnExport = findExportByName(pkg, 'getFn')
|
|
584
|
+
const setFnExport = findExportByName(pkg, 'setFn')
|
|
585
|
+
if (getFnExport && setFnExport) {
|
|
586
|
+
vitestGetFn = getFnExport.value
|
|
587
|
+
vitestSetFn = setFnExport.value
|
|
588
|
+
}
|
|
589
|
+
const getHooksExport = findExportByName(pkg, 'getHooks')
|
|
590
|
+
if (getHooksExport) {
|
|
591
|
+
vitestGetHooks = getHooksExport.value
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
addHook({
|
|
596
|
+
name: 'vitest',
|
|
597
|
+
versions: ['>=4.0.0'],
|
|
598
|
+
filePattern: 'dist/chunks/test.*',
|
|
599
|
+
}, (testPackage) => {
|
|
600
|
+
const testRunner = getTestRunnerExport(testPackage)
|
|
601
|
+
if (!testRunner) {
|
|
602
|
+
return testPackage
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
captureRunnerFunctions(testPackage)
|
|
606
|
+
wrapVitestTestRunner(testRunner.value)
|
|
607
|
+
|
|
608
|
+
return testPackage
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
addHook({
|
|
612
|
+
name: '@vitest/runner',
|
|
613
|
+
versions: ['>=1.6.0'],
|
|
614
|
+
}, (runnerModule) => {
|
|
615
|
+
if (!vitestGetFn && runnerModule.getFn && runnerModule.setFn) {
|
|
616
|
+
vitestGetFn = runnerModule.getFn
|
|
617
|
+
vitestSetFn = runnerModule.setFn
|
|
618
|
+
}
|
|
619
|
+
if (!vitestGetHooks && runnerModule.getHooks) {
|
|
620
|
+
vitestGetHooks = runnerModule.getHooks
|
|
621
|
+
}
|
|
622
|
+
return runnerModule
|
|
623
|
+
})
|
|
624
|
+
|
|
625
|
+
addHook({
|
|
626
|
+
name: 'vitest',
|
|
627
|
+
versions: ['>=1.6.0 <4.0.0'],
|
|
628
|
+
file: 'dist/runners.js',
|
|
629
|
+
}, (vitestPackage) => {
|
|
630
|
+
const { VitestTestRunner } = vitestPackage
|
|
631
|
+
|
|
632
|
+
wrapVitestTestRunner(VitestTestRunner)
|
|
633
|
+
|
|
634
|
+
return vitestPackage
|
|
635
|
+
})
|
|
636
|
+
|
|
637
|
+
// test suite start and finish
|
|
638
|
+
// only relevant for workers
|
|
639
|
+
addHook({
|
|
640
|
+
name: '@vitest/runner',
|
|
641
|
+
versions: ['>=1.6.0'],
|
|
642
|
+
}, (vitestPackage, frameworkVersion) => {
|
|
643
|
+
shimmer.wrap(vitestPackage, 'startTests', startTests => async function (testPaths) {
|
|
644
|
+
let testSuiteError = null
|
|
645
|
+
if (!testSuiteFinishCh.hasSubscribers) {
|
|
646
|
+
return startTests.apply(this, arguments)
|
|
647
|
+
}
|
|
648
|
+
// From >=3.0.1, the first arguments changes from a string to an object containing the filepath
|
|
649
|
+
const testSuiteAbsolutePath = testPaths[0]?.filepath || testPaths[0]
|
|
650
|
+
const providedContext = getProvidedContext()
|
|
651
|
+
|
|
652
|
+
const testSuiteCtx = {
|
|
653
|
+
testSuiteAbsolutePath,
|
|
654
|
+
frameworkVersion,
|
|
655
|
+
testSessionId: providedContext.testSessionId,
|
|
656
|
+
testModuleId: providedContext.testModuleId,
|
|
657
|
+
testCommand: providedContext.testCommand,
|
|
658
|
+
repositoryRoot: providedContext.repositoryRoot,
|
|
659
|
+
codeOwnersEntries: providedContext.codeOwnersEntries,
|
|
660
|
+
}
|
|
661
|
+
testSuiteStartCh.runStores(testSuiteCtx, () => {})
|
|
662
|
+
const startTestsResponse = await startTests.apply(this, arguments)
|
|
663
|
+
|
|
664
|
+
let onFinish = null
|
|
665
|
+
const onFinishPromise = new Promise(resolve => {
|
|
666
|
+
onFinish = resolve
|
|
667
|
+
})
|
|
668
|
+
|
|
669
|
+
const testTasks = getTypeTasks(startTestsResponse[0].tasks)
|
|
670
|
+
const testEventPromises = []
|
|
671
|
+
|
|
672
|
+
// Only one test task per test, even if there are retries
|
|
673
|
+
for (const task of testTasks) {
|
|
674
|
+
const testCtx = taskToCtx.get(task)
|
|
675
|
+
const { result } = task
|
|
676
|
+
// We have to trick vitest into thinking that the test has passed
|
|
677
|
+
// but we want to report it as failed if it did fail
|
|
678
|
+
const isSwitchedStatus = switchedStatuses.has(task)
|
|
679
|
+
|
|
680
|
+
if (result) {
|
|
681
|
+
const { state, duration, errors } = result
|
|
682
|
+
const testError = getCurrentAttemptTestError(task, errors)
|
|
683
|
+
if (attemptToFixTasks.has(task)) {
|
|
684
|
+
const status = getFinalAttemptToFixStatus(task, state, isSwitchedStatus, testCtx)
|
|
685
|
+
recordFinalAttemptToFixExecution(task, status, providedContext)
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (state === 'skip') { // programmatic skip
|
|
689
|
+
testSkipCh.publish({
|
|
690
|
+
testName: getTestName(task),
|
|
691
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
692
|
+
isNew: newTasks.has(task),
|
|
693
|
+
isDisabled: disabledTasks.has(task),
|
|
694
|
+
})
|
|
695
|
+
} else if (state === 'pass' && !isSwitchedStatus) {
|
|
696
|
+
if (testCtx) {
|
|
697
|
+
const isSkippedByTestManagement =
|
|
698
|
+
!attemptToFixTasks.has(task) && (disabledTasks.has(task) || quarantinedTasks.has(task))
|
|
699
|
+
const promises = {}
|
|
700
|
+
testPassCh.publish({
|
|
701
|
+
task,
|
|
702
|
+
finalStatus: isSkippedByTestManagement ? 'skip' : 'pass',
|
|
703
|
+
earlyFlakeAbortReason: efdSlowAbortedTasks.has(task) ? 'slow' : undefined,
|
|
704
|
+
promises,
|
|
705
|
+
...testCtx.currentStore,
|
|
706
|
+
})
|
|
707
|
+
if (promises.hitBreakpointPromise) {
|
|
708
|
+
testEventPromises.push(promises.hitBreakpointPromise)
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
} else if (state === 'fail' || isSwitchedStatus) {
|
|
712
|
+
let hasFailedAllRetries = false
|
|
713
|
+
let attemptToFixFailed = false
|
|
714
|
+
if (attemptToFixTasks.has(task)) {
|
|
715
|
+
const statuses = attemptToFixTaskToStatuses.get(task)
|
|
716
|
+
if (statuses.includes('fail')) {
|
|
717
|
+
attemptToFixFailed = true
|
|
718
|
+
}
|
|
719
|
+
if (statuses.every(status => status === 'fail')) {
|
|
720
|
+
hasFailedAllRetries = true
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// Check if all EFD retries failed
|
|
725
|
+
const isEfdRetry =
|
|
726
|
+
providedContext.isEarlyFlakeDetectionEnabled && (newTasks.has(task) || modifiedTasks.has(task))
|
|
727
|
+
if (isEfdRetry) {
|
|
728
|
+
const statuses = taskToStatuses.get(task)
|
|
729
|
+
const efdRetryCount = efdDeterminedRetries.get(task) ?? providedContext.numRepeats
|
|
730
|
+
// statuses only includes repetitions (not the initial run), so we check against retry count (not +1)
|
|
731
|
+
if (efdRetryCount > 0 && statuses && statuses.length === efdRetryCount &&
|
|
732
|
+
statuses.every(status => status === 'fail')) {
|
|
733
|
+
hasFailedAllRetries = true
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
738
|
+
const isAtrRetry = isFlakyTestRetriesEnabledForTask(providedContext, task) && !attemptToFixTasks.has(task) &&
|
|
739
|
+
!newTasks.has(task) && !modifiedTasks.has(task)
|
|
740
|
+
if (isAtrRetry) {
|
|
741
|
+
const maxRetries = providedContext.flakyTestRetriesCount ?? 0
|
|
742
|
+
if (maxRetries > 0 && task.result?.retryCount === maxRetries) {
|
|
743
|
+
hasFailedAllRetries = true
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
if (testCtx) {
|
|
748
|
+
const isRetry = task.result?.retryCount > 0
|
|
749
|
+
const promises = {}
|
|
750
|
+
// `duration` is the duration of all the retries, so it can't be used if there are retries
|
|
751
|
+
|
|
752
|
+
let finalStatus
|
|
753
|
+
if (isSwitchedStatus) {
|
|
754
|
+
if (!attemptToFixTasks.has(task) && (disabledTasks.has(task) || quarantinedTasks.has(task))) {
|
|
755
|
+
finalStatus = 'skip'
|
|
756
|
+
} else if (isAtrRetry || isEfdRetry) {
|
|
757
|
+
finalStatus = hasFailedAllRetries ? 'fail' : 'pass'
|
|
758
|
+
} else if (attemptToFixTasks.has(task)) {
|
|
759
|
+
finalStatus = attemptToFixFailed ? 'fail' : 'pass'
|
|
760
|
+
} else {
|
|
761
|
+
finalStatus = undefined
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
finalStatus = 'fail'
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
testErrorCh.publish({
|
|
768
|
+
duration: isRetry ? undefined : duration,
|
|
769
|
+
error: testError,
|
|
770
|
+
hasFailedAllRetries,
|
|
771
|
+
attemptToFixFailed,
|
|
772
|
+
finalStatus,
|
|
773
|
+
earlyFlakeAbortReason: efdSlowAbortedTasks.has(task) ? 'slow' : undefined,
|
|
774
|
+
promises,
|
|
775
|
+
...testCtx.currentStore,
|
|
776
|
+
})
|
|
777
|
+
if (promises.hitBreakpointPromise) {
|
|
778
|
+
testEventPromises.push(promises.hitBreakpointPromise)
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (errors?.length) {
|
|
782
|
+
testSuiteError = testError // we store the error to bubble it up to the suite
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
} else { // test.skip or test.todo
|
|
786
|
+
testSkipCh.publish({
|
|
787
|
+
testName: getTestName(task),
|
|
788
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
789
|
+
isNew: newTasks.has(task),
|
|
790
|
+
isDisabled: disabledTasks.has(task),
|
|
791
|
+
})
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
await Promise.all(testEventPromises)
|
|
796
|
+
|
|
797
|
+
const testSuiteResult = startTestsResponse[0].result
|
|
798
|
+
|
|
799
|
+
if (testSuiteResult.errors?.length) { // Errors from root level hooks
|
|
800
|
+
testSuiteError = testSuiteResult.errors[0]
|
|
801
|
+
} else if (testSuiteResult.state === 'fail') { // Errors from `describe` level hooks
|
|
802
|
+
const suiteTasks = getTypeTasks(startTestsResponse[0].tasks, 'suite')
|
|
803
|
+
const failedSuites = suiteTasks.filter(task => task.result?.state === 'fail')
|
|
804
|
+
if (failedSuites.length && failedSuites[0].result?.errors?.length) {
|
|
805
|
+
testSuiteError = failedSuites[0].result.errors[0]
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
if (testSuiteError) {
|
|
810
|
+
testSuiteCtx.error = testSuiteError
|
|
811
|
+
testSuiteErrorCh.runStores(testSuiteCtx, () => {})
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
testSuiteFinishCh.publish({ status: testSuiteResult.state, onFinish, ...testSuiteCtx.currentStore })
|
|
815
|
+
|
|
816
|
+
await onFinishPromise
|
|
817
|
+
|
|
818
|
+
return startTestsResponse
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
return vitestPackage
|
|
822
|
+
})
|