@depup/dd-trace 5.90.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 +6 -0
- package/LICENSE-3rdparty.csv +102 -0
- package/LICENSE.Apache +200 -0
- package/LICENSE.BSD3 +29 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/ci/cypress/after-run.js +3 -0
- package/ci/cypress/after-spec.js +3 -0
- package/ci/cypress/plugin.js +13 -0
- package/ci/cypress/polyfills.js +25 -0
- package/ci/cypress/support.js +3 -0
- package/ci/init.js +86 -0
- package/esbuild.js +3 -0
- package/ext/exporters.d.ts +14 -0
- package/ext/exporters.js +13 -0
- package/ext/formats.d.ts +11 -0
- package/ext/formats.js +9 -0
- package/ext/index.d.ts +8 -0
- package/ext/index.js +17 -0
- package/ext/kinds.d.ts +9 -0
- package/ext/kinds.js +9 -0
- package/ext/priority.d.ts +8 -0
- package/ext/priority.js +8 -0
- package/ext/scopes.d.ts +9 -0
- package/ext/scopes.js +9 -0
- package/ext/tags.d.ts +26 -0
- package/ext/tags.js +40 -0
- package/ext/types.d.ts +7 -0
- package/ext/types.js +7 -0
- package/index.d.ts +3811 -0
- package/index.js +3 -0
- package/init.js +7 -0
- package/initialize.mjs +85 -0
- package/loader-hook.mjs +77 -0
- package/package.json +215 -0
- package/packages/datadog-code-origin/index.js +66 -0
- package/packages/datadog-core/index.js +5 -0
- package/packages/datadog-core/src/storage.js +132 -0
- package/packages/datadog-core/src/utils/src/kebabcase.js +14 -0
- package/packages/datadog-core/src/utils/src/parse-tags.js +33 -0
- package/packages/datadog-core/src/utils/src/pick.js +11 -0
- package/packages/datadog-core/src/utils/src/set.js +18 -0
- package/packages/datadog-core/src/utils/src/uniq.js +5 -0
- package/packages/datadog-esbuild/index.js +403 -0
- package/packages/datadog-esbuild/src/log.js +32 -0
- package/packages/datadog-esbuild/src/utils.js +218 -0
- package/packages/datadog-instrumentations/index.js +5 -0
- package/packages/datadog-instrumentations/src/aerospike.js +48 -0
- package/packages/datadog-instrumentations/src/ai.js +119 -0
- package/packages/datadog-instrumentations/src/amqp10.js +73 -0
- package/packages/datadog-instrumentations/src/amqplib.js +146 -0
- package/packages/datadog-instrumentations/src/anthropic.js +127 -0
- package/packages/datadog-instrumentations/src/apollo-server-core.js +40 -0
- package/packages/datadog-instrumentations/src/apollo-server.js +135 -0
- package/packages/datadog-instrumentations/src/apollo.js +101 -0
- package/packages/datadog-instrumentations/src/avsc.js +39 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +264 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +75 -0
- package/packages/datadog-instrumentations/src/azure-event-hubs.js +38 -0
- package/packages/datadog-instrumentations/src/azure-functions.js +56 -0
- package/packages/datadog-instrumentations/src/azure-service-bus.js +71 -0
- package/packages/datadog-instrumentations/src/bluebird.js +26 -0
- package/packages/datadog-instrumentations/src/body-parser.js +44 -0
- package/packages/datadog-instrumentations/src/bullmq.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +22 -0
- package/packages/datadog-instrumentations/src/cassandra-driver.js +179 -0
- package/packages/datadog-instrumentations/src/child_process.js +246 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +421 -0
- package/packages/datadog-instrumentations/src/connect.js +118 -0
- package/packages/datadog-instrumentations/src/cookie-parser.js +36 -0
- package/packages/datadog-instrumentations/src/cookie.js +21 -0
- package/packages/datadog-instrumentations/src/couchbase.js +324 -0
- package/packages/datadog-instrumentations/src/crypto.js +33 -0
- package/packages/datadog-instrumentations/src/cucumber.js +1096 -0
- package/packages/datadog-instrumentations/src/cypress.js +11 -0
- package/packages/datadog-instrumentations/src/dd-trace-api.js +7 -0
- package/packages/datadog-instrumentations/src/dns.js +98 -0
- package/packages/datadog-instrumentations/src/elasticsearch.js +129 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +45 -0
- package/packages/datadog-instrumentations/src/express-session.js +41 -0
- package/packages/datadog-instrumentations/src/express.js +253 -0
- package/packages/datadog-instrumentations/src/fastify.js +300 -0
- package/packages/datadog-instrumentations/src/fetch.js +33 -0
- package/packages/datadog-instrumentations/src/find-my-way.js +31 -0
- package/packages/datadog-instrumentations/src/fs.js +372 -0
- package/packages/datadog-instrumentations/src/generic-pool.js +48 -0
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +287 -0
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +101 -0
- package/packages/datadog-instrumentations/src/google-genai.js +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +382 -0
- package/packages/datadog-instrumentations/src/grpc/client.js +258 -0
- package/packages/datadog-instrumentations/src/grpc/server.js +154 -0
- package/packages/datadog-instrumentations/src/grpc/types.js +10 -0
- package/packages/datadog-instrumentations/src/grpc.js +4 -0
- package/packages/datadog-instrumentations/src/handlebars.js +40 -0
- package/packages/datadog-instrumentations/src/hapi.js +178 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +68 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +103 -0
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +26 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +75 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +151 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +57 -0
- package/packages/datadog-instrumentations/src/helpers/instrumentations.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +29 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +242 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +70 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +103 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.js +108 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/compiler.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/index.js +43 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/matcher.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/transformer.js +121 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/transforms.js +322 -0
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +238 -0
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
- package/packages/datadog-instrumentations/src/hono.js +150 -0
- package/packages/datadog-instrumentations/src/http/client.js +315 -0
- package/packages/datadog-instrumentations/src/http/server.js +223 -0
- package/packages/datadog-instrumentations/src/http.js +4 -0
- package/packages/datadog-instrumentations/src/http2/client.js +76 -0
- package/packages/datadog-instrumentations/src/http2/server.js +64 -0
- package/packages/datadog-instrumentations/src/http2.js +4 -0
- package/packages/datadog-instrumentations/src/ioredis.js +57 -0
- package/packages/datadog-instrumentations/src/iovalkey.js +47 -0
- package/packages/datadog-instrumentations/src/jest.js +1895 -0
- package/packages/datadog-instrumentations/src/kafkajs.js +266 -0
- package/packages/datadog-instrumentations/src/knex.js +86 -0
- package/packages/datadog-instrumentations/src/koa.js +173 -0
- package/packages/datadog-instrumentations/src/langchain.js +7 -0
- package/packages/datadog-instrumentations/src/ldapjs.js +101 -0
- package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +22 -0
- package/packages/datadog-instrumentations/src/lodash.js +30 -0
- package/packages/datadog-instrumentations/src/mariadb.js +186 -0
- package/packages/datadog-instrumentations/src/memcached.js +45 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +69 -0
- package/packages/datadog-instrumentations/src/mocha/common.js +50 -0
- package/packages/datadog-instrumentations/src/mocha/main.js +753 -0
- package/packages/datadog-instrumentations/src/mocha/utils.js +526 -0
- package/packages/datadog-instrumentations/src/mocha/worker.js +104 -0
- package/packages/datadog-instrumentations/src/mocha.js +13 -0
- package/packages/datadog-instrumentations/src/moleculer/client.js +44 -0
- package/packages/datadog-instrumentations/src/moleculer/server.js +58 -0
- package/packages/datadog-instrumentations/src/moleculer.js +4 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +213 -0
- package/packages/datadog-instrumentations/src/mongodb.js +59 -0
- package/packages/datadog-instrumentations/src/mongoose.js +179 -0
- package/packages/datadog-instrumentations/src/mquery.js +65 -0
- package/packages/datadog-instrumentations/src/multer.js +37 -0
- package/packages/datadog-instrumentations/src/mysql.js +105 -0
- package/packages/datadog-instrumentations/src/mysql2.js +380 -0
- package/packages/datadog-instrumentations/src/net.js +143 -0
- package/packages/datadog-instrumentations/src/next.js +320 -0
- package/packages/datadog-instrumentations/src/node-serialize.js +22 -0
- package/packages/datadog-instrumentations/src/nyc.js +59 -0
- package/packages/datadog-instrumentations/src/openai.js +326 -0
- package/packages/datadog-instrumentations/src/opensearch.js +11 -0
- package/packages/datadog-instrumentations/src/oracledb.js +162 -0
- package/packages/datadog-instrumentations/src/orchestrion-config/index.js +86 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +24 -0
- package/packages/datadog-instrumentations/src/passport-http.js +10 -0
- package/packages/datadog-instrumentations/src/passport-local.js +10 -0
- package/packages/datadog-instrumentations/src/passport-utils.js +61 -0
- package/packages/datadog-instrumentations/src/passport.js +45 -0
- package/packages/datadog-instrumentations/src/pg.js +201 -0
- package/packages/datadog-instrumentations/src/pino.js +117 -0
- package/packages/datadog-instrumentations/src/playwright.js +1383 -0
- package/packages/datadog-instrumentations/src/prisma.js +272 -0
- package/packages/datadog-instrumentations/src/process.js +29 -0
- package/packages/datadog-instrumentations/src/promise-js.js +15 -0
- package/packages/datadog-instrumentations/src/promise.js +14 -0
- package/packages/datadog-instrumentations/src/protobufjs.js +128 -0
- package/packages/datadog-instrumentations/src/pug.js +23 -0
- package/packages/datadog-instrumentations/src/q.js +21 -0
- package/packages/datadog-instrumentations/src/redis.js +161 -0
- package/packages/datadog-instrumentations/src/restify.js +89 -0
- package/packages/datadog-instrumentations/src/rhea.js +237 -0
- package/packages/datadog-instrumentations/src/router.js +326 -0
- package/packages/datadog-instrumentations/src/selenium.js +80 -0
- package/packages/datadog-instrumentations/src/sequelize.js +45 -0
- package/packages/datadog-instrumentations/src/sharedb.js +72 -0
- package/packages/datadog-instrumentations/src/stripe.js +92 -0
- package/packages/datadog-instrumentations/src/tedious.js +63 -0
- package/packages/datadog-instrumentations/src/undici.js +29 -0
- package/packages/datadog-instrumentations/src/url.js +80 -0
- package/packages/datadog-instrumentations/src/vitest.js +1116 -0
- package/packages/datadog-instrumentations/src/vm.js +49 -0
- package/packages/datadog-instrumentations/src/when.js +14 -0
- package/packages/datadog-instrumentations/src/winston.js +78 -0
- package/packages/datadog-instrumentations/src/ws.js +264 -0
- package/packages/datadog-plugin-aerospike/src/index.js +113 -0
- package/packages/datadog-plugin-ai/src/index.js +17 -0
- package/packages/datadog-plugin-ai/src/tracing.js +33 -0
- package/packages/datadog-plugin-ai/src/utils.js +28 -0
- package/packages/datadog-plugin-amqp10/src/consumer.js +34 -0
- package/packages/datadog-plugin-amqp10/src/index.js +17 -0
- package/packages/datadog-plugin-amqp10/src/producer.js +37 -0
- package/packages/datadog-plugin-amqp10/src/util.js +15 -0
- package/packages/datadog-plugin-amqplib/src/client.js +44 -0
- package/packages/datadog-plugin-amqplib/src/consumer.js +57 -0
- package/packages/datadog-plugin-amqplib/src/index.js +20 -0
- package/packages/datadog-plugin-amqplib/src/producer.js +63 -0
- package/packages/datadog-plugin-amqplib/src/util.js +14 -0
- package/packages/datadog-plugin-anthropic/src/index.js +17 -0
- package/packages/datadog-plugin-anthropic/src/tracing.js +30 -0
- package/packages/datadog-plugin-apollo/src/gateway/execute.js +18 -0
- package/packages/datadog-plugin-apollo/src/gateway/fetch.js +39 -0
- package/packages/datadog-plugin-apollo/src/gateway/index.js +36 -0
- package/packages/datadog-plugin-apollo/src/gateway/plan.js +18 -0
- package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +15 -0
- package/packages/datadog-plugin-apollo/src/gateway/request.js +122 -0
- package/packages/datadog-plugin-apollo/src/gateway/validate.js +23 -0
- package/packages/datadog-plugin-apollo/src/index.js +43 -0
- package/packages/datadog-plugin-avsc/src/index.js +11 -0
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +176 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +335 -0
- package/packages/datadog-plugin-aws-sdk/src/index.js +26 -0
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +16 -0
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +31 -0
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +487 -0
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +19 -0
- package/packages/datadog-plugin-aws-sdk/src/services/default.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +197 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +53 -0
- package/packages/datadog-plugin-aws-sdk/src/services/index.js +16 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +214 -0
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +67 -0
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +19 -0
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +55 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sfn.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +125 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +298 -0
- package/packages/datadog-plugin-aws-sdk/src/services/states.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +64 -0
- package/packages/datadog-plugin-aws-sdk/src/util.js +151 -0
- package/packages/datadog-plugin-azure-durable-functions/src/index.js +49 -0
- package/packages/datadog-plugin-azure-event-hubs/src/index.js +15 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +96 -0
- package/packages/datadog-plugin-azure-functions/src/index.js +171 -0
- package/packages/datadog-plugin-azure-service-bus/src/index.js +15 -0
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +97 -0
- package/packages/datadog-plugin-bullmq/src/consumer.js +82 -0
- package/packages/datadog-plugin-bullmq/src/index.js +18 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +207 -0
- package/packages/datadog-plugin-bunyan/src/index.js +8 -0
- package/packages/datadog-plugin-cassandra-driver/src/index.js +47 -0
- package/packages/datadog-plugin-child_process/src/index.js +111 -0
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +127 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js +9 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js +9 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +25 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js +9 -0
- package/packages/datadog-plugin-connect/src/index.js +17 -0
- package/packages/datadog-plugin-couchbase/src/index.js +94 -0
- package/packages/datadog-plugin-cucumber/src/index.js +461 -0
- package/packages/datadog-plugin-cypress/src/after-run.js +5 -0
- package/packages/datadog-plugin-cypress/src/after-spec.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1089 -0
- package/packages/datadog-plugin-cypress/src/index.js +11 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +57 -0
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +297 -0
- package/packages/datadog-plugin-cypress/src/support.js +303 -0
- package/packages/datadog-plugin-dd-trace-api/src/index.js +117 -0
- package/packages/datadog-plugin-dns/src/index.js +23 -0
- package/packages/datadog-plugin-dns/src/lookup.js +45 -0
- package/packages/datadog-plugin-dns/src/lookup_service.js +28 -0
- package/packages/datadog-plugin-dns/src/resolve.js +27 -0
- package/packages/datadog-plugin-dns/src/reverse.js +25 -0
- package/packages/datadog-plugin-elasticsearch/src/index.js +49 -0
- package/packages/datadog-plugin-express/src/code_origin.js +47 -0
- package/packages/datadog-plugin-express/src/index.js +17 -0
- package/packages/datadog-plugin-express/src/tracing.js +17 -0
- package/packages/datadog-plugin-fastify/src/code_origin.js +41 -0
- package/packages/datadog-plugin-fastify/src/index.js +17 -0
- package/packages/datadog-plugin-fastify/src/tracing.js +34 -0
- package/packages/datadog-plugin-fetch/src/index.js +40 -0
- package/packages/datadog-plugin-find-my-way/src/index.js +18 -0
- package/packages/datadog-plugin-fs/src/index.js +52 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +39 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +212 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +19 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +191 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +17 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +49 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +21 -0
- package/packages/datadog-plugin-google-genai/src/index.js +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/execute.js +88 -0
- package/packages/datadog-plugin-graphql/src/index.js +72 -0
- package/packages/datadog-plugin-graphql/src/parse.js +35 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +191 -0
- package/packages/datadog-plugin-graphql/src/tools/index.js +6 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +9 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +108 -0
- package/packages/datadog-plugin-graphql/src/utils.js +49 -0
- package/packages/datadog-plugin-graphql/src/validate.js +40 -0
- package/packages/datadog-plugin-grpc/src/client.js +129 -0
- package/packages/datadog-plugin-grpc/src/index.js +17 -0
- package/packages/datadog-plugin-grpc/src/server.js +112 -0
- package/packages/datadog-plugin-grpc/src/util.js +66 -0
- package/packages/datadog-plugin-hapi/src/index.js +39 -0
- package/packages/datadog-plugin-hono/src/index.js +26 -0
- package/packages/datadog-plugin-http/src/client.js +244 -0
- package/packages/datadog-plugin-http/src/index.js +37 -0
- package/packages/datadog-plugin-http/src/server.js +92 -0
- package/packages/datadog-plugin-http2/src/client.js +217 -0
- package/packages/datadog-plugin-http2/src/index.js +17 -0
- package/packages/datadog-plugin-http2/src/server.js +73 -0
- package/packages/datadog-plugin-ioredis/src/index.js +9 -0
- package/packages/datadog-plugin-iovalkey/src/index.js +16 -0
- package/packages/datadog-plugin-jest/src/index.js +558 -0
- package/packages/datadog-plugin-jest/src/util.js +176 -0
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +28 -0
- package/packages/datadog-plugin-kafkajs/src/consumer.js +128 -0
- package/packages/datadog-plugin-kafkajs/src/index.js +19 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +129 -0
- package/packages/datadog-plugin-kafkajs/src/utils.js +27 -0
- package/packages/datadog-plugin-koa/src/index.js +22 -0
- package/packages/datadog-plugin-langchain/src/handlers/default.js +11 -0
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +18 -0
- package/packages/datadog-plugin-langchain/src/handlers/language_models.js +18 -0
- package/packages/datadog-plugin-langchain/src/index.js +26 -0
- package/packages/datadog-plugin-langchain/src/tokens.js +35 -0
- package/packages/datadog-plugin-langchain/src/tracing.js +155 -0
- package/packages/datadog-plugin-mariadb/src/index.js +21 -0
- package/packages/datadog-plugin-memcached/src/index.js +54 -0
- package/packages/datadog-plugin-microgateway-core/src/index.js +26 -0
- package/packages/datadog-plugin-mocha/src/index.js +480 -0
- package/packages/datadog-plugin-moleculer/src/client.js +42 -0
- package/packages/datadog-plugin-moleculer/src/index.js +19 -0
- package/packages/datadog-plugin-moleculer/src/server.js +30 -0
- package/packages/datadog-plugin-moleculer/src/util.js +21 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +215 -0
- package/packages/datadog-plugin-mongoose/src/index.js +20 -0
- package/packages/datadog-plugin-mysql/src/index.js +42 -0
- package/packages/datadog-plugin-mysql2/src/index.js +25 -0
- package/packages/datadog-plugin-net/src/index.js +23 -0
- package/packages/datadog-plugin-net/src/ipc.js +23 -0
- package/packages/datadog-plugin-net/src/tcp.js +53 -0
- package/packages/datadog-plugin-next/src/index.js +155 -0
- package/packages/datadog-plugin-nyc/src/index.js +95 -0
- package/packages/datadog-plugin-openai/src/index.js +17 -0
- package/packages/datadog-plugin-openai/src/services.js +48 -0
- package/packages/datadog-plugin-openai/src/stream-helpers.js +159 -0
- package/packages/datadog-plugin-openai/src/token-estimator.js +20 -0
- package/packages/datadog-plugin-openai/src/tracing.js +723 -0
- package/packages/datadog-plugin-opensearch/src/index.js +9 -0
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
- package/packages/datadog-plugin-oracledb/src/index.js +44 -0
- package/packages/datadog-plugin-pg/src/index.js +41 -0
- package/packages/datadog-plugin-pino/src/index.js +9 -0
- package/packages/datadog-plugin-playwright/src/index.js +497 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +118 -0
- package/packages/datadog-plugin-prisma/src/index.js +144 -0
- package/packages/datadog-plugin-protobufjs/src/index.js +12 -0
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +181 -0
- package/packages/datadog-plugin-redis/src/index.js +95 -0
- package/packages/datadog-plugin-restify/src/index.js +29 -0
- package/packages/datadog-plugin-rhea/src/consumer.js +68 -0
- package/packages/datadog-plugin-rhea/src/index.js +17 -0
- package/packages/datadog-plugin-rhea/src/producer.js +54 -0
- package/packages/datadog-plugin-router/src/index.js +170 -0
- package/packages/datadog-plugin-selenium/src/index.js +66 -0
- package/packages/datadog-plugin-sharedb/src/index.js +68 -0
- package/packages/datadog-plugin-tedious/src/index.js +36 -0
- package/packages/datadog-plugin-undici/src/index.js +313 -0
- package/packages/datadog-plugin-vitest/src/index.js +444 -0
- package/packages/datadog-plugin-web/src/index.js +18 -0
- package/packages/datadog-plugin-winston/src/index.js +8 -0
- package/packages/datadog-plugin-ws/src/close.js +121 -0
- package/packages/datadog-plugin-ws/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/producer.js +99 -0
- package/packages/datadog-plugin-ws/src/receiver.js +110 -0
- package/packages/datadog-plugin-ws/src/server.js +106 -0
- package/packages/datadog-plugin-ws/src/util.js +139 -0
- package/packages/datadog-shimmer/index.js +3 -0
- package/packages/datadog-shimmer/src/shimmer.js +279 -0
- package/packages/dd-trace/index.js +36 -0
- package/packages/dd-trace/src/agent/info.js +57 -0
- package/packages/dd-trace/src/agent/url.js +28 -0
- package/packages/dd-trace/src/aiguard/client.js +25 -0
- package/packages/dd-trace/src/aiguard/noop.js +9 -0
- package/packages/dd-trace/src/aiguard/sdk.js +223 -0
- package/packages/dd-trace/src/aiguard/tags.js +14 -0
- package/packages/dd-trace/src/analytics_sampler.js +15 -0
- package/packages/dd-trace/src/appsec/activation.js +29 -0
- package/packages/dd-trace/src/appsec/addresses.js +51 -0
- package/packages/dd-trace/src/appsec/api_security_sampler.js +117 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +14 -0
- package/packages/dd-trace/src/appsec/blocking.js +196 -0
- package/packages/dd-trace/src/appsec/channels.js +50 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +302 -0
- package/packages/dd-trace/src/appsec/graphql.js +166 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +24 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +36 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +15 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +62 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +72 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-analyzer.js +18 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +11 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-rule-type.js +6 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-analyzer.js +15 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +741 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +44 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/index.js +23 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +42 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/insecure-cookie-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +22 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +82 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/no-httponly-cookie-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/no-samesite-cookie-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +192 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +108 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +58 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +102 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +37 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/stored-injection-analyzer.js +11 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/template-injection-analyzer.js +18 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +16 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +64 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +181 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +31 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +64 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +19 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/xcontenttype-header-missing-analyzer.js +19 -0
- package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +89 -0
- package/packages/dd-trace/src/appsec/iast/context/kafka-ctx-plugin.js +14 -0
- package/packages/dd-trace/src/appsec/iast/iast-context.js +75 -0
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +230 -0
- package/packages/dd-trace/src/appsec/iast/index.js +126 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +209 -0
- package/packages/dd-trace/src/appsec/iast/path-line.js +116 -0
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +179 -0
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +128 -0
- package/packages/dd-trace/src/appsec/iast/tags.js +7 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/constants.js +6 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +24 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +16 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +36 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +88 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +108 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +293 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +46 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +76 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +13 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +266 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/secure-marks-generator.js +13 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/secure-marks.js +30 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/source-types.js +15 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +258 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +113 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +41 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +112 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +54 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +41 -0
- package/packages/dd-trace/src/appsec/iast/utils.js +24 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/constants.js +7 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +36 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +22 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/hardcoded-password-analyzer.js +13 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/json-sensitive-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +28 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +112 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/tainted-range-based-sensitive-analyzer.js +25 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +40 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +294 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +126 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +168 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +24 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +169 -0
- package/packages/dd-trace/src/appsec/index.js +560 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +56 -0
- package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +103 -0
- package/packages/dd-trace/src/appsec/rasp/index.js +140 -0
- package/packages/dd-trace/src/appsec/rasp/lfi.js +129 -0
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +108 -0
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +102 -0
- package/packages/dd-trace/src/appsec/rasp/utils.js +85 -0
- package/packages/dd-trace/src/appsec/rc-products.js +10 -0
- package/packages/dd-trace/src/appsec/recommended.json +10731 -0
- package/packages/dd-trace/src/appsec/remote_config.js +177 -0
- package/packages/dd-trace/src/appsec/reporter.js +599 -0
- package/packages/dd-trace/src/appsec/rule_manager.js +168 -0
- package/packages/dd-trace/src/appsec/sdk/index.js +63 -0
- package/packages/dd-trace/src/appsec/sdk/noop.js +27 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +44 -0
- package/packages/dd-trace/src/appsec/sdk/track_event.js +230 -0
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +60 -0
- package/packages/dd-trace/src/appsec/sdk/utils.js +29 -0
- package/packages/dd-trace/src/appsec/stack_trace.js +117 -0
- package/packages/dd-trace/src/appsec/telemetry/common.js +28 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +184 -0
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +103 -0
- package/packages/dd-trace/src/appsec/telemetry/user.js +32 -0
- package/packages/dd-trace/src/appsec/telemetry/waf.js +143 -0
- package/packages/dd-trace/src/appsec/user_tracking.js +190 -0
- package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
- package/packages/dd-trace/src/appsec/waf/index.js +149 -0
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +188 -0
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +98 -0
- package/packages/dd-trace/src/azure_metadata.js +137 -0
- package/packages/dd-trace/src/baggage.js +72 -0
- package/packages/dd-trace/src/ci-visibility/coverage-report-discovery.js +82 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +159 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +156 -0
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +111 -0
- package/packages/dd-trace/src/ci-visibility/encode/json-encoder.js +27 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +104 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +78 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +56 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +52 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +83 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +420 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +317 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +114 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +76 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +120 -0
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +54 -0
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +156 -0
- package/packages/dd-trace/src/ci-visibility/requests/request.js +236 -0
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +107 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +204 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +63 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +121 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +61 -0
- package/packages/dd-trace/src/config/defaults.js +174 -0
- package/packages/dd-trace/src/config/git_properties.js +120 -0
- package/packages/dd-trace/src/config/helper.js +214 -0
- package/packages/dd-trace/src/config/index.js +1676 -0
- package/packages/dd-trace/src/config/remote_config.js +203 -0
- package/packages/dd-trace/src/config/stable.js +93 -0
- package/packages/dd-trace/src/config/supported-configurations.json +4136 -0
- package/packages/dd-trace/src/constants.js +61 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +120 -0
- package/packages/dd-trace/src/crashtracking/index.js +15 -0
- package/packages/dd-trace/src/crashtracking/noop.js +11 -0
- package/packages/dd-trace/src/datastreams/checkpointer.js +80 -0
- package/packages/dd-trace/src/datastreams/context.js +20 -0
- package/packages/dd-trace/src/datastreams/encoding.js +99 -0
- package/packages/dd-trace/src/datastreams/fnv.js +25 -0
- package/packages/dd-trace/src/datastreams/index.js +129 -0
- package/packages/dd-trace/src/datastreams/manager.js +36 -0
- package/packages/dd-trace/src/datastreams/pathway.js +187 -0
- package/packages/dd-trace/src/datastreams/processor.js +494 -0
- package/packages/dd-trace/src/datastreams/schemas/schema.js +10 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +140 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +27 -0
- package/packages/dd-trace/src/datastreams/size.js +53 -0
- package/packages/dd-trace/src/datastreams/writer.js +70 -0
- package/packages/dd-trace/src/debugger/config.js +18 -0
- package/packages/dd-trace/src/debugger/constants.js +7 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +320 -0
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +294 -0
- package/packages/dd-trace/src/debugger/devtools_client/config.js +23 -0
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +7 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +336 -0
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +27 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +41 -0
- package/packages/dd-trace/src/debugger/devtools_client/log.js +30 -0
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +106 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +138 -0
- package/packages/dd-trace/src/debugger/devtools_client/session.js +17 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +336 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +215 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +349 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +112 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +8 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +72 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +238 -0
- package/packages/dd-trace/src/debugger/devtools_client/status.js +123 -0
- package/packages/dd-trace/src/debugger/index.js +259 -0
- package/packages/dd-trace/src/dogstatsd.js +412 -0
- package/packages/dd-trace/src/encode/0.4.js +425 -0
- package/packages/dd-trace/src/encode/0.5.js +77 -0
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +361 -0
- package/packages/dd-trace/src/encode/agentless-json.js +200 -0
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +131 -0
- package/packages/dd-trace/src/encode/span-stats.js +136 -0
- package/packages/dd-trace/src/encode/tags-processors.js +91 -0
- package/packages/dd-trace/src/exporter.js +32 -0
- package/packages/dd-trace/src/exporters/agent/index.js +65 -0
- package/packages/dd-trace/src/exporters/agent/writer.js +110 -0
- package/packages/dd-trace/src/exporters/agentless/index.js +132 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +201 -0
- package/packages/dd-trace/src/exporters/common/agents.js +42 -0
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +62 -0
- package/packages/dd-trace/src/exporters/common/docker.js +52 -0
- package/packages/dd-trace/src/exporters/common/form-data.js +59 -0
- package/packages/dd-trace/src/exporters/common/request.js +190 -0
- package/packages/dd-trace/src/exporters/common/url-to-http-options-polyfill.js +31 -0
- package/packages/dd-trace/src/exporters/common/util.js +13 -0
- package/packages/dd-trace/src/exporters/common/writer.js +49 -0
- package/packages/dd-trace/src/exporters/log/index.js +52 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +20 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +54 -0
- package/packages/dd-trace/src/external-logger/src/index.js +139 -0
- package/packages/dd-trace/src/flare/file.js +40 -0
- package/packages/dd-trace/src/flare/index.js +101 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +19 -0
- package/packages/dd-trace/src/guardrails/index.js +76 -0
- package/packages/dd-trace/src/guardrails/log.js +32 -0
- package/packages/dd-trace/src/guardrails/telemetry.js +92 -0
- package/packages/dd-trace/src/guardrails/util.js +8 -0
- package/packages/dd-trace/src/heap_snapshots.js +58 -0
- package/packages/dd-trace/src/histogram.js +35 -0
- package/packages/dd-trace/src/id.js +247 -0
- package/packages/dd-trace/src/iitm.js +15 -0
- package/packages/dd-trace/src/index.js +15 -0
- package/packages/dd-trace/src/lambda/context.js +27 -0
- package/packages/dd-trace/src/lambda/handler.js +87 -0
- package/packages/dd-trace/src/lambda/index.js +17 -0
- package/packages/dd-trace/src/lambda/runtime/errors.js +20 -0
- package/packages/dd-trace/src/lambda/runtime/patch.js +77 -0
- package/packages/dd-trace/src/lambda/runtime/ritm.js +133 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +55 -0
- package/packages/dd-trace/src/llmobs/constants/text.js +6 -0
- package/packages/dd-trace/src/llmobs/constants/writers.js +17 -0
- package/packages/dd-trace/src/llmobs/index.js +149 -0
- package/packages/dd-trace/src/llmobs/noop.js +88 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +399 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +218 -0
- package/packages/dd-trace/src/llmobs/plugins/anthropic.js +288 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +137 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +20 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +111 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +42 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +106 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +32 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +214 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +501 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +126 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +195 -0
- package/packages/dd-trace/src/llmobs/sdk.js +578 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +311 -0
- package/packages/dd-trace/src/llmobs/storage.js +6 -0
- package/packages/dd-trace/src/llmobs/tagger.js +648 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +174 -0
- package/packages/dd-trace/src/llmobs/util.js +182 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +242 -0
- package/packages/dd-trace/src/llmobs/writers/evaluations.js +32 -0
- package/packages/dd-trace/src/llmobs/writers/spans.js +69 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +54 -0
- package/packages/dd-trace/src/log/channels.js +78 -0
- package/packages/dd-trace/src/log/index.js +157 -0
- package/packages/dd-trace/src/log/log.js +76 -0
- package/packages/dd-trace/src/log/utils.js +16 -0
- package/packages/dd-trace/src/log/writer.js +72 -0
- package/packages/dd-trace/src/msgpack/chunk.js +69 -0
- package/packages/dd-trace/src/msgpack/encoder.js +308 -0
- package/packages/dd-trace/src/msgpack/index.js +6 -0
- package/packages/dd-trace/src/noop/dogstatsd.js +19 -0
- package/packages/dd-trace/src/noop/proxy.js +106 -0
- package/packages/dd-trace/src/noop/scope.js +19 -0
- package/packages/dd-trace/src/noop/span.js +50 -0
- package/packages/dd-trace/src/noop/span_context.js +16 -0
- package/packages/dd-trace/src/noop/tracer.js +47 -0
- package/packages/dd-trace/src/openfeature/constants/constants.js +51 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +47 -0
- package/packages/dd-trace/src/openfeature/index.js +77 -0
- package/packages/dd-trace/src/openfeature/noop.js +101 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +174 -0
- package/packages/dd-trace/src/openfeature/writers/exposures.js +173 -0
- package/packages/dd-trace/src/openfeature/writers/util.js +38 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +91 -0
- package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +100 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +87 -0
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +83 -0
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +126 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +55 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +245 -0
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +557 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +116 -0
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +226 -0
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +720 -0
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +168 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +181 -0
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +66 -0
- package/packages/dd-trace/src/opentelemetry/otlp/resource.proto +45 -0
- package/packages/dd-trace/src/opentelemetry/sampler.js +18 -0
- package/packages/dd-trace/src/opentelemetry/span.js +317 -0
- package/packages/dd-trace/src/opentelemetry/span_context.js +44 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +50 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +226 -0
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +80 -0
- package/packages/dd-trace/src/opentracing/propagation/binary.js +11 -0
- package/packages/dd-trace/src/opentracing/propagation/http.js +7 -0
- package/packages/dd-trace/src/opentracing/propagation/log.js +54 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +818 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +47 -0
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +103 -0
- package/packages/dd-trace/src/opentracing/span.js +412 -0
- package/packages/dd-trace/src/opentracing/span_context.js +75 -0
- package/packages/dd-trace/src/opentracing/tracer.js +145 -0
- package/packages/dd-trace/src/payload-tagging/config/aws.json +106 -0
- package/packages/dd-trace/src/payload-tagging/config/index.js +44 -0
- package/packages/dd-trace/src/payload-tagging/index.js +110 -0
- package/packages/dd-trace/src/payload-tagging/tagging.js +94 -0
- package/packages/dd-trace/src/pkg.js +44 -0
- package/packages/dd-trace/src/plugin_manager.js +219 -0
- package/packages/dd-trace/src/plugins/apollo.js +59 -0
- package/packages/dd-trace/src/plugins/cache.js +16 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +786 -0
- package/packages/dd-trace/src/plugins/client.js +11 -0
- package/packages/dd-trace/src/plugins/composite.js +29 -0
- package/packages/dd-trace/src/plugins/consumer.js +21 -0
- package/packages/dd-trace/src/plugins/database.js +123 -0
- package/packages/dd-trace/src/plugins/inbound.js +11 -0
- package/packages/dd-trace/src/plugins/index.js +117 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +54 -0
- package/packages/dd-trace/src/plugins/outbound.js +159 -0
- package/packages/dd-trace/src/plugins/plugin.js +195 -0
- package/packages/dd-trace/src/plugins/producer.js +27 -0
- package/packages/dd-trace/src/plugins/schema.js +35 -0
- package/packages/dd-trace/src/plugins/server.js +11 -0
- package/packages/dd-trace/src/plugins/storage.js +23 -0
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +9 -0
- package/packages/dd-trace/src/plugins/tracing.js +222 -0
- package/packages/dd-trace/src/plugins/util/ci.js +843 -0
- package/packages/dd-trace/src/plugins/util/env.js +31 -0
- package/packages/dd-trace/src/plugins/util/git-cache.js +129 -0
- package/packages/dd-trace/src/plugins/util/git.js +613 -0
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +157 -0
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +139 -0
- package/packages/dd-trace/src/plugins/util/llm.js +54 -0
- package/packages/dd-trace/src/plugins/util/stacktrace.js +244 -0
- package/packages/dd-trace/src/plugins/util/tags.js +81 -0
- package/packages/dd-trace/src/plugins/util/test.js +1202 -0
- package/packages/dd-trace/src/plugins/util/url.js +146 -0
- package/packages/dd-trace/src/plugins/util/urlfilter.js +32 -0
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +91 -0
- package/packages/dd-trace/src/plugins/util/web.js +631 -0
- package/packages/dd-trace/src/priority_sampler.js +374 -0
- package/packages/dd-trace/src/process-tags/index.js +83 -0
- package/packages/dd-trace/src/profiler.js +17 -0
- package/packages/dd-trace/src/profiling/config.js +473 -0
- package/packages/dd-trace/src/profiling/constants.js +15 -0
- package/packages/dd-trace/src/profiling/exporter_cli.js +74 -0
- package/packages/dd-trace/src/profiling/exporters/agent.js +199 -0
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +91 -0
- package/packages/dd-trace/src/profiling/exporters/file.js +35 -0
- package/packages/dd-trace/src/profiling/index.js +20 -0
- package/packages/dd-trace/src/profiling/libuv-size.js +49 -0
- package/packages/dd-trace/src/profiling/loggers/console.js +41 -0
- package/packages/dd-trace/src/profiling/profiler.js +430 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +11 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +24 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +16 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +66 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +45 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +20 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +466 -0
- package/packages/dd-trace/src/profiling/profilers/poisson.js +105 -0
- package/packages/dd-trace/src/profiling/profilers/shared.js +55 -0
- package/packages/dd-trace/src/profiling/profilers/space.js +77 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +434 -0
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +84 -0
- package/packages/dd-trace/src/profiling/tagger.js +40 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +25 -0
- package/packages/dd-trace/src/propagation-hash/index.js +145 -0
- package/packages/dd-trace/src/proxy.js +351 -0
- package/packages/dd-trace/src/random_sampler.js +40 -0
- package/packages/dd-trace/src/rate_limiter.js +82 -0
- package/packages/dd-trace/src/remote_config/apply_states.js +7 -0
- package/packages/dd-trace/src/remote_config/capabilities.js +47 -0
- package/packages/dd-trace/src/remote_config/index.js +574 -0
- package/packages/dd-trace/src/remote_config/scheduler.js +30 -0
- package/packages/dd-trace/src/require-package-json.js +33 -0
- package/packages/dd-trace/src/ritm.js +211 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +34 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +373 -0
- package/packages/dd-trace/src/sampler.js +63 -0
- package/packages/dd-trace/src/sampling_rule.js +267 -0
- package/packages/dd-trace/src/scope.js +63 -0
- package/packages/dd-trace/src/serverless.js +52 -0
- package/packages/dd-trace/src/service-naming/extra-services.js +24 -0
- package/packages/dd-trace/src/service-naming/index.js +75 -0
- package/packages/dd-trace/src/service-naming/schemas/definition.js +19 -0
- package/packages/dd-trace/src/service-naming/schemas/util.js +25 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +14 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +11 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +102 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +18 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +118 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +92 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +30 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +14 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +11 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +90 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +18 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +86 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +92 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +30 -0
- package/packages/dd-trace/src/span_format.js +264 -0
- package/packages/dd-trace/src/span_processor.js +171 -0
- package/packages/dd-trace/src/span_sampler.js +58 -0
- package/packages/dd-trace/src/span_stats.js +227 -0
- package/packages/dd-trace/src/spanleak.js +97 -0
- package/packages/dd-trace/src/standalone/index.js +70 -0
- package/packages/dd-trace/src/standalone/product.js +36 -0
- package/packages/dd-trace/src/standalone/tracesource.js +36 -0
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +59 -0
- package/packages/dd-trace/src/startup-log.js +146 -0
- package/packages/dd-trace/src/tagger.js +58 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +174 -0
- package/packages/dd-trace/src/telemetry/endpoints.js +212 -0
- package/packages/dd-trace/src/telemetry/index.js +26 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +90 -0
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +128 -0
- package/packages/dd-trace/src/telemetry/metrics.js +288 -0
- package/packages/dd-trace/src/telemetry/send-data.js +225 -0
- package/packages/dd-trace/src/telemetry/telemetry.js +535 -0
- package/packages/dd-trace/src/tracer.js +171 -0
- package/packages/dd-trace/src/tracer_metadata.js +29 -0
- package/packages/dd-trace/src/util.js +94 -0
- package/register.js +8 -0
- package/scripts/preinstall.js +34 -0
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
- package/version.js +18 -0
|
@@ -0,0 +1,1116 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const path = require('node:path')
|
|
3
|
+
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const log = require('../../dd-trace/src/log')
|
|
6
|
+
const {
|
|
7
|
+
VITEST_WORKER_TRACE_PAYLOAD_CODE,
|
|
8
|
+
VITEST_WORKER_LOGS_PAYLOAD_CODE,
|
|
9
|
+
} = require('../../dd-trace/src/plugins/util/test')
|
|
10
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
11
|
+
|
|
12
|
+
// test hooks
|
|
13
|
+
const testStartCh = channel('ci:vitest:test:start')
|
|
14
|
+
const testFinishTimeCh = channel('ci:vitest:test:finish-time')
|
|
15
|
+
const testPassCh = channel('ci:vitest:test:pass')
|
|
16
|
+
const testErrorCh = channel('ci:vitest:test:error')
|
|
17
|
+
const testSkipCh = channel('ci:vitest:test:skip')
|
|
18
|
+
const isNewTestCh = channel('ci:vitest:test:is-new')
|
|
19
|
+
const isAttemptToFixCh = channel('ci:vitest:test:is-attempt-to-fix')
|
|
20
|
+
const isDisabledCh = channel('ci:vitest:test:is-disabled')
|
|
21
|
+
const isQuarantinedCh = channel('ci:vitest:test:is-quarantined')
|
|
22
|
+
const isModifiedCh = channel('ci:vitest:test:is-modified')
|
|
23
|
+
|
|
24
|
+
// test suite hooks
|
|
25
|
+
const testSuiteStartCh = channel('ci:vitest:test-suite:start')
|
|
26
|
+
const testSuiteFinishCh = channel('ci:vitest:test-suite:finish')
|
|
27
|
+
const testSuiteErrorCh = channel('ci:vitest:test-suite:error')
|
|
28
|
+
|
|
29
|
+
// test session hooks
|
|
30
|
+
const testSessionStartCh = channel('ci:vitest:session:start')
|
|
31
|
+
const testSessionFinishCh = channel('ci:vitest:session:finish')
|
|
32
|
+
const libraryConfigurationCh = channel('ci:vitest:library-configuration')
|
|
33
|
+
const knownTestsCh = channel('ci:vitest:known-tests')
|
|
34
|
+
const isEarlyFlakeDetectionFaultyCh = channel('ci:vitest:is-early-flake-detection-faulty')
|
|
35
|
+
const testManagementTestsCh = channel('ci:vitest:test-management-tests')
|
|
36
|
+
const modifiedFilesCh = channel('ci:vitest:modified-files')
|
|
37
|
+
|
|
38
|
+
const workerReportTraceCh = channel('ci:vitest:worker-report:trace')
|
|
39
|
+
const workerReportLogsCh = channel('ci:vitest:worker-report:logs')
|
|
40
|
+
const codeCoverageReportCh = channel('ci:vitest:coverage-report')
|
|
41
|
+
|
|
42
|
+
const taskToCtx = new WeakMap()
|
|
43
|
+
const taskToStatuses = new WeakMap()
|
|
44
|
+
const newTasks = new WeakSet()
|
|
45
|
+
const disabledTasks = new WeakSet()
|
|
46
|
+
const quarantinedTasks = new WeakSet()
|
|
47
|
+
const attemptToFixTasks = new WeakSet()
|
|
48
|
+
const modifiedTasks = new WeakSet()
|
|
49
|
+
let isRetryReasonEfd = false
|
|
50
|
+
let isRetryReasonAttemptToFix = false
|
|
51
|
+
const switchedStatuses = new WeakSet()
|
|
52
|
+
const workerProcesses = new WeakSet()
|
|
53
|
+
let isFlakyTestRetriesEnabled = false
|
|
54
|
+
let flakyTestRetriesCount = 0
|
|
55
|
+
let isEarlyFlakeDetectionEnabled = false
|
|
56
|
+
let earlyFlakeDetectionNumRetries = 0
|
|
57
|
+
let isEarlyFlakeDetectionFaulty = false
|
|
58
|
+
let isKnownTestsEnabled = false
|
|
59
|
+
let isTestManagementTestsEnabled = false
|
|
60
|
+
let isImpactedTestsEnabled = false
|
|
61
|
+
let testManagementAttemptToFixRetries = 0
|
|
62
|
+
let isDiEnabled = false
|
|
63
|
+
let testCodeCoverageLinesTotal
|
|
64
|
+
let coverageRootDir
|
|
65
|
+
let isSessionStarted = false
|
|
66
|
+
let vitestPool = null
|
|
67
|
+
|
|
68
|
+
const BREAKPOINT_HIT_GRACE_PERIOD_MS = 400
|
|
69
|
+
|
|
70
|
+
function getTestCommand () {
|
|
71
|
+
return `vitest ${process.argv.slice(2).join(' ')}`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function waitForHitProbe () {
|
|
75
|
+
return new Promise(resolve => {
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
resolve()
|
|
78
|
+
}, BREAKPOINT_HIT_GRACE_PERIOD_MS)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isValidKnownTests (receivedKnownTests) {
|
|
83
|
+
return !!receivedKnownTests.vitest
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getProvidedContext () {
|
|
87
|
+
try {
|
|
88
|
+
const {
|
|
89
|
+
_ddIsEarlyFlakeDetectionEnabled,
|
|
90
|
+
_ddIsDiEnabled,
|
|
91
|
+
_ddKnownTests: knownTests,
|
|
92
|
+
_ddEarlyFlakeDetectionNumRetries: numRepeats,
|
|
93
|
+
_ddIsKnownTestsEnabled: isKnownTestsEnabled,
|
|
94
|
+
_ddIsTestManagementTestsEnabled: isTestManagementTestsEnabled,
|
|
95
|
+
_ddTestManagementAttemptToFixRetries: testManagementAttemptToFixRetries,
|
|
96
|
+
_ddTestManagementTests: testManagementTests,
|
|
97
|
+
_ddIsFlakyTestRetriesEnabled: isFlakyTestRetriesEnabled,
|
|
98
|
+
_ddFlakyTestRetriesCount: flakyTestRetriesCount,
|
|
99
|
+
_ddIsImpactedTestsEnabled: isImpactedTestsEnabled,
|
|
100
|
+
_ddModifiedFiles: modifiedFiles,
|
|
101
|
+
} = globalThis.__vitest_worker__.providedContext
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
isDiEnabled: _ddIsDiEnabled,
|
|
105
|
+
isEarlyFlakeDetectionEnabled: _ddIsEarlyFlakeDetectionEnabled,
|
|
106
|
+
knownTests,
|
|
107
|
+
numRepeats,
|
|
108
|
+
isKnownTestsEnabled,
|
|
109
|
+
isTestManagementTestsEnabled,
|
|
110
|
+
testManagementAttemptToFixRetries,
|
|
111
|
+
testManagementTests,
|
|
112
|
+
isFlakyTestRetriesEnabled,
|
|
113
|
+
flakyTestRetriesCount: flakyTestRetriesCount ?? 0,
|
|
114
|
+
isImpactedTestsEnabled,
|
|
115
|
+
modifiedFiles,
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
log.error('Vitest workers could not parse provided context, so some features will not work.')
|
|
119
|
+
return {
|
|
120
|
+
isDiEnabled: false,
|
|
121
|
+
isEarlyFlakeDetectionEnabled: false,
|
|
122
|
+
knownTests: {},
|
|
123
|
+
numRepeats: 0,
|
|
124
|
+
isKnownTestsEnabled: false,
|
|
125
|
+
isTestManagementTestsEnabled: false,
|
|
126
|
+
testManagementAttemptToFixRetries: 0,
|
|
127
|
+
testManagementTests: {},
|
|
128
|
+
isFlakyTestRetriesEnabled: false,
|
|
129
|
+
flakyTestRetriesCount: 0,
|
|
130
|
+
isImpactedTestsEnabled: false,
|
|
131
|
+
modifiedFiles: {},
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function isReporterPackage (vitestPackage) {
|
|
137
|
+
return vitestPackage.B?.name === 'BaseSequencer'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// from 2.0.0
|
|
141
|
+
function isReporterPackageNew (vitestPackage) {
|
|
142
|
+
return vitestPackage.e?.name === 'BaseSequencer'
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function isReporterPackageNewest (vitestPackage) {
|
|
146
|
+
return vitestPackage.h?.name === 'BaseSequencer'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function isBaseSequencer (vitestPackage) {
|
|
150
|
+
return vitestPackage.b?.name === 'BaseSequencer'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getChannelPromise (channelToPublishTo, frameworkVersion) {
|
|
154
|
+
return new Promise(resolve => {
|
|
155
|
+
channelToPublishTo.publish({ onDone: resolve, frameworkVersion })
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function isCliApiPackage (vitestPackage) {
|
|
160
|
+
return vitestPackage.s?.name === 'startVitest'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function isTestPackage (testPackage) {
|
|
164
|
+
return testPackage.V?.name === 'VitestTestRunner'
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function hasForksPoolWorker (vitestPackage) {
|
|
168
|
+
return vitestPackage.f?.name === 'ForksPoolWorker'
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function hasThreadsPoolWorker (vitestPackage) {
|
|
172
|
+
return vitestPackage.T?.name === 'ThreadsPoolWorker'
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function getSessionStatus (state) {
|
|
176
|
+
if (state.getCountOfFailedTests() > 0) {
|
|
177
|
+
return 'fail'
|
|
178
|
+
}
|
|
179
|
+
if (state.pathsSet.size === 0) {
|
|
180
|
+
return 'skip'
|
|
181
|
+
}
|
|
182
|
+
return 'pass'
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// From https://github.com/vitest-dev/vitest/blob/51c04e2f44d91322b334f8ccbcdb368facc3f8ec/packages/runner/src/run.ts#L243-L250
|
|
186
|
+
function getVitestTestStatus (test, retryCount) {
|
|
187
|
+
if (test.result.state !== 'fail') {
|
|
188
|
+
if (!test.repeats) {
|
|
189
|
+
return 'pass'
|
|
190
|
+
} else if (test.repeats && (test.retry ?? 0) === retryCount) {
|
|
191
|
+
return 'pass'
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return 'fail'
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function getTypeTasks (fileTasks, type = 'test') {
|
|
198
|
+
const typeTasks = []
|
|
199
|
+
|
|
200
|
+
function getTasks (tasks) {
|
|
201
|
+
for (const task of tasks) {
|
|
202
|
+
if (task.type === type) {
|
|
203
|
+
typeTasks.push(task)
|
|
204
|
+
} else if (task.tasks) {
|
|
205
|
+
getTasks(task.tasks)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
getTasks(fileTasks)
|
|
211
|
+
|
|
212
|
+
return typeTasks
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getTestName (task) {
|
|
216
|
+
let testName = task.name
|
|
217
|
+
let currentTask = task.suite
|
|
218
|
+
|
|
219
|
+
while (currentTask) {
|
|
220
|
+
if (currentTask.name) {
|
|
221
|
+
testName = `${currentTask.name} ${testName}`
|
|
222
|
+
}
|
|
223
|
+
currentTask = currentTask.suite
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return testName
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function getSortWrapper (sort, frameworkVersion) {
|
|
230
|
+
return async function () {
|
|
231
|
+
if (!testSessionFinishCh.hasSubscribers) {
|
|
232
|
+
return sort.apply(this, arguments)
|
|
233
|
+
}
|
|
234
|
+
// There isn't any other async function that we seem to be able to hook into
|
|
235
|
+
// So we will use the sort from BaseSequencer. This means that a custom sequencer
|
|
236
|
+
// will not work. This will be a known limitation.
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
const { err, libraryConfig } = await getChannelPromise(libraryConfigurationCh, frameworkVersion)
|
|
240
|
+
if (!err) {
|
|
241
|
+
isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
242
|
+
flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
243
|
+
isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
244
|
+
earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
245
|
+
isDiEnabled = libraryConfig.isDiEnabled
|
|
246
|
+
isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
247
|
+
isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
248
|
+
testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
249
|
+
isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
250
|
+
}
|
|
251
|
+
} catch {
|
|
252
|
+
isFlakyTestRetriesEnabled = false
|
|
253
|
+
isEarlyFlakeDetectionEnabled = false
|
|
254
|
+
isDiEnabled = false
|
|
255
|
+
isKnownTestsEnabled = false
|
|
256
|
+
isImpactedTestsEnabled = false
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (isFlakyTestRetriesEnabled && !this.ctx.config.retry && flakyTestRetriesCount > 0) {
|
|
260
|
+
this.ctx.config.retry = flakyTestRetriesCount
|
|
261
|
+
try {
|
|
262
|
+
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
263
|
+
? this.ctx.getCoreWorkspaceProject()
|
|
264
|
+
: this.ctx.getRootProject()
|
|
265
|
+
workspaceProject._provided._ddIsFlakyTestRetriesEnabled = isFlakyTestRetriesEnabled
|
|
266
|
+
workspaceProject._provided._ddFlakyTestRetriesCount = flakyTestRetriesCount
|
|
267
|
+
} catch {
|
|
268
|
+
log.warn('Could not send library configuration to workers.')
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (isKnownTestsEnabled) {
|
|
273
|
+
const knownTestsResponse = await getChannelPromise(knownTestsCh)
|
|
274
|
+
if (knownTestsResponse.err) {
|
|
275
|
+
isEarlyFlakeDetectionEnabled = false
|
|
276
|
+
} else {
|
|
277
|
+
const knownTests = knownTestsResponse.knownTests
|
|
278
|
+
const getFilePaths = this.ctx.getTestFilepaths || this.ctx._globTestFilepaths
|
|
279
|
+
|
|
280
|
+
const testFilepaths = await getFilePaths.call(this.ctx)
|
|
281
|
+
|
|
282
|
+
if (isValidKnownTests(knownTests)) {
|
|
283
|
+
isEarlyFlakeDetectionFaultyCh.publish({
|
|
284
|
+
knownTests: knownTests.vitest,
|
|
285
|
+
testFilepaths,
|
|
286
|
+
onDone: (isFaulty) => {
|
|
287
|
+
isEarlyFlakeDetectionFaulty = isFaulty
|
|
288
|
+
},
|
|
289
|
+
})
|
|
290
|
+
if (isEarlyFlakeDetectionFaulty) {
|
|
291
|
+
isEarlyFlakeDetectionEnabled = false
|
|
292
|
+
log.warn('New test detection is disabled because the number of new tests is too high.')
|
|
293
|
+
} else {
|
|
294
|
+
// TODO: use this to pass session and module IDs to the worker, instead of polluting process.env
|
|
295
|
+
// Note: setting this.ctx.config.provide directly does not work because it's cached
|
|
296
|
+
try {
|
|
297
|
+
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
298
|
+
? this.ctx.getCoreWorkspaceProject()
|
|
299
|
+
: this.ctx.getRootProject()
|
|
300
|
+
workspaceProject._provided._ddIsKnownTestsEnabled = isKnownTestsEnabled
|
|
301
|
+
workspaceProject._provided._ddKnownTests = knownTests
|
|
302
|
+
workspaceProject._provided._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
303
|
+
workspaceProject._provided._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
304
|
+
} catch {
|
|
305
|
+
log.warn('Could not send known tests to workers so Early Flake Detection will not work.')
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
isEarlyFlakeDetectionFaulty = true
|
|
310
|
+
isEarlyFlakeDetectionEnabled = false
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (isDiEnabled) {
|
|
316
|
+
try {
|
|
317
|
+
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
318
|
+
? this.ctx.getCoreWorkspaceProject()
|
|
319
|
+
: this.ctx.getRootProject()
|
|
320
|
+
workspaceProject._provided._ddIsDiEnabled = isDiEnabled
|
|
321
|
+
} catch {
|
|
322
|
+
log.warn('Could not send Dynamic Instrumentation configuration to workers.')
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (isTestManagementTestsEnabled) {
|
|
327
|
+
const { err, testManagementTests: receivedTestManagementTests } = await getChannelPromise(testManagementTestsCh)
|
|
328
|
+
if (err) {
|
|
329
|
+
isTestManagementTestsEnabled = false
|
|
330
|
+
log.error('Could not get test management tests.')
|
|
331
|
+
} else {
|
|
332
|
+
const testManagementTests = receivedTestManagementTests
|
|
333
|
+
try {
|
|
334
|
+
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
335
|
+
? this.ctx.getCoreWorkspaceProject()
|
|
336
|
+
: this.ctx.getRootProject()
|
|
337
|
+
workspaceProject._provided._ddIsTestManagementTestsEnabled = isTestManagementTestsEnabled
|
|
338
|
+
workspaceProject._provided._ddTestManagementAttemptToFixRetries = testManagementAttemptToFixRetries
|
|
339
|
+
workspaceProject._provided._ddTestManagementTests = testManagementTests
|
|
340
|
+
} catch {
|
|
341
|
+
log.warn('Could not send test management tests to workers so Test Management will not work.')
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (isImpactedTestsEnabled) {
|
|
347
|
+
const { err, modifiedFiles } = await getChannelPromise(modifiedFilesCh)
|
|
348
|
+
if (err) {
|
|
349
|
+
log.error('Could not get modified tests.')
|
|
350
|
+
} else {
|
|
351
|
+
try {
|
|
352
|
+
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
353
|
+
? this.ctx.getCoreWorkspaceProject()
|
|
354
|
+
: this.ctx.getRootProject()
|
|
355
|
+
workspaceProject._provided._ddIsImpactedTestsEnabled = isImpactedTestsEnabled
|
|
356
|
+
workspaceProject._provided._ddModifiedFiles = modifiedFiles
|
|
357
|
+
} catch {
|
|
358
|
+
log.warn('Could not send modified tests to workers so Impacted Tests will not work.')
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (this.ctx.coverageProvider?.generateCoverage) {
|
|
364
|
+
// Capture coverage root directory from config (default is 'coverage' in cwd)
|
|
365
|
+
try {
|
|
366
|
+
const coverageConfig = this.ctx.config?.coverage
|
|
367
|
+
const reportsDirectory = coverageConfig?.reportsDirectory || 'coverage'
|
|
368
|
+
const rootDir = this.ctx.config?.root || process.cwd()
|
|
369
|
+
coverageRootDir = path.isAbsolute(reportsDirectory) ? reportsDirectory : path.join(rootDir, reportsDirectory)
|
|
370
|
+
} catch {
|
|
371
|
+
// Fallback to cwd if we can't get config
|
|
372
|
+
coverageRootDir = process.cwd()
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
shimmer.wrap(this.ctx.coverageProvider, 'generateCoverage', generateCoverage => async function () {
|
|
376
|
+
const totalCodeCoverage = await generateCoverage.apply(this, arguments)
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
testCodeCoverageLinesTotal = totalCodeCoverage.getCoverageSummary().lines.pct
|
|
380
|
+
} catch {
|
|
381
|
+
// ignore errors
|
|
382
|
+
}
|
|
383
|
+
return totalCodeCoverage
|
|
384
|
+
})
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
shimmer.wrap(this.ctx, 'exit', getFinishWrapper)
|
|
388
|
+
shimmer.wrap(this.ctx, 'close', getFinishWrapper)
|
|
389
|
+
|
|
390
|
+
return sort.apply(this, arguments)
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function getFinishWrapper (exitOrClose) {
|
|
395
|
+
let isClosed = false
|
|
396
|
+
return async function () {
|
|
397
|
+
if (isClosed) { // needed because exit calls close
|
|
398
|
+
return exitOrClose.apply(this, arguments)
|
|
399
|
+
}
|
|
400
|
+
isClosed = true
|
|
401
|
+
let onFinish
|
|
402
|
+
|
|
403
|
+
const flushPromise = new Promise(resolve => {
|
|
404
|
+
onFinish = resolve
|
|
405
|
+
})
|
|
406
|
+
const failedSuites = this.state.getFailedFilepaths()
|
|
407
|
+
let error
|
|
408
|
+
if (failedSuites.length) {
|
|
409
|
+
error = new Error(`Test suites failed: ${failedSuites.length}.`)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
testSessionFinishCh.publish({
|
|
413
|
+
status: getSessionStatus(this.state),
|
|
414
|
+
testCodeCoverageLinesTotal,
|
|
415
|
+
error,
|
|
416
|
+
isEarlyFlakeDetectionEnabled,
|
|
417
|
+
isEarlyFlakeDetectionFaulty,
|
|
418
|
+
isTestManagementTestsEnabled,
|
|
419
|
+
vitestPool,
|
|
420
|
+
onFinish,
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
await flushPromise
|
|
424
|
+
|
|
425
|
+
// If coverage was generated, publish coverage report channel for upload
|
|
426
|
+
if (coverageRootDir && codeCoverageReportCh.hasSubscribers) {
|
|
427
|
+
await new Promise((resolve) => {
|
|
428
|
+
codeCoverageReportCh.publish({ rootDir: coverageRootDir, onDone: resolve })
|
|
429
|
+
})
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return exitOrClose.apply(this, arguments)
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
437
|
+
return function (oldCliOrStartVitest) {
|
|
438
|
+
return function () {
|
|
439
|
+
if (!testSessionStartCh.hasSubscribers || isSessionStarted) {
|
|
440
|
+
return oldCliOrStartVitest.apply(this, arguments)
|
|
441
|
+
}
|
|
442
|
+
isSessionStarted = true
|
|
443
|
+
testSessionStartCh.publish({ command: getTestCommand(), frameworkVersion })
|
|
444
|
+
return oldCliOrStartVitest.apply(this, arguments)
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function getCreateCliWrapper (vitestPackage, frameworkVersion) {
|
|
450
|
+
shimmer.wrap(vitestPackage, 'c', getCliOrStartVitestWrapper(frameworkVersion))
|
|
451
|
+
|
|
452
|
+
return vitestPackage
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function threadHandler (thread) {
|
|
456
|
+
const { runtime } = thread
|
|
457
|
+
let workerProcess
|
|
458
|
+
if (runtime === 'child_process') {
|
|
459
|
+
vitestPool = 'child_process'
|
|
460
|
+
workerProcess = thread.process
|
|
461
|
+
} else if (runtime === 'worker_threads') {
|
|
462
|
+
vitestPool = 'worker_threads'
|
|
463
|
+
workerProcess = thread.thread
|
|
464
|
+
} else {
|
|
465
|
+
vitestPool = 'unknown'
|
|
466
|
+
}
|
|
467
|
+
if (!workerProcess) {
|
|
468
|
+
log.error('Vitest error: could not get process or thread from TinyPool#run')
|
|
469
|
+
return
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (workerProcesses.has(workerProcess)) {
|
|
473
|
+
return
|
|
474
|
+
}
|
|
475
|
+
workerProcesses.add(workerProcess)
|
|
476
|
+
workerProcess.on('message', (message) => {
|
|
477
|
+
if (message.__tinypool_worker_message__ && message.data) {
|
|
478
|
+
if (message.interprocessCode === VITEST_WORKER_TRACE_PAYLOAD_CODE) {
|
|
479
|
+
workerReportTraceCh.publish(message.data)
|
|
480
|
+
} else if (message.interprocessCode === VITEST_WORKER_LOGS_PAYLOAD_CODE) {
|
|
481
|
+
workerReportLogsCh.publish(message.data)
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function wrapTinyPoolRun (TinyPool) {
|
|
488
|
+
shimmer.wrap(TinyPool.prototype, 'run', run => async function () {
|
|
489
|
+
// We have to do this before and after because the threads list gets recycled, that is, the processes are re-created
|
|
490
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
491
|
+
this.threads.forEach(threadHandler)
|
|
492
|
+
const runResult = await run.apply(this, arguments)
|
|
493
|
+
// eslint-disable-next-line unicorn/no-array-for-each
|
|
494
|
+
this.threads.forEach(threadHandler)
|
|
495
|
+
return runResult
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
addHook({
|
|
500
|
+
name: 'tinypool',
|
|
501
|
+
// version from tinypool@0.8 was used in vitest@1.6.0
|
|
502
|
+
versions: ['>=0.8.0'],
|
|
503
|
+
}, (TinyPool) => {
|
|
504
|
+
wrapTinyPoolRun(TinyPool)
|
|
505
|
+
return TinyPool
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
function getWrappedOn (on) {
|
|
509
|
+
return function (event, callback) {
|
|
510
|
+
if (event !== 'message') {
|
|
511
|
+
return on.apply(this, arguments)
|
|
512
|
+
}
|
|
513
|
+
// `arguments[1]` is the callback function, which
|
|
514
|
+
// we modify to intercept our messages to not interfere
|
|
515
|
+
// with vitest's own messages
|
|
516
|
+
arguments[1] = shimmer.wrapFunction(callback, callback => function (message) {
|
|
517
|
+
if (message.type !== 'Buffer' && Array.isArray(message)) {
|
|
518
|
+
const [interprocessCode, data] = message
|
|
519
|
+
if (interprocessCode === VITEST_WORKER_TRACE_PAYLOAD_CODE) {
|
|
520
|
+
workerReportTraceCh.publish(data)
|
|
521
|
+
} else if (interprocessCode === VITEST_WORKER_LOGS_PAYLOAD_CODE) {
|
|
522
|
+
workerReportLogsCh.publish(data)
|
|
523
|
+
}
|
|
524
|
+
// If we execute the callback vitest crashes, as the message is not supported
|
|
525
|
+
return
|
|
526
|
+
}
|
|
527
|
+
return callback.apply(this, arguments)
|
|
528
|
+
})
|
|
529
|
+
return on.apply(this, arguments)
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
534
|
+
if (!isCliApiPackage(cliApiPackage)) {
|
|
535
|
+
return cliApiPackage
|
|
536
|
+
}
|
|
537
|
+
shimmer.wrap(cliApiPackage, 's', getCliOrStartVitestWrapper(frameworkVersion))
|
|
538
|
+
|
|
539
|
+
if (hasForksPoolWorker(cliApiPackage)) {
|
|
540
|
+
// function is async
|
|
541
|
+
shimmer.wrap(cliApiPackage.f.prototype, 'start', start => function () {
|
|
542
|
+
vitestPool = 'child_process'
|
|
543
|
+
this.env.DD_VITEST_WORKER = '1'
|
|
544
|
+
|
|
545
|
+
return start.apply(this, arguments)
|
|
546
|
+
})
|
|
547
|
+
shimmer.wrap(cliApiPackage.f.prototype, 'on', getWrappedOn)
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (hasThreadsPoolWorker(cliApiPackage)) {
|
|
551
|
+
// function is async
|
|
552
|
+
shimmer.wrap(cliApiPackage.T.prototype, 'start', start => function () {
|
|
553
|
+
vitestPool = 'worker_threads'
|
|
554
|
+
this.env.DD_VITEST_WORKER = '1'
|
|
555
|
+
return start.apply(this, arguments)
|
|
556
|
+
})
|
|
557
|
+
shimmer.wrap(cliApiPackage.T.prototype, 'on', getWrappedOn)
|
|
558
|
+
}
|
|
559
|
+
return cliApiPackage
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function wrapVitestTestRunner (VitestTestRunner) {
|
|
563
|
+
// `onBeforeRunTask` is run before any repetition or attempt is run
|
|
564
|
+
// `onBeforeRunTask` is an async function
|
|
565
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeRunTask', onBeforeRunTask => function (task) {
|
|
566
|
+
const testName = getTestName(task)
|
|
567
|
+
|
|
568
|
+
const {
|
|
569
|
+
knownTests,
|
|
570
|
+
isEarlyFlakeDetectionEnabled,
|
|
571
|
+
isKnownTestsEnabled,
|
|
572
|
+
numRepeats,
|
|
573
|
+
isTestManagementTestsEnabled,
|
|
574
|
+
testManagementAttemptToFixRetries,
|
|
575
|
+
testManagementTests,
|
|
576
|
+
isImpactedTestsEnabled,
|
|
577
|
+
modifiedFiles,
|
|
578
|
+
} = getProvidedContext()
|
|
579
|
+
|
|
580
|
+
if (isTestManagementTestsEnabled) {
|
|
581
|
+
isAttemptToFixCh.publish({
|
|
582
|
+
testManagementTests,
|
|
583
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
584
|
+
testName,
|
|
585
|
+
onDone: (isAttemptToFix) => {
|
|
586
|
+
if (isAttemptToFix) {
|
|
587
|
+
isRetryReasonAttemptToFix = task.repeats !== testManagementAttemptToFixRetries
|
|
588
|
+
task.repeats = testManagementAttemptToFixRetries
|
|
589
|
+
attemptToFixTasks.add(task)
|
|
590
|
+
taskToStatuses.set(task, [])
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
})
|
|
594
|
+
isDisabledCh.publish({
|
|
595
|
+
testManagementTests,
|
|
596
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
597
|
+
testName,
|
|
598
|
+
onDone: (isTestDisabled) => {
|
|
599
|
+
if (isTestDisabled) {
|
|
600
|
+
disabledTasks.add(task)
|
|
601
|
+
if (!attemptToFixTasks.has(task)) {
|
|
602
|
+
// we only actually skip if the test is not being attempted to be fixed
|
|
603
|
+
task.mode = 'skip'
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
})
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (isImpactedTestsEnabled) {
|
|
611
|
+
isModifiedCh.publish({
|
|
612
|
+
modifiedFiles,
|
|
613
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
614
|
+
onDone: (isImpacted) => {
|
|
615
|
+
if (isImpacted) {
|
|
616
|
+
if (isEarlyFlakeDetectionEnabled) {
|
|
617
|
+
isRetryReasonEfd = task.repeats !== numRepeats
|
|
618
|
+
task.repeats = numRepeats
|
|
619
|
+
}
|
|
620
|
+
modifiedTasks.add(task)
|
|
621
|
+
taskToStatuses.set(task, [])
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
})
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (isKnownTestsEnabled) {
|
|
628
|
+
isNewTestCh.publish({
|
|
629
|
+
knownTests,
|
|
630
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
631
|
+
testName,
|
|
632
|
+
onDone: (isNew) => {
|
|
633
|
+
if (isNew && !attemptToFixTasks.has(task)) {
|
|
634
|
+
if (isEarlyFlakeDetectionEnabled && !modifiedTasks.has(task)) {
|
|
635
|
+
isRetryReasonEfd = task.repeats !== numRepeats
|
|
636
|
+
task.repeats = numRepeats
|
|
637
|
+
}
|
|
638
|
+
newTasks.add(task)
|
|
639
|
+
taskToStatuses.set(task, [])
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
})
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
return onBeforeRunTask.apply(this, arguments)
|
|
646
|
+
})
|
|
647
|
+
|
|
648
|
+
// `onAfterRunTask` is run after all repetitions or attempts are run
|
|
649
|
+
// `onAfterRunTask` is an async function
|
|
650
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onAfterRunTask', onAfterRunTask => function (task) {
|
|
651
|
+
const { isEarlyFlakeDetectionEnabled, isTestManagementTestsEnabled } = getProvidedContext()
|
|
652
|
+
|
|
653
|
+
if (isTestManagementTestsEnabled) {
|
|
654
|
+
const isAttemptingToFix = attemptToFixTasks.has(task)
|
|
655
|
+
const isDisabled = disabledTasks.has(task)
|
|
656
|
+
const isQuarantined = quarantinedTasks.has(task)
|
|
657
|
+
|
|
658
|
+
if (isAttemptingToFix && (isDisabled || isQuarantined)) {
|
|
659
|
+
if (task.result.state === 'fail') {
|
|
660
|
+
switchedStatuses.add(task)
|
|
661
|
+
}
|
|
662
|
+
task.result.state = 'pass'
|
|
663
|
+
} else if (isQuarantined) {
|
|
664
|
+
if (task.result.state === 'fail') {
|
|
665
|
+
switchedStatuses.add(task)
|
|
666
|
+
}
|
|
667
|
+
task.result.state = 'pass'
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (isEarlyFlakeDetectionEnabled && taskToStatuses.has(task) && !attemptToFixTasks.has(task)) {
|
|
672
|
+
const statuses = taskToStatuses.get(task)
|
|
673
|
+
// If the test has passed at least once, we consider it passed
|
|
674
|
+
if (statuses.includes('pass')) {
|
|
675
|
+
if (task.result.state === 'fail') {
|
|
676
|
+
switchedStatuses.add(task)
|
|
677
|
+
}
|
|
678
|
+
task.result.state = 'pass'
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return onAfterRunTask.apply(this, arguments)
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
// test start (only tests that are not marked as skip or todo)
|
|
686
|
+
// `onBeforeTryTask` is run for every repetition and attempt of the test
|
|
687
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeTryTask', onBeforeTryTask => async function (task, retryInfo) {
|
|
688
|
+
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
689
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
690
|
+
}
|
|
691
|
+
const testName = getTestName(task)
|
|
692
|
+
let isNew = false
|
|
693
|
+
let isQuarantined = false
|
|
694
|
+
|
|
695
|
+
const {
|
|
696
|
+
isKnownTestsEnabled,
|
|
697
|
+
isEarlyFlakeDetectionEnabled,
|
|
698
|
+
isDiEnabled,
|
|
699
|
+
isTestManagementTestsEnabled,
|
|
700
|
+
testManagementTests,
|
|
701
|
+
isFlakyTestRetriesEnabled,
|
|
702
|
+
} = getProvidedContext()
|
|
703
|
+
|
|
704
|
+
if (isKnownTestsEnabled) {
|
|
705
|
+
isNew = newTasks.has(task)
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (isTestManagementTestsEnabled) {
|
|
709
|
+
isQuarantinedCh.publish({
|
|
710
|
+
testManagementTests,
|
|
711
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
712
|
+
testName,
|
|
713
|
+
onDone: (isTestQuarantined) => {
|
|
714
|
+
isQuarantined = isTestQuarantined
|
|
715
|
+
if (isTestQuarantined) {
|
|
716
|
+
quarantinedTasks.add(task)
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
})
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
const { retry: numAttempt, repeats: numRepetition } = retryInfo
|
|
723
|
+
|
|
724
|
+
// We finish the previous test here because we know it has failed already
|
|
725
|
+
if (numAttempt > 0) {
|
|
726
|
+
const shouldWaitForHitProbe = isDiEnabled && numAttempt > 1
|
|
727
|
+
if (shouldWaitForHitProbe) {
|
|
728
|
+
await waitForHitProbe()
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
const promises = {}
|
|
732
|
+
const shouldSetProbe = isDiEnabled && numAttempt === 1
|
|
733
|
+
const ctx = taskToCtx.get(task)
|
|
734
|
+
const testError = task.result?.errors?.[0]
|
|
735
|
+
if (ctx) {
|
|
736
|
+
testErrorCh.publish({
|
|
737
|
+
error: testError,
|
|
738
|
+
shouldSetProbe,
|
|
739
|
+
promises,
|
|
740
|
+
...ctx.currentStore,
|
|
741
|
+
})
|
|
742
|
+
// We wait for the probe to be set
|
|
743
|
+
if (promises.setProbePromise) {
|
|
744
|
+
await promises.setProbePromise
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const lastExecutionStatus = task.result.state
|
|
750
|
+
const shouldFlipStatus = isEarlyFlakeDetectionEnabled || attemptToFixTasks.has(task)
|
|
751
|
+
const statuses = taskToStatuses.get(task)
|
|
752
|
+
|
|
753
|
+
// These clauses handle task.repeats, whether EFD is enabled or not
|
|
754
|
+
// The only thing that EFD does is to forcefully pass the test if it has passed at least once
|
|
755
|
+
if (numRepetition > 0 && numRepetition < task.repeats) { // it may or may have not failed
|
|
756
|
+
// Here we finish the earlier iteration,
|
|
757
|
+
// as long as it's not the _last_ iteration (which will be finished normally)
|
|
758
|
+
|
|
759
|
+
// TODO: check test duration (not to repeat if it's too slow)
|
|
760
|
+
const ctx = taskToCtx.get(task)
|
|
761
|
+
if (ctx) {
|
|
762
|
+
if (lastExecutionStatus === 'fail') {
|
|
763
|
+
const testError = task.result?.errors?.[0]
|
|
764
|
+
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
765
|
+
} else {
|
|
766
|
+
testPassCh.publish({ task, ...ctx.currentStore })
|
|
767
|
+
}
|
|
768
|
+
if (shouldFlipStatus) {
|
|
769
|
+
statuses.push(lastExecutionStatus)
|
|
770
|
+
// If we don't "reset" the result.state to "pass", once a repetition fails,
|
|
771
|
+
// vitest will always consider the test as failed, so we can't read the actual status
|
|
772
|
+
// This means that we change vitest's behavior:
|
|
773
|
+
// if the last attempt passes, vitest would consider the test as failed
|
|
774
|
+
// but after this change, it will consider the test as passed
|
|
775
|
+
task.result.state = 'pass'
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
} else if (numRepetition === task.repeats) {
|
|
779
|
+
if (shouldFlipStatus) {
|
|
780
|
+
statuses.push(lastExecutionStatus)
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
const ctx = taskToCtx.get(task)
|
|
784
|
+
if (lastExecutionStatus === 'fail') {
|
|
785
|
+
const testError = task.result?.errors?.[0]
|
|
786
|
+
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
787
|
+
} else {
|
|
788
|
+
testPassCh.publish({ task, ...ctx.currentStore })
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
const isRetryReasonAtr = numAttempt > 0 &&
|
|
793
|
+
isFlakyTestRetriesEnabled &&
|
|
794
|
+
!isRetryReasonAttemptToFix &&
|
|
795
|
+
!isRetryReasonEfd
|
|
796
|
+
|
|
797
|
+
const ctx = {
|
|
798
|
+
testName,
|
|
799
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
800
|
+
isRetry: numAttempt > 0 || numRepetition > 0,
|
|
801
|
+
isRetryReasonEfd,
|
|
802
|
+
isRetryReasonAttemptToFix: isRetryReasonAttemptToFix && numRepetition > 0,
|
|
803
|
+
isNew,
|
|
804
|
+
mightHitProbe: isDiEnabled && numAttempt > 0,
|
|
805
|
+
isAttemptToFix: attemptToFixTasks.has(task),
|
|
806
|
+
isDisabled: disabledTasks.has(task),
|
|
807
|
+
isQuarantined,
|
|
808
|
+
isRetryReasonAtr,
|
|
809
|
+
isModified: modifiedTasks.has(task),
|
|
810
|
+
}
|
|
811
|
+
taskToCtx.set(task, ctx)
|
|
812
|
+
|
|
813
|
+
testStartCh.runStores(ctx, () => {})
|
|
814
|
+
return onBeforeTryTask.apply(this, arguments)
|
|
815
|
+
})
|
|
816
|
+
|
|
817
|
+
// test finish (only passed tests)
|
|
818
|
+
shimmer.wrap(VitestTestRunner.prototype, 'onAfterTryTask', onAfterTryTask =>
|
|
819
|
+
async function (task, { retry: retryCount }) {
|
|
820
|
+
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
821
|
+
return onAfterTryTask.apply(this, arguments)
|
|
822
|
+
}
|
|
823
|
+
const result = await onAfterTryTask.apply(this, arguments)
|
|
824
|
+
|
|
825
|
+
const { testManagementAttemptToFixRetries } = getProvidedContext()
|
|
826
|
+
|
|
827
|
+
const status = getVitestTestStatus(task, retryCount)
|
|
828
|
+
const ctx = taskToCtx.get(task)
|
|
829
|
+
|
|
830
|
+
const { isDiEnabled } = getProvidedContext()
|
|
831
|
+
|
|
832
|
+
if (isDiEnabled && retryCount > 1) {
|
|
833
|
+
await waitForHitProbe()
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
let attemptToFixPassed = false
|
|
837
|
+
let attemptToFixFailed = false
|
|
838
|
+
if (attemptToFixTasks.has(task)) {
|
|
839
|
+
const statuses = taskToStatuses.get(task)
|
|
840
|
+
if (statuses.length === testManagementAttemptToFixRetries) {
|
|
841
|
+
if (statuses.every(status => status === 'pass')) {
|
|
842
|
+
attemptToFixPassed = true
|
|
843
|
+
} else if (statuses.includes('fail')) {
|
|
844
|
+
attemptToFixFailed = true
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
if (ctx) {
|
|
850
|
+
// We don't finish here because the test might fail in a later hook (afterEach)
|
|
851
|
+
ctx.status = status
|
|
852
|
+
ctx.task = task
|
|
853
|
+
ctx.attemptToFixPassed = attemptToFixPassed
|
|
854
|
+
ctx.attemptToFixFailed = attemptToFixFailed
|
|
855
|
+
testFinishTimeCh.runStores(ctx, () => {})
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return result
|
|
859
|
+
})
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
addHook({
|
|
863
|
+
name: 'vitest',
|
|
864
|
+
versions: ['>=4.0.0'],
|
|
865
|
+
filePattern: 'dist/chunks/test.*',
|
|
866
|
+
}, (testPackage) => {
|
|
867
|
+
if (!isTestPackage(testPackage)) {
|
|
868
|
+
return testPackage
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
wrapVitestTestRunner(testPackage.V)
|
|
872
|
+
|
|
873
|
+
return testPackage
|
|
874
|
+
})
|
|
875
|
+
|
|
876
|
+
addHook({
|
|
877
|
+
name: 'vitest',
|
|
878
|
+
versions: ['>=1.6.0 <4.0.0'],
|
|
879
|
+
file: 'dist/runners.js',
|
|
880
|
+
}, (vitestPackage) => {
|
|
881
|
+
const { VitestTestRunner } = vitestPackage
|
|
882
|
+
|
|
883
|
+
wrapVitestTestRunner(VitestTestRunner)
|
|
884
|
+
|
|
885
|
+
return vitestPackage
|
|
886
|
+
})
|
|
887
|
+
|
|
888
|
+
// There are multiple index* files across different versions of vitest,
|
|
889
|
+
// so we check for the existence of BaseSequencer to determine if we are in the right file
|
|
890
|
+
addHook({
|
|
891
|
+
name: 'vitest',
|
|
892
|
+
versions: ['>=1.6.0 <2.0.0'],
|
|
893
|
+
filePattern: 'dist/vendor/index.*',
|
|
894
|
+
}, (vitestPackage) => {
|
|
895
|
+
if (isReporterPackage(vitestPackage)) {
|
|
896
|
+
shimmer.wrap(vitestPackage.B.prototype, 'sort', getSortWrapper)
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return vitestPackage
|
|
900
|
+
})
|
|
901
|
+
|
|
902
|
+
addHook({
|
|
903
|
+
name: 'vitest',
|
|
904
|
+
versions: ['>=2.0.0 <2.0.5'],
|
|
905
|
+
filePattern: 'dist/vendor/index.*',
|
|
906
|
+
}, (vitestPackage) => {
|
|
907
|
+
if (isReporterPackageNew(vitestPackage)) {
|
|
908
|
+
shimmer.wrap(vitestPackage.e.prototype, 'sort', getSortWrapper)
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
return vitestPackage
|
|
912
|
+
})
|
|
913
|
+
|
|
914
|
+
addHook({
|
|
915
|
+
name: 'vitest',
|
|
916
|
+
versions: ['>=2.0.5 <2.1.0'],
|
|
917
|
+
filePattern: 'dist/chunks/index.*',
|
|
918
|
+
}, (vitestPackage) => {
|
|
919
|
+
if (isReporterPackageNewest(vitestPackage)) {
|
|
920
|
+
shimmer.wrap(vitestPackage.h.prototype, 'sort', getSortWrapper)
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
return vitestPackage
|
|
924
|
+
})
|
|
925
|
+
|
|
926
|
+
addHook({
|
|
927
|
+
name: 'vitest',
|
|
928
|
+
versions: ['>=2.1.0 <3.0.0'],
|
|
929
|
+
filePattern: 'dist/chunks/RandomSequencer.*',
|
|
930
|
+
}, (randomSequencerPackage) => {
|
|
931
|
+
shimmer.wrap(randomSequencerPackage.B.prototype, 'sort', getSortWrapper)
|
|
932
|
+
return randomSequencerPackage
|
|
933
|
+
})
|
|
934
|
+
|
|
935
|
+
addHook({
|
|
936
|
+
name: 'vitest',
|
|
937
|
+
versions: ['>=3.0.9'],
|
|
938
|
+
filePattern: 'dist/chunks/coverage.*',
|
|
939
|
+
}, (coveragePackage) => {
|
|
940
|
+
if (isBaseSequencer(coveragePackage)) {
|
|
941
|
+
shimmer.wrap(coveragePackage.b.prototype, 'sort', getSortWrapper)
|
|
942
|
+
}
|
|
943
|
+
return coveragePackage
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
addHook({
|
|
947
|
+
name: 'vitest',
|
|
948
|
+
versions: ['>=3.0.0 <3.0.9'],
|
|
949
|
+
filePattern: 'dist/chunks/resolveConfig.*',
|
|
950
|
+
}, (resolveConfigPackage) => {
|
|
951
|
+
shimmer.wrap(resolveConfigPackage.B.prototype, 'sort', getSortWrapper)
|
|
952
|
+
return resolveConfigPackage
|
|
953
|
+
})
|
|
954
|
+
|
|
955
|
+
// Can't specify file because compiled vitest includes hashes in their files
|
|
956
|
+
// Following 3 wrappers are for test session start
|
|
957
|
+
addHook({
|
|
958
|
+
name: 'vitest',
|
|
959
|
+
versions: ['>=1.6.0 <2.0.5'],
|
|
960
|
+
filePattern: 'dist/vendor/cac.*',
|
|
961
|
+
}, getCreateCliWrapper)
|
|
962
|
+
|
|
963
|
+
addHook({
|
|
964
|
+
name: 'vitest',
|
|
965
|
+
versions: ['>=2.0.5'],
|
|
966
|
+
filePattern: 'dist/chunks/cac.*',
|
|
967
|
+
}, getCreateCliWrapper)
|
|
968
|
+
|
|
969
|
+
addHook({
|
|
970
|
+
name: 'vitest',
|
|
971
|
+
versions: ['>=1.6.0 <2.0.5'],
|
|
972
|
+
filePattern: 'dist/vendor/cli-api.*',
|
|
973
|
+
}, getStartVitestWrapper)
|
|
974
|
+
|
|
975
|
+
addHook({
|
|
976
|
+
name: 'vitest',
|
|
977
|
+
versions: ['>=2.0.5'],
|
|
978
|
+
filePattern: 'dist/chunks/cli-api.*',
|
|
979
|
+
}, getStartVitestWrapper)
|
|
980
|
+
|
|
981
|
+
// test suite start and finish
|
|
982
|
+
// only relevant for workers
|
|
983
|
+
addHook({
|
|
984
|
+
name: '@vitest/runner',
|
|
985
|
+
versions: ['>=1.6.0'],
|
|
986
|
+
}, (vitestPackage, frameworkVersion) => {
|
|
987
|
+
shimmer.wrap(vitestPackage, 'startTests', startTests => async function (testPaths) {
|
|
988
|
+
let testSuiteError = null
|
|
989
|
+
if (!testSuiteFinishCh.hasSubscribers) {
|
|
990
|
+
return startTests.apply(this, arguments)
|
|
991
|
+
}
|
|
992
|
+
// From >=3.0.1, the first arguments changes from a string to an object containing the filepath
|
|
993
|
+
const testSuiteAbsolutePath = testPaths[0]?.filepath || testPaths[0]
|
|
994
|
+
|
|
995
|
+
const testSuiteCtx = { testSuiteAbsolutePath, frameworkVersion }
|
|
996
|
+
testSuiteStartCh.runStores(testSuiteCtx, () => {})
|
|
997
|
+
const startTestsResponse = await startTests.apply(this, arguments)
|
|
998
|
+
|
|
999
|
+
let onFinish = null
|
|
1000
|
+
const onFinishPromise = new Promise(resolve => {
|
|
1001
|
+
onFinish = resolve
|
|
1002
|
+
})
|
|
1003
|
+
|
|
1004
|
+
const testTasks = getTypeTasks(startTestsResponse[0].tasks)
|
|
1005
|
+
|
|
1006
|
+
// Only one test task per test, even if there are retries
|
|
1007
|
+
for (const task of testTasks) {
|
|
1008
|
+
const testCtx = taskToCtx.get(task)
|
|
1009
|
+
const { result } = task
|
|
1010
|
+
// We have to trick vitest into thinking that the test has passed
|
|
1011
|
+
// but we want to report it as failed if it did fail
|
|
1012
|
+
const isSwitchedStatus = switchedStatuses.has(task)
|
|
1013
|
+
|
|
1014
|
+
if (result) {
|
|
1015
|
+
const { state, duration, errors } = result
|
|
1016
|
+
if (state === 'skip') { // programmatic skip
|
|
1017
|
+
testSkipCh.publish({
|
|
1018
|
+
testName: getTestName(task),
|
|
1019
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
1020
|
+
isNew: newTasks.has(task),
|
|
1021
|
+
isDisabled: disabledTasks.has(task),
|
|
1022
|
+
})
|
|
1023
|
+
} else if (state === 'pass' && !isSwitchedStatus) {
|
|
1024
|
+
if (testCtx) {
|
|
1025
|
+
testPassCh.publish({ task, ...testCtx.currentStore })
|
|
1026
|
+
}
|
|
1027
|
+
} else if (state === 'fail' || isSwitchedStatus) {
|
|
1028
|
+
let testError
|
|
1029
|
+
|
|
1030
|
+
if (errors?.length) {
|
|
1031
|
+
testError = errors[0]
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
let hasFailedAllRetries = false
|
|
1035
|
+
let attemptToFixFailed = false
|
|
1036
|
+
if (attemptToFixTasks.has(task)) {
|
|
1037
|
+
const statuses = taskToStatuses.get(task)
|
|
1038
|
+
if (statuses.includes('fail')) {
|
|
1039
|
+
attemptToFixFailed = true
|
|
1040
|
+
}
|
|
1041
|
+
if (statuses.every(status => status === 'fail')) {
|
|
1042
|
+
hasFailedAllRetries = true
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// Check if all EFD retries failed
|
|
1047
|
+
const providedContext = getProvidedContext()
|
|
1048
|
+
if (providedContext.isEarlyFlakeDetectionEnabled && (newTasks.has(task) || modifiedTasks.has(task))) {
|
|
1049
|
+
const statuses = taskToStatuses.get(task)
|
|
1050
|
+
// statuses only includes repetitions (not the initial run), so we check against numRepeats (not +1)
|
|
1051
|
+
if (statuses && statuses.length === providedContext.numRepeats &&
|
|
1052
|
+
statuses.every(status => status === 'fail')) {
|
|
1053
|
+
hasFailedAllRetries = true
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
1058
|
+
if (providedContext.isFlakyTestRetriesEnabled && !attemptToFixTasks.has(task) &&
|
|
1059
|
+
!newTasks.has(task) && !modifiedTasks.has(task)) {
|
|
1060
|
+
const maxRetries = providedContext.flakyTestRetriesCount ?? 0
|
|
1061
|
+
if (maxRetries > 0 && task.result?.retryCount === maxRetries) {
|
|
1062
|
+
hasFailedAllRetries = true
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
if (testCtx) {
|
|
1067
|
+
const isRetry = task.result?.retryCount > 0
|
|
1068
|
+
// `duration` is the duration of all the retries, so it can't be used if there are retries
|
|
1069
|
+
testErrorCh.publish({
|
|
1070
|
+
duration: isRetry ? undefined : duration,
|
|
1071
|
+
error: testError,
|
|
1072
|
+
hasFailedAllRetries,
|
|
1073
|
+
attemptToFixFailed,
|
|
1074
|
+
...testCtx.currentStore,
|
|
1075
|
+
})
|
|
1076
|
+
}
|
|
1077
|
+
if (errors?.length) {
|
|
1078
|
+
testSuiteError = testError // we store the error to bubble it up to the suite
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
} else { // test.skip or test.todo
|
|
1082
|
+
testSkipCh.publish({
|
|
1083
|
+
testName: getTestName(task),
|
|
1084
|
+
testSuiteAbsolutePath: task.file.filepath,
|
|
1085
|
+
isNew: newTasks.has(task),
|
|
1086
|
+
isDisabled: disabledTasks.has(task),
|
|
1087
|
+
})
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
const testSuiteResult = startTestsResponse[0].result
|
|
1092
|
+
|
|
1093
|
+
if (testSuiteResult.errors?.length) { // Errors from root level hooks
|
|
1094
|
+
testSuiteError = testSuiteResult.errors[0]
|
|
1095
|
+
} else if (testSuiteResult.state === 'fail') { // Errors from `describe` level hooks
|
|
1096
|
+
const suiteTasks = getTypeTasks(startTestsResponse[0].tasks, 'suite')
|
|
1097
|
+
const failedSuites = suiteTasks.filter(task => task.result?.state === 'fail')
|
|
1098
|
+
if (failedSuites.length && failedSuites[0].result?.errors?.length) {
|
|
1099
|
+
testSuiteError = failedSuites[0].result.errors[0]
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (testSuiteError) {
|
|
1104
|
+
testSuiteCtx.error = testSuiteError
|
|
1105
|
+
testSuiteErrorCh.runStores(testSuiteCtx, () => {})
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
testSuiteFinishCh.publish({ status: testSuiteResult.state, onFinish, ...testSuiteCtx.currentStore })
|
|
1109
|
+
|
|
1110
|
+
await onFinishPromise
|
|
1111
|
+
|
|
1112
|
+
return startTestsResponse
|
|
1113
|
+
})
|
|
1114
|
+
|
|
1115
|
+
return vitestPackage
|
|
1116
|
+
})
|