dd-trace 5.53.0 → 5.55.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 +2 -1
- package/ci/cypress/plugin.js +8 -0
- package/ci/cypress/polyfills.js +23 -0
- package/ci/init.js +8 -7
- package/index.d.ts +33 -16
- package/initialize.mjs +5 -6
- package/package.json +40 -38
- package/packages/datadog-code-origin/index.js +22 -4
- package/packages/datadog-core/src/utils/src/get.js +1 -1
- package/packages/datadog-core/src/utils/src/has.js +1 -1
- package/packages/datadog-core/src/utils/src/kebabcase.js +4 -6
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-core/src/utils/src/pick.js +2 -2
- package/packages/datadog-core/src/utils/src/set.js +1 -1
- package/packages/datadog-core/src/utils/src/uniq.js +1 -1
- package/packages/datadog-instrumentations/src/amqp10.js +19 -17
- package/packages/datadog-instrumentations/src/amqplib.js +52 -35
- package/packages/datadog-instrumentations/src/apollo.js +2 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +10 -10
- package/packages/datadog-instrumentations/src/child_process.js +1 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +89 -75
- package/packages/datadog-instrumentations/src/cookie-parser.js +1 -1
- package/packages/datadog-instrumentations/src/couchbase.js +6 -9
- package/packages/datadog-instrumentations/src/cucumber.js +108 -68
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +5 -5
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -10
- package/packages/datadog-instrumentations/src/fastify.js +7 -9
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +35 -43
- package/packages/datadog-instrumentations/src/graphql.js +7 -10
- package/packages/datadog-instrumentations/src/grpc/client.js +11 -23
- package/packages/datadog-instrumentations/src/grpc/server.js +7 -20
- package/packages/datadog-instrumentations/src/hapi.js +10 -11
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +16 -10
- package/packages/datadog-instrumentations/src/helpers/fetch.js +4 -5
- package/packages/datadog-instrumentations/src/helpers/hook.js +2 -3
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
- package/packages/datadog-instrumentations/src/helpers/register.js +11 -12
- package/packages/datadog-instrumentations/src/http/client.js +14 -20
- package/packages/datadog-instrumentations/src/jest.js +201 -143
- package/packages/datadog-instrumentations/src/kafkajs.js +52 -44
- package/packages/datadog-instrumentations/src/knex.js +4 -4
- package/packages/datadog-instrumentations/src/koa.js +2 -3
- package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
- package/packages/datadog-instrumentations/src/mariadb.js +49 -65
- package/packages/datadog-instrumentations/src/mocha/main.js +116 -73
- package/packages/datadog-instrumentations/src/mocha/utils.js +36 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +6 -0
- package/packages/datadog-instrumentations/src/mocha.js +3 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +30 -37
- package/packages/datadog-instrumentations/src/mysql2.js +53 -47
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -0
- package/packages/datadog-instrumentations/src/nyc.js +3 -2
- package/packages/datadog-instrumentations/src/openai.js +22 -24
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +4 -3
- package/packages/datadog-instrumentations/src/pg.js +3 -5
- package/packages/datadog-instrumentations/src/playwright.js +123 -83
- package/packages/datadog-instrumentations/src/protobufjs.js +3 -4
- package/packages/datadog-instrumentations/src/redis.js +4 -4
- package/packages/datadog-instrumentations/src/restify.js +9 -13
- package/packages/datadog-instrumentations/src/rhea.js +42 -54
- package/packages/datadog-instrumentations/src/router.js +30 -32
- package/packages/datadog-instrumentations/src/tedious.js +2 -3
- package/packages/datadog-instrumentations/src/vitest.js +87 -52
- package/packages/datadog-plugin-amqp10/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqp10/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/client.js +6 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/util.js +1 -1
- package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -6
- package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -3
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +12 -12
- package/packages/datadog-plugin-aws-sdk/src/base.js +15 -10
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +13 -13
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +28 -43
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +10 -11
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +4 -6
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -3
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +11 -15
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +5 -6
- package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
- package/packages/datadog-plugin-child_process/src/index.js +4 -4
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +23 -23
- package/packages/datadog-plugin-cucumber/src/index.js +60 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +99 -28
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
- package/packages/datadog-plugin-cypress/src/support.js +24 -5
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-express/src/code_origin.js +30 -0
- package/packages/datadog-plugin-express/src/index.js +10 -12
- package/packages/datadog-plugin-express/src/tracing.js +19 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +7 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +12 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +6 -2
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +27 -10
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/index.js +10 -8
- package/packages/datadog-plugin-graphql/src/resolve.js +19 -12
- package/packages/datadog-plugin-graphql/src/tools/index.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-grpc/src/client.js +2 -2
- package/packages/datadog-plugin-grpc/src/util.js +2 -2
- package/packages/datadog-plugin-http/src/client.js +23 -13
- package/packages/datadog-plugin-http2/src/client.js +24 -25
- package/packages/datadog-plugin-jest/src/index.js +26 -23
- package/packages/datadog-plugin-jest/src/util.js +8 -8
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +3 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -5
- package/packages/datadog-plugin-kafkajs/src/producer.js +8 -3
- package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +7 -7
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -2
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +6 -4
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +5 -4
- package/packages/datadog-plugin-langchain/src/tracing.js +11 -10
- package/packages/datadog-plugin-mariadb/src/index.js +3 -9
- package/packages/datadog-plugin-mocha/src/index.js +39 -14
- package/packages/datadog-plugin-mongodb-core/src/index.js +3 -2
- package/packages/datadog-plugin-mysql/src/index.js +22 -9
- package/packages/datadog-plugin-mysql2/src/index.js +16 -0
- package/packages/datadog-plugin-net/src/tcp.js +1 -1
- package/packages/datadog-plugin-next/src/index.js +7 -6
- package/packages/datadog-plugin-openai/src/services.js +6 -10
- package/packages/datadog-plugin-openai/src/tracing.js +12 -18
- package/packages/datadog-plugin-oracledb/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +25 -4
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +8 -9
- package/packages/datadog-plugin-redis/src/index.js +2 -4
- package/packages/datadog-plugin-rhea/src/consumer.js +8 -6
- package/packages/datadog-plugin-rhea/src/producer.js +5 -2
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/datadog-plugin-selenium/src/index.js +1 -6
- package/packages/datadog-plugin-vitest/src/index.js +52 -35
- package/packages/datadog-shimmer/src/shimmer.js +4 -8
- package/packages/dd-trace/src/appsec/api_security_sampler.js +2 -2
- package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
- package/packages/dd-trace/src/appsec/blocking.js +6 -20
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +7 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +5 -8
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +9 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +5 -4
- package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +2 -3
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +102 -7
- package/packages/dd-trace/src/appsec/iast/path-line.js +7 -8
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +16 -24
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +6 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +4 -28
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -8
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +3 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +7 -8
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +7 -7
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +2 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +10 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +7 -7
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +23 -28
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +6 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +0 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +9 -11
- package/packages/dd-trace/src/appsec/index.js +5 -5
- package/packages/dd-trace/src/appsec/rasp/index.js +15 -15
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
- package/packages/dd-trace/src/appsec/reporter.js +232 -41
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -3
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- package/packages/dd-trace/src/appsec/telemetry/index.js +31 -1
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -5
- package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -5
- package/packages/dd-trace/src/appsec/user_tracking.js +3 -5
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +8 -4
- package/packages/dd-trace/src/azure_metadata.js +9 -9
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +9 -8
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +6 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +6 -5
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +7 -6
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +0 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +3 -2
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +5 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +12 -8
- package/packages/dd-trace/src/ci-visibility/telemetry.js +4 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +3 -2
- package/packages/dd-trace/src/config-helper.js +89 -0
- package/packages/dd-trace/src/config.js +159 -129
- package/packages/dd-trace/src/config_stable.js +10 -7
- package/packages/dd-trace/src/datastreams/encoding.js +9 -9
- package/packages/dd-trace/src/datastreams/fnv.js +2 -2
- package/packages/dd-trace/src/datastreams/pathway.js +4 -4
- package/packages/dd-trace/src/datastreams/processor.js +5 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +7 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +4 -6
- package/packages/dd-trace/src/datastreams/size.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +75 -69
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +7 -10
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +9 -2
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/send.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +11 -14
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +4 -4
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +2 -10
- package/packages/dd-trace/src/debugger/devtools_client/state.js +10 -3
- package/packages/dd-trace/src/debugger/index.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +7 -6
- package/packages/dd-trace/src/encode/0.4.js +14 -11
- package/packages/dd-trace/src/encode/0.5.js +4 -6
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +8 -8
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/tags-processors.js +1 -1
- package/packages/dd-trace/src/exporter.js +7 -6
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
- package/packages/dd-trace/src/exporters/common/docker.js +4 -3
- package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
- package/packages/dd-trace/src/exporters/common/request.js +5 -2
- package/packages/dd-trace/src/exporters/common/util.js +4 -2
- package/packages/dd-trace/src/external-logger/src/index.js +5 -5
- package/packages/dd-trace/src/flare/file.js +1 -5
- package/packages/dd-trace/src/format.js +1 -1
- package/packages/dd-trace/src/git_properties.js +1 -1
- package/packages/dd-trace/src/id.js +15 -9
- package/packages/dd-trace/src/iitm.js +10 -22
- package/packages/dd-trace/src/index.js +4 -3
- package/packages/dd-trace/src/lambda/handler.js +7 -6
- package/packages/dd-trace/src/lambda/index.js +2 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +7 -6
- package/packages/dd-trace/src/lambda/runtime/ritm.js +4 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +21 -5
- package/packages/dd-trace/src/llmobs/noop.js +18 -20
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +2 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +11 -13
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/openai.js +2 -3
- package/packages/dd-trace/src/llmobs/sdk.js +4 -3
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +129 -102
- package/packages/dd-trace/src/llmobs/util.js +9 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -1
- package/packages/dd-trace/src/log/index.js +9 -8
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/log/writer.js +3 -4
- package/packages/dd-trace/src/msgpack/chunk.js +3 -3
- package/packages/dd-trace/src/msgpack/encoder.js +31 -31
- package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
- package/packages/dd-trace/src/noop/span.js +4 -6
- package/packages/dd-trace/src/noop/tracer.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span_processor.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +7 -6
- package/packages/dd-trace/src/opentracing/propagation/log.js +10 -13
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +40 -37
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
- package/packages/dd-trace/src/opentracing/span.js +16 -20
- package/packages/dd-trace/src/opentracing/tracer.js +9 -6
- package/packages/dd-trace/src/payload-tagging/config/index.js +17 -21
- package/packages/dd-trace/src/payload-tagging/index.js +1 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +6 -6
- package/packages/dd-trace/src/pkg.js +1 -1
- package/packages/dd-trace/src/plugin_manager.js +4 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +87 -11
- package/packages/dd-trace/src/plugins/consumer.js +2 -2
- package/packages/dd-trace/src/plugins/inbound.js +5 -1
- package/packages/dd-trace/src/plugins/index.js +0 -1
- package/packages/dd-trace/src/plugins/outbound.js +4 -5
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +2 -2
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/util/ci.js +28 -20
- package/packages/dd-trace/src/plugins/util/git.js +166 -12
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -1
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +27 -10
- package/packages/dd-trace/src/plugins/util/stacktrace.js +9 -2
- package/packages/dd-trace/src/plugins/util/test.js +315 -51
- package/packages/dd-trace/src/plugins/util/url.js +1 -1
- package/packages/dd-trace/src/plugins/util/urlfilter.js +13 -17
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +14 -4
- package/packages/dd-trace/src/plugins/util/web.js +8 -8
- package/packages/dd-trace/src/priority_sampler.js +64 -53
- package/packages/dd-trace/src/profiling/config.js +51 -35
- package/packages/dd-trace/src/profiling/exporter_cli.js +20 -20
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +7 -6
- package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
- package/packages/dd-trace/src/profiling/index.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +44 -6
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -17
- package/packages/dd-trace/src/profiling/profilers/shared.js +6 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +6 -7
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -5
- package/packages/dd-trace/src/profiling/ssi-telemetry-mock-profiler.js +3 -1
- package/packages/dd-trace/src/profiling/tagger.js +21 -13
- package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
- package/packages/dd-trace/src/proxy.js +9 -10
- package/packages/dd-trace/src/random_sampler.js +40 -0
- package/packages/dd-trace/src/rate_limiter.js +4 -4
- package/packages/dd-trace/src/remote_config/index.js +3 -7
- package/packages/dd-trace/src/remote_config/manager.js +25 -13
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +8 -8
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +5 -4
- package/packages/dd-trace/src/sampler.js +41 -4
- package/packages/dd-trace/src/sampling_rule.js +12 -3
- package/packages/dd-trace/src/scope.js +1 -1
- package/packages/dd-trace/src/serverless.js +11 -4
- package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
- package/packages/dd-trace/src/span_processor.js +5 -4
- package/packages/dd-trace/src/span_sampler.js +4 -1
- package/packages/dd-trace/src/standalone/tracesource.js +2 -3
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +1 -2
- package/packages/dd-trace/src/startup-log.js +6 -18
- package/packages/dd-trace/src/supported-configurations.json +439 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +64 -59
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +9 -10
- package/packages/dd-trace/src/telemetry/metrics.js +10 -5
- package/packages/dd-trace/src/telemetry/send-data.js +8 -7
- package/packages/dd-trace/src/telemetry/telemetry.js +31 -45
- package/packages/dd-trace/src/tracer.js +3 -7
- package/packages/dd-trace/src/util.js +1 -6
- package/version.js +1 -0
- package/packages/datadog-instrumentations/src/paperplane.js +0 -77
- package/packages/datadog-plugin-paperplane/src/index.js +0 -25
- package/packages/datadog-plugin-paperplane/src/logger.js +0 -11
- package/packages/datadog-plugin-paperplane/src/server.js +0 -24
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +0 -122
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +0 -20
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('../helpers/instrument')
|
|
5
5
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
6
|
const { isMarkedAsUnskippable } = require('../../../datadog-plugin-jest/src/util')
|
|
7
7
|
const log = require('../../../dd-trace/src/log')
|
|
8
|
+
const { getEnvironmentVariable } = require('../../../dd-trace/src/config-helper')
|
|
8
9
|
const {
|
|
9
10
|
getTestSuitePath,
|
|
10
11
|
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
|
|
@@ -37,7 +38,6 @@ const {
|
|
|
37
38
|
|
|
38
39
|
require('./common')
|
|
39
40
|
|
|
40
|
-
const testSessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
41
41
|
const patched = new WeakSet()
|
|
42
42
|
|
|
43
43
|
const unskippableSuites = []
|
|
@@ -65,7 +65,10 @@ const testSuiteCodeCoverageCh = channel('ci:mocha:test-suite:code-coverage')
|
|
|
65
65
|
const libraryConfigurationCh = channel('ci:mocha:library-configuration')
|
|
66
66
|
const knownTestsCh = channel('ci:mocha:known-tests')
|
|
67
67
|
const skippableSuitesCh = channel('ci:mocha:test-suite:skippable')
|
|
68
|
+
const mochaGlobalRunCh = channel('ci:mocha:global:run')
|
|
69
|
+
|
|
68
70
|
const testManagementTestsCh = channel('ci:mocha:test-management-tests')
|
|
71
|
+
const impactedTestsCh = channel('ci:mocha:modified-tests')
|
|
69
72
|
const workerReportTraceCh = channel('ci:mocha:worker-report:trace')
|
|
70
73
|
const testSessionStartCh = channel('ci:mocha:session:start')
|
|
71
74
|
const testSessionFinishCh = channel('ci:mocha:session:finish')
|
|
@@ -99,18 +102,18 @@ function getFilteredSuites (originalSuites) {
|
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
function getOnStartHandler (isParallel, frameworkVersion) {
|
|
102
|
-
return
|
|
105
|
+
return function () {
|
|
103
106
|
const processArgv = process.argv.slice(2).join(' ')
|
|
104
107
|
const command = `mocha ${processArgv}`
|
|
105
108
|
testSessionStartCh.publish({ command, frameworkVersion })
|
|
106
109
|
if (!isParallel && skippedSuites.length) {
|
|
107
110
|
itrSkippedSuitesCh.publish({ skippedSuites, frameworkVersion })
|
|
108
111
|
}
|
|
109
|
-
}
|
|
112
|
+
}
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
function getOnEndHandler (isParallel) {
|
|
113
|
-
return
|
|
116
|
+
return function () {
|
|
114
117
|
let status = 'pass'
|
|
115
118
|
let error
|
|
116
119
|
if (this.stats) {
|
|
@@ -175,7 +178,7 @@ function getOnEndHandler (isParallel) {
|
|
|
175
178
|
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
176
179
|
}
|
|
177
180
|
testCodeCoverageLinesTotal = originalCoverageMap.getCoverageSummary().lines.pct
|
|
178
|
-
} catch
|
|
181
|
+
} catch {
|
|
179
182
|
// ignore errors
|
|
180
183
|
}
|
|
181
184
|
// restore the original coverage
|
|
@@ -195,27 +198,12 @@ function getOnEndHandler (isParallel) {
|
|
|
195
198
|
isTestManagementEnabled: config.isTestManagementTestsEnabled,
|
|
196
199
|
isParallel
|
|
197
200
|
})
|
|
198
|
-
}
|
|
201
|
+
}
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const onReceivedTestManagementTests = ({ err, testManagementTests: receivedTestManagementTests }) => {
|
|
205
|
-
if (err) {
|
|
206
|
-
config.testManagementTests = {}
|
|
207
|
-
config.isTestManagementTestsEnabled = false
|
|
208
|
-
config.testManagementAttemptToFixRetries = 0
|
|
209
|
-
} else {
|
|
210
|
-
config.testManagementTests = receivedTestManagementTests
|
|
211
|
-
}
|
|
212
|
-
if (config.isSuitesSkippingEnabled) {
|
|
213
|
-
skippableSuitesCh.publish({
|
|
214
|
-
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
215
|
-
})
|
|
216
|
-
} else {
|
|
217
|
-
onFinishRequest()
|
|
218
|
-
}
|
|
205
|
+
const ctx = {
|
|
206
|
+
isParallel
|
|
219
207
|
}
|
|
220
208
|
|
|
221
209
|
const onReceivedSkippableSuites = ({ err, skippableSuites, itrCorrelationId: responseItrCorrelationId }) => {
|
|
@@ -237,9 +225,49 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
237
225
|
|
|
238
226
|
runner.suite.suites = suitesToRun
|
|
239
227
|
|
|
240
|
-
skippedSuites =
|
|
228
|
+
skippedSuites = [...filteredSuites.skippedSuites]
|
|
229
|
+
|
|
230
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
231
|
+
onFinishRequest()
|
|
232
|
+
})
|
|
233
|
+
}
|
|
241
234
|
|
|
242
|
-
|
|
235
|
+
const onReceivedImpactedTests = ({ err, modifiedTests: receivedModifiedTests }) => {
|
|
236
|
+
if (err) {
|
|
237
|
+
config.modifiedTests = []
|
|
238
|
+
config.isImpactedTestsEnabled = false
|
|
239
|
+
} else {
|
|
240
|
+
config.modifiedTests = receivedModifiedTests
|
|
241
|
+
}
|
|
242
|
+
if (config.isSuitesSkippingEnabled) {
|
|
243
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
244
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
245
|
+
} else {
|
|
246
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
247
|
+
onFinishRequest()
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const onReceivedTestManagementTests = ({ err, testManagementTests: receivedTestManagementTests }) => {
|
|
253
|
+
if (err) {
|
|
254
|
+
config.testManagementTests = {}
|
|
255
|
+
config.isTestManagementTestsEnabled = false
|
|
256
|
+
config.testManagementAttemptToFixRetries = 0
|
|
257
|
+
} else {
|
|
258
|
+
config.testManagementTests = receivedTestManagementTests
|
|
259
|
+
}
|
|
260
|
+
if (config.isImpactedTestsEnabled) {
|
|
261
|
+
ctx.onDone = onReceivedImpactedTests
|
|
262
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
263
|
+
} else if (config.isSuitesSkippingEnabled) {
|
|
264
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
265
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
266
|
+
} else {
|
|
267
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
268
|
+
onFinishRequest()
|
|
269
|
+
})
|
|
270
|
+
}
|
|
243
271
|
}
|
|
244
272
|
|
|
245
273
|
const onReceivedKnownTests = ({ err, knownTests }) => {
|
|
@@ -251,55 +279,61 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
251
279
|
config.knownTests = knownTests
|
|
252
280
|
}
|
|
253
281
|
if (config.isTestManagementTestsEnabled) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
282
|
+
ctx.onDone = onReceivedTestManagementTests
|
|
283
|
+
testManagementTestsCh.runStores(ctx, () => {})
|
|
284
|
+
} if (config.isImpactedTestsEnabled) {
|
|
285
|
+
ctx.onDone = onReceivedImpactedTests
|
|
286
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
257
287
|
} else if (config.isSuitesSkippingEnabled) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
})
|
|
288
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
289
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
261
290
|
} else {
|
|
262
|
-
|
|
291
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
292
|
+
onFinishRequest()
|
|
293
|
+
})
|
|
263
294
|
}
|
|
264
295
|
}
|
|
265
296
|
|
|
266
297
|
const onReceivedConfiguration = ({ err, libraryConfig }) => {
|
|
267
298
|
if (err || !skippableSuitesCh.hasSubscribers || !knownTestsCh.hasSubscribers) {
|
|
268
|
-
return
|
|
299
|
+
return mochaGlobalRunCh.runStores(ctx, () => {
|
|
300
|
+
onFinishRequest()
|
|
301
|
+
})
|
|
269
302
|
}
|
|
270
|
-
|
|
271
303
|
config.isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
272
304
|
config.earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
273
305
|
config.earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
274
306
|
config.isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
275
307
|
config.isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
276
308
|
config.testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
309
|
+
config.isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
277
310
|
// ITR and auto test retries are not supported in parallel mode yet
|
|
278
311
|
config.isSuitesSkippingEnabled = !isParallel && libraryConfig.isSuitesSkippingEnabled
|
|
279
312
|
config.isFlakyTestRetriesEnabled = !isParallel && libraryConfig.isFlakyTestRetriesEnabled
|
|
280
313
|
config.flakyTestRetriesCount = !isParallel && libraryConfig.flakyTestRetriesCount
|
|
281
314
|
|
|
282
315
|
if (config.isKnownTestsEnabled) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
})
|
|
316
|
+
ctx.onDone = onReceivedKnownTests
|
|
317
|
+
knownTestsCh.runStores(ctx, () => {})
|
|
286
318
|
} else if (config.isTestManagementTestsEnabled) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
319
|
+
ctx.onDone = onReceivedTestManagementTests
|
|
320
|
+
testManagementTestsCh.runStores(ctx, () => {})
|
|
321
|
+
} else if (config.isImpactedTestsEnabled) {
|
|
322
|
+
ctx.onDone = onReceivedImpactedTests
|
|
323
|
+
impactedTestsCh.runStores(ctx, () => {})
|
|
290
324
|
} else if (config.isSuitesSkippingEnabled) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
})
|
|
325
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
326
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
294
327
|
} else {
|
|
295
|
-
|
|
328
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
329
|
+
onFinishRequest()
|
|
330
|
+
})
|
|
296
331
|
}
|
|
297
332
|
}
|
|
298
333
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
})
|
|
334
|
+
ctx.onDone = onReceivedConfiguration
|
|
335
|
+
|
|
336
|
+
libraryConfigurationCh.runStores(ctx, () => {})
|
|
303
337
|
}
|
|
304
338
|
|
|
305
339
|
// In this hook we delay the execution with options.delay to grab library configuration,
|
|
@@ -312,7 +346,7 @@ addHook({
|
|
|
312
346
|
}, (Mocha) => {
|
|
313
347
|
shimmer.wrap(Mocha.prototype, 'run', run => function () {
|
|
314
348
|
// Workers do not need to request any data, just run the tests
|
|
315
|
-
if (!testFinishCh.hasSubscribers ||
|
|
349
|
+
if (!testFinishCh.hasSubscribers || getEnvironmentVariable('MOCHA_WORKER_ID') || this.options.parallel) {
|
|
316
350
|
return run.apply(this, arguments)
|
|
317
351
|
}
|
|
318
352
|
|
|
@@ -441,7 +475,7 @@ addHook({
|
|
|
441
475
|
itrCorrelationId
|
|
442
476
|
}
|
|
443
477
|
testFileToSuiteCtx.set(suite.file, ctx)
|
|
444
|
-
testSuiteStartCh.runStores(ctx, () => {
|
|
478
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
445
479
|
}
|
|
446
480
|
})
|
|
447
481
|
|
|
@@ -485,9 +519,9 @@ addHook({
|
|
|
485
519
|
|
|
486
520
|
const ctx = testFileToSuiteCtx.get(suite.file)
|
|
487
521
|
if (ctx) {
|
|
488
|
-
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {
|
|
522
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
489
523
|
} else {
|
|
490
|
-
log.warn(() => `No
|
|
524
|
+
log.warn(() => `No ctx found for suite ${suite.file}`)
|
|
491
525
|
}
|
|
492
526
|
})
|
|
493
527
|
|
|
@@ -505,6 +539,15 @@ addHook({
|
|
|
505
539
|
file: 'lib/runnable.js'
|
|
506
540
|
}, (runnablePackage) => runnableWrapper(runnablePackage, config))
|
|
507
541
|
|
|
542
|
+
function onMessage (message) {
|
|
543
|
+
if (Array.isArray(message)) {
|
|
544
|
+
const [messageCode, payload] = message
|
|
545
|
+
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
546
|
+
workerReportTraceCh.publish(payload)
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
508
551
|
// Only used in parallel mode (--parallel flag is passed)
|
|
509
552
|
// Used to generate suite events and receive test payloads from workers
|
|
510
553
|
addHook({
|
|
@@ -523,42 +566,33 @@ addHook({
|
|
|
523
566
|
return exec.apply(this, arguments)
|
|
524
567
|
}
|
|
525
568
|
const [testSuiteAbsolutePath] = path
|
|
526
|
-
const testSuiteContext = {
|
|
527
|
-
|
|
528
|
-
function onMessage (message) {
|
|
529
|
-
if (Array.isArray(message)) {
|
|
530
|
-
const [messageCode, payload] = message
|
|
531
|
-
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
532
|
-
workerReportTraceCh.publish(payload)
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
569
|
+
const testSuiteContext = {}
|
|
536
570
|
|
|
537
571
|
this.worker.on('message', onMessage)
|
|
538
572
|
|
|
539
573
|
testSuiteContext.testSuiteAbsolutePath = testSuiteAbsolutePath
|
|
540
|
-
testSuiteStartCh.runStores(testSuiteContext, () => {
|
|
574
|
+
testSuiteStartCh.runStores(testSuiteContext, () => {})
|
|
541
575
|
|
|
542
576
|
try {
|
|
543
577
|
const promise = exec.apply(this, arguments)
|
|
544
578
|
promise.then(
|
|
545
579
|
(result) => {
|
|
546
580
|
const status = result.failureCount === 0 ? 'pass' : 'fail'
|
|
547
|
-
testSuiteFinishCh.publish({ status, ...testSuiteContext.currentStore }, () => {
|
|
581
|
+
testSuiteFinishCh.publish({ status, ...testSuiteContext.currentStore }, () => {})
|
|
548
582
|
this.worker.off('message', onMessage)
|
|
549
583
|
},
|
|
550
584
|
(err) => {
|
|
551
585
|
testSuiteContext.error = err
|
|
552
|
-
testSuiteErrorCh.runStores(testSuiteContext, () => {
|
|
553
|
-
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {
|
|
586
|
+
testSuiteErrorCh.runStores(testSuiteContext, () => {})
|
|
587
|
+
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {})
|
|
554
588
|
this.worker.off('message', onMessage)
|
|
555
589
|
}
|
|
556
590
|
)
|
|
557
591
|
return promise
|
|
558
592
|
} catch (err) {
|
|
559
593
|
testSuiteContext.error = err
|
|
560
|
-
testSuiteErrorCh.runStores(testSuiteContext, () => {
|
|
561
|
-
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {
|
|
594
|
+
testSuiteErrorCh.runStores(testSuiteContext, () => {})
|
|
595
|
+
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {})
|
|
562
596
|
this.worker.off('message', onMessage)
|
|
563
597
|
throw err
|
|
564
598
|
}
|
|
@@ -616,7 +650,10 @@ addHook({
|
|
|
616
650
|
const { BufferedWorkerPool } = BufferedWorkerPoolPackage
|
|
617
651
|
|
|
618
652
|
shimmer.wrap(BufferedWorkerPool.prototype, 'run', run => async function (testSuiteAbsolutePath, workerArgs) {
|
|
619
|
-
if (!testFinishCh.hasSubscribers ||
|
|
653
|
+
if (!testFinishCh.hasSubscribers ||
|
|
654
|
+
(!config.isKnownTestsEnabled &&
|
|
655
|
+
!config.isTestManagementTestsEnabled &&
|
|
656
|
+
!config.isImpactedTestsEnabled)) {
|
|
620
657
|
return run.apply(this, arguments)
|
|
621
658
|
}
|
|
622
659
|
|
|
@@ -649,6 +686,12 @@ addHook({
|
|
|
649
686
|
}
|
|
650
687
|
}
|
|
651
688
|
|
|
689
|
+
if (config.isImpactedTestsEnabled) {
|
|
690
|
+
const testSuiteImpactedTests = config.modifiedTests || {}
|
|
691
|
+
newWorkerArgs._ddIsImpactedTestsEnabled = true
|
|
692
|
+
newWorkerArgs._ddModifiedTests = testSuiteImpactedTests
|
|
693
|
+
}
|
|
694
|
+
|
|
652
695
|
// We pass the known tests for the test file to the worker
|
|
653
696
|
const testFileResult = await run.apply(
|
|
654
697
|
this,
|
|
@@ -669,10 +712,10 @@ addHook({
|
|
|
669
712
|
const testFullName = getTestFullName(test)
|
|
670
713
|
const tests = newTests[testFullName]
|
|
671
714
|
|
|
672
|
-
if (
|
|
673
|
-
newTests[testFullName] = [test]
|
|
674
|
-
} else {
|
|
715
|
+
if (tests) {
|
|
675
716
|
tests.push(test)
|
|
717
|
+
} else {
|
|
718
|
+
newTests[testFullName] = [test]
|
|
676
719
|
}
|
|
677
720
|
}
|
|
678
721
|
// `testsQuarantined` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
@@ -18,7 +18,7 @@ const testRetryCh = channel('ci:mocha:test:retry')
|
|
|
18
18
|
const errorCh = channel('ci:mocha:test:error')
|
|
19
19
|
const skipCh = channel('ci:mocha:test:skip')
|
|
20
20
|
const testFnCh = channel('ci:mocha:test:fn')
|
|
21
|
-
|
|
21
|
+
const isModifiedCh = channel('ci:mocha:test:is-modified')
|
|
22
22
|
// suite channels
|
|
23
23
|
const testSuiteErrorCh = channel('ci:mocha:test-suite:error')
|
|
24
24
|
|
|
@@ -209,7 +209,8 @@ function getOnTestHandler (isMain) {
|
|
|
209
209
|
_ddIsEfdRetry: isEfdRetry,
|
|
210
210
|
_ddIsAttemptToFix: isAttemptToFix,
|
|
211
211
|
_ddIsDisabled: isDisabled,
|
|
212
|
-
_ddIsQuarantined: isQuarantined
|
|
212
|
+
_ddIsQuarantined: isQuarantined,
|
|
213
|
+
_ddIsModified: isModified
|
|
213
214
|
} = test
|
|
214
215
|
|
|
215
216
|
const testName = removeEfdStringFromTestName(removeAttemptToFixStringFromTestName(test.fullTitle()))
|
|
@@ -230,6 +231,7 @@ function getOnTestHandler (isMain) {
|
|
|
230
231
|
testInfo.isAttemptToFix = isAttemptToFix
|
|
231
232
|
testInfo.isDisabled = isDisabled
|
|
232
233
|
testInfo.isQuarantined = isQuarantined
|
|
234
|
+
testInfo.isModified = isModified
|
|
233
235
|
// We want to store the result of the new tests
|
|
234
236
|
if (isNew) {
|
|
235
237
|
const testFullName = getTestFullName(test)
|
|
@@ -246,7 +248,7 @@ function getOnTestHandler (isMain) {
|
|
|
246
248
|
|
|
247
249
|
const ctx = testInfo
|
|
248
250
|
testToContext.set(test.fn, ctx)
|
|
249
|
-
testStartCh.runStores(ctx, () => {
|
|
251
|
+
testStartCh.runStores(ctx, () => {})
|
|
250
252
|
}
|
|
251
253
|
}
|
|
252
254
|
|
|
@@ -271,17 +273,17 @@ function getOnTestEndHandler (config) {
|
|
|
271
273
|
|
|
272
274
|
const testName = getTestFullName(test)
|
|
273
275
|
|
|
274
|
-
if (
|
|
275
|
-
testsStatuses.set(testName, [status])
|
|
276
|
-
} else {
|
|
276
|
+
if (testsStatuses.get(testName)) {
|
|
277
277
|
testsStatuses.get(testName).push(status)
|
|
278
|
+
} else {
|
|
279
|
+
testsStatuses.set(testName, [status])
|
|
278
280
|
}
|
|
279
281
|
const testStatuses = testsStatuses.get(testName)
|
|
280
282
|
|
|
281
283
|
const isLastAttempt = testStatuses.length === config.testManagementAttemptToFixRetries + 1
|
|
282
284
|
|
|
283
285
|
if (test._ddIsAttemptToFix && isLastAttempt) {
|
|
284
|
-
if (testStatuses.
|
|
286
|
+
if (testStatuses.includes('fail')) {
|
|
285
287
|
attemptToFixFailed = true
|
|
286
288
|
}
|
|
287
289
|
if (testStatuses.every(status => status === 'fail')) {
|
|
@@ -351,12 +353,12 @@ function getOnFailHandler (isMain) {
|
|
|
351
353
|
if (isHook) {
|
|
352
354
|
err.message = `${testOrHook.fullTitle()}: ${err.message}`
|
|
353
355
|
testContext.err = err
|
|
354
|
-
errorCh.runStores(testContext, () => {
|
|
356
|
+
errorCh.runStores(testContext, () => {})
|
|
355
357
|
// if it's a hook and it has failed, 'test end' will not be called
|
|
356
358
|
testFinishCh.publish({ status: 'fail', hasBeenRetried: isMochaRetry(test), ...testContext.currentStore })
|
|
357
359
|
} else {
|
|
358
360
|
testContext.err = err
|
|
359
|
-
errorCh.runStores(testContext, () => {
|
|
361
|
+
errorCh.runStores(testContext, () => {})
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
|
|
@@ -370,7 +372,7 @@ function getOnFailHandler (isMain) {
|
|
|
370
372
|
)
|
|
371
373
|
testSuiteError.stack = err.stack
|
|
372
374
|
testSuiteContext.error = testSuiteError
|
|
373
|
-
testSuiteErrorCh.runStores(testSuiteContext, () => {
|
|
375
|
+
testSuiteErrorCh.runStores(testSuiteContext, () => {})
|
|
374
376
|
}
|
|
375
377
|
}
|
|
376
378
|
}
|
|
@@ -420,7 +422,7 @@ function getOnPendingHandler () {
|
|
|
420
422
|
} else {
|
|
421
423
|
testToContext.set(test, testCtx)
|
|
422
424
|
}
|
|
423
|
-
skipCh.runStores(testCtx, () => {
|
|
425
|
+
skipCh.runStores(testCtx, () => {})
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
}
|
|
@@ -452,12 +454,34 @@ function getRunTestsWrapper (runTests, config) {
|
|
|
452
454
|
})
|
|
453
455
|
}
|
|
454
456
|
|
|
457
|
+
if (config.isImpactedTestsEnabled) {
|
|
458
|
+
suite.tests.forEach((test) => {
|
|
459
|
+
isModifiedCh.publish({
|
|
460
|
+
modifiedTests: config.modifiedTests,
|
|
461
|
+
file: suite.file,
|
|
462
|
+
onDone: (isModified) => {
|
|
463
|
+
if (isModified) {
|
|
464
|
+
test._ddIsModified = true
|
|
465
|
+
if (!test.isPending() && !test._ddIsAttemptToFix && config.isEarlyFlakeDetectionEnabled) {
|
|
466
|
+
retryTest(
|
|
467
|
+
test,
|
|
468
|
+
config.earlyFlakeDetectionNumRetries,
|
|
469
|
+
addEfdStringToTestName,
|
|
470
|
+
['_ddIsModified', '_ddIsEfdRetry']
|
|
471
|
+
)
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
})
|
|
476
|
+
})
|
|
477
|
+
}
|
|
478
|
+
|
|
455
479
|
if (config.isKnownTestsEnabled) {
|
|
456
480
|
// by the time we reach `this.on('test')`, it is too late. We need to add retries here
|
|
457
481
|
suite.tests.forEach(test => {
|
|
458
482
|
if (!test.isPending() && isNewTest(test, config.knownTests)) {
|
|
459
483
|
test._ddIsNew = true
|
|
460
|
-
if (config.isEarlyFlakeDetectionEnabled) {
|
|
484
|
+
if (config.isEarlyFlakeDetectionEnabled && !test._ddIsAttemptToFix && !test._ddIsModified) {
|
|
461
485
|
retryTest(
|
|
462
486
|
test,
|
|
463
487
|
config.earlyFlakeDetectionNumRetries,
|
|
@@ -34,6 +34,12 @@ addHook({
|
|
|
34
34
|
delete this.options._ddEfdNumRetries
|
|
35
35
|
delete this.options._ddIsKnownTestsEnabled
|
|
36
36
|
}
|
|
37
|
+
if (this.options._ddIsImpactedTestsEnabled) {
|
|
38
|
+
config.isImpactedTestsEnabled = true
|
|
39
|
+
config.modifiedTests = this.options._ddModifiedTests
|
|
40
|
+
delete this.options._ddIsImpactedTestsEnabled
|
|
41
|
+
delete this.options._ddModifiedTests
|
|
42
|
+
}
|
|
37
43
|
if (this.options._ddIsTestManagementTestsEnabled) {
|
|
38
44
|
config.isTestManagementTestsEnabled = true
|
|
39
45
|
// TODO: attempt to fix does not work in parallel mode yet
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
channel,
|
|
5
|
-
addHook,
|
|
6
|
-
AsyncResource
|
|
7
|
-
} = require('./helpers/instrument')
|
|
3
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
8
4
|
const shimmer = require('../../datadog-shimmer')
|
|
9
5
|
|
|
10
6
|
addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connection => {
|
|
@@ -19,43 +15,38 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
|
|
|
19
15
|
|
|
20
16
|
const sql = arguments[0].sql || arguments[0]
|
|
21
17
|
const conf = this.config
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
25
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
26
|
-
|
|
27
|
-
return asyncResource.runInAsyncScope(() => {
|
|
28
|
-
startCh.publish(payload)
|
|
18
|
+
const ctx = { sql, conf }
|
|
29
19
|
|
|
20
|
+
return startCh.runStores(ctx, () => {
|
|
30
21
|
if (arguments[0].sql) {
|
|
31
|
-
arguments[0].sql =
|
|
22
|
+
arguments[0].sql = ctx.sql
|
|
32
23
|
} else {
|
|
33
|
-
arguments[0] =
|
|
24
|
+
arguments[0] = ctx.sql
|
|
34
25
|
}
|
|
26
|
+
|
|
35
27
|
try {
|
|
36
28
|
const res = query.apply(this, arguments)
|
|
37
29
|
|
|
38
30
|
if (res._callback) {
|
|
39
|
-
const cb =
|
|
40
|
-
res._callback = shimmer.wrapFunction(cb, cb =>
|
|
31
|
+
const cb = res._callback
|
|
32
|
+
res._callback = shimmer.wrapFunction(cb, cb => function (error, result) {
|
|
41
33
|
if (error) {
|
|
42
|
-
|
|
34
|
+
ctx.error = error
|
|
35
|
+
errorCh.publish(ctx)
|
|
43
36
|
}
|
|
44
|
-
|
|
37
|
+
ctx.result = result
|
|
45
38
|
|
|
46
|
-
return
|
|
47
|
-
}))
|
|
48
|
-
} else {
|
|
49
|
-
const cb = asyncResource.bind(function () {
|
|
50
|
-
finishCh.publish(undefined)
|
|
39
|
+
return finishCh.runStores(ctx, cb, this, error, result)
|
|
51
40
|
})
|
|
52
|
-
|
|
41
|
+
} else {
|
|
42
|
+
res.on('end', () => finishCh.publish(ctx))
|
|
53
43
|
}
|
|
54
44
|
|
|
55
45
|
return res
|
|
56
46
|
} catch (err) {
|
|
57
47
|
err.stack // trigger getting the stack at the original throwing point
|
|
58
|
-
|
|
48
|
+
ctx.error = err
|
|
49
|
+
errorCh.publish(ctx)
|
|
59
50
|
|
|
60
51
|
throw err
|
|
61
52
|
}
|
|
@@ -66,11 +57,20 @@ addHook({ name: 'mysql', file: 'lib/Connection.js', versions: ['>=2'] }, Connect
|
|
|
66
57
|
})
|
|
67
58
|
|
|
68
59
|
addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
|
|
60
|
+
const connectionStartCh = channel('apm:mysql:connection:start')
|
|
61
|
+
const connectionFinishCh = channel('apm:mysql:connection:finish')
|
|
69
62
|
const startPoolQueryCh = channel('datadog:mysql:pool:query:start')
|
|
70
63
|
const finishPoolQueryCh = channel('datadog:mysql:pool:query:finish')
|
|
71
64
|
|
|
72
65
|
shimmer.wrap(Pool.prototype, 'getConnection', getConnection => function (cb) {
|
|
73
|
-
arguments[0] =
|
|
66
|
+
arguments[0] = function () {
|
|
67
|
+
return connectionFinishCh.runStores(ctx, cb, this, ...arguments)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ctx = {}
|
|
71
|
+
|
|
72
|
+
connectionStartCh.publish(ctx)
|
|
73
|
+
|
|
74
74
|
return getConnection.apply(this, arguments)
|
|
75
75
|
})
|
|
76
76
|
|
|
@@ -79,22 +79,15 @@ addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
|
|
|
79
79
|
return query.apply(this, arguments)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
83
|
-
|
|
84
82
|
const sql = arguments[0].sql || arguments[0]
|
|
83
|
+
const ctx = { sql }
|
|
84
|
+
const finish = () => finishPoolQueryCh.publish(ctx)
|
|
85
85
|
|
|
86
|
-
return
|
|
87
|
-
startPoolQueryCh.publish({ sql })
|
|
88
|
-
|
|
89
|
-
const finish = asyncResource.bind(function () {
|
|
90
|
-
finishPoolQueryCh.publish()
|
|
91
|
-
})
|
|
92
|
-
|
|
86
|
+
return startPoolQueryCh.runStores(ctx, () => {
|
|
93
87
|
const cb = arguments[arguments.length - 1]
|
|
94
88
|
if (typeof cb === 'function') {
|
|
95
89
|
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function () {
|
|
96
|
-
|
|
97
|
-
return cb.apply(this, arguments)
|
|
90
|
+
return finishPoolQueryCh.runStores(ctx, cb, this, ...arguments)
|
|
98
91
|
})
|
|
99
92
|
}
|
|
100
93
|
|