@depup/dd-trace 5.97.0-depup.0 → 6.5.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +89 -104
- package/README.electron.md +7 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/ci/diagnose.js +2100 -0
- package/ci/init.js +46 -5
- package/ci/runbook.md +198 -0
- package/ci/test-optimization-validation/approval-artifacts.js +143 -0
- package/ci/test-optimization-validation/approval.js +299 -0
- package/ci/test-optimization-validation/artifact-id.js +20 -0
- package/ci/test-optimization-validation/bounded-json.js +121 -0
- package/ci/test-optimization-validation/ci-command-candidate.js +83 -0
- package/ci/test-optimization-validation/ci-discovery.js +181 -0
- package/ci/test-optimization-validation/ci-remediation.js +210 -0
- package/ci/test-optimization-validation/cli.js +903 -0
- package/ci/test-optimization-validation/command-blocker.js +81 -0
- package/ci/test-optimization-validation/command-output-policy.js +206 -0
- package/ci/test-optimization-validation/command-runner.js +707 -0
- package/ci/test-optimization-validation/command-suitability.js +471 -0
- package/ci/test-optimization-validation/executable-approval.js +48 -0
- package/ci/test-optimization-validation/executable.js +480 -0
- package/ci/test-optimization-validation/generated-file-policy.js +63 -0
- package/ci/test-optimization-validation/generated-files.js +351 -0
- package/ci/test-optimization-validation/generated-verifier.js +196 -0
- package/ci/test-optimization-validation/init-probe-preload.js +163 -0
- package/ci/test-optimization-validation/init-probe.js +246 -0
- package/ci/test-optimization-validation/late-initialization.js +63 -0
- package/ci/test-optimization-validation/local-command.js +163 -0
- package/ci/test-optimization-validation/manifest-loader.js +133 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +738 -0
- package/ci/test-optimization-validation/manifest-schema.js +862 -0
- package/ci/test-optimization-validation/offline-fixtures.js +327 -0
- package/ci/test-optimization-validation/offline-output.js +406 -0
- package/ci/test-optimization-validation/payload-normalizer.js +72 -0
- package/ci/test-optimization-validation/plan-writer.js +1120 -0
- package/ci/test-optimization-validation/preflight-runner.js +114 -0
- package/ci/test-optimization-validation/redaction.js +331 -0
- package/ci/test-optimization-validation/report-writer.js +1508 -0
- package/ci/test-optimization-validation/safe-files.js +203 -0
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +159 -0
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +657 -0
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +780 -0
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +141 -0
- package/ci/test-optimization-validation/scenarios/helpers.js +539 -0
- package/ci/test-optimization-validation/scenarios/test-management.js +218 -0
- package/ci/test-optimization-validation/setup-runner.js +97 -0
- package/ci/test-optimization-validation/static-diagnosis.js +159 -0
- package/ci/test-optimization-validation/test-output.js +129 -0
- package/ci/test-optimization-validation-manifest.schema.json +1 -0
- package/ci/validate-test-optimization.js +3 -0
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +2 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +436 -252
- package/index.electron.js +3 -0
- package/init.js +18 -0
- package/initialize.mjs +10 -9
- package/loader-hook.mjs +170 -53
- package/openfeature.d.ts +1 -0
- package/openfeature.js +4 -0
- package/package.json +118 -80
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +137 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +16 -16
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +25 -0
- package/packages/datadog-instrumentations/src/cucumber.js +762 -189
- package/packages/datadog-instrumentations/src/cypress-config.js +547 -93
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +166 -87
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +31 -7
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +111 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1809 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -120
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -135
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +82 -8
- package/packages/datadog-instrumentations/src/mongoose.js +46 -37
- package/packages/datadog-instrumentations/src/mquery.js +7 -7
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +68 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -8
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1229 -356
- package/packages/datadog-instrumentations/src/process.js +3 -0
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +253 -87
- package/packages/datadog-instrumentations/src/selenium.js +53 -28
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1590 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +9 -8
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +80 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-aws-sdk/src/util.js +2 -2
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +47 -29
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +929 -98
- package/packages/datadog-plugin-cypress/src/index.js +109 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +272 -51
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +748 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +54 -8
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +7 -4
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +195 -72
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +55 -44
- package/packages/datadog-plugin-selenium/src/index.js +5 -36
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +5 -2
- package/packages/datadog-plugin-ws/src/producer.js +4 -1
- package/packages/datadog-plugin-ws/src/receiver.js +4 -2
- package/packages/datadog-plugin-ws/src/server.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +148 -55
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +3 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +19 -7
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +123 -33
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +160 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +288 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +84 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +369 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +60 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +188 -27
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +110 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +10 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/rum.js +7 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +9 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +256 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +451 -0
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +90 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +692 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +140 -33
- package/packages/dd-trace/src/config/index.js +127 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +460 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +5 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/client-library-headers.js +21 -0
- package/packages/dd-trace/src/exporters/common/request.js +93 -44
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +48 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +29 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/experiments/client.js +113 -0
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +154 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +283 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +152 -0
- package/packages/dd-trace/src/llmobs/experiments/noop.js +30 -0
- package/packages/dd-trace/src/llmobs/experiments/result.js +34 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +380 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +4 -29
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +8 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +68 -64
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +43 -0
- package/packages/dd-trace/src/llmobs/sdk.js +73 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +197 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +33 -2
- package/packages/dd-trace/src/llmobs/util.js +234 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +322 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +90 -0
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +32 -16
- package/packages/dd-trace/src/openfeature/index.js +0 -2
- package/packages/dd-trace/src/openfeature/noop.js +41 -64
- package/packages/dd-trace/src/openfeature/register.js +35 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -14
- package/packages/dd-trace/src/openfeature/require-provider.js +18 -0
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +10 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +64 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +407 -91
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +6 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +29 -5
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +950 -69
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +128 -37
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +18 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +0 -36
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +22 -22
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +57 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -6,10 +6,10 @@ const { URL } = require('url')
|
|
|
6
6
|
const { getLageTestSessionName } = require('../../ci-visibility/lage')
|
|
7
7
|
const log = require('../../log')
|
|
8
8
|
const { getEnvironmentVariable } = require('../../config/helper')
|
|
9
|
+
const { getSegment } = require('../../util')
|
|
9
10
|
const satisfies = require('../../../../../vendor/dist/semifies')
|
|
10
11
|
|
|
11
12
|
const istanbul = require('../../../../../vendor/dist/istanbul-lib-coverage')
|
|
12
|
-
const ignore = require('../../../../../vendor/dist/ignore')
|
|
13
13
|
|
|
14
14
|
const id = require('../../id')
|
|
15
15
|
const {
|
|
@@ -23,17 +23,40 @@ const { SAMPLING_RULE_DECISION } = require('../../constants')
|
|
|
23
23
|
const { AUTO_KEEP } = require('../../../../../ext/priority')
|
|
24
24
|
const { version: ddTraceVersion } = require('../../../../../package.json')
|
|
25
25
|
const {
|
|
26
|
+
CI_JOB_ID,
|
|
26
27
|
GIT_BRANCH,
|
|
27
28
|
GIT_COMMIT_SHA,
|
|
28
29
|
GIT_REPOSITORY_URL,
|
|
29
30
|
GIT_TAG,
|
|
31
|
+
GIT_COMMIT_AUTHOR_DATE,
|
|
30
32
|
GIT_COMMIT_AUTHOR_EMAIL,
|
|
31
33
|
GIT_COMMIT_AUTHOR_NAME,
|
|
34
|
+
GIT_COMMIT_COMMITTER_DATE,
|
|
35
|
+
GIT_COMMIT_COMMITTER_EMAIL,
|
|
36
|
+
GIT_COMMIT_COMMITTER_NAME,
|
|
32
37
|
GIT_COMMIT_MESSAGE,
|
|
38
|
+
GIT_COMMIT_HEAD_AUTHOR_DATE,
|
|
39
|
+
GIT_COMMIT_HEAD_AUTHOR_EMAIL,
|
|
40
|
+
GIT_COMMIT_HEAD_AUTHOR_NAME,
|
|
41
|
+
GIT_COMMIT_HEAD_COMMITTER_DATE,
|
|
42
|
+
GIT_COMMIT_HEAD_COMMITTER_EMAIL,
|
|
43
|
+
GIT_COMMIT_HEAD_COMMITTER_NAME,
|
|
44
|
+
GIT_COMMIT_HEAD_MESSAGE,
|
|
33
45
|
CI_WORKSPACE_PATH,
|
|
46
|
+
CI_PIPELINE_ID,
|
|
47
|
+
CI_PIPELINE_NAME,
|
|
48
|
+
CI_PIPELINE_NUMBER,
|
|
34
49
|
CI_PIPELINE_URL,
|
|
35
50
|
CI_JOB_NAME,
|
|
51
|
+
CI_JOB_URL,
|
|
52
|
+
CI_NODE_LABELS,
|
|
53
|
+
CI_NODE_NAME,
|
|
54
|
+
CI_PROVIDER_NAME,
|
|
55
|
+
CI_STAGE_NAME,
|
|
36
56
|
GIT_COMMIT_HEAD_SHA,
|
|
57
|
+
GIT_PULL_REQUEST_BASE_BRANCH,
|
|
58
|
+
GIT_PULL_REQUEST_BASE_BRANCH_HEAD_SHA,
|
|
59
|
+
GIT_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
37
60
|
} = require('./tags')
|
|
38
61
|
const { getRuntimeAndOSMetadata } = require('./env')
|
|
39
62
|
const { getCIMetadata } = require('./ci')
|
|
@@ -55,6 +78,11 @@ const {
|
|
|
55
78
|
*
|
|
56
79
|
* @typedef {{ service?: string, isServiceUserProvided?: boolean }} TestEnvironmentConfig
|
|
57
80
|
* @typedef {Record<string, string|number|undefined>} TestEnvironmentMetadata
|
|
81
|
+
* @typedef {{
|
|
82
|
+
* isRumActive?: boolean,
|
|
83
|
+
* browserVersion?: string,
|
|
84
|
+
* testExecutionId?: string
|
|
85
|
+
* }} RumTestCorrelationContext
|
|
58
86
|
*/
|
|
59
87
|
|
|
60
88
|
// session tags
|
|
@@ -73,6 +101,8 @@ const TEST_IS_RUM_ACTIVE = 'test.is_rum_active'
|
|
|
73
101
|
const TEST_CODE_OWNERS = 'test.codeowners'
|
|
74
102
|
const TEST_SOURCE_FILE = 'test.source.file'
|
|
75
103
|
const TEST_SOURCE_START = 'test.source.start'
|
|
104
|
+
const TEST_FAILURE_SCREENSHOT_UPLOADED = 'test.failure_screenshot.uploaded'
|
|
105
|
+
const TEST_FAILURE_SCREENSHOT_UPLOAD_ERROR = 'test.failure_screenshot.upload_error'
|
|
76
106
|
const LIBRARY_VERSION = 'library_version'
|
|
77
107
|
const TEST_COMMAND = 'test.command'
|
|
78
108
|
const TEST_MODULE = 'test.module'
|
|
@@ -90,6 +120,12 @@ const TEST_RETRY_REASON = 'test.retry_reason'
|
|
|
90
120
|
const TEST_HAS_FAILED_ALL_RETRIES = 'test.has_failed_all_retries'
|
|
91
121
|
const TEST_IS_MODIFIED = 'test.is_modified'
|
|
92
122
|
const TEST_HAS_DYNAMIC_NAME = '_dd.has_dynamic_name'
|
|
123
|
+
const EARLY_FLAKE_DETECTION_RETRY_THRESHOLDS = [
|
|
124
|
+
{ limitMs: 5 * 1000, key: '5s' },
|
|
125
|
+
{ limitMs: 10 * 1000, key: '10s' },
|
|
126
|
+
{ limitMs: 30 * 1000, key: '30s' },
|
|
127
|
+
{ limitMs: 5 * 60 * 1000, key: '5m' },
|
|
128
|
+
]
|
|
93
129
|
const CI_APP_ORIGIN = 'ciapp-test'
|
|
94
130
|
|
|
95
131
|
// Matches patterns that are almost certainly runtime-generated values in test names:
|
|
@@ -100,7 +136,7 @@ const CI_APP_ORIGIN = 'ciapp-test'
|
|
|
100
136
|
// - Math.random() float values (10+ decimal digits after 0.)
|
|
101
137
|
const DYNAMIC_NAME_RE = new RegExp(
|
|
102
138
|
String.raw`\b1[6-9]\d{8,11}\b|` +
|
|
103
|
-
|
|
139
|
+
'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|' +
|
|
104
140
|
String.raw`\b\d{4}-\d{2}-\d{2}|` +
|
|
105
141
|
String.raw`(?:localhost|127\.0\.0\.1|0\.0\.0\.0):\d{4,5}\b|` +
|
|
106
142
|
String.raw`\b0\.\d{10,}`,
|
|
@@ -137,6 +173,7 @@ const JEST_WORKER_TRACE_PAYLOAD_CODE = 60
|
|
|
137
173
|
const JEST_WORKER_COVERAGE_PAYLOAD_CODE = 61
|
|
138
174
|
const JEST_WORKER_LOGS_PAYLOAD_CODE = 62
|
|
139
175
|
const JEST_WORKER_TELEMETRY_PAYLOAD_CODE = 63
|
|
176
|
+
const JEST_WORKER_QUARANTINE_PAYLOAD_CODE = 64
|
|
140
177
|
|
|
141
178
|
// cucumber worker variables
|
|
142
179
|
const CUCUMBER_WORKER_TRACE_PAYLOAD_CODE = 70
|
|
@@ -163,8 +200,12 @@ const DD_CAPABILITIES_TEST_MANAGEMENT_DISABLE = '_dd.library_capabilities.test_m
|
|
|
163
200
|
const DD_CAPABILITIES_TEST_MANAGEMENT_ATTEMPT_TO_FIX = '_dd.library_capabilities.test_management.attempt_to_fix'
|
|
164
201
|
const DD_CAPABILITIES_FAILED_TEST_REPLAY = '_dd.library_capabilities.failed_test_replay'
|
|
165
202
|
|
|
166
|
-
// Library configuration request error
|
|
167
|
-
const
|
|
203
|
+
// Library configuration request error tags
|
|
204
|
+
const DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS = '_dd.ci.library_configuration_error.settings'
|
|
205
|
+
const DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS = '_dd.ci.library_configuration_error.skippable_tests'
|
|
206
|
+
const DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS = '_dd.ci.library_configuration_error.known_tests'
|
|
207
|
+
const DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS =
|
|
208
|
+
'_dd.ci.library_configuration_error.test_management_tests'
|
|
168
209
|
|
|
169
210
|
const UNSUPPORTED_TIA_FRAMEWORKS = new Set(['playwright', 'vitest'])
|
|
170
211
|
const MINIMUM_FRAMEWORK_VERSION_FOR_EFD = {
|
|
@@ -194,6 +235,43 @@ const TEST_LEVEL_EVENT_TYPES = [
|
|
|
194
235
|
'test_module_end',
|
|
195
236
|
'test_session_end',
|
|
196
237
|
]
|
|
238
|
+
const TEST_LEVELS_METADATA = 'test_levels'
|
|
239
|
+
const TEST_LEVELS_METADATA_TAGS = [
|
|
240
|
+
CI_JOB_ID,
|
|
241
|
+
CI_JOB_NAME,
|
|
242
|
+
CI_JOB_URL,
|
|
243
|
+
CI_NODE_LABELS,
|
|
244
|
+
CI_NODE_NAME,
|
|
245
|
+
CI_PIPELINE_ID,
|
|
246
|
+
CI_PIPELINE_NAME,
|
|
247
|
+
CI_PIPELINE_NUMBER,
|
|
248
|
+
CI_PIPELINE_URL,
|
|
249
|
+
CI_PROVIDER_NAME,
|
|
250
|
+
CI_STAGE_NAME,
|
|
251
|
+
CI_WORKSPACE_PATH,
|
|
252
|
+
GIT_BRANCH,
|
|
253
|
+
GIT_COMMIT_AUTHOR_DATE,
|
|
254
|
+
GIT_COMMIT_AUTHOR_EMAIL,
|
|
255
|
+
GIT_COMMIT_AUTHOR_NAME,
|
|
256
|
+
GIT_COMMIT_COMMITTER_DATE,
|
|
257
|
+
GIT_COMMIT_COMMITTER_EMAIL,
|
|
258
|
+
GIT_COMMIT_COMMITTER_NAME,
|
|
259
|
+
GIT_COMMIT_HEAD_AUTHOR_DATE,
|
|
260
|
+
GIT_COMMIT_HEAD_AUTHOR_EMAIL,
|
|
261
|
+
GIT_COMMIT_HEAD_AUTHOR_NAME,
|
|
262
|
+
GIT_COMMIT_HEAD_COMMITTER_DATE,
|
|
263
|
+
GIT_COMMIT_HEAD_COMMITTER_EMAIL,
|
|
264
|
+
GIT_COMMIT_HEAD_COMMITTER_NAME,
|
|
265
|
+
GIT_COMMIT_HEAD_MESSAGE,
|
|
266
|
+
GIT_COMMIT_HEAD_SHA,
|
|
267
|
+
GIT_COMMIT_MESSAGE,
|
|
268
|
+
GIT_COMMIT_SHA,
|
|
269
|
+
GIT_PULL_REQUEST_BASE_BRANCH,
|
|
270
|
+
GIT_PULL_REQUEST_BASE_BRANCH_HEAD_SHA,
|
|
271
|
+
GIT_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
272
|
+
GIT_REPOSITORY_URL,
|
|
273
|
+
GIT_TAG,
|
|
274
|
+
]
|
|
197
275
|
const TEST_RETRY_REASON_TYPES = {
|
|
198
276
|
efd: 'early_flake_detection',
|
|
199
277
|
atr: 'auto_test_retry',
|
|
@@ -217,26 +295,133 @@ const TEST_MANAGEMENT_IS_QUARANTINED = 'test.test_management.is_quarantined'
|
|
|
217
295
|
const TEST_MANAGEMENT_ENABLED = 'test.test_management.enabled'
|
|
218
296
|
const TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED = 'test.test_management.attempt_to_fix_passed'
|
|
219
297
|
|
|
298
|
+
const MAX_TEST_OPTIMIZATION_SUMMARY_ITEMS = 10
|
|
299
|
+
|
|
220
300
|
// Impacted tests
|
|
221
301
|
const POSSIBLE_BASE_BRANCHES = ['main', 'master', 'preprod', 'prod', 'dev', 'development', 'trunk']
|
|
222
302
|
const BASE_LIKE_BRANCH_FILTER = /^(main|master|preprod|prod|dev|development|trunk|release\/.*|hotfix\/.*)$/
|
|
223
303
|
|
|
224
304
|
/**
|
|
225
305
|
* Returns request error tags from a test session span for propagation to child events.
|
|
226
|
-
* @param {{ context: () => {
|
|
306
|
+
* @param {{ context: () => { getTag?: (key: string) => string } } | undefined} sessionSpan
|
|
227
307
|
* @returns {Record<string, string>}
|
|
228
308
|
*/
|
|
229
309
|
function getSessionRequestErrorTags (sessionSpan) {
|
|
230
|
-
const tags = sessionSpan?.context()
|
|
310
|
+
const tags = sessionSpan?.context()?.getTags?.()
|
|
311
|
+
const sessionRequestErrorTags = {}
|
|
312
|
+
if (!tags || typeof tags !== 'object') return {}
|
|
313
|
+
if (tags[DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS] === 'true') {
|
|
314
|
+
sessionRequestErrorTags[DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS] = 'true'
|
|
315
|
+
}
|
|
316
|
+
if (tags[DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS] === 'true') {
|
|
317
|
+
sessionRequestErrorTags[DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS] = 'true'
|
|
318
|
+
}
|
|
319
|
+
if (tags[DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS] === 'true') {
|
|
320
|
+
sessionRequestErrorTags[DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS] = 'true'
|
|
321
|
+
}
|
|
322
|
+
if (tags[DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS] === 'true') {
|
|
323
|
+
sessionRequestErrorTags[DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS] = 'true'
|
|
324
|
+
}
|
|
325
|
+
return sessionRequestErrorTags
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Returns ITR skipping-enabled tags from a test session span for propagation to child events.
|
|
330
|
+
* @param {{ context: () => { getTags?: () => Record<string, string> } } | undefined} sessionSpan
|
|
331
|
+
* @returns {Record<string, string>}
|
|
332
|
+
*/
|
|
333
|
+
function getSessionItrSkippingEnabledTags (sessionSpan) {
|
|
334
|
+
const tags = sessionSpan?.context()?.getTags?.()
|
|
231
335
|
if (!tags || typeof tags !== 'object') return {}
|
|
232
|
-
if (tags[
|
|
336
|
+
if (tags[TEST_ITR_SKIPPING_ENABLED] !== undefined) {
|
|
233
337
|
return {
|
|
234
|
-
[
|
|
338
|
+
[TEST_ITR_SKIPPING_ENABLED]: tags[TEST_ITR_SKIPPING_ENABLED],
|
|
235
339
|
}
|
|
236
340
|
}
|
|
237
341
|
return {}
|
|
238
342
|
}
|
|
239
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Starts supported test optimization requests together when each feature is enabled.
|
|
346
|
+
*
|
|
347
|
+
* @param {{
|
|
348
|
+
* isKnownTestsEnabled: boolean,
|
|
349
|
+
* isTestManagementTestsEnabled: boolean,
|
|
350
|
+
* isSuitesSkippingEnabled?: boolean,
|
|
351
|
+
* getKnownTests: () => Promise<object>,
|
|
352
|
+
* getTestManagementTests: () => Promise<object>,
|
|
353
|
+
* getSkippableSuites?: () => Promise<object>
|
|
354
|
+
* }} options - Test optimization request factories.
|
|
355
|
+
* @returns {Promise<{
|
|
356
|
+
* knownTestsResponse?: object,
|
|
357
|
+
* testManagementTestsResponse?: object,
|
|
358
|
+
* skippableSuitesResponse?: object
|
|
359
|
+
* }>}
|
|
360
|
+
*/
|
|
361
|
+
function getTestOptimizationRequestResults ({
|
|
362
|
+
isKnownTestsEnabled,
|
|
363
|
+
isTestManagementTestsEnabled,
|
|
364
|
+
isSuitesSkippingEnabled,
|
|
365
|
+
getKnownTests,
|
|
366
|
+
getTestManagementTests,
|
|
367
|
+
getSkippableSuites,
|
|
368
|
+
}) {
|
|
369
|
+
const requestPromises = []
|
|
370
|
+
const responseNames = []
|
|
371
|
+
|
|
372
|
+
if (isKnownTestsEnabled) {
|
|
373
|
+
addTestOptimizationRequest(requestPromises, responseNames, 'knownTestsResponse', getKnownTests)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (isTestManagementTestsEnabled) {
|
|
377
|
+
addTestOptimizationRequest(
|
|
378
|
+
requestPromises,
|
|
379
|
+
responseNames,
|
|
380
|
+
'testManagementTestsResponse',
|
|
381
|
+
getTestManagementTests
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (isSuitesSkippingEnabled && getSkippableSuites) {
|
|
386
|
+
addTestOptimizationRequest(requestPromises, responseNames, 'skippableSuitesResponse', getSkippableSuites)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!requestPromises.length) {
|
|
390
|
+
return Promise.resolve({})
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return Promise.allSettled(requestPromises).then(requestResults => {
|
|
394
|
+
const responses = {}
|
|
395
|
+
|
|
396
|
+
for (let index = 0; index < requestResults.length; index++) {
|
|
397
|
+
const requestResult = requestResults[index]
|
|
398
|
+
responses[responseNames[index]] = requestResult.status === 'fulfilled'
|
|
399
|
+
? requestResult.value
|
|
400
|
+
: { err: requestResult.reason }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return responses
|
|
404
|
+
})
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Starts a test optimization request.
|
|
409
|
+
*
|
|
410
|
+
* @param {Promise<object>[]} requestPromises - Test optimization request promises.
|
|
411
|
+
* @param {string[]} responseNames - Response keys matching request promises.
|
|
412
|
+
* @param {string} responseName - Response key for this request.
|
|
413
|
+
* @param {() => Promise<object>} getRequest - Test optimization request factory.
|
|
414
|
+
*/
|
|
415
|
+
function addTestOptimizationRequest (requestPromises, responseNames, responseName, getRequest) {
|
|
416
|
+
responseNames.push(responseName)
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
requestPromises.push(Promise.resolve(getRequest()))
|
|
420
|
+
} catch (err) {
|
|
421
|
+
requestPromises.push(Promise.reject(err))
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
240
425
|
module.exports = {
|
|
241
426
|
TEST_CODE_OWNERS,
|
|
242
427
|
TEST_SESSION_NAME,
|
|
@@ -255,13 +440,18 @@ module.exports = {
|
|
|
255
440
|
TEST_PARAMETERS,
|
|
256
441
|
TEST_SKIP_REASON,
|
|
257
442
|
TEST_IS_RUM_ACTIVE,
|
|
443
|
+
setRumTestCorrelation,
|
|
444
|
+
setRumTestTags,
|
|
258
445
|
TEST_SOURCE_FILE,
|
|
446
|
+
TEST_FAILURE_SCREENSHOT_UPLOADED,
|
|
447
|
+
TEST_FAILURE_SCREENSHOT_UPLOAD_ERROR,
|
|
259
448
|
CI_APP_ORIGIN,
|
|
260
449
|
LIBRARY_VERSION,
|
|
261
450
|
JEST_WORKER_TRACE_PAYLOAD_CODE,
|
|
262
451
|
JEST_WORKER_COVERAGE_PAYLOAD_CODE,
|
|
263
452
|
JEST_WORKER_LOGS_PAYLOAD_CODE,
|
|
264
453
|
JEST_WORKER_TELEMETRY_PAYLOAD_CODE,
|
|
454
|
+
JEST_WORKER_QUARANTINE_PAYLOAD_CODE,
|
|
265
455
|
CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
|
|
266
456
|
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
|
|
267
457
|
PLAYWRIGHT_WORKER_TRACE_PAYLOAD_CODE,
|
|
@@ -286,6 +476,7 @@ module.exports = {
|
|
|
286
476
|
getCodeOwnersFileEntries,
|
|
287
477
|
getCodeOwnersForFilename,
|
|
288
478
|
getTestCommonTags,
|
|
479
|
+
getTestLevelsMetadataTags,
|
|
289
480
|
getTestSessionCommonTags,
|
|
290
481
|
getTestModuleCommonTags,
|
|
291
482
|
getTestSuiteCommonTags,
|
|
@@ -306,6 +497,12 @@ module.exports = {
|
|
|
306
497
|
ITR_CORRELATION_ID,
|
|
307
498
|
addIntelligentTestRunnerSpanTags,
|
|
308
499
|
getCoveredFilenamesFromCoverage,
|
|
500
|
+
getCoveredFilesFromCoverage,
|
|
501
|
+
getExecutableFilesFromCoverage,
|
|
502
|
+
getRelativeCoverageFiles,
|
|
503
|
+
getLineCoverageBitmap,
|
|
504
|
+
applySkippedCoverageToCoverage,
|
|
505
|
+
getTestCoverageLinesPercentage,
|
|
309
506
|
resetCoverage,
|
|
310
507
|
mergeCoverage,
|
|
311
508
|
fromCoverageMapToCoverage,
|
|
@@ -314,7 +511,9 @@ module.exports = {
|
|
|
314
511
|
removeInvalidMetadata,
|
|
315
512
|
parseAnnotations,
|
|
316
513
|
getIsFaultyEarlyFlakeDetection,
|
|
514
|
+
EARLY_FLAKE_DETECTION_RETRY_THRESHOLDS,
|
|
317
515
|
getEfdRetryCount,
|
|
516
|
+
getMaxEfdRetryCount,
|
|
318
517
|
TEST_BROWSER_DRIVER,
|
|
319
518
|
TEST_BROWSER_DRIVER_VERSION,
|
|
320
519
|
TEST_BROWSER_NAME,
|
|
@@ -329,6 +528,7 @@ module.exports = {
|
|
|
329
528
|
DD_CAPABILITIES_TEST_MANAGEMENT_ATTEMPT_TO_FIX,
|
|
330
529
|
DD_CAPABILITIES_FAILED_TEST_REPLAY,
|
|
331
530
|
TEST_LEVEL_EVENT_TYPES,
|
|
531
|
+
TEST_LEVELS_METADATA,
|
|
332
532
|
TEST_RETRY_REASON_TYPES,
|
|
333
533
|
getNumFromKnownTests,
|
|
334
534
|
getFileAndLineNumberFromError,
|
|
@@ -346,7 +546,12 @@ module.exports = {
|
|
|
346
546
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
347
547
|
getLibraryCapabilitiesTags,
|
|
348
548
|
getSessionRequestErrorTags,
|
|
349
|
-
|
|
549
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_SETTINGS,
|
|
550
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_SKIPPABLE_TESTS,
|
|
551
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_KNOWN_TESTS,
|
|
552
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR_TEST_MANAGEMENT_TESTS,
|
|
553
|
+
getSessionItrSkippingEnabledTags,
|
|
554
|
+
getTestOptimizationRequestResults,
|
|
350
555
|
checkShaDiscrepancies,
|
|
351
556
|
getPullRequestDiff,
|
|
352
557
|
getPullRequestBaseBranch,
|
|
@@ -357,13 +562,20 @@ module.exports = {
|
|
|
357
562
|
GIT_REPOSITORY_URL,
|
|
358
563
|
DYNAMIC_NAME_RE,
|
|
359
564
|
collectDynamicNamesFromTraces,
|
|
565
|
+
collectTestOptimizationSummariesFromTraces,
|
|
360
566
|
logDynamicNamesWarning,
|
|
567
|
+
recordAttemptToFixExecution,
|
|
568
|
+
collectAttemptToFixExecutionsFromTraces,
|
|
569
|
+
formatAttemptToFixSummary,
|
|
570
|
+
logAttemptToFixTestExecution,
|
|
571
|
+
formatDynamicNamesSummary,
|
|
572
|
+
logTestOptimizationSummary,
|
|
361
573
|
}
|
|
362
574
|
|
|
363
575
|
// Returns pkg manager and its version, separated by '-', e.g. npm-8.15.0 or yarn-1.22.19
|
|
364
576
|
function getPkgManager () {
|
|
365
577
|
try {
|
|
366
|
-
return getEnvironmentVariable('npm_config_user_agent')
|
|
578
|
+
return getSegment(getEnvironmentVariable('npm_config_user_agent'), ' ', 0).replace('/', '-')
|
|
367
579
|
} catch {
|
|
368
580
|
return ''
|
|
369
581
|
}
|
|
@@ -569,6 +781,24 @@ function getTestParametersString (parametersByTestName, testName) {
|
|
|
569
781
|
}
|
|
570
782
|
}
|
|
571
783
|
|
|
784
|
+
/**
|
|
785
|
+
* Extracts CI and Git tags that apply to every test level.
|
|
786
|
+
*
|
|
787
|
+
* @param {TestEnvironmentMetadata} testEnvironmentMetadata
|
|
788
|
+
* @returns {Record<string, string|number>}
|
|
789
|
+
*/
|
|
790
|
+
function getTestLevelsMetadataTags (testEnvironmentMetadata) {
|
|
791
|
+
const testLevelsMetadataTags = {}
|
|
792
|
+
for (let i = 0; i < TEST_LEVELS_METADATA_TAGS.length; i++) {
|
|
793
|
+
const key = TEST_LEVELS_METADATA_TAGS[i]
|
|
794
|
+
const value = testEnvironmentMetadata[key]
|
|
795
|
+
if (value !== undefined) {
|
|
796
|
+
testLevelsMetadataTags[key] = value
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return testLevelsMetadataTags
|
|
800
|
+
}
|
|
801
|
+
|
|
572
802
|
function getTestTypeFromFramework (testFramework) {
|
|
573
803
|
if (testFramework === 'playwright' || testFramework === 'cypress') {
|
|
574
804
|
return 'browser'
|
|
@@ -576,6 +806,9 @@ function getTestTypeFromFramework (testFramework) {
|
|
|
576
806
|
return 'test'
|
|
577
807
|
}
|
|
578
808
|
|
|
809
|
+
/**
|
|
810
|
+
* @param {import('../../opentracing/span')} span
|
|
811
|
+
*/
|
|
579
812
|
function finishAllTraceSpans (span) {
|
|
580
813
|
for (const traceSpan of span.context()._trace.started) {
|
|
581
814
|
if (traceSpan !== span) {
|
|
@@ -584,6 +817,49 @@ function finishAllTraceSpans (span) {
|
|
|
584
817
|
}
|
|
585
818
|
}
|
|
586
819
|
|
|
820
|
+
/**
|
|
821
|
+
* @param {import('../../opentracing/span')} testSpan
|
|
822
|
+
* @param {boolean|undefined} isRumActive
|
|
823
|
+
* @param {string} [browserVersion]
|
|
824
|
+
* @returns {void}
|
|
825
|
+
*/
|
|
826
|
+
function setRumTestTags (testSpan, isRumActive, browserVersion) {
|
|
827
|
+
if (isRumActive) {
|
|
828
|
+
testSpan.setTag(TEST_IS_RUM_ACTIVE, 'true')
|
|
829
|
+
}
|
|
830
|
+
if (browserVersion) {
|
|
831
|
+
testSpan.setTag(TEST_BROWSER_VERSION, browserVersion)
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @param {RumTestCorrelationContext} context
|
|
837
|
+
* @param {import('../../opentracing/span')|undefined} activeSpan
|
|
838
|
+
* @returns {import('../../opentracing/span')|undefined}
|
|
839
|
+
*/
|
|
840
|
+
function setRumTestCorrelation (context, activeSpan) {
|
|
841
|
+
if (!activeSpan) return
|
|
842
|
+
|
|
843
|
+
const activeContext = activeSpan.context()
|
|
844
|
+
let testSpan
|
|
845
|
+
if (activeContext.getTag(SPAN_TYPE) === 'test') {
|
|
846
|
+
testSpan = activeSpan
|
|
847
|
+
} else {
|
|
848
|
+
for (const traceSpan of activeContext._trace.started) {
|
|
849
|
+
if (traceSpan.context().getTag(SPAN_TYPE) === 'test') {
|
|
850
|
+
testSpan = traceSpan
|
|
851
|
+
break
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
if (!testSpan) return
|
|
857
|
+
|
|
858
|
+
context.testExecutionId = testSpan.context().toTraceId()
|
|
859
|
+
setRumTestTags(testSpan, context.isRumActive, context.browserVersion)
|
|
860
|
+
return testSpan
|
|
861
|
+
}
|
|
862
|
+
|
|
587
863
|
function getTestParentSpan (tracer) {
|
|
588
864
|
return tracer.extract('text_map', {
|
|
589
865
|
'x-datadog-trace-id': id().toString(10),
|
|
@@ -669,24 +945,146 @@ function getCodeOwnersFileEntries (rootDir) {
|
|
|
669
945
|
const trimmed = content.trim()
|
|
670
946
|
if (trimmed === '') continue
|
|
671
947
|
const [pattern, ...owners] = trimmed.split(/\s+/)
|
|
672
|
-
entries.push({ pattern, owners })
|
|
948
|
+
entries.push(setCodeOwnersPatternRegex({ pattern, owners }))
|
|
673
949
|
}
|
|
674
950
|
// Reverse because rules defined last take precedence
|
|
675
951
|
return entries.reverse()
|
|
676
952
|
}
|
|
677
953
|
|
|
678
|
-
const
|
|
954
|
+
const codeOwnersPerEntries = new WeakMap()
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* @param {string} character
|
|
958
|
+
* @returns {string}
|
|
959
|
+
*/
|
|
960
|
+
function escapeRegexCharacter (character) {
|
|
961
|
+
return character.replaceAll(/[|\\{}()[\]^$+*?.]/g, String.raw`\$&`)
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* @param {string} pattern
|
|
966
|
+
* @returns {boolean}
|
|
967
|
+
*/
|
|
968
|
+
function hasUnescapedWildcard (pattern) {
|
|
969
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
970
|
+
const character = pattern[i]
|
|
971
|
+
if (character === '\\') {
|
|
972
|
+
i++
|
|
973
|
+
} else if (character === '*' || character === '?') {
|
|
974
|
+
return true
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return false
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* @param {string} pattern
|
|
982
|
+
* @returns {string}
|
|
983
|
+
*/
|
|
984
|
+
function codeOwnersPatternToRegexSource (pattern) {
|
|
985
|
+
let source = ''
|
|
986
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
987
|
+
const character = pattern[i]
|
|
988
|
+
|
|
989
|
+
if (character === '\\') {
|
|
990
|
+
const escapedCharacter = pattern[i + 1]
|
|
991
|
+
source += escapedCharacter === undefined
|
|
992
|
+
? escapeRegexCharacter(character)
|
|
993
|
+
: escapeRegexCharacter(escapedCharacter)
|
|
994
|
+
i++
|
|
995
|
+
} else if (character === '*') {
|
|
996
|
+
if (pattern[i + 1] === '*') {
|
|
997
|
+
if (pattern[i + 2] === '/') {
|
|
998
|
+
source += '(?:.*/)?'
|
|
999
|
+
i += 2
|
|
1000
|
+
} else {
|
|
1001
|
+
source += '.*'
|
|
1002
|
+
i++
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
source += '[^/]*'
|
|
1006
|
+
}
|
|
1007
|
+
} else if (character === '?') {
|
|
1008
|
+
source += '[^/]'
|
|
1009
|
+
} else {
|
|
1010
|
+
source += escapeRegexCharacter(character)
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return source
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* @param {string} pattern
|
|
1018
|
+
* @returns {RegExp|null}
|
|
1019
|
+
*/
|
|
1020
|
+
function getCodeOwnersPatternRegex (pattern) {
|
|
1021
|
+
if (!pattern || pattern[0] === '!') {
|
|
1022
|
+
return null
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
const directoryOnly = pattern.endsWith('/')
|
|
1026
|
+
const normalizedPattern = pattern.replace(/^\/+/, '').replace(/\/+$/, '')
|
|
1027
|
+
const anchored = pattern.startsWith('/') || normalizedPattern.includes('/')
|
|
1028
|
+
|
|
1029
|
+
if (!normalizedPattern) {
|
|
1030
|
+
return null
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
const lastSlashIndex = normalizedPattern.lastIndexOf('/')
|
|
1034
|
+
const lastSegment = lastSlashIndex === -1 ? normalizedPattern : normalizedPattern.slice(lastSlashIndex + 1)
|
|
1035
|
+
const descendantSuffix = directoryOnly || !hasUnescapedWildcard(lastSegment) ? '(?:/.*)?' : ''
|
|
1036
|
+
const patternSource = codeOwnersPatternToRegexSource(normalizedPattern)
|
|
1037
|
+
const regexSource = anchored
|
|
1038
|
+
? `^${patternSource}${descendantSuffix}$`
|
|
1039
|
+
: `(?:^|/)${patternSource}${descendantSuffix}$`
|
|
1040
|
+
|
|
1041
|
+
return new RegExp(regexSource)
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function setCodeOwnersPatternRegex (entry) {
|
|
1045
|
+
Object.defineProperty(entry, 'regex', {
|
|
1046
|
+
configurable: true,
|
|
1047
|
+
value: getCodeOwnersPatternRegex(entry.pattern),
|
|
1048
|
+
writable: true,
|
|
1049
|
+
})
|
|
1050
|
+
return entry
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Match a repository-relative filename against a CODEOWNERS pattern.
|
|
1055
|
+
* See GitHub's CODEOWNERS pattern rules:
|
|
1056
|
+
* https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
|
1057
|
+
*
|
|
1058
|
+
* @param {RegExp|null} regex
|
|
1059
|
+
* @param {string} filename
|
|
1060
|
+
* @returns {boolean}
|
|
1061
|
+
*/
|
|
1062
|
+
function isCodeOwnersPatternMatch (regex, filename) {
|
|
1063
|
+
if (!regex || !filename) {
|
|
1064
|
+
return false
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const normalizedFilename = filename.replaceAll('\\', '/').replace(/^\/+/, '')
|
|
1068
|
+
return regex.test(normalizedFilename)
|
|
1069
|
+
}
|
|
679
1070
|
|
|
680
1071
|
function getCodeOwnersForFilename (filename, entries) {
|
|
681
1072
|
if (!entries) {
|
|
682
1073
|
return null
|
|
683
1074
|
}
|
|
684
|
-
|
|
1075
|
+
let codeOwnersPerFileName = codeOwnersPerEntries.get(entries)
|
|
1076
|
+
|
|
1077
|
+
if (!codeOwnersPerFileName) {
|
|
1078
|
+
codeOwnersPerFileName = new Map()
|
|
1079
|
+
codeOwnersPerEntries.set(entries, codeOwnersPerFileName)
|
|
1080
|
+
} else if (codeOwnersPerFileName.has(filename)) {
|
|
685
1081
|
return codeOwnersPerFileName.get(filename)
|
|
686
1082
|
}
|
|
1083
|
+
|
|
687
1084
|
for (const entry of entries) {
|
|
688
1085
|
try {
|
|
689
|
-
const
|
|
1086
|
+
const regex = entry.regex === undefined ? setCodeOwnersPatternRegex(entry).regex : entry.regex
|
|
1087
|
+
const isResponsible = isCodeOwnersPatternMatch(regex, filename)
|
|
690
1088
|
if (isResponsible) {
|
|
691
1089
|
const codeOwners = JSON.stringify(entry.owners)
|
|
692
1090
|
codeOwnersPerFileName.set(filename, codeOwners)
|
|
@@ -705,7 +1103,6 @@ function getTestLevelCommonTags (command, testFrameworkVersion, testFramework) {
|
|
|
705
1103
|
return {
|
|
706
1104
|
[TEST_FRAMEWORK_VERSION]: testFrameworkVersion,
|
|
707
1105
|
[LIBRARY_VERSION]: ddTraceVersion,
|
|
708
|
-
[TEST_COMMAND]: command,
|
|
709
1106
|
[TEST_TYPE]: getTestTypeFromFramework(testFramework),
|
|
710
1107
|
}
|
|
711
1108
|
}
|
|
@@ -783,17 +1180,233 @@ function addIntelligentTestRunnerSpanTags (
|
|
|
783
1180
|
}
|
|
784
1181
|
|
|
785
1182
|
function getCoveredFilenamesFromCoverage (coverage) {
|
|
786
|
-
|
|
1183
|
+
return getCoveredFilesFromCoverage(coverage).map(({ filename }) => filename)
|
|
1184
|
+
}
|
|
787
1185
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1186
|
+
function getCoverageMap (coverage) {
|
|
1187
|
+
if (coverage?.files && coverage?.fileCoverageFor) {
|
|
1188
|
+
return coverage
|
|
1189
|
+
}
|
|
1190
|
+
return istanbul.createCoverageMap(coverage)
|
|
1191
|
+
}
|
|
794
1192
|
|
|
795
|
-
|
|
796
|
-
|
|
1193
|
+
function getCoveredFilesFromCoverage (coverage) {
|
|
1194
|
+
const coverageMap = getCoverageMap(coverage)
|
|
1195
|
+
const coverageFiles = []
|
|
1196
|
+
|
|
1197
|
+
for (const filename of coverageMap.files()) {
|
|
1198
|
+
const fileCoverage = coverageMap.fileCoverageFor(filename)
|
|
1199
|
+
const bitmap = getLineCoverageBitmap(fileCoverage.getLineCoverage(), true)
|
|
1200
|
+
if (bitmap) {
|
|
1201
|
+
coverageFiles.push({ filename, bitmap })
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return coverageFiles
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function getExecutableFilesFromCoverage (coverage) {
|
|
1209
|
+
const coverageMap = getCoverageMap(coverage)
|
|
1210
|
+
const coverageFiles = []
|
|
1211
|
+
|
|
1212
|
+
for (const filename of coverageMap.files()) {
|
|
1213
|
+
const fileCoverage = coverageMap.fileCoverageFor(filename)
|
|
1214
|
+
const bitmap = getLineCoverageBitmap(fileCoverage.getLineCoverage())
|
|
1215
|
+
if (bitmap) {
|
|
1216
|
+
coverageFiles.push({ filename, bitmap })
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
return coverageFiles
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
function getRelativeCoverageFiles (coverageFiles, rootDir) {
|
|
1224
|
+
return coverageFiles.map(({ filename, bitmap }) => ({
|
|
1225
|
+
filename: getTestSuitePath(filename, rootDir),
|
|
1226
|
+
bitmap,
|
|
1227
|
+
}))
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function getLineCoverageBitmap (lineCoverage, onlyCoveredLines = false) {
|
|
1231
|
+
let maxLine = 0
|
|
1232
|
+
const lines = []
|
|
1233
|
+
|
|
1234
|
+
for (const [line, hits] of Object.entries(lineCoverage)) {
|
|
1235
|
+
if (onlyCoveredLines && !hits) continue
|
|
1236
|
+
|
|
1237
|
+
const lineNumber = Number(line)
|
|
1238
|
+
if (!Number.isSafeInteger(lineNumber) || lineNumber <= 0) continue
|
|
1239
|
+
|
|
1240
|
+
lines.push(lineNumber)
|
|
1241
|
+
if (lineNumber > maxLine) {
|
|
1242
|
+
maxLine = lineNumber
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (maxLine === 0) return
|
|
1247
|
+
|
|
1248
|
+
const bitmap = Buffer.alloc(Math.ceil((maxLine + 1) / 8))
|
|
1249
|
+
for (const lineNumber of lines) {
|
|
1250
|
+
bitmap[lineNumber >> 3] |= 1 << (lineNumber % 8)
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
return bitmap
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
function mergeCoverageBitmaps (targetBitmap, bitmap) {
|
|
1257
|
+
if (!targetBitmap) {
|
|
1258
|
+
return Buffer.from(bitmap)
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (targetBitmap.length < bitmap.length) {
|
|
1262
|
+
const biggerBitmap = Buffer.alloc(bitmap.length)
|
|
1263
|
+
targetBitmap.copy(biggerBitmap)
|
|
1264
|
+
targetBitmap = biggerBitmap
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
for (let i = 0; i < bitmap.length; i++) {
|
|
1268
|
+
targetBitmap[i] |= bitmap[i]
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
return targetBitmap
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
function countBitmapBits (bitmap) {
|
|
1275
|
+
let count = 0
|
|
1276
|
+
|
|
1277
|
+
for (const byte of bitmap) {
|
|
1278
|
+
let value = byte
|
|
1279
|
+
while (value) {
|
|
1280
|
+
value &= value - 1
|
|
1281
|
+
count++
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
return count
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
function countCoveredExecutableBits (coveredBitmap, executableBitmap) {
|
|
1289
|
+
if (!coveredBitmap) return 0
|
|
1290
|
+
|
|
1291
|
+
let count = 0
|
|
1292
|
+
const length = Math.min(coveredBitmap.length, executableBitmap.length)
|
|
1293
|
+
|
|
1294
|
+
for (let i = 0; i < length; i++) {
|
|
1295
|
+
let value = coveredBitmap[i] & executableBitmap[i]
|
|
1296
|
+
while (value) {
|
|
1297
|
+
value &= value - 1
|
|
1298
|
+
count++
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
return count
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
function getCoverageFileBitmap (bitmap) {
|
|
1306
|
+
if (!bitmap) return
|
|
1307
|
+
if (Buffer.isBuffer(bitmap)) return bitmap
|
|
1308
|
+
if (ArrayBuffer.isView(bitmap)) {
|
|
1309
|
+
return Buffer.from(bitmap.buffer, bitmap.byteOffset, bitmap.byteLength)
|
|
1310
|
+
}
|
|
1311
|
+
if (typeof bitmap === 'string') {
|
|
1312
|
+
return Buffer.from(bitmap, 'base64')
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function addCoverageFilesToMap (files, targetMap, rootDir) {
|
|
1317
|
+
for (const file of files) {
|
|
1318
|
+
const bitmap = getCoverageFileBitmap(file.bitmap)
|
|
1319
|
+
if (!bitmap) continue
|
|
1320
|
+
|
|
1321
|
+
const filename = rootDir ? getTestSuitePath(file.filename, rootDir) : file.filename
|
|
1322
|
+
targetMap.set(filename, mergeCoverageBitmaps(targetMap.get(filename), bitmap))
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
function addSkippedCoverageToMap (skippedCoverage, targetMap) {
|
|
1327
|
+
if (!skippedCoverage) return
|
|
1328
|
+
|
|
1329
|
+
for (const [filename, bitmap] of Object.entries(skippedCoverage)) {
|
|
1330
|
+
const coverageBitmap = getCoverageFileBitmap(bitmap)
|
|
1331
|
+
if (!coverageBitmap) continue
|
|
1332
|
+
targetMap.set(filename, mergeCoverageBitmaps(targetMap.get(filename), coverageBitmap))
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function hasSkippedCoverage (skippedCoverage) {
|
|
1337
|
+
return skippedCoverage && typeof skippedCoverage === 'object' && Object.keys(skippedCoverage).length > 0
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
function getTestCoverageLinesPercentage (coverage, skippedCoverage, rootDir) {
|
|
1341
|
+
const executableLinesByFile = new Map()
|
|
1342
|
+
const coveredLinesByFile = new Map()
|
|
1343
|
+
|
|
1344
|
+
addCoverageFilesToMap(getExecutableFilesFromCoverage(coverage), executableLinesByFile, rootDir)
|
|
1345
|
+
addCoverageFilesToMap(getCoveredFilesFromCoverage(coverage), coveredLinesByFile, rootDir)
|
|
1346
|
+
addSkippedCoverageToMap(skippedCoverage, coveredLinesByFile)
|
|
1347
|
+
|
|
1348
|
+
let totalExecutableLines = 0
|
|
1349
|
+
let totalCoveredLines = 0
|
|
1350
|
+
|
|
1351
|
+
for (const [filename, executableLines] of executableLinesByFile) {
|
|
1352
|
+
totalExecutableLines += countBitmapBits(executableLines)
|
|
1353
|
+
totalCoveredLines += countCoveredExecutableBits(coveredLinesByFile.get(filename), executableLines)
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
return totalExecutableLines === 0 ? 0 : Math.floor((totalCoveredLines / totalExecutableLines) * 10_000) / 100
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
function isLineCoveredByBitmap (bitmap, line) {
|
|
1360
|
+
if (!Number.isSafeInteger(line) || line <= 0) return false
|
|
1361
|
+
|
|
1362
|
+
const byteIndex = line >> 3
|
|
1363
|
+
return byteIndex < bitmap.length && !!(bitmap[byteIndex] & (1 << (line % 8)))
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function getSkippedCoverageByFilename (skippedCoverage) {
|
|
1367
|
+
const skippedCoverageByFilename = new Map()
|
|
1368
|
+
addSkippedCoverageToMap(skippedCoverage, skippedCoverageByFilename)
|
|
1369
|
+
return skippedCoverageByFilename
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
function applySkippedCoverageToFileCoverage (fileCoverage, skippedBitmap) {
|
|
1373
|
+
let updated = false
|
|
1374
|
+
for (const [statementId, statementLocation] of Object.entries(fileCoverage.data.statementMap)) {
|
|
1375
|
+
const startLine = statementLocation?.start?.line
|
|
1376
|
+
if (!isLineCoveredByBitmap(skippedBitmap, startLine)) continue
|
|
1377
|
+
if (fileCoverage.data.s[statementId] > 0) continue
|
|
1378
|
+
|
|
1379
|
+
fileCoverage.data.s[statementId] = 1
|
|
1380
|
+
updated = true
|
|
1381
|
+
}
|
|
1382
|
+
return updated
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Applies backend skipped-suite coverage to an Istanbul coverage map.
|
|
1387
|
+
* @param {object} coverage
|
|
1388
|
+
* @param {object} skippedCoverage
|
|
1389
|
+
* @param {string} [rootDir]
|
|
1390
|
+
* @returns {boolean}
|
|
1391
|
+
*/
|
|
1392
|
+
function applySkippedCoverageToCoverage (coverage, skippedCoverage, rootDir) {
|
|
1393
|
+
if (!hasSkippedCoverage(skippedCoverage)) return false
|
|
1394
|
+
|
|
1395
|
+
const coverageMap = getCoverageMap(coverage)
|
|
1396
|
+
const skippedCoverageByFilename = getSkippedCoverageByFilename(skippedCoverage)
|
|
1397
|
+
let matched = false
|
|
1398
|
+
|
|
1399
|
+
for (const filename of coverageMap.files()) {
|
|
1400
|
+
const relativeFilename = rootDir ? getTestSuitePath(filename, rootDir) : filename
|
|
1401
|
+
const skippedBitmap = skippedCoverageByFilename.get(relativeFilename)
|
|
1402
|
+
if (!skippedBitmap) continue
|
|
1403
|
+
|
|
1404
|
+
const fileCoverage = coverageMap.fileCoverageFor(filename)
|
|
1405
|
+
applySkippedCoverageToFileCoverage(fileCoverage, skippedBitmap)
|
|
1406
|
+
matched = true
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
return matched
|
|
797
1410
|
}
|
|
798
1411
|
|
|
799
1412
|
function resetCoverage (coverage) {
|
|
@@ -801,7 +1414,6 @@ function resetCoverage (coverage) {
|
|
|
801
1414
|
|
|
802
1415
|
return coverageMap
|
|
803
1416
|
.files()
|
|
804
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
805
1417
|
.forEach(filename => {
|
|
806
1418
|
const fileCoverage = coverageMap.fileCoverageFor(filename)
|
|
807
1419
|
fileCoverage.resetHits()
|
|
@@ -812,7 +1424,6 @@ function mergeCoverage (coverage, targetCoverage) {
|
|
|
812
1424
|
const coverageMap = istanbul.createCoverageMap(coverage)
|
|
813
1425
|
return coverageMap
|
|
814
1426
|
.files()
|
|
815
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
816
1427
|
.forEach(filename => {
|
|
817
1428
|
const fileCoverage = coverageMap.fileCoverageFor(filename)
|
|
818
1429
|
|
|
@@ -895,17 +1506,11 @@ function parseAnnotations (annotations) {
|
|
|
895
1506
|
* Returns 0 when the test is too slow to retry (≥ 5 min).
|
|
896
1507
|
*
|
|
897
1508
|
* @param {number} durationMs
|
|
898
|
-
* @param {Record<string, number>} slowTestRetries
|
|
1509
|
+
* @param {Record<string, number>} slowTestRetries e.g. { '5s': 10, '10s': 5, '30s': 3, '5m': 2 }
|
|
899
1510
|
* @returns {number}
|
|
900
1511
|
*/
|
|
901
1512
|
function getEfdRetryCount (durationMs, slowTestRetries) {
|
|
902
|
-
const
|
|
903
|
-
{ limitMs: 5 * 1000, key: '5s' },
|
|
904
|
-
{ limitMs: 10 * 1000, key: '10s' },
|
|
905
|
-
{ limitMs: 30 * 1000, key: '30s' },
|
|
906
|
-
{ limitMs: 5 * 60 * 1000, key: '5m' },
|
|
907
|
-
]
|
|
908
|
-
for (const { limitMs, key } of thresholds) {
|
|
1513
|
+
for (const { limitMs, key } of EARLY_FLAKE_DETECTION_RETRY_THRESHOLDS) {
|
|
909
1514
|
if (durationMs < limitMs) {
|
|
910
1515
|
return slowTestRetries[key] ?? 0
|
|
911
1516
|
}
|
|
@@ -913,6 +1518,27 @@ function getEfdRetryCount (durationMs, slowTestRetries) {
|
|
|
913
1518
|
return 0 // ≥ 5 min — abort
|
|
914
1519
|
}
|
|
915
1520
|
|
|
1521
|
+
/**
|
|
1522
|
+
* Returns the maximum retry count configured by the backend for EFD.
|
|
1523
|
+
*
|
|
1524
|
+
* @param {Record<string, number> | undefined} slowTestRetries
|
|
1525
|
+
* @returns {number | undefined}
|
|
1526
|
+
*/
|
|
1527
|
+
function getMaxEfdRetryCount (slowTestRetries) {
|
|
1528
|
+
if (slowTestRetries === undefined) return
|
|
1529
|
+
|
|
1530
|
+
const retryCounts = Object.values(slowTestRetries)
|
|
1531
|
+
if (retryCounts.length === 0) return
|
|
1532
|
+
|
|
1533
|
+
let maxRetries = 0
|
|
1534
|
+
for (const retryCount of retryCounts) {
|
|
1535
|
+
if (retryCount > maxRetries) {
|
|
1536
|
+
maxRetries = retryCount
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return maxRetries
|
|
1540
|
+
}
|
|
1541
|
+
|
|
916
1542
|
function getIsFaultyEarlyFlakeDetection (projectSuites, testsBySuiteName, faultyThresholdPercentage) {
|
|
917
1543
|
let newSuites = 0
|
|
918
1544
|
for (const suite of projectSuites) {
|
|
@@ -932,8 +1558,8 @@ function getIsFaultyEarlyFlakeDetection (projectSuites, testsBySuiteName, faulty
|
|
|
932
1558
|
}
|
|
933
1559
|
|
|
934
1560
|
function getTestSessionName (config, trimmedCommand, envTags) {
|
|
935
|
-
if (config.
|
|
936
|
-
return config.
|
|
1561
|
+
if (config.DD_TEST_SESSION_NAME) {
|
|
1562
|
+
return config.DD_TEST_SESSION_NAME
|
|
937
1563
|
}
|
|
938
1564
|
const lageTestSessionName = getLageTestSessionName()
|
|
939
1565
|
if (lageTestSessionName) {
|
|
@@ -1052,7 +1678,7 @@ function isFailedTestReplaySupported (testFramework, frameworkVersion) {
|
|
|
1052
1678
|
: true
|
|
1053
1679
|
}
|
|
1054
1680
|
|
|
1055
|
-
function getLibraryCapabilitiesTags (testFramework, frameworkVersion) {
|
|
1681
|
+
function getLibraryCapabilitiesTags (testFramework, frameworkVersion, options = {}) {
|
|
1056
1682
|
return {
|
|
1057
1683
|
[DD_CAPABILITIES_TEST_IMPACT_ANALYSIS]: isTiaSupported(testFramework)
|
|
1058
1684
|
? '1'
|
|
@@ -1074,7 +1700,8 @@ function getLibraryCapabilitiesTags (testFramework, frameworkVersion) {
|
|
|
1074
1700
|
isAttemptToFixSupported(testFramework, frameworkVersion)
|
|
1075
1701
|
? '5'
|
|
1076
1702
|
: undefined,
|
|
1077
|
-
[DD_CAPABILITIES_FAILED_TEST_REPLAY]:
|
|
1703
|
+
[DD_CAPABILITIES_FAILED_TEST_REPLAY]: !options.omitFailedTestReplay &&
|
|
1704
|
+
isFailedTestReplaySupported(testFramework, frameworkVersion)
|
|
1078
1705
|
? '1'
|
|
1079
1706
|
: undefined,
|
|
1080
1707
|
}
|
|
@@ -1144,10 +1771,7 @@ function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
|
1144
1771
|
let bestScore = Infinity
|
|
1145
1772
|
for (const branch of Object.keys(metrics)) {
|
|
1146
1773
|
const score = metrics[branch].ahead
|
|
1147
|
-
if (score < bestScore) {
|
|
1148
|
-
bestScore = score
|
|
1149
|
-
bestBranch = branch
|
|
1150
|
-
} else if (score === bestScore && isDefaultBranch(branch)) {
|
|
1774
|
+
if (score < bestScore || score === bestScore && isDefaultBranch(branch)) {
|
|
1151
1775
|
bestScore = score
|
|
1152
1776
|
bestBranch = branch
|
|
1153
1777
|
}
|
|
@@ -1204,23 +1828,149 @@ function getModifiedFilesFromDiff (diff) {
|
|
|
1204
1828
|
}
|
|
1205
1829
|
|
|
1206
1830
|
/**
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1831
|
+
* @typedef {object} AttemptToFixExecutionResult
|
|
1832
|
+
* @property {string} name
|
|
1833
|
+
* @property {number} executions
|
|
1834
|
+
* @property {number} failedCount
|
|
1835
|
+
* @property {boolean} isDisabled
|
|
1836
|
+
* @property {boolean} isQuarantined
|
|
1837
|
+
*/
|
|
1838
|
+
|
|
1839
|
+
/**
|
|
1840
|
+
* @typedef {Map<string, AttemptToFixExecutionResult>} AttemptToFixExecutions
|
|
1841
|
+
*/
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Formats a test name for user-facing Test Optimization summaries.
|
|
1845
|
+
*
|
|
1846
|
+
* @param {string | undefined} testSuite
|
|
1847
|
+
* @param {string} testName
|
|
1848
|
+
* @returns {string}
|
|
1849
|
+
*/
|
|
1850
|
+
function formatTestOptimizationName (testSuite, testName) {
|
|
1851
|
+
return testSuite ? `${testSuite} › ${testName}` : testName
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* Renders a bounded bullet list for Test Optimization summaries.
|
|
1856
|
+
*
|
|
1857
|
+
* @param {Array<{ text: string, suffix?: string }>} items
|
|
1858
|
+
* @returns {string}
|
|
1859
|
+
*/
|
|
1860
|
+
function formatTestOptimizationList (items) {
|
|
1861
|
+
const shown = items.slice(0, MAX_TEST_OPTIMIZATION_SUMMARY_ITEMS)
|
|
1862
|
+
const more = items.length - shown.length
|
|
1863
|
+
const moreSuffix = more > 0 ? `\n ... and ${more} more` : ''
|
|
1864
|
+
|
|
1865
|
+
return shown.map(({ text, suffix }) => ` • ${text}${suffix ? ` (${suffix})` : ''}`).join('\n') + moreSuffix
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* Logs a compact message when an attempt-to-fix test execution starts.
|
|
1870
|
+
*
|
|
1871
|
+
* @param {string | undefined} testSuite
|
|
1872
|
+
* @param {string} testName
|
|
1873
|
+
* @param {Set<string>} [loggedAttemptToFixTests]
|
|
1874
|
+
*/
|
|
1875
|
+
function logAttemptToFixTestExecution (testSuite, testName, loggedAttemptToFixTests) {
|
|
1876
|
+
if (!testName) return
|
|
1877
|
+
|
|
1878
|
+
const name = formatTestOptimizationName(testSuite, testName)
|
|
1879
|
+
if (loggedAttemptToFixTests) {
|
|
1880
|
+
if (loggedAttemptToFixTests.has(name)) return
|
|
1881
|
+
|
|
1882
|
+
loggedAttemptToFixTests.add(name)
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// eslint-disable-next-line no-console -- Intentional user-facing attempt-to-fix progress report
|
|
1886
|
+
console.warn(`Datadog Test Optimization: attempting to fix ${name}`)
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* Records a single attempt-to-fix execution for the end-of-session user summary.
|
|
1891
|
+
*
|
|
1892
|
+
* @param {AttemptToFixExecutions} attemptToFixExecutions
|
|
1893
|
+
* @param {{
|
|
1894
|
+
* testSuite?: string,
|
|
1895
|
+
* testName: string,
|
|
1896
|
+
* status: string,
|
|
1897
|
+
* isDisabled?: boolean,
|
|
1898
|
+
* isQuarantined?: boolean
|
|
1899
|
+
* }} execution
|
|
1900
|
+
*/
|
|
1901
|
+
function recordAttemptToFixExecution (attemptToFixExecutions, execution) {
|
|
1902
|
+
if (!execution?.testName) return
|
|
1903
|
+
|
|
1904
|
+
const { testSuite, testName, status, isDisabled, isQuarantined } = execution
|
|
1905
|
+
const name = formatTestOptimizationName(testSuite, testName)
|
|
1906
|
+
let result = attemptToFixExecutions.get(name)
|
|
1907
|
+
|
|
1908
|
+
if (!result) {
|
|
1909
|
+
result = {
|
|
1910
|
+
name,
|
|
1911
|
+
executions: 0,
|
|
1912
|
+
failedCount: 0,
|
|
1913
|
+
isDisabled: false,
|
|
1914
|
+
isQuarantined: false,
|
|
1915
|
+
}
|
|
1916
|
+
attemptToFixExecutions.set(name, result)
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
result.executions++
|
|
1920
|
+
result.isDisabled = result.isDisabled || !!isDisabled
|
|
1921
|
+
result.isQuarantined = result.isQuarantined || !!isQuarantined
|
|
1922
|
+
|
|
1923
|
+
if (status === 'fail') {
|
|
1924
|
+
result.failedCount++
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
function collectDynamicNameFromTraceSpan (span, newTestsWithDynamicNames) {
|
|
1929
|
+
const meta = span.meta
|
|
1930
|
+
if (meta?.[TEST_HAS_DYNAMIC_NAME] !== 'true') return
|
|
1931
|
+
|
|
1932
|
+
const suite = meta[TEST_SUITE]
|
|
1933
|
+
const name = meta[TEST_NAME]
|
|
1934
|
+
if (suite && name) {
|
|
1935
|
+
newTestsWithDynamicNames.add(`${suite} › ${name}`)
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
function collectAttemptToFixExecutionFromTraceSpan (span, attemptToFixExecutions) {
|
|
1940
|
+
const meta = span.meta
|
|
1941
|
+
if (meta?.[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] !== 'true') return
|
|
1942
|
+
|
|
1943
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
1944
|
+
testSuite: meta[TEST_SUITE],
|
|
1945
|
+
testName: meta[TEST_NAME],
|
|
1946
|
+
status: meta[TEST_STATUS],
|
|
1947
|
+
isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true',
|
|
1948
|
+
isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true',
|
|
1949
|
+
})
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* Scans serialized worker trace payloads and populates Test Optimization summary data.
|
|
1954
|
+
* Silently ignores parse errors.
|
|
1209
1955
|
*
|
|
1210
1956
|
* @param {string} data - JSON-serialized traces from a worker
|
|
1211
|
-
* @param {
|
|
1957
|
+
* @param {{
|
|
1958
|
+
* newTestsWithDynamicNames?: Set<string>,
|
|
1959
|
+
* attemptToFixExecutions?: AttemptToFixExecutions
|
|
1960
|
+
* }} summaries
|
|
1212
1961
|
*/
|
|
1213
|
-
function
|
|
1962
|
+
function collectTestOptimizationSummariesFromTraces (data, summaries) {
|
|
1963
|
+
const { newTestsWithDynamicNames, attemptToFixExecutions } = summaries
|
|
1964
|
+
|
|
1214
1965
|
try {
|
|
1215
1966
|
const traces = JSON.parse(data)
|
|
1216
1967
|
for (const trace of traces) {
|
|
1217
1968
|
for (const span of trace) {
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1969
|
+
if (newTestsWithDynamicNames) {
|
|
1970
|
+
collectDynamicNameFromTraceSpan(span, newTestsWithDynamicNames)
|
|
1971
|
+
}
|
|
1972
|
+
if (attemptToFixExecutions) {
|
|
1973
|
+
collectAttemptToFixExecutionFromTraceSpan(span, attemptToFixExecutions)
|
|
1224
1974
|
}
|
|
1225
1975
|
}
|
|
1226
1976
|
}
|
|
@@ -1230,33 +1980,164 @@ function collectDynamicNamesFromTraces (data, newTestsWithDynamicNames) {
|
|
|
1230
1980
|
}
|
|
1231
1981
|
|
|
1232
1982
|
/**
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1983
|
+
* Scans serialized worker trace payloads for tests tagged with TEST_HAS_DYNAMIC_NAME
|
|
1984
|
+
* and populates the provided Set. Silently ignores parse errors.
|
|
1235
1985
|
*
|
|
1236
|
-
* @param {
|
|
1986
|
+
* @param {string} data - JSON-serialized traces from a worker
|
|
1987
|
+
* @param {Set<string>} newTestsWithDynamicNames - Set to populate with "suite › name" strings
|
|
1237
1988
|
*/
|
|
1238
|
-
function
|
|
1239
|
-
|
|
1989
|
+
function collectDynamicNamesFromTraces (data, newTestsWithDynamicNames) {
|
|
1990
|
+
collectTestOptimizationSummariesFromTraces(data, { newTestsWithDynamicNames })
|
|
1991
|
+
}
|
|
1240
1992
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1993
|
+
/**
|
|
1994
|
+
* Scans serialized worker trace payloads for attempt-to-fix test spans.
|
|
1995
|
+
*
|
|
1996
|
+
* @param {string} data - JSON-serialized traces from a worker
|
|
1997
|
+
* @param {AttemptToFixExecutions} attemptToFixExecutions
|
|
1998
|
+
*/
|
|
1999
|
+
function collectAttemptToFixExecutionsFromTraces (data, attemptToFixExecutions) {
|
|
2000
|
+
collectTestOptimizationSummariesFromTraces(data, { attemptToFixExecutions })
|
|
2001
|
+
}
|
|
1247
2002
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
2003
|
+
function getAttemptToFixManagementNotes (result) {
|
|
2004
|
+
const notes = []
|
|
2005
|
+
|
|
2006
|
+
if (result.isDisabled) {
|
|
2007
|
+
notes.push('Test was marked as disabled but was run because it is attempt to fix.')
|
|
2008
|
+
}
|
|
2009
|
+
if (result.isQuarantined) {
|
|
2010
|
+
notes.push('Test was marked as quarantined but was not quarantined because it is attempt to fix.')
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
return notes
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
function hasAttemptToFixManagementNotes (result) {
|
|
2017
|
+
return result.isDisabled || result.isQuarantined
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
function addAttemptToFixResultLine (lines, result) {
|
|
2021
|
+
lines.push(` • ${result.name}`)
|
|
2022
|
+
|
|
2023
|
+
for (const note of getAttemptToFixManagementNotes(result)) {
|
|
2024
|
+
lines.push(` ${note}`)
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Formats the attempt-to-fix end-of-session summary.
|
|
2030
|
+
*
|
|
2031
|
+
* @param {AttemptToFixExecutions} attemptToFixExecutions
|
|
2032
|
+
* @returns {string}
|
|
2033
|
+
*/
|
|
2034
|
+
function formatAttemptToFixSummary (attemptToFixExecutions) {
|
|
2035
|
+
if (attemptToFixExecutions.size === 0) return ''
|
|
2036
|
+
|
|
2037
|
+
const results = [...attemptToFixExecutions.values()]
|
|
2038
|
+
const failedResults = results.filter(result => result.failedCount > 0)
|
|
2039
|
+
const totalExecutions = results.reduce((total, result) => total + result.executions, 0)
|
|
2040
|
+
|
|
2041
|
+
if (failedResults.length === 0) {
|
|
2042
|
+
const lines = [
|
|
2043
|
+
`Attempt to fix passed: all ${totalExecutions} execution(s) passed for ${results.length} test(s).`,
|
|
2044
|
+
]
|
|
2045
|
+
|
|
2046
|
+
for (const result of results) {
|
|
2047
|
+
if (hasAttemptToFixManagementNotes(result)) {
|
|
2048
|
+
addAttemptToFixResultLine(lines, result)
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
return lines.join('\n')
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
const totalFailedExecutions = failedResults.reduce(
|
|
2056
|
+
(total, result) => total + result.failedCount,
|
|
2057
|
+
0
|
|
2058
|
+
)
|
|
2059
|
+
const lines = [
|
|
2060
|
+
`Attempt to fix failed: ${totalFailedExecutions} of ${totalExecutions} execution(s) failed ` +
|
|
2061
|
+
`across ${failedResults.length} of ${results.length} test(s).`,
|
|
2062
|
+
]
|
|
2063
|
+
|
|
2064
|
+
for (const result of failedResults) {
|
|
2065
|
+
addAttemptToFixResultLine(lines, result)
|
|
2066
|
+
}
|
|
2067
|
+
for (const result of results) {
|
|
2068
|
+
if (result.failedCount === 0 && hasAttemptToFixManagementNotes(result)) {
|
|
2069
|
+
addAttemptToFixResultLine(lines, result)
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
return lines.join('\n')
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* Formats the dynamic-name warning section of the Test Optimization summary.
|
|
2078
|
+
*
|
|
2079
|
+
* @param {Set<string>} newTestsWithDynamicNames
|
|
2080
|
+
* @returns {string}
|
|
2081
|
+
*/
|
|
2082
|
+
function formatDynamicNamesSummary (newTestsWithDynamicNames) {
|
|
2083
|
+
if (newTestsWithDynamicNames.size === 0) return ''
|
|
2084
|
+
|
|
2085
|
+
const items = [...newTestsWithDynamicNames].map(name => ({ text: name }))
|
|
2086
|
+
return (
|
|
1252
2087
|
`${newTestsWithDynamicNames.size} test(s) detected as new but their names contain ` +
|
|
1253
2088
|
'dynamic data (timestamps, UUIDs, etc.).\n' +
|
|
1254
2089
|
'Tests with changing names are always treated as new on every run, ' +
|
|
1255
2090
|
'causing unnecessary Early Flake Detection retries and preventing correct new test detection.\n' +
|
|
1256
2091
|
'Consider using stable, deterministic test names.\n\n' +
|
|
1257
|
-
|
|
2092
|
+
formatTestOptimizationList(items)
|
|
1258
2093
|
)
|
|
1259
|
-
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* Logs a single Test Optimization session summary.
|
|
2098
|
+
*
|
|
2099
|
+
* @param {{
|
|
2100
|
+
* attemptToFixExecutions?: AttemptToFixExecutions,
|
|
2101
|
+
* newTestsWithDynamicNames?: Set<string>,
|
|
2102
|
+
* extraSections?: string[]
|
|
2103
|
+
* }} summary
|
|
2104
|
+
*/
|
|
2105
|
+
function logTestOptimizationSummary (summary) {
|
|
2106
|
+
const { attemptToFixExecutions, newTestsWithDynamicNames, extraSections = [] } = summary
|
|
2107
|
+
const sections = []
|
|
2108
|
+
const attemptToFixSummary = attemptToFixExecutions
|
|
2109
|
+
? formatAttemptToFixSummary(attemptToFixExecutions)
|
|
2110
|
+
: ''
|
|
2111
|
+
const dynamicNamesSummary = newTestsWithDynamicNames
|
|
2112
|
+
? formatDynamicNamesSummary(newTestsWithDynamicNames)
|
|
2113
|
+
: ''
|
|
2114
|
+
|
|
2115
|
+
if (attemptToFixSummary) sections.push(attemptToFixSummary)
|
|
2116
|
+
sections.push(...extraSections.filter(Boolean))
|
|
2117
|
+
if (dynamicNamesSummary) sections.push(dynamicNamesSummary)
|
|
2118
|
+
|
|
2119
|
+
if (sections.length === 0) return
|
|
2120
|
+
|
|
2121
|
+
const line = '-'.repeat(50)
|
|
2122
|
+
// eslint-disable-next-line no-console -- Intentional user-facing session summary
|
|
2123
|
+
console.warn(`\n${line}\nDatadog Test Optimization\n${line}\n${sections.join('\n\n')}\n`)
|
|
2124
|
+
|
|
2125
|
+
if (attemptToFixExecutions) {
|
|
2126
|
+
attemptToFixExecutions.clear()
|
|
2127
|
+
}
|
|
2128
|
+
if (newTestsWithDynamicNames) {
|
|
2129
|
+
newTestsWithDynamicNames.clear()
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/**
|
|
2134
|
+
* Logs a "Datadog Test Optimization" warning about new tests with dynamic names.
|
|
2135
|
+
* Clears the Set after logging. No-op if the Set is empty.
|
|
2136
|
+
*
|
|
2137
|
+
* @param {Set<string>} newTestsWithDynamicNames
|
|
2138
|
+
*/
|
|
2139
|
+
function logDynamicNamesWarning (newTestsWithDynamicNames) {
|
|
2140
|
+
logTestOptimizationSummary({ newTestsWithDynamicNames })
|
|
1260
2141
|
}
|
|
1261
2142
|
|
|
1262
2143
|
function isModifiedTest (testPath, testStartLine, testEndLine, modifiedFiles, testFramework) {
|