@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
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
// Capture real timers at module load, before any test can install fake timers.
|
|
4
|
+
const { performance } = require('perf_hooks')
|
|
5
|
+
const { statSync } = require('node:fs')
|
|
6
|
+
const { basename } = require('node:path')
|
|
7
|
+
const dateNow = Date.now
|
|
8
|
+
|
|
9
|
+
const { createCoverageMap } = require('../../../vendor/dist/istanbul-lib-coverage')
|
|
10
|
+
const satisfies = require('../../../vendor/dist/semifies')
|
|
3
11
|
const {
|
|
4
12
|
TEST_STATUS,
|
|
5
13
|
TEST_IS_RUM_ACTIVE,
|
|
6
14
|
TEST_CODE_OWNERS,
|
|
7
15
|
getTestEnvironmentMetadata,
|
|
16
|
+
getTestLevelsMetadataTags,
|
|
8
17
|
CI_APP_ORIGIN,
|
|
9
18
|
getTestParentSpan,
|
|
10
19
|
getCodeOwnersFileEntries,
|
|
@@ -17,23 +26,30 @@ const {
|
|
|
17
26
|
TEST_MODULE_ID,
|
|
18
27
|
TEST_SESSION_ID,
|
|
19
28
|
TEST_COMMAND,
|
|
29
|
+
TEST_LEVELS_METADATA,
|
|
20
30
|
TEST_MODULE,
|
|
21
31
|
TEST_SOURCE_START,
|
|
22
32
|
finishAllTraceSpans,
|
|
23
|
-
|
|
33
|
+
getCoveredFilesFromCoverage,
|
|
34
|
+
getExecutableFilesFromCoverage,
|
|
35
|
+
getRelativeCoverageFiles,
|
|
36
|
+
getTestCoverageLinesPercentage,
|
|
37
|
+
applySkippedCoverageToCoverage,
|
|
38
|
+
mergeCoverage,
|
|
24
39
|
getTestSuitePath,
|
|
25
40
|
addIntelligentTestRunnerSpanTags,
|
|
26
41
|
TEST_SKIPPED_BY_ITR,
|
|
27
42
|
TEST_ITR_UNSKIPPABLE,
|
|
28
43
|
TEST_ITR_FORCED_RUN,
|
|
44
|
+
TEST_ITR_SKIPPING_ENABLED,
|
|
29
45
|
ITR_CORRELATION_ID,
|
|
30
46
|
TEST_SOURCE_FILE,
|
|
31
47
|
TEST_IS_NEW,
|
|
32
48
|
TEST_IS_RETRY,
|
|
33
49
|
TEST_EARLY_FLAKE_ENABLED,
|
|
50
|
+
TEST_EARLY_FLAKE_ABORT_REASON,
|
|
34
51
|
getTestSessionName,
|
|
35
52
|
TEST_SESSION_NAME,
|
|
36
|
-
TEST_LEVEL_EVENT_TYPES,
|
|
37
53
|
TEST_RETRY_REASON,
|
|
38
54
|
DD_TEST_IS_USER_PROVIDED_SERVICE,
|
|
39
55
|
TEST_MANAGEMENT_IS_QUARANTINED,
|
|
@@ -47,16 +63,30 @@ const {
|
|
|
47
63
|
getPullRequestDiff,
|
|
48
64
|
getModifiedFilesFromDiff,
|
|
49
65
|
getSessionRequestErrorTags,
|
|
50
|
-
|
|
66
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS,
|
|
67
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS,
|
|
68
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS,
|
|
69
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS,
|
|
70
|
+
getSessionItrSkippingEnabledTags,
|
|
51
71
|
TEST_IS_MODIFIED,
|
|
52
72
|
TEST_HAS_DYNAMIC_NAME,
|
|
73
|
+
getIsFaultyEarlyFlakeDetection,
|
|
53
74
|
DYNAMIC_NAME_RE,
|
|
54
|
-
|
|
75
|
+
recordAttemptToFixExecution,
|
|
76
|
+
logAttemptToFixTestExecution,
|
|
77
|
+
logTestOptimizationSummary,
|
|
78
|
+
getEfdRetryCount,
|
|
79
|
+
getMaxEfdRetryCount,
|
|
55
80
|
getPullRequestBaseBranch,
|
|
81
|
+
TEST_FINAL_STATUS,
|
|
82
|
+
TEST_FAILURE_SCREENSHOT_UPLOADED,
|
|
83
|
+
TEST_FAILURE_SCREENSHOT_UPLOAD_ERROR,
|
|
84
|
+
getTestOptimizationRequestResults,
|
|
56
85
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
57
86
|
const { isMarkedAsUnskippable } = require('../../datadog-plugin-jest/src/util')
|
|
58
87
|
const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
|
|
59
|
-
const {
|
|
88
|
+
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
89
|
+
const getConfig = require('../../dd-trace/src/config')
|
|
60
90
|
const { appClosing: appClosingTelemetry } = require('../../dd-trace/src/telemetry')
|
|
61
91
|
const log = require('../../dd-trace/src/log')
|
|
62
92
|
|
|
@@ -95,12 +125,13 @@ const {
|
|
|
95
125
|
} = require('../../dd-trace/src/plugins/util/env')
|
|
96
126
|
const { DD_MAJOR } = require('../../../version')
|
|
97
127
|
const {
|
|
98
|
-
|
|
128
|
+
resolveOriginalSourceFile,
|
|
99
129
|
resolveSourceLineForTest,
|
|
100
130
|
shouldTrustInvocationDetailsLine,
|
|
101
131
|
} = require('./source-map-utils')
|
|
102
132
|
|
|
103
133
|
const TEST_FRAMEWORK_NAME = 'cypress'
|
|
134
|
+
let hasWarnedDeprecatedCypressVersion = false
|
|
104
135
|
|
|
105
136
|
const CYPRESS_STATUS_TO_TEST_STATUS = {
|
|
106
137
|
passed: 'pass',
|
|
@@ -109,6 +140,127 @@ const CYPRESS_STATUS_TO_TEST_STATUS = {
|
|
|
109
140
|
skipped: 'skip',
|
|
110
141
|
}
|
|
111
142
|
|
|
143
|
+
const SCREENSHOT_ATTEMPT_RE = /\(attempt \d+\)/
|
|
144
|
+
const SCREENSHOT_UPLOAD_RESULT_UPLOADED = 'uploaded'
|
|
145
|
+
const SCREENSHOT_UPLOAD_RESULT_ERROR = 'error'
|
|
146
|
+
|
|
147
|
+
function getScreenshotFilePath (screenshot) {
|
|
148
|
+
return typeof screenshot === 'string' ? screenshot : screenshot?.path
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function isFailureScreenshotByMetadata (screenshot, screenshotFilePath) {
|
|
152
|
+
if (screenshot !== null && typeof screenshot === 'object' && screenshot.testFailure !== undefined) {
|
|
153
|
+
return screenshot.testFailure === true
|
|
154
|
+
}
|
|
155
|
+
return screenshotFilePath.includes('(failed)')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Resolves a screenshot's capture time (epoch ms) for the media upload. Cypress
|
|
160
|
+
* screenshot objects carry an ISO `takenAt`; falls back to the file's mtime, then
|
|
161
|
+
* to the current time. Stamped once here and reused on retry via the idempotency
|
|
162
|
+
* key, so the stored object is overwritten rather than duplicated.
|
|
163
|
+
*
|
|
164
|
+
* @param {object|string} screenshot - Cypress screenshot object or path
|
|
165
|
+
* @param {string} filePath - Resolved screenshot file path
|
|
166
|
+
* @returns {number} Capture time in epoch milliseconds
|
|
167
|
+
*/
|
|
168
|
+
function getScreenshotCapturedAtMs (screenshot, filePath) {
|
|
169
|
+
const takenAt = screenshot !== null && typeof screenshot === 'object' ? screenshot.takenAt : undefined
|
|
170
|
+
if (takenAt) {
|
|
171
|
+
const parsedMs = new Date(takenAt).getTime()
|
|
172
|
+
if (Number.isInteger(parsedMs) && parsedMs > 0) {
|
|
173
|
+
return parsedMs
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
return Math.floor(statSync(filePath).mtimeMs)
|
|
178
|
+
} catch {
|
|
179
|
+
return dateNow()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function isFailureScreenshotForUpload (screenshot) {
|
|
184
|
+
const screenshotFilePath = getScreenshotFilePath(screenshot)
|
|
185
|
+
if (!screenshotFilePath) {
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
if (screenshot !== null && typeof screenshot === 'object') {
|
|
189
|
+
// after:screenshot details omit testFailure for manual cy.screenshot() captures, so this
|
|
190
|
+
// path cannot safely fall back to the '(failed)' filename marker.
|
|
191
|
+
return screenshot.testFailure === true
|
|
192
|
+
}
|
|
193
|
+
return screenshotFilePath.includes('(failed)')
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function isFailureScreenshot (screenshot) {
|
|
197
|
+
const screenshotFilePath = getScreenshotFilePath(screenshot)
|
|
198
|
+
// Require an explicit failure signal: prefer the `testFailure` metadata, and fall back to the
|
|
199
|
+
// '(failed)' filename marker only when the RunResult omits `testFailure`. This keeps manual
|
|
200
|
+
// cy.screenshot() captures out of the failure-screenshot upload (privacy).
|
|
201
|
+
return !!screenshotFilePath && isFailureScreenshotByMetadata(screenshot, screenshotFilePath)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function getAttemptScreenshots (cypressTest, attemptIndex) {
|
|
205
|
+
if (!Array.isArray(cypressTest.attempts)) {
|
|
206
|
+
return []
|
|
207
|
+
}
|
|
208
|
+
const attempt = cypressTest.attempts[attemptIndex]
|
|
209
|
+
if (!Array.isArray(attempt?.screenshots)) {
|
|
210
|
+
return []
|
|
211
|
+
}
|
|
212
|
+
return attempt.screenshots.filter(isFailureScreenshot)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function isScreenshotForTestAttempt (screenshot, titleParts, attemptIndex) {
|
|
216
|
+
const screenshotFilePath = getScreenshotFilePath(screenshot)
|
|
217
|
+
if (!screenshotFilePath || !isFailureScreenshot(screenshot)) {
|
|
218
|
+
return false
|
|
219
|
+
}
|
|
220
|
+
for (const titlePart of titleParts) {
|
|
221
|
+
if (!screenshotFilePath.includes(titlePart)) {
|
|
222
|
+
return false
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (attemptIndex === 0) {
|
|
226
|
+
return !SCREENSHOT_ATTEMPT_RE.test(screenshotFilePath)
|
|
227
|
+
}
|
|
228
|
+
return screenshotFilePath.includes(`(attempt ${attemptIndex + 1})`)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function getTestScreenshots (cypressTest, attemptIndex, specScreenshots) {
|
|
232
|
+
const attemptScreenshots = getAttemptScreenshots(cypressTest, attemptIndex)
|
|
233
|
+
if (attemptScreenshots.length > 0) {
|
|
234
|
+
return attemptScreenshots
|
|
235
|
+
}
|
|
236
|
+
if (!Array.isArray(specScreenshots)) {
|
|
237
|
+
return []
|
|
238
|
+
}
|
|
239
|
+
const titleParts = Array.isArray(cypressTest.title) ? cypressTest.title : []
|
|
240
|
+
return specScreenshots.filter(screenshot => isScreenshotForTestAttempt(screenshot, titleParts, attemptIndex))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function getScreenshotUploadResult (uploadResults) {
|
|
244
|
+
let hasUploaded = false
|
|
245
|
+
for (const uploadResult of uploadResults) {
|
|
246
|
+
if (uploadResult === SCREENSHOT_UPLOAD_RESULT_ERROR) {
|
|
247
|
+
return SCREENSHOT_UPLOAD_RESULT_ERROR
|
|
248
|
+
}
|
|
249
|
+
if (uploadResult === SCREENSHOT_UPLOAD_RESULT_UPLOADED) {
|
|
250
|
+
hasUploaded = true
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return hasUploaded ? SCREENSHOT_UPLOAD_RESULT_UPLOADED : undefined
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function setScreenshotUploadTags (testSpan, uploadResult) {
|
|
257
|
+
if (uploadResult === SCREENSHOT_UPLOAD_RESULT_ERROR) {
|
|
258
|
+
testSpan.setTag(TEST_FAILURE_SCREENSHOT_UPLOAD_ERROR, 'true')
|
|
259
|
+
} else if (uploadResult === SCREENSHOT_UPLOAD_RESULT_UPLOADED) {
|
|
260
|
+
testSpan.setTag(TEST_FAILURE_SCREENSHOT_UPLOADED, 'true')
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
112
264
|
function getSessionStatus (summary) {
|
|
113
265
|
if (summary.totalFailed !== undefined && summary.totalFailed > 0) {
|
|
114
266
|
return 'fail'
|
|
@@ -129,6 +281,20 @@ function getCypressVersion (details) {
|
|
|
129
281
|
return ''
|
|
130
282
|
}
|
|
131
283
|
|
|
284
|
+
function warnDeprecatedCypressVersion (version) {
|
|
285
|
+
if (DD_MAJOR >= 6 || hasWarnedDeprecatedCypressVersion || !version || !satisfies(version, '<12.0.0')) {
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
hasWarnedDeprecatedCypressVersion = true
|
|
290
|
+
// console.warn does not seem to work reliably in Cypress, so use console.log instead.
|
|
291
|
+
// eslint-disable-next-line no-console
|
|
292
|
+
console.log(
|
|
293
|
+
'WARNING: dd-trace support for Cypress<12.0.0 is deprecated' +
|
|
294
|
+
' and will not be supported in dd-trace v6. Please upgrade Cypress to >=12.0.0.'
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
132
298
|
function getRootDir (details) {
|
|
133
299
|
if (details?.config) {
|
|
134
300
|
return details.config.projectRoot || details.config.repoRoot || process.cwd()
|
|
@@ -168,13 +334,17 @@ function getSkippableTests (tracer, testConfiguration) {
|
|
|
168
334
|
if (!tracer._tracer._exporter?.getSkippableSuites) {
|
|
169
335
|
return resolve({ err: new Error('Test Optimization was not initialized correctly') })
|
|
170
336
|
}
|
|
171
|
-
tracer._tracer._exporter.getSkippableSuites(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
337
|
+
tracer._tracer._exporter.getSkippableSuites(
|
|
338
|
+
testConfiguration,
|
|
339
|
+
(err, skippableTests, correlationId, skippableTestsCoverage) => {
|
|
340
|
+
resolve({
|
|
341
|
+
err,
|
|
342
|
+
skippableTests,
|
|
343
|
+
correlationId,
|
|
344
|
+
skippableTestsCoverage,
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
)
|
|
178
348
|
})
|
|
179
349
|
}
|
|
180
350
|
|
|
@@ -240,22 +410,114 @@ function getSuiteStatus (suiteStats) {
|
|
|
240
410
|
return 'pass'
|
|
241
411
|
}
|
|
242
412
|
|
|
413
|
+
function getMatchingCypressTest (cypressTests, testName, attemptIndex, testStatus, preferIndexedMatch = false) {
|
|
414
|
+
let matchingTestByIndex
|
|
415
|
+
let matchingTestByStatus
|
|
416
|
+
let matchingTestIndex = 0
|
|
417
|
+
|
|
418
|
+
for (const cypressTest of cypressTests) {
|
|
419
|
+
if (cypressTest.title.join(' ') !== testName) {
|
|
420
|
+
continue
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (matchingTestIndex === attemptIndex) {
|
|
424
|
+
matchingTestByIndex = cypressTest
|
|
425
|
+
}
|
|
426
|
+
matchingTestIndex++
|
|
427
|
+
|
|
428
|
+
if (!matchingTestByStatus && CYPRESS_STATUS_TO_TEST_STATUS[cypressTest.state] === testStatus) {
|
|
429
|
+
matchingTestByStatus = cypressTest
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return preferIndexedMatch
|
|
434
|
+
? matchingTestByIndex || matchingTestByStatus
|
|
435
|
+
: matchingTestByStatus || matchingTestByIndex
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function isCypressHookFailure (cypressTest) {
|
|
439
|
+
return CYPRESS_STATUS_TO_TEST_STATUS[cypressTest.state] === 'fail' &&
|
|
440
|
+
/\bhook\b/.test(String(cypressTest.displayError || ''))
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const FINAL_STATUS_RETRY_KIND = {
|
|
444
|
+
none: 'none',
|
|
445
|
+
atr: 'atr',
|
|
446
|
+
efd: 'efd',
|
|
447
|
+
atf: 'atf',
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function getFinalStatusRetryKind ({ finishedTest, finishedTestAttempts, flakyTestRetriesCount }) {
|
|
451
|
+
// Infer retry kind from the executions we actually saw so ATR enabled with
|
|
452
|
+
// a retry count of 0 is still treated as a single final execution.
|
|
453
|
+
if (finishedTest.isAttemptToFix) {
|
|
454
|
+
return FINAL_STATUS_RETRY_KIND.atf
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (finishedTestAttempts.some(testAttempt => testAttempt.isEfdRetry)) {
|
|
458
|
+
return FINAL_STATUS_RETRY_KIND.efd
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (finishedTestAttempts.length > 1 && flakyTestRetriesCount > 0) {
|
|
462
|
+
return FINAL_STATUS_RETRY_KIND.atr
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return FINAL_STATUS_RETRY_KIND.none
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function getFinalStatus ({
|
|
469
|
+
status,
|
|
470
|
+
retryKind,
|
|
471
|
+
hasFailedAllRetries,
|
|
472
|
+
hasPassedAllAtfRetries,
|
|
473
|
+
isQuarantined,
|
|
474
|
+
isDisabled,
|
|
475
|
+
}) {
|
|
476
|
+
// If the test is quarantined or disabled, its final status is skip unless attempt-to-fix takes precedence.
|
|
477
|
+
if (status === 'skip' || (retryKind !== FINAL_STATUS_RETRY_KIND.atf && (isQuarantined || isDisabled))) {
|
|
478
|
+
return 'skip'
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
switch (retryKind) {
|
|
482
|
+
case FINAL_STATUS_RETRY_KIND.atr:
|
|
483
|
+
case FINAL_STATUS_RETRY_KIND.efd:
|
|
484
|
+
// These modes report the aggregate result across attempts.
|
|
485
|
+
return hasFailedAllRetries ? 'fail' : 'pass'
|
|
486
|
+
case FINAL_STATUS_RETRY_KIND.atf:
|
|
487
|
+
// Attempt-to-fix only passes if every execution passed.
|
|
488
|
+
return hasPassedAllAtfRetries ? 'pass' : 'fail'
|
|
489
|
+
default:
|
|
490
|
+
return status
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
243
494
|
class CypressPlugin {
|
|
244
495
|
_isInit = false
|
|
245
496
|
testEnvironmentMetadata = getTestEnvironmentMetadata(TEST_FRAMEWORK_NAME)
|
|
246
497
|
|
|
247
498
|
finishedTestsByFile = {}
|
|
248
499
|
testStatuses = {}
|
|
500
|
+
hasLibraryConfiguration = false
|
|
501
|
+
isItrEnabled = false
|
|
249
502
|
isTestsSkipped = false
|
|
250
503
|
isSuitesSkippingEnabled = false
|
|
251
504
|
isCodeCoverageEnabled = false
|
|
505
|
+
isCoverageReportUploadEnabled = false
|
|
252
506
|
isFlakyTestRetriesEnabled = false
|
|
253
507
|
flakyTestRetriesCount = 0
|
|
254
508
|
isEarlyFlakeDetectionEnabled = false
|
|
509
|
+
isEarlyFlakeDetectionFaulty = false
|
|
255
510
|
isKnownTestsEnabled = false
|
|
256
511
|
earlyFlakeDetectionNumRetries = 0
|
|
512
|
+
earlyFlakeDetectionSlowTestRetries = {}
|
|
513
|
+
efdRetryCountByTest = {}
|
|
514
|
+
efdSlowAbortedTests = {}
|
|
515
|
+
earlyFlakeDetectionFaultyThreshold = 0
|
|
257
516
|
testsToSkip = []
|
|
258
517
|
skippedTests = []
|
|
518
|
+
skippedTestIds = new Set()
|
|
519
|
+
skippableTestsCoverage = {}
|
|
520
|
+
testSessionCoverageMap = createCoverageMap()
|
|
259
521
|
hasForcedToRunSuites = false
|
|
260
522
|
hasUnskippableSuites = false
|
|
261
523
|
unskippableSuites = []
|
|
@@ -265,6 +527,13 @@ class CypressPlugin {
|
|
|
265
527
|
isImpactedTestsEnabled = false
|
|
266
528
|
modifiedFiles = []
|
|
267
529
|
newTestsWithDynamicNames = new Set()
|
|
530
|
+
attemptToFixExecutions = new Map()
|
|
531
|
+
loggedAttemptToFixTests = new Set()
|
|
532
|
+
uploadedScreenshotPaths = new Set()
|
|
533
|
+
screenshotUploadPromisesByTraceId = new Map()
|
|
534
|
+
afterScreenshotHandler = undefined
|
|
535
|
+
lastFinishedTest = null
|
|
536
|
+
pendingScreenshotUploads = []
|
|
268
537
|
|
|
269
538
|
constructor () {
|
|
270
539
|
const {
|
|
@@ -317,16 +586,27 @@ class CypressPlugin {
|
|
|
317
586
|
this._isInit = false
|
|
318
587
|
this.finishedTestsByFile = {}
|
|
319
588
|
this.testStatuses = {}
|
|
589
|
+
this.hasLibraryConfiguration = false
|
|
590
|
+
this.isItrEnabled = false
|
|
320
591
|
this.isTestsSkipped = false
|
|
321
592
|
this.isSuitesSkippingEnabled = false
|
|
322
593
|
this.isCodeCoverageEnabled = false
|
|
594
|
+
this.isCoverageReportUploadEnabled = false
|
|
323
595
|
this.isFlakyTestRetriesEnabled = false
|
|
324
596
|
this.flakyTestRetriesCount = 0
|
|
325
597
|
this.isEarlyFlakeDetectionEnabled = false
|
|
598
|
+
this.isEarlyFlakeDetectionFaulty = false
|
|
326
599
|
this.isKnownTestsEnabled = false
|
|
327
600
|
this.earlyFlakeDetectionNumRetries = 0
|
|
601
|
+
this.earlyFlakeDetectionSlowTestRetries = {}
|
|
602
|
+
this.efdRetryCountByTest = {}
|
|
603
|
+
this.efdSlowAbortedTests = {}
|
|
604
|
+
this.earlyFlakeDetectionFaultyThreshold = 0
|
|
328
605
|
this.testsToSkip = []
|
|
329
606
|
this.skippedTests = []
|
|
607
|
+
this.skippedTestIds = new Set()
|
|
608
|
+
this.skippableTestsCoverage = {}
|
|
609
|
+
this.testSessionCoverageMap = createCoverageMap()
|
|
330
610
|
this.hasForcedToRunSuites = false
|
|
331
611
|
this.hasUnskippableSuites = false
|
|
332
612
|
this.unskippableSuites = []
|
|
@@ -337,6 +617,12 @@ class CypressPlugin {
|
|
|
337
617
|
this.testManagementTests = undefined
|
|
338
618
|
this.isImpactedTestsEnabled = false
|
|
339
619
|
this.modifiedFiles = []
|
|
620
|
+
this.attemptToFixExecutions = new Map()
|
|
621
|
+
this.loggedAttemptToFixTests = new Set()
|
|
622
|
+
this.uploadedScreenshotPaths = new Set()
|
|
623
|
+
this.screenshotUploadPromisesByTraceId = new Map()
|
|
624
|
+
this.lastFinishedTest = null
|
|
625
|
+
this.pendingScreenshotUploads = []
|
|
340
626
|
this.activeTestSpan = null
|
|
341
627
|
this.testSuiteSpan = null
|
|
342
628
|
this.testModuleSpan = null
|
|
@@ -349,6 +635,205 @@ class CypressPlugin {
|
|
|
349
635
|
this.rumFlushWaitMillis = undefined
|
|
350
636
|
this._pendingRequestErrorTags = []
|
|
351
637
|
this.libraryConfigurationPromise = undefined
|
|
638
|
+
this._timeOrigin = 0
|
|
639
|
+
this._perfOrigin = 0
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Returns a stable after:screenshot handler so auto-instrumentation can recognize
|
|
644
|
+
* the handler registered by the manual plugin and avoid treating it as a user hook.
|
|
645
|
+
*
|
|
646
|
+
* @returns {Function} Datadog after:screenshot handler
|
|
647
|
+
*/
|
|
648
|
+
getAfterScreenshotHandler () {
|
|
649
|
+
if (!this.afterScreenshotHandler) {
|
|
650
|
+
this.afterScreenshotHandler = this.afterScreenshot.bind(this)
|
|
651
|
+
}
|
|
652
|
+
return this.afterScreenshotHandler
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Tracks a screenshot upload by its owning test trace id so the test event can be tagged
|
|
657
|
+
* before the span is finished.
|
|
658
|
+
*
|
|
659
|
+
* @param {string} traceId - Test trace id used for the upload
|
|
660
|
+
* @param {Promise<string|undefined>} uploadPromise - Promise resolving to the upload outcome
|
|
661
|
+
* @returns {void}
|
|
662
|
+
*/
|
|
663
|
+
addScreenshotUploadPromise (traceId, uploadPromise) {
|
|
664
|
+
const uploadPromises = this.screenshotUploadPromisesByTraceId.get(traceId)
|
|
665
|
+
if (uploadPromises) {
|
|
666
|
+
uploadPromises.push(uploadPromise)
|
|
667
|
+
} else {
|
|
668
|
+
this.screenshotUploadPromisesByTraceId.set(traceId, [uploadPromise])
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Returns the aggregate upload outcome for all screenshots associated with a test trace id.
|
|
674
|
+
*
|
|
675
|
+
* @param {string} traceId - Test trace id used for the upload
|
|
676
|
+
* @returns {Promise<string|undefined>|undefined} Promise resolving to the aggregate upload outcome
|
|
677
|
+
*/
|
|
678
|
+
getScreenshotUploadResultPromise (traceId) {
|
|
679
|
+
const uploadPromises = this.screenshotUploadPromisesByTraceId.get(traceId)
|
|
680
|
+
if (!uploadPromises?.length) {
|
|
681
|
+
return
|
|
682
|
+
}
|
|
683
|
+
return Promise.all(uploadPromises).then(getScreenshotUploadResult)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Returns the current time in the same coordinate system used by span
|
|
688
|
+
* start/finish. Captured at session span creation so it shares the same
|
|
689
|
+
* epoch as the trace without reaching into span internals.
|
|
690
|
+
*
|
|
691
|
+
* @returns {number}
|
|
692
|
+
*/
|
|
693
|
+
_now () {
|
|
694
|
+
return this._timeOrigin + performance.now() - this._perfOrigin
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Returns the directory used to normalize coverage file names.
|
|
699
|
+
*
|
|
700
|
+
* @returns {string}
|
|
701
|
+
*/
|
|
702
|
+
getCoverageRootDir () {
|
|
703
|
+
return this.repositoryRoot || this.rootDir || process.cwd()
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Returns whether the backend supplied skipped-test coverage data.
|
|
708
|
+
*
|
|
709
|
+
* @returns {boolean}
|
|
710
|
+
*/
|
|
711
|
+
hasSkippableTestsCoverage () {
|
|
712
|
+
return !!(this.skippableTestsCoverage &&
|
|
713
|
+
typeof this.skippableTestsCoverage === 'object' &&
|
|
714
|
+
Object.keys(this.skippableTestsCoverage).length > 0)
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Returns whether skipped test coverage should be backfilled into the session coverage map.
|
|
719
|
+
*
|
|
720
|
+
* @returns {boolean}
|
|
721
|
+
*/
|
|
722
|
+
shouldBackfillSkippedCoverage () {
|
|
723
|
+
return this.isItrEnabled &&
|
|
724
|
+
this.isCoverageReportUploadEnabled &&
|
|
725
|
+
this.isTestsSkipped &&
|
|
726
|
+
this.hasSkippableTestsCoverage()
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Adds a test's Istanbul coverage to the aggregated session coverage map.
|
|
731
|
+
*
|
|
732
|
+
* @param {object} coverage
|
|
733
|
+
* @returns {void}
|
|
734
|
+
*/
|
|
735
|
+
addTestSessionCoverage (coverage) {
|
|
736
|
+
mergeCoverage(coverage, this.testSessionCoverageMap)
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Applies backend skipped-test coverage to the aggregated session coverage map.
|
|
741
|
+
*
|
|
742
|
+
* @returns {boolean}
|
|
743
|
+
*/
|
|
744
|
+
applySkippedCoverageToTestSessionCoverage () {
|
|
745
|
+
if (!this.shouldBackfillSkippedCoverage()) {
|
|
746
|
+
return false
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return applySkippedCoverageToCoverage(
|
|
750
|
+
this.testSessionCoverageMap,
|
|
751
|
+
this.skippableTestsCoverage,
|
|
752
|
+
this.getCoverageRootDir()
|
|
753
|
+
)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Calculates the total session code coverage percentage when product rules allow reporting it.
|
|
758
|
+
*
|
|
759
|
+
* @param {boolean} hasBackfilledCoverage
|
|
760
|
+
* @returns {number | undefined}
|
|
761
|
+
*/
|
|
762
|
+
getTestCodeCoverageLinesTotal (hasBackfilledCoverage) {
|
|
763
|
+
if (!this.testSessionCoverageMap.files().length || (this.isTestsSkipped && !hasBackfilledCoverage)) {
|
|
764
|
+
return
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
return getTestCoverageLinesPercentage(this.testSessionCoverageMap, undefined, this.getCoverageRootDir())
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Returns repository-relative executable-line coverage files for the test session.
|
|
772
|
+
*
|
|
773
|
+
* @returns {Array<{ filename: string, bitmap: Buffer }>}
|
|
774
|
+
*/
|
|
775
|
+
getTestSessionCoverageFiles () {
|
|
776
|
+
return getRelativeCoverageFiles(
|
|
777
|
+
getExecutableFilesFromCoverage(this.testSessionCoverageMap),
|
|
778
|
+
this.getCoverageRootDir()
|
|
779
|
+
)
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Uploads executable-line coverage for the test session when backend configuration enables it.
|
|
784
|
+
*
|
|
785
|
+
* @returns {void}
|
|
786
|
+
*/
|
|
787
|
+
reportTestSessionCoverage () {
|
|
788
|
+
const exporter = this.tracer._tracer._exporter
|
|
789
|
+
if (
|
|
790
|
+
!this.testSessionSpan ||
|
|
791
|
+
!this.isCoverageReportUploadEnabled ||
|
|
792
|
+
!exporter?.exportCoverage
|
|
793
|
+
) {
|
|
794
|
+
return
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
const files = this.getTestSessionCoverageFiles()
|
|
798
|
+
if (!files.length) {
|
|
799
|
+
return
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
exporter.exportCoverage({
|
|
803
|
+
sessionId: this.testSessionSpan.context()._traceId,
|
|
804
|
+
files,
|
|
805
|
+
})
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Warns when screenshot upload is enabled but Cypress cannot produce or send the screenshots.
|
|
810
|
+
*
|
|
811
|
+
* @param {object} cypressConfig - Cypress resolved config
|
|
812
|
+
* @param {object} tracer - dd-trace proxy tracer
|
|
813
|
+
* @param {object} testOptimizationConfig - Test Optimization config
|
|
814
|
+
* @returns {void}
|
|
815
|
+
*/
|
|
816
|
+
warnIfMisconfiguredTestFailureScreenshots (cypressConfig, tracer, testOptimizationConfig) {
|
|
817
|
+
if (!testOptimizationConfig.DD_TEST_FAILURE_SCREENSHOTS_ENABLED) {
|
|
818
|
+
return
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
if (cypressConfig.screenshotOnRunFailure === false) {
|
|
822
|
+
log.warn(
|
|
823
|
+
'%s %s',
|
|
824
|
+
'DD_TEST_FAILURE_SCREENSHOTS_ENABLED is true, but Cypress screenshotOnRunFailure is false.',
|
|
825
|
+
'Datadog cannot upload failure screenshots unless Cypress is configured to capture them.'
|
|
826
|
+
)
|
|
827
|
+
return
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
if (!tracer?._tracer?._exporter?.canUploadTestScreenshots?.()) {
|
|
831
|
+
log.warn(
|
|
832
|
+
'%s %s',
|
|
833
|
+
'DD_TEST_FAILURE_SCREENSHOTS_ENABLED is true, but Cypress failure screenshot upload is only supported',
|
|
834
|
+
'in agentless mode.'
|
|
835
|
+
)
|
|
836
|
+
}
|
|
352
837
|
}
|
|
353
838
|
|
|
354
839
|
// Init function returns a promise that resolves with the Cypress configuration
|
|
@@ -359,11 +844,13 @@ class CypressPlugin {
|
|
|
359
844
|
this._isInit = true
|
|
360
845
|
this.tracer = tracer
|
|
361
846
|
this.cypressConfig = cypressConfig
|
|
847
|
+
warnDeprecatedCypressVersion(cypressConfig.version)
|
|
362
848
|
|
|
363
849
|
this.isTestIsolationEnabled = getIsTestIsolationEnabled(cypressConfig)
|
|
364
850
|
|
|
365
|
-
const
|
|
366
|
-
this.rumFlushWaitMillis =
|
|
851
|
+
const testOptimizationConfig = getConfig().testOptimization
|
|
852
|
+
this.rumFlushWaitMillis = testOptimizationConfig.DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS
|
|
853
|
+
this.warnIfMisconfiguredTestFailureScreenshots(cypressConfig, tracer, testOptimizationConfig)
|
|
367
854
|
|
|
368
855
|
if (!this.isTestIsolationEnabled) {
|
|
369
856
|
log.warn('Test isolation is disabled, retries will not be enabled')
|
|
@@ -379,16 +866,21 @@ class CypressPlugin {
|
|
|
379
866
|
if (libraryConfigurationResponse.err) {
|
|
380
867
|
log.error('Cypress plugin library config response error', libraryConfigurationResponse.err)
|
|
381
868
|
this._pendingRequestErrorTags.push({
|
|
382
|
-
tag:
|
|
869
|
+
tag: DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS,
|
|
383
870
|
value: 'true',
|
|
384
871
|
})
|
|
385
872
|
} else {
|
|
873
|
+
this.hasLibraryConfiguration = true
|
|
386
874
|
const {
|
|
387
875
|
libraryConfig: {
|
|
876
|
+
isItrEnabled,
|
|
388
877
|
isSuitesSkippingEnabled,
|
|
389
878
|
isCodeCoverageEnabled,
|
|
879
|
+
isCoverageReportUploadEnabled,
|
|
390
880
|
isEarlyFlakeDetectionEnabled,
|
|
391
881
|
earlyFlakeDetectionNumRetries,
|
|
882
|
+
earlyFlakeDetectionSlowTestRetries,
|
|
883
|
+
earlyFlakeDetectionFaultyThreshold,
|
|
392
884
|
isFlakyTestRetriesEnabled,
|
|
393
885
|
flakyTestRetriesCount,
|
|
394
886
|
isKnownTestsEnabled,
|
|
@@ -397,10 +889,14 @@ class CypressPlugin {
|
|
|
397
889
|
isImpactedTestsEnabled,
|
|
398
890
|
},
|
|
399
891
|
} = libraryConfigurationResponse
|
|
892
|
+
this.isItrEnabled = isItrEnabled
|
|
400
893
|
this.isSuitesSkippingEnabled = isSuitesSkippingEnabled
|
|
401
894
|
this.isCodeCoverageEnabled = isCodeCoverageEnabled
|
|
895
|
+
this.isCoverageReportUploadEnabled = isCoverageReportUploadEnabled
|
|
402
896
|
this.isEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
403
897
|
this.earlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
898
|
+
this.earlyFlakeDetectionSlowTestRetries = earlyFlakeDetectionSlowTestRetries ?? {}
|
|
899
|
+
this.earlyFlakeDetectionFaultyThreshold = earlyFlakeDetectionFaultyThreshold
|
|
404
900
|
this.isKnownTestsEnabled = isKnownTestsEnabled
|
|
405
901
|
if (isFlakyTestRetriesEnabled && this.isTestIsolationEnabled) {
|
|
406
902
|
this.isFlakyTestRetriesEnabled = true
|
|
@@ -441,15 +937,81 @@ class CypressPlugin {
|
|
|
441
937
|
return { isAttemptToFix, isDisabled, isQuarantined }
|
|
442
938
|
}
|
|
443
939
|
|
|
940
|
+
/**
|
|
941
|
+
* Returns how many EFD retries must be scheduled before the first duration is known.
|
|
942
|
+
*
|
|
943
|
+
* @returns {number}
|
|
944
|
+
*/
|
|
945
|
+
getConfiguredEfdRetryCount () {
|
|
946
|
+
const { earlyFlakeDetectionSlowTestRetries } = this
|
|
947
|
+
if (!earlyFlakeDetectionSlowTestRetries || !Object.keys(earlyFlakeDetectionSlowTestRetries).length) {
|
|
948
|
+
return this.earlyFlakeDetectionNumRetries
|
|
949
|
+
}
|
|
950
|
+
return getMaxEfdRetryCount(earlyFlakeDetectionSlowTestRetries)
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Returns the selected EFD retry count for a test, or the scheduling count if it has not run yet.
|
|
955
|
+
*
|
|
956
|
+
* @param {string} testSuite
|
|
957
|
+
* @param {string} testName
|
|
958
|
+
* @returns {number}
|
|
959
|
+
*/
|
|
960
|
+
getEfdRetryCountForTest (testSuite, testName) {
|
|
961
|
+
const testSuiteRetries = this.efdRetryCountByTest[testSuite]
|
|
962
|
+
if (!testSuiteRetries || testSuiteRetries[testName] === undefined) {
|
|
963
|
+
return this.getConfiguredEfdRetryCount()
|
|
964
|
+
}
|
|
965
|
+
return testSuiteRetries[testName]
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Stores the selected EFD retry count for a test after its first execution duration is known.
|
|
970
|
+
*
|
|
971
|
+
* @param {string} testSuite
|
|
972
|
+
* @param {string} testName
|
|
973
|
+
* @param {number | undefined} duration
|
|
974
|
+
* @returns {number}
|
|
975
|
+
*/
|
|
976
|
+
setEfdRetryCountForTest (testSuite, testName, duration) {
|
|
977
|
+
if (!this.efdRetryCountByTest[testSuite]) {
|
|
978
|
+
this.efdRetryCountByTest[testSuite] = {}
|
|
979
|
+
}
|
|
980
|
+
const retryCount = getEfdRetryCount(duration ?? 0, this.earlyFlakeDetectionSlowTestRetries)
|
|
981
|
+
this.efdRetryCountByTest[testSuite][testName] = retryCount
|
|
982
|
+
if (retryCount === 0) {
|
|
983
|
+
if (!this.efdSlowAbortedTests[testSuite]) {
|
|
984
|
+
this.efdSlowAbortedTests[testSuite] = {}
|
|
985
|
+
}
|
|
986
|
+
this.efdSlowAbortedTests[testSuite][testName] = true
|
|
987
|
+
}
|
|
988
|
+
return retryCount
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Returns whether an EFD retry clone is beyond the selected retry count and should be discarded.
|
|
993
|
+
*
|
|
994
|
+
* @param {string} testSuite
|
|
995
|
+
* @param {string} testName
|
|
996
|
+
* @param {number} efdRetryIndex
|
|
997
|
+
* @returns {boolean}
|
|
998
|
+
*/
|
|
999
|
+
shouldSkipEfdRetry (testSuite, testName, efdRetryIndex) {
|
|
1000
|
+
const testSuiteRetries = this.efdRetryCountByTest[testSuite]
|
|
1001
|
+
return testSuiteRetries?.[testName] !== undefined && efdRetryIndex > testSuiteRetries[testName]
|
|
1002
|
+
}
|
|
1003
|
+
|
|
444
1004
|
getTestSuiteSpan ({ testSuite, testSuiteAbsolutePath }) {
|
|
445
|
-
const testSuiteSpanMetadata =
|
|
446
|
-
getTestSuiteCommonTags(this.command, this.frameworkVersion, testSuite, TEST_FRAMEWORK_NAME)
|
|
1005
|
+
const testSuiteSpanMetadata = {
|
|
1006
|
+
...getTestSuiteCommonTags(this.command, this.frameworkVersion, testSuite, TEST_FRAMEWORK_NAME),
|
|
1007
|
+
...this.getSessionRequestErrorTags(),
|
|
1008
|
+
...this.getSessionItrSkippingEnabledTags(),
|
|
1009
|
+
}
|
|
447
1010
|
|
|
448
1011
|
this.ciVisEvent(TELEMETRY_EVENT_CREATED, 'suite')
|
|
449
1012
|
|
|
450
1013
|
if (testSuiteAbsolutePath) {
|
|
451
|
-
const
|
|
452
|
-
const resolvedSuiteAbsolutePath = resolvedSuitePosition ? resolvedSuitePosition.sourceFile : testSuiteAbsolutePath
|
|
1014
|
+
const resolvedSuiteAbsolutePath = resolveOriginalSourceFile(testSuiteAbsolutePath) || testSuiteAbsolutePath
|
|
453
1015
|
const testSourceFile = getTestSuitePath(resolvedSuiteAbsolutePath, this.repositoryRoot)
|
|
454
1016
|
testSuiteSpanMetadata[TEST_SOURCE_FILE] = testSourceFile
|
|
455
1017
|
testSuiteSpanMetadata[TEST_SOURCE_START] = 1
|
|
@@ -472,7 +1034,6 @@ class CypressPlugin {
|
|
|
472
1034
|
|
|
473
1035
|
getTestSpan ({ testName, testSuite, isUnskippable, isForcedToRun, testSourceFile, isDisabled, isQuarantined }) {
|
|
474
1036
|
const testSuiteTags = {
|
|
475
|
-
[TEST_COMMAND]: this.command,
|
|
476
1037
|
[TEST_MODULE]: TEST_FRAMEWORK_NAME,
|
|
477
1038
|
}
|
|
478
1039
|
if (this.testSuiteSpan) {
|
|
@@ -497,6 +1058,7 @@ class CypressPlugin {
|
|
|
497
1058
|
if (testSourceFile) {
|
|
498
1059
|
testSpanMetadata[TEST_SOURCE_FILE] = testSourceFile
|
|
499
1060
|
}
|
|
1061
|
+
Object.assign(testSpanMetadata, this.getSessionItrSkippingEnabledTags())
|
|
500
1062
|
|
|
501
1063
|
const codeOwners = this.getTestCodeOwners({ testSuite, testSourceFile })
|
|
502
1064
|
if (codeOwners) {
|
|
@@ -546,6 +1108,15 @@ class CypressPlugin {
|
|
|
546
1108
|
return getSessionRequestErrorTags(this.testSessionSpan)
|
|
547
1109
|
}
|
|
548
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns ITR skipping-enabled tags from the test session span for propagation to child events.
|
|
1113
|
+
*
|
|
1114
|
+
* @returns {Record<string, string>}
|
|
1115
|
+
*/
|
|
1116
|
+
getSessionItrSkippingEnabledTags () {
|
|
1117
|
+
return getSessionItrSkippingEnabledTags(this.testSessionSpan)
|
|
1118
|
+
}
|
|
1119
|
+
|
|
549
1120
|
ciVisEvent (name, testLevel, tags = {}) {
|
|
550
1121
|
incrementCountMetric(name, {
|
|
551
1122
|
testLevel,
|
|
@@ -564,18 +1135,32 @@ class CypressPlugin {
|
|
|
564
1135
|
this.frameworkVersion = getCypressVersion(details)
|
|
565
1136
|
this.rootDir = getRootDir(details)
|
|
566
1137
|
|
|
1138
|
+
const {
|
|
1139
|
+
knownTestsResponse,
|
|
1140
|
+
testManagementTestsResponse,
|
|
1141
|
+
skippableSuitesResponse: skippableTestsRequestResponse,
|
|
1142
|
+
} = await getTestOptimizationRequestResults({
|
|
1143
|
+
isKnownTestsEnabled: this.isKnownTestsEnabled,
|
|
1144
|
+
isTestManagementTestsEnabled: this.isTestManagementTestsEnabled,
|
|
1145
|
+
isSuitesSkippingEnabled: this.isSuitesSkippingEnabled,
|
|
1146
|
+
getKnownTests: () => getKnownTests(this.tracer, this.testConfiguration),
|
|
1147
|
+
getTestManagementTests: () => getTestManagementTests(this.tracer, this.testConfiguration),
|
|
1148
|
+
getSkippableSuites: () => getSkippableTests(this.tracer, {
|
|
1149
|
+
...this.testConfiguration,
|
|
1150
|
+
isCoverageReportUploadEnabled: this.isCoverageReportUploadEnabled,
|
|
1151
|
+
}),
|
|
1152
|
+
})
|
|
1153
|
+
|
|
567
1154
|
if (this.isKnownTestsEnabled) {
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (knownTestsResponse.err) {
|
|
573
|
-
log.error('Cypress known tests response error', knownTestsResponse.err)
|
|
1155
|
+
const currentKnownTestsResponse = knownTestsResponse || await getKnownTests(this.tracer, this.testConfiguration)
|
|
1156
|
+
if (currentKnownTestsResponse.err) {
|
|
1157
|
+
log.error('Cypress known tests response error', currentKnownTestsResponse.err)
|
|
1158
|
+
this._pendingRequestErrorTags.push({ tag: DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS, value: 'true' })
|
|
574
1159
|
this.isEarlyFlakeDetectionEnabled = false
|
|
575
1160
|
this.isKnownTestsEnabled = false
|
|
576
1161
|
} else {
|
|
577
|
-
if (
|
|
578
|
-
this.knownTestsByTestSuite =
|
|
1162
|
+
if (currentKnownTestsResponse.knownTests?.[TEST_FRAMEWORK_NAME]) {
|
|
1163
|
+
this.knownTestsByTestSuite = currentKnownTestsResponse.knownTests[TEST_FRAMEWORK_NAME]
|
|
579
1164
|
} else {
|
|
580
1165
|
this.isEarlyFlakeDetectionEnabled = false
|
|
581
1166
|
this.isKnownTestsEnabled = false
|
|
@@ -583,31 +1168,51 @@ class CypressPlugin {
|
|
|
583
1168
|
}
|
|
584
1169
|
}
|
|
585
1170
|
|
|
586
|
-
if (this.
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
1171
|
+
if (this.isKnownTestsEnabled && details.specs) {
|
|
1172
|
+
const testSuites = details.specs.map(({ relative }) => relative)
|
|
1173
|
+
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
1174
|
+
testSuites,
|
|
1175
|
+
this.knownTestsByTestSuite,
|
|
1176
|
+
this.earlyFlakeDetectionFaultyThreshold
|
|
590
1177
|
)
|
|
1178
|
+
if (isFaulty) {
|
|
1179
|
+
log.warn('New test detection is disabled because the number of new test files is too high.')
|
|
1180
|
+
this.isEarlyFlakeDetectionEnabled = false
|
|
1181
|
+
this.isEarlyFlakeDetectionFaulty = true
|
|
1182
|
+
this.isKnownTestsEnabled = false
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
if (this.isSuitesSkippingEnabled) {
|
|
1187
|
+
const skippableTestsResponse =
|
|
1188
|
+
skippableTestsRequestResponse || await getSkippableTests(this.tracer, {
|
|
1189
|
+
...this.testConfiguration,
|
|
1190
|
+
isCoverageReportUploadEnabled: this.isCoverageReportUploadEnabled,
|
|
1191
|
+
})
|
|
591
1192
|
if (skippableTestsResponse.err) {
|
|
592
1193
|
log.error('Cypress skippable tests response error', skippableTestsResponse.err)
|
|
1194
|
+
this._pendingRequestErrorTags.push({ tag: DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS, value: 'true' })
|
|
593
1195
|
} else {
|
|
594
|
-
const { skippableTests, correlationId } = skippableTestsResponse
|
|
1196
|
+
const { skippableTests, correlationId, skippableTestsCoverage } = skippableTestsResponse
|
|
595
1197
|
this.testsToSkip = skippableTests || []
|
|
1198
|
+
this.skippableTestsCoverage = skippableTestsCoverage || {}
|
|
596
1199
|
this.itrCorrelationId = correlationId
|
|
597
1200
|
incrementCountMetric(TELEMETRY_ITR_SKIPPED, { testLevel: 'test' }, this.testsToSkip.length)
|
|
598
1201
|
}
|
|
599
1202
|
}
|
|
600
1203
|
|
|
601
1204
|
if (this.isTestManagementTestsEnabled) {
|
|
602
|
-
const
|
|
603
|
-
this.tracer,
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
1205
|
+
const currentTestManagementTestsResponse =
|
|
1206
|
+
testManagementTestsResponse || await getTestManagementTests(this.tracer, this.testConfiguration)
|
|
1207
|
+
if (currentTestManagementTestsResponse.err) {
|
|
1208
|
+
log.error('Cypress test management tests response error', currentTestManagementTestsResponse.err)
|
|
1209
|
+
this._pendingRequestErrorTags.push({
|
|
1210
|
+
tag: DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS,
|
|
1211
|
+
value: 'true',
|
|
1212
|
+
})
|
|
608
1213
|
this.isTestManagementTestsEnabled = false
|
|
609
1214
|
} else {
|
|
610
|
-
this.testManagementTests =
|
|
1215
|
+
this.testManagementTests = currentTestManagementTestsResponse.testManagementTests
|
|
611
1216
|
}
|
|
612
1217
|
}
|
|
613
1218
|
|
|
@@ -640,6 +1245,9 @@ class CypressPlugin {
|
|
|
640
1245
|
if (this.isEarlyFlakeDetectionEnabled) {
|
|
641
1246
|
testSessionSpanMetadata[TEST_EARLY_FLAKE_ENABLED] = 'true'
|
|
642
1247
|
}
|
|
1248
|
+
if (this.isEarlyFlakeDetectionFaulty) {
|
|
1249
|
+
testSessionSpanMetadata[TEST_EARLY_FLAKE_ABORT_REASON] = 'faulty'
|
|
1250
|
+
}
|
|
643
1251
|
|
|
644
1252
|
const trimmedCommand = DD_MAJOR < 6 ? this.command : 'cypress run'
|
|
645
1253
|
|
|
@@ -650,21 +1258,28 @@ class CypressPlugin {
|
|
|
650
1258
|
)
|
|
651
1259
|
|
|
652
1260
|
if (this.tracer._tracer._exporter?.addMetadataTags) {
|
|
653
|
-
const metadataTags = {
|
|
654
|
-
|
|
655
|
-
|
|
1261
|
+
const metadataTags = {
|
|
1262
|
+
[TEST_LEVELS_METADATA]: {
|
|
1263
|
+
[TEST_COMMAND]: this.command,
|
|
656
1264
|
[TEST_SESSION_NAME]: testSessionName,
|
|
657
|
-
|
|
1265
|
+
...getTestLevelsMetadataTags(this.testEnvironmentMetadata),
|
|
1266
|
+
},
|
|
658
1267
|
}
|
|
659
1268
|
const libraryCapabilitiesTags = getLibraryCapabilitiesTags(this.constructor.id, this.frameworkVersion)
|
|
660
1269
|
metadataTags.test = {
|
|
661
|
-
...metadataTags.test,
|
|
662
1270
|
...libraryCapabilitiesTags,
|
|
663
1271
|
}
|
|
664
1272
|
|
|
665
1273
|
this.tracer._tracer._exporter.addMetadataTags(metadataTags)
|
|
666
1274
|
}
|
|
667
1275
|
|
|
1276
|
+
// Capture time references that match what startSpan records internally
|
|
1277
|
+
// (trace.startTime = Date.now(), trace.ticks = performance.now()).
|
|
1278
|
+
// This lets _now() produce values in the same coordinate system as
|
|
1279
|
+
// span._startTime without accessing span internals.
|
|
1280
|
+
this._timeOrigin = dateNow()
|
|
1281
|
+
this._perfOrigin = performance.now()
|
|
1282
|
+
|
|
668
1283
|
this.testSessionSpan = this.tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_session`, {
|
|
669
1284
|
childOf,
|
|
670
1285
|
tags: {
|
|
@@ -691,6 +1306,11 @@ class CypressPlugin {
|
|
|
691
1306
|
},
|
|
692
1307
|
integrationName: TEST_FRAMEWORK_NAME,
|
|
693
1308
|
})
|
|
1309
|
+
if (this.hasLibraryConfiguration) {
|
|
1310
|
+
const skippingEnabled = this.isSuitesSkippingEnabled ? 'true' : 'false'
|
|
1311
|
+
this.testSessionSpan.setTag(TEST_ITR_SKIPPING_ENABLED, skippingEnabled)
|
|
1312
|
+
this.testModuleSpan.setTag(TEST_ITR_SKIPPING_ENABLED, skippingEnabled)
|
|
1313
|
+
}
|
|
694
1314
|
this.ciVisEvent(TELEMETRY_EVENT_CREATED, 'module')
|
|
695
1315
|
|
|
696
1316
|
return details
|
|
@@ -703,6 +1323,9 @@ class CypressPlugin {
|
|
|
703
1323
|
}
|
|
704
1324
|
if (this.testSessionSpan && this.testModuleSpan) {
|
|
705
1325
|
const testStatus = getSessionStatus(suiteStats)
|
|
1326
|
+
const hasBackfilledCoverage = this.applySkippedCoverageToTestSessionCoverage()
|
|
1327
|
+
const testCodeCoverageLinesTotal = this.getTestCodeCoverageLinesTotal(hasBackfilledCoverage)
|
|
1328
|
+
|
|
706
1329
|
this.testModuleSpan.setTag(TEST_STATUS, testStatus)
|
|
707
1330
|
this.testSessionSpan.setTag(TEST_STATUS, testStatus)
|
|
708
1331
|
|
|
@@ -713,6 +1336,7 @@ class CypressPlugin {
|
|
|
713
1336
|
isSuitesSkipped: this.isTestsSkipped,
|
|
714
1337
|
isSuitesSkippingEnabled: this.isSuitesSkippingEnabled,
|
|
715
1338
|
isCodeCoverageEnabled: this.isCodeCoverageEnabled,
|
|
1339
|
+
testCodeCoverageLinesTotal,
|
|
716
1340
|
skippingType: 'test',
|
|
717
1341
|
skippingCount: this.skippedTests.length,
|
|
718
1342
|
hasForcedToRunSuites: this.hasForcedToRunSuites,
|
|
@@ -720,11 +1344,16 @@ class CypressPlugin {
|
|
|
720
1344
|
}
|
|
721
1345
|
)
|
|
722
1346
|
|
|
1347
|
+
this.reportTestSessionCoverage()
|
|
1348
|
+
|
|
723
1349
|
if (this.isTestManagementTestsEnabled) {
|
|
724
1350
|
this.testSessionSpan.setTag(TEST_MANAGEMENT_ENABLED, 'true')
|
|
725
1351
|
}
|
|
726
1352
|
|
|
727
|
-
|
|
1353
|
+
logTestOptimizationSummary({
|
|
1354
|
+
attemptToFixExecutions: this.attemptToFixExecutions,
|
|
1355
|
+
newTestsWithDynamicNames: this.newTestsWithDynamicNames,
|
|
1356
|
+
})
|
|
728
1357
|
|
|
729
1358
|
this.testModuleSpan.finish()
|
|
730
1359
|
this.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'module')
|
|
@@ -732,7 +1361,7 @@ class CypressPlugin {
|
|
|
732
1361
|
this.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'session')
|
|
733
1362
|
incrementCountMetric(TELEMETRY_TEST_SESSION, {
|
|
734
1363
|
provider: this.ciProviderName,
|
|
735
|
-
autoInjected: !!
|
|
1364
|
+
autoInjected: !!getConfig().testOptimization.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
|
|
736
1365
|
})
|
|
737
1366
|
|
|
738
1367
|
finishAllTraceSpans(this.testSessionSpan)
|
|
@@ -764,10 +1393,42 @@ class CypressPlugin {
|
|
|
764
1393
|
})
|
|
765
1394
|
}
|
|
766
1395
|
|
|
1396
|
+
/**
|
|
1397
|
+
* Uploads failure screenshots as soon as Cypress creates them.
|
|
1398
|
+
*
|
|
1399
|
+
* @param {object} details - Cypress screenshot details
|
|
1400
|
+
* @returns {void}
|
|
1401
|
+
*/
|
|
1402
|
+
afterScreenshot (details) {
|
|
1403
|
+
const lastFailedTestSpan = this.lastFinishedTest?.testStatus === 'fail'
|
|
1404
|
+
? this.lastFinishedTest.testSpan
|
|
1405
|
+
: undefined
|
|
1406
|
+
const testSpan = this.activeTestSpan || lastFailedTestSpan
|
|
1407
|
+
|
|
1408
|
+
if (!testSpan) {
|
|
1409
|
+
return
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
if (!isFailureScreenshotForUpload(details)) {
|
|
1413
|
+
return
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
const screenshotUploadPromise = this.uploadTestScreenshots({
|
|
1417
|
+
screenshots: [details],
|
|
1418
|
+
traceId: testSpan.context().toTraceId(),
|
|
1419
|
+
})
|
|
1420
|
+
if (screenshotUploadPromise) {
|
|
1421
|
+
this.pendingScreenshotUploads.push(screenshotUploadPromise)
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
|
|
767
1425
|
afterSpec (spec, results) {
|
|
768
|
-
const { tests, stats } = results || {}
|
|
1426
|
+
const { tests, stats, screenshots } = results || {}
|
|
769
1427
|
const cypressTests = tests || []
|
|
1428
|
+
const specScreenshots = screenshots || []
|
|
770
1429
|
const finishedTests = this.finishedTestsByFile[spec.relative] || []
|
|
1430
|
+
const screenshotUploadPromises = []
|
|
1431
|
+
const testSpanFinishPromises = []
|
|
771
1432
|
|
|
772
1433
|
if (!this.testSuiteSpan) {
|
|
773
1434
|
// dd:testSuiteStart hasn't been triggered for whatever reason
|
|
@@ -797,6 +1458,7 @@ class CypressPlugin {
|
|
|
797
1458
|
: spec.relative
|
|
798
1459
|
|
|
799
1460
|
const skippedTestSpan = this.getTestSpan({ testName: cypressTestName, testSuite: spec.relative, testSourceFile })
|
|
1461
|
+
skippedTestSpan.setTag(TEST_FINAL_STATUS, 'skip')
|
|
800
1462
|
|
|
801
1463
|
skippedTestSpan.setTag(TEST_STATUS, 'skip')
|
|
802
1464
|
if (isSkippedByItr) {
|
|
@@ -832,17 +1494,25 @@ class CypressPlugin {
|
|
|
832
1494
|
|
|
833
1495
|
for (const [testName, finishedTestAttempts] of Object.entries(finishedTestsByTestName)) {
|
|
834
1496
|
for (const [attemptIndex, finishedTest] of finishedTestAttempts.entries()) {
|
|
835
|
-
//
|
|
836
|
-
|
|
837
|
-
const
|
|
1497
|
+
// We can check if this is the last attempt regardless of the retry mechanism
|
|
1498
|
+
const isLastAttempt = attemptIndex === finishedTestAttempts.length - 1
|
|
1499
|
+
const isDatadogManagedAttempt = finishedTest.isEfdManagedTest || finishedTest.isAttemptToFix
|
|
1500
|
+
const cypressTest = isDatadogManagedAttempt
|
|
1501
|
+
? getMatchingCypressTest(cypressTests, testName, attemptIndex, finishedTest.testStatus, isLastAttempt) ||
|
|
1502
|
+
cypressTests.find(test => test.title.join(' ') === testName)
|
|
1503
|
+
: cypressTests.find(test => test.title.join(' ') === testName)
|
|
838
1504
|
if (!cypressTest) {
|
|
839
1505
|
continue
|
|
840
1506
|
}
|
|
841
1507
|
// finishedTests can include multiple tests with the same name if they have been retried
|
|
842
1508
|
// by early flake detection. Cypress is unaware of this so .attempts does not necessarily have
|
|
843
1509
|
// the same length as `finishedTestAttempts`
|
|
844
|
-
|
|
845
|
-
|
|
1510
|
+
const shouldUseCapturedStatus = isDatadogManagedAttempt && !(isLastAttempt && isCypressHookFailure(cypressTest))
|
|
1511
|
+
let cypressTestStatus = shouldUseCapturedStatus
|
|
1512
|
+
? finishedTest.testStatus
|
|
1513
|
+
: CYPRESS_STATUS_TO_TEST_STATUS[cypressTest.state]
|
|
1514
|
+
if (!finishedTest.isEfdManagedTest && !finishedTest.isAttemptToFix &&
|
|
1515
|
+
cypressTest.attempts && cypressTest.attempts[attemptIndex]) {
|
|
846
1516
|
cypressTestStatus = CYPRESS_STATUS_TO_TEST_STATUS[cypressTest.attempts[attemptIndex].state]
|
|
847
1517
|
const isAtrRetry = attemptIndex > 0 &&
|
|
848
1518
|
this.isFlakyTestRetriesEnabled &&
|
|
@@ -859,21 +1529,42 @@ class CypressPlugin {
|
|
|
859
1529
|
}
|
|
860
1530
|
}
|
|
861
1531
|
}
|
|
1532
|
+
if (finishedTest.isEfdManagedTest && finishedTest.testStatus !== 'skip' && cypressTestStatus === 'skip') {
|
|
1533
|
+
cypressTestStatus = finishedTest.testStatus
|
|
1534
|
+
}
|
|
862
1535
|
if (cypressTest.displayError) {
|
|
863
1536
|
latestError = new Error(cypressTest.displayError)
|
|
864
1537
|
}
|
|
865
|
-
|
|
1538
|
+
|
|
1539
|
+
let failedTestTraceId
|
|
1540
|
+
if (cypressTestStatus === 'fail' || finishedTest.testStatus === 'fail' || cypressTest.displayError) {
|
|
1541
|
+
failedTestTraceId = finishedTest.testSpan.context().toTraceId()
|
|
1542
|
+
const testScreenshots = getTestScreenshots(cypressTest, attemptIndex, specScreenshots)
|
|
1543
|
+
const screenshotUploadPromise = this.uploadTestScreenshots({
|
|
1544
|
+
screenshots: testScreenshots,
|
|
1545
|
+
traceId: failedTestTraceId,
|
|
1546
|
+
})
|
|
1547
|
+
if (screenshotUploadPromise) {
|
|
1548
|
+
screenshotUploadPromises.push(screenshotUploadPromise)
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// Update test status - but NOT for non-ATF quarantined tests where we intentionally
|
|
866
1553
|
// report 'fail' to Datadog even though Cypress sees it as 'pass'
|
|
867
|
-
const isQuarantinedTest = finishedTest.testSpan?.context()?.
|
|
868
|
-
if (cypressTestStatus !== finishedTest.testStatus && !isQuarantinedTest) {
|
|
1554
|
+
const isQuarantinedTest = finishedTest.testSpan?.context()?.getTag(TEST_MANAGEMENT_IS_QUARANTINED) === 'true'
|
|
1555
|
+
if (cypressTestStatus !== finishedTest.testStatus && (!isQuarantinedTest || finishedTest.isAttemptToFix)) {
|
|
869
1556
|
finishedTest.testSpan.setTag(TEST_STATUS, cypressTestStatus)
|
|
870
1557
|
finishedTest.testSpan.setTag('error', latestError)
|
|
1558
|
+
if (finishedTest.isAttemptToFix && cypressTestStatus === 'fail') {
|
|
1559
|
+
finishedTest.testSpan.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'false')
|
|
1560
|
+
}
|
|
871
1561
|
}
|
|
872
1562
|
if (this.itrCorrelationId) {
|
|
873
1563
|
finishedTest.testSpan.setTag(ITR_CORRELATION_ID, this.itrCorrelationId)
|
|
874
1564
|
}
|
|
875
|
-
const
|
|
876
|
-
|
|
1565
|
+
const resolvedSpecAbsolutePath = spec.absolute
|
|
1566
|
+
? resolveOriginalSourceFile(spec.absolute) || spec.absolute
|
|
1567
|
+
: spec.absolute
|
|
877
1568
|
const testSourceFile = resolvedSpecAbsolutePath && this.repositoryRoot
|
|
878
1569
|
? getTestSuitePath(resolvedSpecAbsolutePath, this.repositoryRoot)
|
|
879
1570
|
: spec.relative
|
|
@@ -886,20 +1577,130 @@ class CypressPlugin {
|
|
|
886
1577
|
finishedTest.testSpan.setTag(TEST_CODE_OWNERS, codeOwners)
|
|
887
1578
|
}
|
|
888
1579
|
|
|
889
|
-
|
|
1580
|
+
if (isLastAttempt) {
|
|
1581
|
+
const testSpanTags = finishedTest.testSpan.context().getTags()
|
|
1582
|
+
const retryKind = getFinalStatusRetryKind({
|
|
1583
|
+
finishedTest,
|
|
1584
|
+
finishedTestAttempts,
|
|
1585
|
+
flakyTestRetriesCount: this.flakyTestRetriesCount,
|
|
1586
|
+
})
|
|
1587
|
+
|
|
1588
|
+
const hasFailedAllRetries = testSpanTags[TEST_HAS_FAILED_ALL_RETRIES] === 'true'
|
|
1589
|
+
const hasPassedAllAtfRetries =
|
|
1590
|
+
testSpanTags[TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED] === 'true'
|
|
1591
|
+
const isQuarantined = testSpanTags[TEST_MANAGEMENT_IS_QUARANTINED] === 'true'
|
|
1592
|
+
const isDisabled = testSpanTags[TEST_MANAGEMENT_IS_DISABLED] === 'true'
|
|
1593
|
+
|
|
1594
|
+
const finalStatus = getFinalStatus({
|
|
1595
|
+
status: cypressTestStatus,
|
|
1596
|
+
retryKind,
|
|
1597
|
+
hasFailedAllRetries,
|
|
1598
|
+
hasPassedAllAtfRetries,
|
|
1599
|
+
isQuarantined,
|
|
1600
|
+
isDisabled,
|
|
1601
|
+
})
|
|
1602
|
+
|
|
1603
|
+
if (finalStatus) {
|
|
1604
|
+
finishedTest.testSpan.setTag(TEST_FINAL_STATUS, finalStatus)
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
const screenshotUploadResultPromise = failedTestTraceId
|
|
1609
|
+
? this.getScreenshotUploadResultPromise(failedTestTraceId)
|
|
1610
|
+
: undefined
|
|
1611
|
+
if (screenshotUploadResultPromise) {
|
|
1612
|
+
testSpanFinishPromises.push(screenshotUploadResultPromise.then((uploadResult) => {
|
|
1613
|
+
setScreenshotUploadTags(finishedTest.testSpan, uploadResult)
|
|
1614
|
+
this.screenshotUploadPromisesByTraceId.delete(failedTestTraceId)
|
|
1615
|
+
finishedTest.testSpan.finish(finishedTest.finishTime)
|
|
1616
|
+
}))
|
|
1617
|
+
} else {
|
|
1618
|
+
finishedTest.testSpan.finish(finishedTest.finishTime)
|
|
1619
|
+
}
|
|
890
1620
|
}
|
|
891
1621
|
}
|
|
892
1622
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1623
|
+
const finishSuite = () => {
|
|
1624
|
+
if (this.testSuiteSpan) {
|
|
1625
|
+
const status = getSuiteStatus(stats)
|
|
1626
|
+
this.testSuiteSpan.setTag(TEST_STATUS, status)
|
|
1627
|
+
|
|
1628
|
+
if (latestError) {
|
|
1629
|
+
this.testSuiteSpan.setTag('error', latestError)
|
|
1630
|
+
}
|
|
1631
|
+
this.testSuiteSpan.finish()
|
|
1632
|
+
this.testSuiteSpan = null
|
|
1633
|
+
this.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'suite')
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
const waitForScreenshotUploads = () => {
|
|
1638
|
+
if (screenshotUploadPromises.length > 0 || this.pendingScreenshotUploads.length > 0) {
|
|
1639
|
+
const pendingScreenshotUploads = this.pendingScreenshotUploads
|
|
1640
|
+
this.pendingScreenshotUploads = []
|
|
1641
|
+
return Promise.all([...pendingScreenshotUploads, ...screenshotUploadPromises]).then(() => null)
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
finishSuite()
|
|
896
1646
|
|
|
897
|
-
|
|
898
|
-
|
|
1647
|
+
const screenshotUploadsPromise = waitForScreenshotUploads()
|
|
1648
|
+
if (testSpanFinishPromises.length > 0) {
|
|
1649
|
+
const testSpansPromise = Promise.all(testSpanFinishPromises).then(() => null)
|
|
1650
|
+
if (screenshotUploadsPromise) {
|
|
1651
|
+
return Promise.all([testSpansPromise, screenshotUploadsPromise]).then(() => null)
|
|
899
1652
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1653
|
+
return testSpansPromise
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
return screenshotUploadsPromise
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Uploads failure screenshots for a Cypress test attempt.
|
|
1661
|
+
*
|
|
1662
|
+
* @param {object} options - Upload options
|
|
1663
|
+
* @param {Array<object|string>} options.screenshots - Cypress screenshot objects or screenshot paths
|
|
1664
|
+
* @param {string} options.traceId - Test trace id used as the screenshot key
|
|
1665
|
+
* @returns {Promise<string|undefined>|undefined}
|
|
1666
|
+
*/
|
|
1667
|
+
uploadTestScreenshots ({ screenshots, traceId }) {
|
|
1668
|
+
const exporter = this.tracer?._tracer?._exporter
|
|
1669
|
+
if (!screenshots.length ||
|
|
1670
|
+
!exporter?.canUploadTestScreenshots?.() ||
|
|
1671
|
+
!exporter.uploadTestScreenshot) {
|
|
1672
|
+
return
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
const uploadPromises = []
|
|
1676
|
+
|
|
1677
|
+
for (const screenshot of screenshots) {
|
|
1678
|
+
const filePath = getScreenshotFilePath(screenshot)
|
|
1679
|
+
if (!filePath || this.uploadedScreenshotPaths.has(filePath)) {
|
|
1680
|
+
continue
|
|
1681
|
+
}
|
|
1682
|
+
this.uploadedScreenshotPaths.add(filePath)
|
|
1683
|
+
// Stable per-artifact key (trace + filename) so an upload retry overwrites the
|
|
1684
|
+
// same stored object instead of duplicating; the Cypress filename encodes the
|
|
1685
|
+
// test name and attempt, so it is unique within the trace.
|
|
1686
|
+
const idempotencyKey = `${traceId}:${basename(filePath)}`
|
|
1687
|
+
const capturedAtMs = getScreenshotCapturedAtMs(screenshot, filePath)
|
|
1688
|
+
uploadPromises.push(new Promise(resolve => {
|
|
1689
|
+
exporter.uploadTestScreenshot({
|
|
1690
|
+
filePath,
|
|
1691
|
+
traceId,
|
|
1692
|
+
idempotencyKey,
|
|
1693
|
+
capturedAtMs,
|
|
1694
|
+
}, (err) => {
|
|
1695
|
+
resolve(err ? SCREENSHOT_UPLOAD_RESULT_ERROR : SCREENSHOT_UPLOAD_RESULT_UPLOADED)
|
|
1696
|
+
})
|
|
1697
|
+
}))
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
if (uploadPromises.length > 0) {
|
|
1701
|
+
const uploadPromise = Promise.all(uploadPromises).then(getScreenshotUploadResult)
|
|
1702
|
+
this.addScreenshotUploadPromise(traceId, uploadPromise)
|
|
1703
|
+
return uploadPromise
|
|
903
1704
|
}
|
|
904
1705
|
}
|
|
905
1706
|
|
|
@@ -909,7 +1710,8 @@ class CypressPlugin {
|
|
|
909
1710
|
const suitePayload = {
|
|
910
1711
|
isEarlyFlakeDetectionEnabled: this.isEarlyFlakeDetectionEnabled,
|
|
911
1712
|
knownTestsForSuite: this.knownTestsByTestSuite?.[testSuite] || [],
|
|
912
|
-
earlyFlakeDetectionNumRetries: this.
|
|
1713
|
+
earlyFlakeDetectionNumRetries: this.getConfiguredEfdRetryCount(),
|
|
1714
|
+
earlyFlakeDetectionSlowTestRetries: this.earlyFlakeDetectionSlowTestRetries,
|
|
913
1715
|
isKnownTestsEnabled: this.isKnownTestsEnabled,
|
|
914
1716
|
isTestManagementEnabled: this.isTestManagementTestsEnabled,
|
|
915
1717
|
testManagementAttemptToFixRetries: this.testManagementAttemptToFixRetries,
|
|
@@ -921,14 +1723,14 @@ class CypressPlugin {
|
|
|
921
1723
|
rumFlushWaitMillis: this.rumFlushWaitMillis,
|
|
922
1724
|
}
|
|
923
1725
|
|
|
924
|
-
|
|
925
|
-
return suitePayload
|
|
926
|
-
}
|
|
927
|
-
this.testSuiteSpan = this.getTestSuiteSpan({ testSuite, testSuiteAbsolutePath })
|
|
1726
|
+
this.testSuiteSpan ||= this.getTestSuiteSpan({ testSuite, testSuiteAbsolutePath })
|
|
928
1727
|
return suitePayload
|
|
929
1728
|
},
|
|
930
1729
|
'dd:beforeEach': (test) => {
|
|
931
|
-
const { testName, testSuite } = test
|
|
1730
|
+
const { testId, testName, testSuite, isEfdRetry, efdRetryIndex } = test
|
|
1731
|
+
if (isEfdRetry && this.shouldSkipEfdRetry(testSuite, testName, efdRetryIndex)) {
|
|
1732
|
+
return { shouldSkip: true, shouldDiscard: true }
|
|
1733
|
+
}
|
|
932
1734
|
const shouldSkip = this.testsToSkip.some(test => {
|
|
933
1735
|
return testName === test.name && testSuite === test.suite
|
|
934
1736
|
})
|
|
@@ -937,11 +1739,19 @@ class CypressPlugin {
|
|
|
937
1739
|
const { isAttemptToFix, isDisabled, isQuarantined } = this.getTestProperties(testSuite, testName)
|
|
938
1740
|
// skip test
|
|
939
1741
|
if (shouldSkip && !isUnskippable) {
|
|
940
|
-
|
|
1742
|
+
const skippedTestId = `${testSuite}:${testId || testName}`
|
|
1743
|
+
if (!this.skippedTestIds.has(skippedTestId)) {
|
|
1744
|
+
this.skippedTestIds.add(skippedTestId)
|
|
1745
|
+
this.skippedTests.push(test)
|
|
1746
|
+
}
|
|
941
1747
|
this.isTestsSkipped = true
|
|
942
1748
|
return { shouldSkip: true }
|
|
943
1749
|
}
|
|
944
1750
|
|
|
1751
|
+
if (isAttemptToFix) {
|
|
1752
|
+
logAttemptToFixTestExecution(testSuite, testName, this.loggedAttemptToFixTests)
|
|
1753
|
+
}
|
|
1754
|
+
|
|
945
1755
|
// For disabled tests (not attemptToFix), skip them
|
|
946
1756
|
if (!isAttemptToFix && isDisabled) {
|
|
947
1757
|
return { shouldSkip: true }
|
|
@@ -962,7 +1772,7 @@ class CypressPlugin {
|
|
|
962
1772
|
|
|
963
1773
|
return this.activeTestSpan ? { traceId: this.activeTestSpan.context().toTraceId() } : {}
|
|
964
1774
|
},
|
|
965
|
-
'dd:afterEach': ({ test, coverage }) => {
|
|
1775
|
+
'dd:afterEach': ({ test, coverage, commands }) => {
|
|
966
1776
|
if (!this.activeTestSpan) {
|
|
967
1777
|
log.warn('There is no active test span in dd:afterEach handler')
|
|
968
1778
|
return null
|
|
@@ -981,13 +1791,22 @@ class CypressPlugin {
|
|
|
981
1791
|
isEfdRetry,
|
|
982
1792
|
isAttemptToFix,
|
|
983
1793
|
isModified,
|
|
1794
|
+
duration,
|
|
984
1795
|
isQuarantined: isQuarantinedFromSupport,
|
|
1796
|
+
isDisabled: isDisabledFromSupport,
|
|
985
1797
|
} = test
|
|
1798
|
+
if (coverage && (this.isCodeCoverageEnabled || this.isCoverageReportUploadEnabled)) {
|
|
1799
|
+
this.addTestSessionCoverage(coverage)
|
|
1800
|
+
}
|
|
1801
|
+
|
|
986
1802
|
if (coverage && this.isCodeCoverageEnabled && this.tracer._tracer._exporter?.exportCoverage) {
|
|
987
|
-
const coverageFiles =
|
|
988
|
-
const relativeCoverageFiles =
|
|
989
|
-
|
|
990
|
-
|
|
1803
|
+
const coverageFiles = getCoveredFilesFromCoverage(coverage)
|
|
1804
|
+
const relativeCoverageFiles = getRelativeCoverageFiles(coverageFiles, this.getCoverageRootDir())
|
|
1805
|
+
if (testSuiteAbsolutePath) {
|
|
1806
|
+
relativeCoverageFiles.push({
|
|
1807
|
+
filename: getTestSuitePath(testSuiteAbsolutePath, this.getCoverageRootDir()),
|
|
1808
|
+
})
|
|
1809
|
+
}
|
|
991
1810
|
if (!relativeCoverageFiles.length) {
|
|
992
1811
|
incrementCountMetric(TELEMETRY_CODE_COVERAGE_EMPTY)
|
|
993
1812
|
}
|
|
@@ -1001,16 +1820,29 @@ class CypressPlugin {
|
|
|
1001
1820
|
}
|
|
1002
1821
|
this.tracer._tracer._exporter.exportCoverage(formattedCoverage)
|
|
1003
1822
|
}
|
|
1004
|
-
const
|
|
1823
|
+
const isEfdManagedTest = (isNew || isModified) && this.isEarlyFlakeDetectionEnabled && !isAttemptToFix
|
|
1824
|
+
let testStatus = CYPRESS_STATUS_TO_TEST_STATUS[state]
|
|
1825
|
+
let didAbortSlowEfdRetries = false
|
|
1826
|
+
if (isEfdManagedTest && !isEfdRetry && this.efdRetryCountByTest[testSuite]?.[testName] === undefined) {
|
|
1827
|
+
const retryCount = this.setEfdRetryCountForTest(testSuite, testName, duration)
|
|
1828
|
+
if (retryCount === 0) {
|
|
1829
|
+
didAbortSlowEfdRetries = true
|
|
1830
|
+
this.activeTestSpan.setTag(TEST_EARLY_FLAKE_ABORT_REASON, 'slow')
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
if (didAbortSlowEfdRetries && testStatus === 'skip' && !error && duration > 0) {
|
|
1834
|
+
testStatus = 'pass'
|
|
1835
|
+
}
|
|
1005
1836
|
this.activeTestSpan.setTag(TEST_STATUS, testStatus)
|
|
1006
1837
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1838
|
+
const testIdentifier = `${testSuite}\0${testName}`
|
|
1839
|
+
let testStatuses = this.testStatuses[testIdentifier]
|
|
1840
|
+
if (testStatuses) {
|
|
1841
|
+
testStatuses.push(testStatus)
|
|
1010
1842
|
} else {
|
|
1011
|
-
this.testStatuses[
|
|
1843
|
+
testStatuses = this.testStatuses[testIdentifier] = [testStatus]
|
|
1012
1844
|
}
|
|
1013
|
-
const
|
|
1845
|
+
const activeSpanTags = this.activeTestSpan.context().getTags()
|
|
1014
1846
|
|
|
1015
1847
|
if (error) {
|
|
1016
1848
|
this.activeTestSpan.setTag('error', error)
|
|
@@ -1063,9 +1895,10 @@ class CypressPlugin {
|
|
|
1063
1895
|
}
|
|
1064
1896
|
}
|
|
1065
1897
|
// Check if all EFD retries failed
|
|
1066
|
-
if (
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1898
|
+
if (isEfdManagedTest) {
|
|
1899
|
+
const efdRetryCount = this.getEfdRetryCountForTest(testSuite, testName)
|
|
1900
|
+
const isLastEfdAttempt = testStatuses.length === efdRetryCount + 1
|
|
1901
|
+
if (efdRetryCount > 0 && isLastEfdAttempt && testStatuses.every(status => status === 'fail')) {
|
|
1069
1902
|
this.activeTestSpan.setTag(TEST_HAS_FAILED_ALL_RETRIES, 'true')
|
|
1070
1903
|
}
|
|
1071
1904
|
}
|
|
@@ -1086,6 +1919,13 @@ class CypressPlugin {
|
|
|
1086
1919
|
this.activeTestSpan.setTag(TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, 'true')
|
|
1087
1920
|
}
|
|
1088
1921
|
}
|
|
1922
|
+
recordAttemptToFixExecution(this.attemptToFixExecutions, {
|
|
1923
|
+
testSuite,
|
|
1924
|
+
testName,
|
|
1925
|
+
status: testStatus,
|
|
1926
|
+
isDisabled: activeSpanTags[TEST_MANAGEMENT_IS_DISABLED] === 'true',
|
|
1927
|
+
isQuarantined: activeSpanTags[TEST_MANAGEMENT_IS_QUARANTINED] === 'true',
|
|
1928
|
+
})
|
|
1089
1929
|
}
|
|
1090
1930
|
// ATR: set TEST_HAS_FAILED_ALL_RETRIES when all auto test retries were exhausted and every attempt failed
|
|
1091
1931
|
if (this.isFlakyTestRetriesEnabled && !isAttemptToFix && !isEfdRetry &&
|
|
@@ -1099,13 +1939,42 @@ class CypressPlugin {
|
|
|
1099
1939
|
if (isQuarantinedFromSupport) {
|
|
1100
1940
|
this.activeTestSpan.setTag(TEST_MANAGEMENT_IS_QUARANTINED, 'true')
|
|
1101
1941
|
}
|
|
1942
|
+
if (isDisabledFromSupport) {
|
|
1943
|
+
this.activeTestSpan.setTag(TEST_MANAGEMENT_IS_DISABLED, 'true')
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
if (Array.isArray(commands) && commands.length > 0) {
|
|
1947
|
+
for (const command of commands) {
|
|
1948
|
+
const { startTime, endTime } = command
|
|
1949
|
+
if (typeof startTime !== 'number' || typeof endTime !== 'number' || endTime < startTime) {
|
|
1950
|
+
continue
|
|
1951
|
+
}
|
|
1952
|
+
const stepSpan = this.tracer.startSpan('cypress.step', {
|
|
1953
|
+
childOf: this.activeTestSpan,
|
|
1954
|
+
startTime,
|
|
1955
|
+
tags: {
|
|
1956
|
+
[COMPONENT]: 'cypress',
|
|
1957
|
+
'cypress.command': command.name,
|
|
1958
|
+
[RESOURCE_NAME]: command.name,
|
|
1959
|
+
},
|
|
1960
|
+
})
|
|
1961
|
+
if (command.error) {
|
|
1962
|
+
const errorObj = new Error(command.error.message || String(command.error))
|
|
1963
|
+
if (command.error.name) errorObj.name = command.error.name
|
|
1964
|
+
if (command.error.stack) errorObj.stack = command.error.stack
|
|
1965
|
+
stepSpan.setTag('error', errorObj)
|
|
1966
|
+
}
|
|
1967
|
+
stepSpan.finish(endTime)
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1102
1970
|
|
|
1103
1971
|
const finishedTest = {
|
|
1104
1972
|
testName,
|
|
1105
1973
|
testStatus,
|
|
1106
|
-
finishTime: this.
|
|
1974
|
+
finishTime: this._now(),
|
|
1107
1975
|
testSpan: this.activeTestSpan,
|
|
1108
1976
|
isEfdRetry,
|
|
1977
|
+
isEfdManagedTest,
|
|
1109
1978
|
isAttemptToFix,
|
|
1110
1979
|
}
|
|
1111
1980
|
if (this.finishedTestsByFile[testSuite]) {
|
|
@@ -1113,14 +1982,14 @@ class CypressPlugin {
|
|
|
1113
1982
|
} else {
|
|
1114
1983
|
this.finishedTestsByFile[testSuite] = [finishedTest]
|
|
1115
1984
|
}
|
|
1985
|
+
this.lastFinishedTest = finishedTest
|
|
1116
1986
|
// test spans are finished at after:spec
|
|
1117
|
-
const activeSpanTags = this.activeTestSpan.context()._tags
|
|
1118
1987
|
this.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'test', {
|
|
1119
1988
|
hasCodeOwners: !!activeSpanTags[TEST_CODE_OWNERS],
|
|
1120
1989
|
isNew,
|
|
1121
1990
|
isRum: isRUMActive,
|
|
1122
1991
|
browserDriver: 'cypress',
|
|
1123
|
-
isQuarantined:
|
|
1992
|
+
isQuarantined: activeSpanTags[TEST_MANAGEMENT_IS_QUARANTINED] === 'true',
|
|
1124
1993
|
isModified,
|
|
1125
1994
|
isDisabled: activeSpanTags[TEST_MANAGEMENT_IS_DISABLED] === 'true',
|
|
1126
1995
|
})
|