@depup/dd-trace 5.97.0-depup.0 → 6.4.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +89 -104
- package/README.md +9 -3
- package/changes.json +8 -3
- package/ci/init.js +25 -5
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +1 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +315 -244
- package/index.electron.js +3 -0
- package/initialize.mjs +9 -8
- package/loader-hook.mjs +154 -47
- package/package.json +118 -78
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +131 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +15 -15
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +19 -0
- package/packages/datadog-instrumentations/src/cucumber.js +747 -187
- package/packages/datadog-instrumentations/src/cypress-config.js +164 -56
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +169 -86
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +85 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1783 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -118
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -131
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +79 -5
- package/packages/datadog-instrumentations/src/mongoose.js +43 -34
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +44 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -6
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1086 -350
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +243 -87
- package/packages/datadog-instrumentations/src/selenium.js +1 -2
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1592 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +79 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +46 -28
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +961 -92
- package/packages/datadog-plugin-cypress/src/index.js +104 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +180 -25
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +706 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +53 -7
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +6 -3
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +21 -11
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +46 -44
- package/packages/datadog-plugin-selenium/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +3 -1
- package/packages/datadog-plugin-ws/src/producer.js +2 -0
- package/packages/datadog-plugin-ws/src/receiver.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +147 -54
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +17 -6
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +30 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +148 -25
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +105 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +4 -4
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +5 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +128 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +291 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +676 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +139 -33
- package/packages/dd-trace/src/config/index.js +117 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +394 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +3 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/request.js +48 -28
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +34 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +22 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +363 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +3 -28
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +21 -51
- package/packages/dd-trace/src/llmobs/sdk.js +56 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +129 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +31 -1
- package/packages/dd-trace/src/llmobs/util.js +202 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +26 -1
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/register.js +46 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +59 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +387 -85
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +3 -1
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +894 -65
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +50 -36
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +13 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +3 -25
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +20 -20
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +31 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -0,0 +1,1297 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('node:path')
|
|
4
|
+
|
|
5
|
+
const satisfies = require('../../../vendor/dist/semifies')
|
|
6
|
+
|
|
7
|
+
const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
8
|
+
const log = require('../../dd-trace/src/log')
|
|
9
|
+
const {
|
|
10
|
+
DYNAMIC_NAME_RE,
|
|
11
|
+
EARLY_FLAKE_DETECTION_RETRY_THRESHOLDS,
|
|
12
|
+
getTestSuitePath,
|
|
13
|
+
logAttemptToFixTestExecution,
|
|
14
|
+
recordAttemptToFixExecution,
|
|
15
|
+
} = require('../../dd-trace/src/plugins/util/test')
|
|
16
|
+
const {
|
|
17
|
+
getTestName,
|
|
18
|
+
getTypeTasks,
|
|
19
|
+
getWorkspaceProject,
|
|
20
|
+
isFlakyTestRetriesEnabledForTask,
|
|
21
|
+
setProvidedContext,
|
|
22
|
+
testErrorCh,
|
|
23
|
+
testFinishTimeCh,
|
|
24
|
+
testPassCh,
|
|
25
|
+
testSkipCh,
|
|
26
|
+
testStartCh,
|
|
27
|
+
testSuiteErrorCh,
|
|
28
|
+
testSuiteFinishCh,
|
|
29
|
+
testSuiteStartCh,
|
|
30
|
+
} = require('./vitest-util')
|
|
31
|
+
|
|
32
|
+
// No-worker-init instrumentation for DD_EXPERIMENTAL_TEST_OPT_VITEST_NO_WORKER_INIT.
|
|
33
|
+
// When enabled, Vitest workers do not initialize dd-trace, so this main-process instrumentation
|
|
34
|
+
// takes over some worker responsibilities, including test span creation and lifecycle reporting.
|
|
35
|
+
const mainProcessReporterStates = new WeakMap()
|
|
36
|
+
const loggedAttemptToFixTests = new Set()
|
|
37
|
+
|
|
38
|
+
const DATADOG_TEST_OPTIMIZATION_BOOTSTRAPS = new Set([
|
|
39
|
+
'dd-trace/register.js',
|
|
40
|
+
'dd-trace/ci/init',
|
|
41
|
+
'dd-trace/ci/init.js',
|
|
42
|
+
])
|
|
43
|
+
const DATADOG_TEST_OPTIMIZATION_NODE_OPTION_FLAGS = new Set(['--import', '--require', '-r'])
|
|
44
|
+
const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
|
|
45
|
+
const VITEST_NO_WORKER_INIT_REQUEST_ENV = 'DD_EXPERIMENTAL_TEST_OPT_VITEST_NO_WORKER_INIT'
|
|
46
|
+
const VITEST_NO_WORKER_INIT_MINIMUM_VERSION = '3.2.6'
|
|
47
|
+
const VITEST_DEFAULT_POOL = 'forks'
|
|
48
|
+
const VITEST_NO_WORKER_INIT_SETUP_FILE = path.join(
|
|
49
|
+
__dirname,
|
|
50
|
+
'..',
|
|
51
|
+
'..',
|
|
52
|
+
'..',
|
|
53
|
+
'ci',
|
|
54
|
+
'vitest-no-worker-init-setup.mjs'
|
|
55
|
+
)
|
|
56
|
+
const VITEST_NO_WORKER_INIT_ISOLATE_WARNING =
|
|
57
|
+
`${VITEST_NO_WORKER_INIT_REQUEST_ENV} is ignored because Vitest isolate is disabled. ` +
|
|
58
|
+
'The lighter Vitest worker path only works when each test file runs in an isolated worker.'
|
|
59
|
+
const NODE_OPTIONS_QUOTE_RE = /[\s"\\]/
|
|
60
|
+
let hasWarnedDisabledIsolate = false
|
|
61
|
+
let hasWarnedUnsupportedVersion = false
|
|
62
|
+
let nodeOptionsBeforeNoWorkerInit
|
|
63
|
+
|
|
64
|
+
function noop () {}
|
|
65
|
+
|
|
66
|
+
function isRequested () {
|
|
67
|
+
return getValueFromEnvSources(VITEST_NO_WORKER_INIT_REQUEST_ENV) === true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function shouldUse (ctx, frameworkVersion, testSpecifications, options) {
|
|
71
|
+
if (!isRequested()) return false
|
|
72
|
+
if (!isSupportedVersion(frameworkVersion)) {
|
|
73
|
+
warnUnsupportedVersion(frameworkVersion)
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const config = ctx?.config
|
|
78
|
+
if (!config) return false
|
|
79
|
+
|
|
80
|
+
const { isVitestWorkerPool } = options
|
|
81
|
+
if (Array.isArray(testSpecifications)) {
|
|
82
|
+
return shouldUseForTestSpecifications(config, testSpecifications, isVitestWorkerPool)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const pool = getEffectiveConfigPool(config)
|
|
86
|
+
if (!isNoWorkerInitPool(pool, isVitestWorkerPool)) return false
|
|
87
|
+
if (getEffectiveConfigIsolate(config, pool) === false) {
|
|
88
|
+
warnDisabledIsolate()
|
|
89
|
+
return false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isSupportedVersion (frameworkVersion) {
|
|
96
|
+
return !!frameworkVersion && satisfies(frameworkVersion, `>=${VITEST_NO_WORKER_INIT_MINIMUM_VERSION}`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function warnUnsupportedVersion (frameworkVersion) {
|
|
100
|
+
if (hasWarnedUnsupportedVersion) return
|
|
101
|
+
|
|
102
|
+
hasWarnedUnsupportedVersion = true
|
|
103
|
+
log.warn(
|
|
104
|
+
'%s is only supported for vitest >=%s. Falling back to normal Vitest worker instrumentation for vitest %s.',
|
|
105
|
+
VITEST_NO_WORKER_INIT_REQUEST_ENV,
|
|
106
|
+
VITEST_NO_WORKER_INIT_MINIMUM_VERSION,
|
|
107
|
+
frameworkVersion || 'unknown'
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function warnDisabledIsolate () {
|
|
112
|
+
if (hasWarnedDisabledIsolate) return
|
|
113
|
+
|
|
114
|
+
hasWarnedDisabledIsolate = true
|
|
115
|
+
log.warn(VITEST_NO_WORKER_INIT_ISOLATE_WARNING)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function shouldUseForTestSpecifications (config, testSpecifications, isVitestWorkerPool) {
|
|
119
|
+
const defaultPool = getEffectiveConfigPool(config)
|
|
120
|
+
let hasNoWorkerInitSpecification = false
|
|
121
|
+
let hasNonWorkerSpecification = false
|
|
122
|
+
|
|
123
|
+
for (const testSpecification of testSpecifications) {
|
|
124
|
+
const pool = getEffectiveTestSpecificationPool(testSpecification, defaultPool)
|
|
125
|
+
if (!isNoWorkerInitPool(pool, isVitestWorkerPool)) {
|
|
126
|
+
hasNonWorkerSpecification = true
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const defaultIsolate = getEffectiveConfigIsolate(config, pool)
|
|
131
|
+
if (getEffectiveTestSpecificationIsolate(testSpecification, pool, defaultIsolate) === false) {
|
|
132
|
+
warnDisabledIsolate()
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
hasNoWorkerInitSpecification = true
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return hasNoWorkerInitSpecification && !hasNonWorkerSpecification
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isNoWorkerInitPool (pool, isVitestWorkerPool) {
|
|
143
|
+
return pool === undefined || isVitestWorkerPool(pool)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function configure (ctx, frameworkVersion, testSpecifications, setupData, options) {
|
|
147
|
+
const { getConfiguredEfdRetryCount, state } = options
|
|
148
|
+
addSetupFileToVitestConfigs(ctx, VITEST_NO_WORKER_INIT_SETUP_FILE, testSpecifications)
|
|
149
|
+
|
|
150
|
+
const {
|
|
151
|
+
knownTestsBySuite,
|
|
152
|
+
modifiedFiles,
|
|
153
|
+
repositoryRoot,
|
|
154
|
+
testManagementTestsBySuite,
|
|
155
|
+
testSessionConfiguration,
|
|
156
|
+
} = setupData
|
|
157
|
+
|
|
158
|
+
setProvidedContext(ctx, {
|
|
159
|
+
_ddVitestWorkerSetup: {
|
|
160
|
+
attemptToFixRetries: state.testManagementAttemptToFixRetries,
|
|
161
|
+
attemptToFixTests: getSelectedTestManagementTests(testManagementTestsBySuite, 'isAttemptToFix'),
|
|
162
|
+
disabledTests: getSelectedTestManagementTests(testManagementTestsBySuite, 'isDisabled'),
|
|
163
|
+
earlyFlakeDetectionRetries: getConfiguredEfdRetryCount(
|
|
164
|
+
state.earlyFlakeDetectionSlowTestRetries,
|
|
165
|
+
state.earlyFlakeDetectionNumRetries
|
|
166
|
+
),
|
|
167
|
+
earlyFlakeDetectionRetryThresholds: EARLY_FLAKE_DETECTION_RETRY_THRESHOLDS,
|
|
168
|
+
earlyFlakeDetectionSlowRetries: state.earlyFlakeDetectionSlowTestRetries,
|
|
169
|
+
isEarlyFlakeDetectionEnabled: state.isEarlyFlakeDetectionEnabled && !state.isEarlyFlakeDetectionFaulty,
|
|
170
|
+
knownTests: knownTestsBySuite || {},
|
|
171
|
+
modifiedFiles: modifiedFiles || {},
|
|
172
|
+
quarantinedTests: getSelectedTestManagementTests(testManagementTestsBySuite, 'isQuarantined'),
|
|
173
|
+
repositoryRoot: repositoryRoot || process.cwd(),
|
|
174
|
+
},
|
|
175
|
+
}, 'Could not send Vitest worker setup context, so no-worker execution changes will not work.')
|
|
176
|
+
|
|
177
|
+
installMainProcessReporter(ctx, frameworkVersion, testSessionConfiguration || {}, setupData, state)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function deactivate (ctx) {
|
|
181
|
+
const installedReporterState = mainProcessReporterStates.get(ctx)
|
|
182
|
+
if (installedReporterState) {
|
|
183
|
+
installedReporterState.isActive = false
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function configureWorkerEnv (workerEnv, shouldSkipWorkerInit = false) {
|
|
188
|
+
if (!shouldSkipWorkerInit) {
|
|
189
|
+
delete workerEnv[VITEST_NO_WORKER_INIT_ACTIVE_ENV]
|
|
190
|
+
restoreDatadogTestOptimizationNodeOptions(workerEnv)
|
|
191
|
+
return workerEnv
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
workerEnv[VITEST_NO_WORKER_INIT_ACTIVE_ENV] = '1'
|
|
195
|
+
rememberDatadogTestOptimizationNodeOptions(workerEnv.NODE_OPTIONS)
|
|
196
|
+
|
|
197
|
+
const nodeOptions = removeDatadogTestOptimizationNodeOptions(workerEnv.NODE_OPTIONS)
|
|
198
|
+
if (nodeOptions) {
|
|
199
|
+
workerEnv.NODE_OPTIONS = nodeOptions
|
|
200
|
+
} else {
|
|
201
|
+
delete workerEnv.NODE_OPTIONS
|
|
202
|
+
}
|
|
203
|
+
return workerEnv
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function rememberDatadogTestOptimizationNodeOptions (nodeOptions) {
|
|
207
|
+
if (hasDatadogTestOptimizationNodeOptions(nodeOptions)) {
|
|
208
|
+
nodeOptionsBeforeNoWorkerInit = nodeOptions
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function restoreDatadogTestOptimizationNodeOptions (workerEnv) {
|
|
213
|
+
if (!nodeOptionsBeforeNoWorkerInit || hasDatadogTestOptimizationNodeOptions(workerEnv.NODE_OPTIONS)) return
|
|
214
|
+
|
|
215
|
+
const strippedNodeOptions = removeDatadogTestOptimizationNodeOptions(nodeOptionsBeforeNoWorkerInit)
|
|
216
|
+
if (workerEnv.NODE_OPTIONS === strippedNodeOptions || (!workerEnv.NODE_OPTIONS && !strippedNodeOptions)) {
|
|
217
|
+
workerEnv.NODE_OPTIONS = nodeOptionsBeforeNoWorkerInit
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function addSetupFileToVitestConfigs (ctx, setupFile, testSpecifications) {
|
|
222
|
+
const configs = getNoWorkerInitVitestConfigs(ctx, testSpecifications)
|
|
223
|
+
|
|
224
|
+
for (const config of configs) {
|
|
225
|
+
if (!config) continue
|
|
226
|
+
|
|
227
|
+
if (config.setupFiles === undefined) {
|
|
228
|
+
config.setupFiles = []
|
|
229
|
+
} else if (typeof config.setupFiles === 'string') {
|
|
230
|
+
config.setupFiles = [config.setupFiles]
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!config.setupFiles.includes(setupFile)) {
|
|
234
|
+
config.setupFiles.push(setupFile)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function getNoWorkerInitVitestConfigs (ctx, testSpecifications) {
|
|
240
|
+
const configs = new Set()
|
|
241
|
+
if (Array.isArray(testSpecifications)) {
|
|
242
|
+
let shouldAddRootConfig = false
|
|
243
|
+
for (const testSpecification of testSpecifications) {
|
|
244
|
+
const project = getTestSpecificationProject(testSpecification)
|
|
245
|
+
const config = safeConfig(project)
|
|
246
|
+
if (config) {
|
|
247
|
+
addNoWorkerInitConfig(configs, config)
|
|
248
|
+
} else {
|
|
249
|
+
shouldAddRootConfig = true
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!shouldAddRootConfig && configs.size > 0) {
|
|
254
|
+
return configs
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
addNoWorkerInitConfig(configs, safeConfig(ctx))
|
|
259
|
+
addNoWorkerInitConfig(configs, safeConfig(safeWorkspaceProject(ctx)))
|
|
260
|
+
return configs
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function addNoWorkerInitConfig (configs, config) {
|
|
264
|
+
if (config) configs.add(config)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function getSelectedTestManagementTests (testManagementTestsBySuite, propertyName) {
|
|
268
|
+
if (!testManagementTestsBySuite) return {}
|
|
269
|
+
|
|
270
|
+
const selectedTests = {}
|
|
271
|
+
for (const [testSuite, tests] of Object.entries(testManagementTestsBySuite)) {
|
|
272
|
+
for (const [testName, properties] of Object.entries(tests)) {
|
|
273
|
+
if (properties?.[propertyName]) {
|
|
274
|
+
selectedTests[testSuite] ||= {}
|
|
275
|
+
selectedTests[testSuite][testName] = true
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return selectedTests
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function installMainProcessReporter (ctx, frameworkVersion, testSessionConfiguration, testOptimizationData, state) {
|
|
283
|
+
if (!ctx?.reporters) return
|
|
284
|
+
|
|
285
|
+
const reporterState = {
|
|
286
|
+
frameworkVersion,
|
|
287
|
+
isActive: true,
|
|
288
|
+
state,
|
|
289
|
+
testSessionConfiguration,
|
|
290
|
+
testOptimizationData,
|
|
291
|
+
}
|
|
292
|
+
const installedReporterState = mainProcessReporterStates.get(ctx)
|
|
293
|
+
if (installedReporterState) {
|
|
294
|
+
Object.assign(installedReporterState, reporterState)
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
mainProcessReporterStates.set(ctx, reporterState)
|
|
299
|
+
ctx.reporters.push(createMainProcessReporter(reporterState))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function createMainProcessReporter (reporterState) {
|
|
303
|
+
const testSuiteContexts = new Map()
|
|
304
|
+
const finishedTestModules = new Set()
|
|
305
|
+
const taskAttemptStatuses = new Map()
|
|
306
|
+
const tasksWithRecordedFinalAttempt = new Set()
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
onTestModuleStart (testModule) {
|
|
310
|
+
if (!isActive()) return
|
|
311
|
+
|
|
312
|
+
startTestSuite(testModule)
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
onTestModuleEnd (testModule) {
|
|
316
|
+
if (!isActive()) return
|
|
317
|
+
|
|
318
|
+
return reportTestModule(testModule)
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
onTestCaseResult (testCase) {
|
|
322
|
+
if (!isActive()) return
|
|
323
|
+
|
|
324
|
+
const task = getTestCaseTask(testCase)
|
|
325
|
+
recordFinalTaskAttemptResult(task)
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
onTaskUpdate (packs, events) {
|
|
329
|
+
if (!isActive()) return
|
|
330
|
+
if (!events) return
|
|
331
|
+
|
|
332
|
+
for (const event of events) {
|
|
333
|
+
if (event[1] === 'test-retried') {
|
|
334
|
+
recordTaskAttemptStatus(event[0], 'fail', getTaskUpdateAttemptCount(event[0], packs))
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
onFinished (files) {
|
|
340
|
+
if (!isActive()) return
|
|
341
|
+
if (!files) return
|
|
342
|
+
|
|
343
|
+
for (const file of files) {
|
|
344
|
+
const testModule = createTestModuleFromFile(file)
|
|
345
|
+
if (!finishedTestModules.has(file.id)) {
|
|
346
|
+
reportTestModule(testModule)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function isActive () {
|
|
353
|
+
return reporterState.isActive === true
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function recordTaskAttemptStatus (taskId, status, attemptCount) {
|
|
357
|
+
let statuses = taskAttemptStatuses.get(taskId)
|
|
358
|
+
if (!statuses) {
|
|
359
|
+
statuses = []
|
|
360
|
+
taskAttemptStatuses.set(taskId, statuses)
|
|
361
|
+
}
|
|
362
|
+
if (attemptCount !== undefined && statuses.length >= attemptCount) return
|
|
363
|
+
|
|
364
|
+
if (tasksWithRecordedFinalAttempt.has(taskId)) {
|
|
365
|
+
statuses.splice(-1, 0, status)
|
|
366
|
+
return
|
|
367
|
+
}
|
|
368
|
+
statuses.push(status)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function recordFinalTaskAttemptResult (task) {
|
|
372
|
+
const statuses = taskAttemptStatuses.get(task.id)
|
|
373
|
+
if (!statuses) return
|
|
374
|
+
|
|
375
|
+
const attemptCount = getRepeatedAttemptCount(task, statuses)
|
|
376
|
+
if (statuses.length < attemptCount) {
|
|
377
|
+
statuses.push(getFinalRepeatedTaskStatus(task))
|
|
378
|
+
tasksWithRecordedFinalAttempt.add(task.id)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function reportTestModule (testModule) {
|
|
383
|
+
const testModuleId = getTestModuleId(testModule)
|
|
384
|
+
const testModuleTask = getTestModuleTask(testModule)
|
|
385
|
+
finishedTestModules.add(testModuleId)
|
|
386
|
+
const testSuiteCtx = testSuiteContexts.get(testModuleId) || startTestSuite(testModule)
|
|
387
|
+
const testTasks = getTypeTasks(testModuleTask.tasks)
|
|
388
|
+
const testReports = []
|
|
389
|
+
let testSuiteError
|
|
390
|
+
|
|
391
|
+
for (const task of testTasks) {
|
|
392
|
+
const testReport = getTestReport(task, testSuiteCtx.currentStore)
|
|
393
|
+
testReports.push(testReport)
|
|
394
|
+
|
|
395
|
+
for (const attempt of testReport.nonFinalAttempts) {
|
|
396
|
+
reportTestAttempt(testReport, attempt)
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
for (const testReport of testReports) {
|
|
401
|
+
const error = reportFinalTestAttempt(testReport)
|
|
402
|
+
testSuiteError ||= error
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const suiteTaskError = getSuiteTaskError(testModuleTask)
|
|
406
|
+
recomputeTaskState(testModuleTask)
|
|
407
|
+
const testSuiteResult = testModuleTask.result
|
|
408
|
+
if (testSuiteResult?.errors?.length) {
|
|
409
|
+
testSuiteError = testSuiteResult.errors[0]
|
|
410
|
+
} else if (suiteTaskError) {
|
|
411
|
+
testSuiteError = suiteTaskError
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (testSuiteError) {
|
|
415
|
+
testSuiteCtx.error = testSuiteError
|
|
416
|
+
testSuiteErrorCh.runStores(testSuiteCtx, () => {})
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
testSuiteFinishCh.publish({
|
|
420
|
+
status: getDatadogStatus(testSuiteResult),
|
|
421
|
+
deferFlush: true,
|
|
422
|
+
onFinish: noop,
|
|
423
|
+
...testSuiteCtx.currentStore,
|
|
424
|
+
})
|
|
425
|
+
testSuiteContexts.delete(testModuleId)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function startTestSuite (testModule) {
|
|
429
|
+
const { frameworkVersion, testSessionConfiguration } = reporterState
|
|
430
|
+
const testModuleId = getTestModuleId(testModule)
|
|
431
|
+
const testSuiteCtx = {
|
|
432
|
+
testSuiteAbsolutePath: getTestModuleFilepath(testModule),
|
|
433
|
+
frameworkVersion,
|
|
434
|
+
testSessionId: testSessionConfiguration.testSessionId,
|
|
435
|
+
testModuleId: testSessionConfiguration.testModuleId,
|
|
436
|
+
testCommand: testSessionConfiguration.testCommand,
|
|
437
|
+
repositoryRoot: testSessionConfiguration.repositoryRoot,
|
|
438
|
+
codeOwnersEntries: testSessionConfiguration.codeOwnersEntries,
|
|
439
|
+
requestErrorTags: reporterState.state.requestErrorTags,
|
|
440
|
+
isTestFrameworkWorker: true,
|
|
441
|
+
isVitestNoWorkerInitActive: true,
|
|
442
|
+
}
|
|
443
|
+
testSuiteStartCh.runStores(testSuiteCtx, () => {})
|
|
444
|
+
testSuiteContexts.set(testModuleId, testSuiteCtx)
|
|
445
|
+
return testSuiteCtx
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function getTestReport (task, testSuiteStore) {
|
|
449
|
+
const result = task.result
|
|
450
|
+
const testSuiteAbsolutePath = task.file?.filepath
|
|
451
|
+
const testName = getTestName(task)
|
|
452
|
+
const testProperties = getMainProcessTestProperties(task, testSuiteAbsolutePath, testName)
|
|
453
|
+
const { state } = reporterState
|
|
454
|
+
let status = getDatadogStatus(result)
|
|
455
|
+
|
|
456
|
+
if (task.meta?.__ddTestOptQuarantinedFailed && testProperties.isQuarantined && !testProperties.isAttemptToFix) {
|
|
457
|
+
status = 'fail'
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (testProperties.isAttemptToFix && task.meta?.__ddTestOptAtfStatuses?.length) {
|
|
461
|
+
return getRepeatedTestReport(task, testName, testSuiteAbsolutePath, testProperties, status, {
|
|
462
|
+
errorCounts: task.meta.__ddTestOptAtfErrorCounts,
|
|
463
|
+
finalStatus: getAttemptToFixFinalStatus,
|
|
464
|
+
state,
|
|
465
|
+
statuses: task.meta.__ddTestOptAtfStatuses,
|
|
466
|
+
testSuiteStore,
|
|
467
|
+
type: 'attempt_to_fix',
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (testProperties.isEarlyFlakeDetection && task.meta?.__ddTestOptEfdStatuses?.length) {
|
|
472
|
+
return getRepeatedTestReport(task, testName, testSuiteAbsolutePath, testProperties, status, {
|
|
473
|
+
errorCounts: task.meta.__ddTestOptEfdErrorCounts,
|
|
474
|
+
finalStatus: getEarlyFlakeDetectionFinalStatus,
|
|
475
|
+
state,
|
|
476
|
+
statuses: task.meta.__ddTestOptEfdStatuses,
|
|
477
|
+
testSuiteStore,
|
|
478
|
+
type: 'early_flake_detection',
|
|
479
|
+
})
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (!testProperties.isAttemptToFix && task.meta?.__ddTestOptRepeatStatuses?.length) {
|
|
483
|
+
return getRepeatedTestReport(task, testName, testSuiteAbsolutePath, testProperties, status, {
|
|
484
|
+
errorCounts: task.meta.__ddTestOptRepeatErrorCounts,
|
|
485
|
+
finalStatus: () => status,
|
|
486
|
+
state,
|
|
487
|
+
statuses: task.meta.__ddTestOptRepeatStatuses,
|
|
488
|
+
testSuiteStore,
|
|
489
|
+
type: 'external',
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const attemptStatuses = taskAttemptStatuses.get(task.id)
|
|
494
|
+
if (!testProperties.isAttemptToFix && !testProperties.isEarlyFlakeDetection && attemptStatuses?.length > 1) {
|
|
495
|
+
return getRepeatedTestReport(task, testName, testSuiteAbsolutePath, testProperties, status, {
|
|
496
|
+
finalStatus: () => status,
|
|
497
|
+
state,
|
|
498
|
+
statuses: attemptStatuses,
|
|
499
|
+
testSuiteStore,
|
|
500
|
+
type: 'external',
|
|
501
|
+
})
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (!testProperties.isAttemptToFix && task.result?.repeatCount > 0) {
|
|
505
|
+
return getRepeatedTestReport(task, testName, testSuiteAbsolutePath, testProperties, status, {
|
|
506
|
+
finalStatus: () => status,
|
|
507
|
+
state,
|
|
508
|
+
statuses: getRepeatedTaskStatuses(task, status),
|
|
509
|
+
testSuiteStore,
|
|
510
|
+
type: 'external',
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (testProperties.isAttemptToFix) {
|
|
515
|
+
logAttemptToFixTestExecution(testProperties.testSuite, testName, loggedAttemptToFixTests)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (testProperties.isDisabled && !testProperties.isAttemptToFix) {
|
|
519
|
+
status = 'skip'
|
|
520
|
+
if (result) result.state = 'skip'
|
|
521
|
+
} else if (testProperties.isQuarantined && status === 'fail' && !testProperties.isAttemptToFix) {
|
|
522
|
+
result.state = 'pass'
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const errors = result?.errors || []
|
|
526
|
+
const finalErrorIndex = status === 'fail' ? errors.length - 1 : -1
|
|
527
|
+
const nonFinalAttempts = []
|
|
528
|
+
|
|
529
|
+
if (status !== 'skip') {
|
|
530
|
+
for (let index = 0; index < errors.length; index++) {
|
|
531
|
+
if (index === finalErrorIndex) continue
|
|
532
|
+
nonFinalAttempts.push({
|
|
533
|
+
error: errors[index],
|
|
534
|
+
isRetry: index > 0,
|
|
535
|
+
status: 'fail',
|
|
536
|
+
})
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
errors,
|
|
542
|
+
nonFinalAttempts,
|
|
543
|
+
state,
|
|
544
|
+
status,
|
|
545
|
+
task,
|
|
546
|
+
testName,
|
|
547
|
+
testProperties,
|
|
548
|
+
testSuiteAbsolutePath,
|
|
549
|
+
testSuiteStore,
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function getMainProcessTestProperties (task, testSuiteAbsolutePath, testName) {
|
|
554
|
+
const { state, testOptimizationData, testSessionConfiguration } = reporterState
|
|
555
|
+
const testProperties = testOptimizationData.testPropertiesByFilepath?.[testSuiteAbsolutePath]
|
|
556
|
+
const testSuite = testProperties?.testSuite || getTestSuitePath(
|
|
557
|
+
testSuiteAbsolutePath,
|
|
558
|
+
testSessionConfiguration.repositoryRoot || process.cwd()
|
|
559
|
+
)
|
|
560
|
+
const knownTests = testProperties?.knownTests
|
|
561
|
+
const testManagementProperties = testProperties?.testManagementTests?.[testName] || {}
|
|
562
|
+
const isAttemptToFix = testManagementProperties.isAttemptToFix
|
|
563
|
+
const isNew = !!(
|
|
564
|
+
!isAttemptToFix &&
|
|
565
|
+
state.isKnownTestsEnabled &&
|
|
566
|
+
knownTests &&
|
|
567
|
+
!state.isEarlyFlakeDetectionFaulty &&
|
|
568
|
+
!knownTests.includes(testName)
|
|
569
|
+
)
|
|
570
|
+
const isModified = testProperties?.isModified === true
|
|
571
|
+
const { flakyTestRetriesConfiguration } = testOptimizationData
|
|
572
|
+
const isFlakyTestRetries = !!flakyTestRetriesConfiguration && isFlakyTestRetriesEnabledForTask({
|
|
573
|
+
isFlakyTestRetriesEnabled: state.isFlakyTestRetriesEnabled,
|
|
574
|
+
flakyTestRetriesIncludesUnnamedProject: flakyTestRetriesConfiguration.includesUnnamedProject,
|
|
575
|
+
flakyTestRetriesProjectNames: flakyTestRetriesConfiguration.projectNames,
|
|
576
|
+
}, task)
|
|
577
|
+
|
|
578
|
+
return {
|
|
579
|
+
isAttemptToFix,
|
|
580
|
+
isDisabled: testManagementProperties.isDisabled,
|
|
581
|
+
isEarlyFlakeDetection: (isNew || isModified) && state.isEarlyFlakeDetectionEnabled,
|
|
582
|
+
isFlakyTestRetries,
|
|
583
|
+
isQuarantined: testManagementProperties.isQuarantined,
|
|
584
|
+
isModified,
|
|
585
|
+
isNew,
|
|
586
|
+
testSuite,
|
|
587
|
+
hasDynamicName: isNew && DYNAMIC_NAME_RE.test(testName),
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function getTaskUpdateAttemptCount (taskId, packs) {
|
|
593
|
+
if (!packs) return
|
|
594
|
+
|
|
595
|
+
for (const pack of packs) {
|
|
596
|
+
if (pack[0] === taskId) {
|
|
597
|
+
return getRepeatedAttemptCount({
|
|
598
|
+
id: taskId,
|
|
599
|
+
result: pack[1],
|
|
600
|
+
meta: pack[2],
|
|
601
|
+
}, [])
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function createTestModuleFromFile (file) {
|
|
607
|
+
return {
|
|
608
|
+
id: file.id,
|
|
609
|
+
moduleId: file.filepath,
|
|
610
|
+
project: file.project,
|
|
611
|
+
projectName: file.projectName,
|
|
612
|
+
task: file,
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function getTestModuleId (testModule) {
|
|
617
|
+
return testModule.id || getTestModuleFilepath(testModule)
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function getTestModuleTask (testModule) {
|
|
621
|
+
if (testModule.task?.tasks) {
|
|
622
|
+
return testModule.task
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const task = createTaskFromReportedTask(testModule)
|
|
626
|
+
task.file = task
|
|
627
|
+
return task
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function getTestCaseTask (testCase) {
|
|
631
|
+
if (testCase.task) {
|
|
632
|
+
return testCase.task
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return createTaskFromReportedTask(testCase, {
|
|
636
|
+
filepath: getTestModuleFilepath(testCase.module),
|
|
637
|
+
projectName: getTestModuleProjectName(testCase.module),
|
|
638
|
+
})
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function createTaskFromReportedTask (reportedTask, file, suite) {
|
|
642
|
+
const task = {
|
|
643
|
+
id: reportedTask.id,
|
|
644
|
+
type: reportedTask.type,
|
|
645
|
+
name: reportedTask.name || reportedTask.relativeModuleId || reportedTask.moduleId,
|
|
646
|
+
mode: reportedTask.options?.mode,
|
|
647
|
+
meta: getReportedTaskMeta(reportedTask),
|
|
648
|
+
result: getReportedTaskResult(reportedTask),
|
|
649
|
+
file,
|
|
650
|
+
suite,
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (reportedTask.type === 'module') {
|
|
654
|
+
task.filepath = reportedTask.moduleId
|
|
655
|
+
task.projectName = getTestModuleProjectName(reportedTask)
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const children = getReportedTaskChildren(reportedTask)
|
|
659
|
+
if (children) {
|
|
660
|
+
task.tasks = []
|
|
661
|
+
const taskFile = file || task
|
|
662
|
+
const childSuite = task.type === 'suite' ? task : undefined
|
|
663
|
+
for (const child of children) {
|
|
664
|
+
task.tasks.push(createTaskFromReportedTask(child, taskFile, childSuite))
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return task
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function getReportedTaskChildren (reportedTask) {
|
|
672
|
+
const children = reportedTask.children
|
|
673
|
+
if (!children) return
|
|
674
|
+
|
|
675
|
+
if (typeof children.array === 'function') {
|
|
676
|
+
return children.array()
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (Array.isArray(children)) {
|
|
680
|
+
return children
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return [...children]
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function getReportedTaskMeta (reportedTask) {
|
|
687
|
+
if (typeof reportedTask.meta === 'function') {
|
|
688
|
+
return reportedTask.meta()
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return reportedTask.meta || {}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function getReportedTaskResult (reportedTask) {
|
|
695
|
+
let result
|
|
696
|
+
if (typeof reportedTask.result === 'function') {
|
|
697
|
+
result = reportedTask.result()
|
|
698
|
+
} else if (typeof reportedTask.state === 'function') {
|
|
699
|
+
result = {
|
|
700
|
+
errors: typeof reportedTask.errors === 'function' ? reportedTask.errors() : undefined,
|
|
701
|
+
state: reportedTask.state(),
|
|
702
|
+
}
|
|
703
|
+
} else {
|
|
704
|
+
result = reportedTask.result
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const diagnostic = typeof reportedTask.diagnostic === 'function'
|
|
708
|
+
? reportedTask.diagnostic()
|
|
709
|
+
: undefined
|
|
710
|
+
|
|
711
|
+
return {
|
|
712
|
+
duration: diagnostic?.duration,
|
|
713
|
+
errors: result?.errors,
|
|
714
|
+
note: result?.note,
|
|
715
|
+
repeatCount: diagnostic?.repeatCount,
|
|
716
|
+
retryCount: diagnostic?.retryCount,
|
|
717
|
+
state: result?.state,
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function getTestModuleFilepath (testModule) {
|
|
722
|
+
return testModule.moduleId || testModule.task?.filepath || testModule.filepath
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function getTestModuleProjectName (testModule) {
|
|
726
|
+
return normalizeProjectName(
|
|
727
|
+
testModule.projectName || getProjectName(testModule.project) || testModule.task?.projectName ||
|
|
728
|
+
testModule.task?.file?.projectName
|
|
729
|
+
)
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function getRepeatedTestReport (task, testName, testSuiteAbsolutePath, testProperties, status, options) {
|
|
733
|
+
const result = task.result
|
|
734
|
+
const errors = result?.errors || []
|
|
735
|
+
const { errorCounts, finalStatus, state, statuses, testSuiteStore, type } = options
|
|
736
|
+
const finalAttemptStatus = finalStatus(statuses)
|
|
737
|
+
const hasFailure = finalAttemptStatus === 'fail'
|
|
738
|
+
const attempts = []
|
|
739
|
+
const attemptCount = getRepeatedAttemptCount(task, statuses)
|
|
740
|
+
let errorIndex = 0
|
|
741
|
+
let previousErrorCount = 0
|
|
742
|
+
|
|
743
|
+
if (type === 'attempt_to_fix') {
|
|
744
|
+
logAttemptToFixTestExecution(testProperties.testSuite, testName, loggedAttemptToFixTests)
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
for (let index = 0; index < attemptCount; index++) {
|
|
748
|
+
const isFinalAttempt = index === attemptCount - 1
|
|
749
|
+
const attemptStatus = statuses[index] || 'pass'
|
|
750
|
+
const nextErrorCount = errorCounts?.[index]
|
|
751
|
+
const error = attemptStatus === 'fail'
|
|
752
|
+
? errors[nextErrorCount === undefined ? errorIndex : previousErrorCount] || errors[errorIndex] || errors[0]
|
|
753
|
+
: undefined
|
|
754
|
+
if (nextErrorCount !== undefined) {
|
|
755
|
+
previousErrorCount = nextErrorCount
|
|
756
|
+
} else if (attemptStatus === 'fail') {
|
|
757
|
+
errorIndex++
|
|
758
|
+
}
|
|
759
|
+
const attempt = {
|
|
760
|
+
attemptToFixFailed: type === 'attempt_to_fix' && isFinalAttempt && hasFailure,
|
|
761
|
+
earlyFlakeAbortReason: type === 'early_flake_detection' && isFinalAttempt
|
|
762
|
+
? task.meta?.__ddTestOptEfdAbortReason
|
|
763
|
+
: undefined,
|
|
764
|
+
error,
|
|
765
|
+
finalStatus: isFinalAttempt ? finalAttemptStatus : undefined,
|
|
766
|
+
hasFailedAllRetries: hasFailedAllManagedRetries(
|
|
767
|
+
task,
|
|
768
|
+
testProperties,
|
|
769
|
+
type,
|
|
770
|
+
statuses,
|
|
771
|
+
isFinalAttempt,
|
|
772
|
+
hasFailure
|
|
773
|
+
),
|
|
774
|
+
isRetry: index > 0,
|
|
775
|
+
status: attemptStatus,
|
|
776
|
+
}
|
|
777
|
+
if (type === 'attempt_to_fix') {
|
|
778
|
+
attempt.attemptToFixPassed = isFinalAttempt && !hasFailure
|
|
779
|
+
} else if (type === 'early_flake_detection') {
|
|
780
|
+
attempt.isRetryReasonEfd = index > 0
|
|
781
|
+
}
|
|
782
|
+
attempts.push(attempt)
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return {
|
|
786
|
+
errors,
|
|
787
|
+
finalAttempt: attempts[attempts.length - 1],
|
|
788
|
+
nonFinalAttempts: attempts.slice(0, -1),
|
|
789
|
+
state,
|
|
790
|
+
status,
|
|
791
|
+
task,
|
|
792
|
+
testName,
|
|
793
|
+
testProperties,
|
|
794
|
+
testSuiteAbsolutePath,
|
|
795
|
+
testSuiteStore,
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Returns whether a final failed attempt exhausted Datadog-managed retries.
|
|
801
|
+
*
|
|
802
|
+
* @param {{
|
|
803
|
+
* meta?: { __ddTestOptEfdRetries?: number },
|
|
804
|
+
* repeats?: number,
|
|
805
|
+
* result?: { retryCount?: number }
|
|
806
|
+
* }} task
|
|
807
|
+
* @param {{ isFlakyTestRetries?: boolean }} testProperties
|
|
808
|
+
* @param {'attempt_to_fix'|'early_flake_detection'|'external'} type
|
|
809
|
+
* @param {string[]} statuses
|
|
810
|
+
* @param {boolean} isFinalAttempt
|
|
811
|
+
* @param {boolean} hasFailure
|
|
812
|
+
* @returns {boolean}
|
|
813
|
+
*/
|
|
814
|
+
function hasFailedAllManagedRetries (task, testProperties, type, statuses, isFinalAttempt, hasFailure) {
|
|
815
|
+
if (!isFinalAttempt || !hasFailure || statuses.length === 0 || !statuses.every(status => status === 'fail')) {
|
|
816
|
+
return false
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (type === 'attempt_to_fix') {
|
|
820
|
+
return true
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (type === 'early_flake_detection') {
|
|
824
|
+
return (task.meta?.__ddTestOptEfdRetries || 0) > 0
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
return testProperties.isFlakyTestRetries === true && (task.result?.retryCount || 0) > 0
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function getRepeatedAttemptCount (task, statuses) {
|
|
831
|
+
const retries = task.meta?.__ddTestOptAtfRetries ?? task.meta?.__ddTestOptEfdRetries ??
|
|
832
|
+
Math.max(task.result?.retryCount || 0, task.repeats || 0)
|
|
833
|
+
return Math.max(statuses.length, retries + 1)
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function getAttemptToFixFinalStatus (statuses) {
|
|
837
|
+
return statuses.includes('fail') ? 'fail' : 'pass'
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
function getEarlyFlakeDetectionFinalStatus (statuses) {
|
|
841
|
+
return statuses.includes('pass') ? 'pass' : 'fail'
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function getRepeatedTaskStatuses (task, status) {
|
|
845
|
+
const repeatedStatuses = []
|
|
846
|
+
const repeatCount = task.result?.repeatCount || 0
|
|
847
|
+
for (let index = 0; index <= repeatCount; index++) {
|
|
848
|
+
repeatedStatuses.push(status)
|
|
849
|
+
}
|
|
850
|
+
return repeatedStatuses
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function reportFinalTestAttempt (testReport) {
|
|
854
|
+
const {
|
|
855
|
+
errors,
|
|
856
|
+
state,
|
|
857
|
+
status,
|
|
858
|
+
task,
|
|
859
|
+
testName,
|
|
860
|
+
testProperties,
|
|
861
|
+
testSuiteAbsolutePath,
|
|
862
|
+
testSuiteStore,
|
|
863
|
+
} = testReport
|
|
864
|
+
|
|
865
|
+
if (status === 'skip') {
|
|
866
|
+
testSkipCh.publish({
|
|
867
|
+
testName,
|
|
868
|
+
testSuiteAbsolutePath,
|
|
869
|
+
isNew: testProperties.isNew,
|
|
870
|
+
isDisabled: testProperties.isDisabled,
|
|
871
|
+
isTestFrameworkWorker: true,
|
|
872
|
+
requestErrorTags: state.requestErrorTags,
|
|
873
|
+
...testSuiteStore,
|
|
874
|
+
})
|
|
875
|
+
return
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
const result = task.result
|
|
879
|
+
const finalStatus = getFinalTestStatus(testReport)
|
|
880
|
+
const finalAttempt = testReport.finalAttempt
|
|
881
|
+
|
|
882
|
+
if (status === 'fail') {
|
|
883
|
+
const error = errors[errors.length - 1] || errors[0]
|
|
884
|
+
reportTestAttempt(testReport, finalAttempt || {
|
|
885
|
+
error,
|
|
886
|
+
finalStatus,
|
|
887
|
+
hasFailedAllRetries: hasFailedAllManagedRetries(
|
|
888
|
+
task,
|
|
889
|
+
testProperties,
|
|
890
|
+
'external',
|
|
891
|
+
['fail'],
|
|
892
|
+
true,
|
|
893
|
+
true
|
|
894
|
+
),
|
|
895
|
+
isRetry: errors.length > 1 || (result?.retryCount || 0) > 0 || (result?.repeatCount || 0) > 0,
|
|
896
|
+
status: 'fail',
|
|
897
|
+
})
|
|
898
|
+
return finalStatus === 'skip' ? undefined : error
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
reportTestAttempt(testReport, finalAttempt || {
|
|
902
|
+
finalStatus,
|
|
903
|
+
isRetry: errors.length > 0 || (result?.retryCount || 0) > 0 || (result?.repeatCount || 0) > 0,
|
|
904
|
+
status: 'pass',
|
|
905
|
+
})
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function reportTestAttempt (testReport, attempt) {
|
|
909
|
+
const {
|
|
910
|
+
state,
|
|
911
|
+
task,
|
|
912
|
+
testName,
|
|
913
|
+
testProperties,
|
|
914
|
+
testSuiteAbsolutePath,
|
|
915
|
+
testSuiteStore,
|
|
916
|
+
} = testReport
|
|
917
|
+
const result = task.result
|
|
918
|
+
const status = attempt.status
|
|
919
|
+
const testCtx = {
|
|
920
|
+
currentStore: testSuiteStore,
|
|
921
|
+
testName,
|
|
922
|
+
testSuiteAbsolutePath,
|
|
923
|
+
isRetry: attempt.isRetry,
|
|
924
|
+
isNew: testProperties.isNew,
|
|
925
|
+
hasDynamicName: testProperties.hasDynamicName,
|
|
926
|
+
isAttemptToFix: testProperties.isAttemptToFix,
|
|
927
|
+
isDisabled: testProperties.isDisabled,
|
|
928
|
+
isQuarantined: testProperties.isQuarantined,
|
|
929
|
+
isModified: testProperties.isModified,
|
|
930
|
+
isRetryReasonEfd: attempt.isRetryReasonEfd,
|
|
931
|
+
isRetryReasonAttemptToFix: testProperties.isAttemptToFix && attempt.isRetry,
|
|
932
|
+
isRetryReasonAtr: !testProperties.isAttemptToFix && !testProperties.isEarlyFlakeDetection &&
|
|
933
|
+
testProperties.isFlakyTestRetries,
|
|
934
|
+
isTestFrameworkWorker: true,
|
|
935
|
+
requestErrorTags: state.requestErrorTags,
|
|
936
|
+
}
|
|
937
|
+
if (testProperties.isAttemptToFix) {
|
|
938
|
+
recordAttemptToFixExecution(state.attemptToFixExecutions, {
|
|
939
|
+
testSuite: testProperties.testSuite,
|
|
940
|
+
testName,
|
|
941
|
+
status,
|
|
942
|
+
isDisabled: testProperties.isDisabled,
|
|
943
|
+
isQuarantined: testProperties.isQuarantined,
|
|
944
|
+
})
|
|
945
|
+
}
|
|
946
|
+
if (testProperties.hasDynamicName) {
|
|
947
|
+
state.newTestsWithDynamicNames.add(`${testProperties.testSuite} › ${testName}`)
|
|
948
|
+
}
|
|
949
|
+
if (attempt.attemptToFixPassed) {
|
|
950
|
+
testCtx.attemptToFixPassed = true
|
|
951
|
+
} else if (attempt.attemptToFixFailed) {
|
|
952
|
+
testCtx.attemptToFixFailed = true
|
|
953
|
+
}
|
|
954
|
+
testStartCh.runStores(testCtx, () => {})
|
|
955
|
+
testCtx.status = status
|
|
956
|
+
testCtx.task = task
|
|
957
|
+
if (
|
|
958
|
+
status === 'pass' &&
|
|
959
|
+
!attempt.isRetry &&
|
|
960
|
+
isFinalTestAttempt(testReport, attempt) &&
|
|
961
|
+
result?.duration !== undefined
|
|
962
|
+
) {
|
|
963
|
+
testCtx.duration = result.duration
|
|
964
|
+
}
|
|
965
|
+
testFinishTimeCh.runStores(testCtx, () => {})
|
|
966
|
+
|
|
967
|
+
if (status === 'pass') {
|
|
968
|
+
testPassCh.publish({
|
|
969
|
+
task,
|
|
970
|
+
earlyFlakeAbortReason: attempt.earlyFlakeAbortReason,
|
|
971
|
+
finalStatus: attempt.finalStatus,
|
|
972
|
+
...testCtx.currentStore,
|
|
973
|
+
})
|
|
974
|
+
return
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
testErrorCh.publish({
|
|
978
|
+
duration: shouldUseTaskDurationForFailure(testReport, attempt) ? result?.duration : undefined,
|
|
979
|
+
error: attempt.error,
|
|
980
|
+
earlyFlakeAbortReason: attempt.earlyFlakeAbortReason,
|
|
981
|
+
finalStatus: attempt.finalStatus,
|
|
982
|
+
hasFailedAllRetries: attempt.hasFailedAllRetries,
|
|
983
|
+
attemptToFixFailed: attempt.attemptToFixFailed,
|
|
984
|
+
...testCtx.currentStore,
|
|
985
|
+
})
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function isFinalTestAttempt (testReport, attempt) {
|
|
989
|
+
return attempt.finalStatus !== undefined || testReport.finalAttempt === undefined
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function shouldUseTaskDurationForFailure (testReport, attempt) {
|
|
993
|
+
return !attempt.isRetry && attempt.finalStatus !== undefined && testReport.finalAttempt === undefined
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function getFinalTestStatus (testReport) {
|
|
997
|
+
const testProperties = testReport.testProperties
|
|
998
|
+
if (testProperties.isAttemptToFix) {
|
|
999
|
+
return testReport.finalAttempt?.finalStatus
|
|
1000
|
+
}
|
|
1001
|
+
if (testProperties.isDisabled || testProperties.isQuarantined) {
|
|
1002
|
+
return 'skip'
|
|
1003
|
+
}
|
|
1004
|
+
return testReport.status
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
function getDatadogStatus (result) {
|
|
1008
|
+
const state = result?.state
|
|
1009
|
+
if (state === 'pass' || state === 'passed') return 'pass'
|
|
1010
|
+
if (state === 'fail' || state === 'failed') return 'fail'
|
|
1011
|
+
return 'skip'
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function getFinalRepeatedTaskStatus (task) {
|
|
1015
|
+
return task.meta?.__ddTestOptQuarantinedFailed ? 'fail' : getDatadogStatus(task.result)
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function getSuiteTaskError (task) {
|
|
1019
|
+
const suiteTasks = getTypeTasks(task.tasks || [], 'suite')
|
|
1020
|
+
for (const suiteTask of suiteTasks) {
|
|
1021
|
+
if (suiteTask.result?.state === 'fail' && suiteTask.result?.errors?.length) {
|
|
1022
|
+
return suiteTask.result.errors[0]
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function recomputeTaskState (task) {
|
|
1028
|
+
if (!task.tasks) {
|
|
1029
|
+
return getDatadogStatus(task.result)
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const hasErrors = task.result?.errors?.length > 0
|
|
1033
|
+
let hasFailed = false
|
|
1034
|
+
let hasPassed = false
|
|
1035
|
+
|
|
1036
|
+
for (const child of task.tasks) {
|
|
1037
|
+
const childStatus = recomputeTaskState(child)
|
|
1038
|
+
hasFailed ||= childStatus === 'fail'
|
|
1039
|
+
hasPassed ||= childStatus === 'pass'
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
const status = hasErrors || hasFailed ? 'fail' : hasPassed ? 'pass' : 'skip'
|
|
1043
|
+
task.result ||= {}
|
|
1044
|
+
task.result.state = status
|
|
1045
|
+
return status
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
function removeDatadogTestOptimizationNodeOptions (nodeOptions) {
|
|
1049
|
+
if (!nodeOptions) return nodeOptions
|
|
1050
|
+
|
|
1051
|
+
const tokens = splitNodeOptions(nodeOptions)
|
|
1052
|
+
const filteredTokens = []
|
|
1053
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
1054
|
+
const token = tokens[index]
|
|
1055
|
+
const valueSeparator = token.indexOf('=')
|
|
1056
|
+
if (valueSeparator !== -1) {
|
|
1057
|
+
const flag = token.slice(0, valueSeparator)
|
|
1058
|
+
const value = token.slice(valueSeparator + 1)
|
|
1059
|
+
if (shouldRemoveNodeOption(flag, value)) {
|
|
1060
|
+
continue
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
if (token.startsWith('-r') && token.length > 2 && isDatadogTestOptimizationBootstrap(token.slice(2))) {
|
|
1065
|
+
continue
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (
|
|
1069
|
+
DATADOG_TEST_OPTIMIZATION_NODE_OPTION_FLAGS.has(token) &&
|
|
1070
|
+
isDatadogTestOptimizationBootstrap(tokens[index + 1])
|
|
1071
|
+
) {
|
|
1072
|
+
index++
|
|
1073
|
+
continue
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
filteredTokens.push(token)
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
return serializeNodeOptions(filteredTokens)
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function hasDatadogTestOptimizationNodeOptions (nodeOptions) {
|
|
1083
|
+
if (!nodeOptions) return false
|
|
1084
|
+
|
|
1085
|
+
const tokens = splitNodeOptions(nodeOptions)
|
|
1086
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
1087
|
+
const token = tokens[index]
|
|
1088
|
+
const valueSeparator = token.indexOf('=')
|
|
1089
|
+
if (valueSeparator !== -1) {
|
|
1090
|
+
const flag = token.slice(0, valueSeparator)
|
|
1091
|
+
const value = token.slice(valueSeparator + 1)
|
|
1092
|
+
if (shouldRemoveNodeOption(flag, value)) {
|
|
1093
|
+
return true
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
if (token.startsWith('-r') && token.length > 2 && isDatadogTestOptimizationBootstrap(token.slice(2))) {
|
|
1098
|
+
return true
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
if (
|
|
1102
|
+
DATADOG_TEST_OPTIMIZATION_NODE_OPTION_FLAGS.has(token) &&
|
|
1103
|
+
isDatadogTestOptimizationBootstrap(tokens[index + 1])
|
|
1104
|
+
) {
|
|
1105
|
+
return true
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return false
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function shouldRemoveNodeOption (flag, value) {
|
|
1112
|
+
return DATADOG_TEST_OPTIMIZATION_NODE_OPTION_FLAGS.has(flag) &&
|
|
1113
|
+
isDatadogTestOptimizationBootstrap(value)
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function isDatadogTestOptimizationBootstrap (value) {
|
|
1117
|
+
if (!value) return false
|
|
1118
|
+
|
|
1119
|
+
const normalizedValue = value.replaceAll('\\', '/')
|
|
1120
|
+
if (DATADOG_TEST_OPTIMIZATION_BOOTSTRAPS.has(normalizedValue)) return true
|
|
1121
|
+
|
|
1122
|
+
for (const bootstrap of DATADOG_TEST_OPTIMIZATION_BOOTSTRAPS) {
|
|
1123
|
+
if (normalizedValue.endsWith(`/node_modules/${bootstrap}`)) return true
|
|
1124
|
+
}
|
|
1125
|
+
return false
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function splitNodeOptions (nodeOptions) {
|
|
1129
|
+
const tokens = []
|
|
1130
|
+
let token = ''
|
|
1131
|
+
let quote
|
|
1132
|
+
|
|
1133
|
+
for (let index = 0; index < nodeOptions.length; index++) {
|
|
1134
|
+
const char = nodeOptions[index]
|
|
1135
|
+
|
|
1136
|
+
if (quote) {
|
|
1137
|
+
if (char === '\\' && nodeOptions[index + 1] === quote) {
|
|
1138
|
+
token += quote
|
|
1139
|
+
index++
|
|
1140
|
+
continue
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
if (char === quote) {
|
|
1144
|
+
quote = undefined
|
|
1145
|
+
} else {
|
|
1146
|
+
token += char
|
|
1147
|
+
}
|
|
1148
|
+
continue
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
if (char === '"' || char === "'") {
|
|
1152
|
+
quote = char
|
|
1153
|
+
continue
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (char === ' ' || char === '\n' || char === '\t') {
|
|
1157
|
+
if (token) {
|
|
1158
|
+
tokens.push(token)
|
|
1159
|
+
token = ''
|
|
1160
|
+
}
|
|
1161
|
+
continue
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
token += char
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
if (token) {
|
|
1168
|
+
tokens.push(token)
|
|
1169
|
+
}
|
|
1170
|
+
return tokens
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
function serializeNodeOptions (tokens) {
|
|
1174
|
+
const serializedTokens = []
|
|
1175
|
+
for (const token of tokens) {
|
|
1176
|
+
if (NODE_OPTIONS_QUOTE_RE.test(token)) {
|
|
1177
|
+
serializedTokens.push(JSON.stringify(token))
|
|
1178
|
+
} else {
|
|
1179
|
+
serializedTokens.push(token)
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return serializedTokens.join(' ')
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function getTestSpecificationProject (testSpecification) {
|
|
1186
|
+
if (Array.isArray(testSpecification)) {
|
|
1187
|
+
return testSpecification[0]
|
|
1188
|
+
}
|
|
1189
|
+
return testSpecification?.project
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
function getTestSpecificationFile (testSpecification) {
|
|
1193
|
+
if (Array.isArray(testSpecification)) {
|
|
1194
|
+
return testSpecification[1]
|
|
1195
|
+
}
|
|
1196
|
+
return testSpecification
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function getTestSpecificationOptions (testSpecification) {
|
|
1200
|
+
if (Array.isArray(testSpecification)) {
|
|
1201
|
+
return testSpecification[2]
|
|
1202
|
+
}
|
|
1203
|
+
return testSpecification
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
function getTestSpecificationPool (testSpecification) {
|
|
1207
|
+
const options = getTestSpecificationOptions(testSpecification)
|
|
1208
|
+
const file = getTestSpecificationFile(testSpecification)
|
|
1209
|
+
const project = getTestSpecificationProject(testSpecification)
|
|
1210
|
+
return options?.pool ||
|
|
1211
|
+
file?.pool ||
|
|
1212
|
+
testSpecification?.pool ||
|
|
1213
|
+
project?.config?.pool ||
|
|
1214
|
+
project?.serializedConfig?.pool ||
|
|
1215
|
+
project?.pool
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function getEffectiveTestSpecificationPool (testSpecification, defaultPool) {
|
|
1219
|
+
return getTestSpecificationPool(testSpecification) || defaultPool
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Resolves Vitest's default worker pool when the user did not configure one.
|
|
1224
|
+
*
|
|
1225
|
+
* @param {{ pool?: string }|undefined} config
|
|
1226
|
+
* @returns {string}
|
|
1227
|
+
*/
|
|
1228
|
+
function getEffectiveConfigPool (config) {
|
|
1229
|
+
return config?.pool || VITEST_DEFAULT_POOL
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
function getPoolOptionsIsolate (config, pool) {
|
|
1233
|
+
if (!pool) return
|
|
1234
|
+
|
|
1235
|
+
return config?.poolOptions?.[pool]?.isolate
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function getEffectiveConfigIsolate (config, pool) {
|
|
1239
|
+
return getPoolOptionsIsolate(config, pool) ?? config?.isolate
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
function getTestSpecificationIsolate (testSpecification, pool) {
|
|
1243
|
+
const options = getTestSpecificationOptions(testSpecification)
|
|
1244
|
+
const file = getTestSpecificationFile(testSpecification)
|
|
1245
|
+
const project = getTestSpecificationProject(testSpecification)
|
|
1246
|
+
return getPoolOptionsIsolate(options, pool) ??
|
|
1247
|
+
getPoolOptionsIsolate(file, pool) ??
|
|
1248
|
+
getPoolOptionsIsolate(project?.config, pool) ??
|
|
1249
|
+
getPoolOptionsIsolate(project?.serializedConfig, pool) ??
|
|
1250
|
+
getPoolOptionsIsolate(project, pool) ??
|
|
1251
|
+
getPoolOptionsIsolate(testSpecification, pool) ??
|
|
1252
|
+
options?.isolate ??
|
|
1253
|
+
file?.isolate ??
|
|
1254
|
+
project?.config?.isolate ??
|
|
1255
|
+
project?.serializedConfig?.isolate ??
|
|
1256
|
+
project?.isolate ??
|
|
1257
|
+
testSpecification?.isolate
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
function getEffectiveTestSpecificationIsolate (testSpecification, pool, defaultIsolate) {
|
|
1261
|
+
const isolate = getTestSpecificationIsolate(testSpecification, pool)
|
|
1262
|
+
return isolate === undefined ? defaultIsolate : isolate
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function getProjectName (project) {
|
|
1266
|
+
return normalizeProjectName(project?.name || project?.config?.name || project?.test?.name)
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
function normalizeProjectName (name) {
|
|
1270
|
+
if (typeof name === 'string') return name
|
|
1271
|
+
|
|
1272
|
+
const label = name?.label
|
|
1273
|
+
return typeof label === 'string' ? label : undefined
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
function safeConfig (project) {
|
|
1277
|
+
let config
|
|
1278
|
+
try {
|
|
1279
|
+
config = project?.config
|
|
1280
|
+
} catch {}
|
|
1281
|
+
return config
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function safeWorkspaceProject (ctx) {
|
|
1285
|
+
let project
|
|
1286
|
+
try {
|
|
1287
|
+
project = getWorkspaceProject(ctx)
|
|
1288
|
+
} catch {}
|
|
1289
|
+
return project
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
module.exports = {
|
|
1293
|
+
configure,
|
|
1294
|
+
deactivate,
|
|
1295
|
+
configureWorkerEnv,
|
|
1296
|
+
shouldUse,
|
|
1297
|
+
}
|