dd-trace 5.53.0 → 5.54.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/index.d.ts +33 -16
- package/initialize.mjs +3 -4
- package/package.json +36 -34
- 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 +5 -4
- package/packages/datadog-instrumentations/src/child_process.js +1 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +88 -73
- package/packages/datadog-instrumentations/src/couchbase.js +3 -3
- package/packages/datadog-instrumentations/src/cucumber.js +87 -40
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +28 -34
- 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/helpers/extract-package-and-module-path.js +16 -10
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- 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 +5 -7
- package/packages/datadog-instrumentations/src/http/client.js +14 -20
- package/packages/datadog-instrumentations/src/jest.js +137 -48
- package/packages/datadog-instrumentations/src/kafkajs.js +52 -44
- package/packages/datadog-instrumentations/src/knex.js +4 -4
- package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
- package/packages/datadog-instrumentations/src/mariadb.js +38 -61
- package/packages/datadog-instrumentations/src/mocha/main.js +63 -24
- 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/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +20 -36
- 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 +1 -1
- package/packages/datadog-instrumentations/src/openai.js +21 -23
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +1 -2
- package/packages/datadog-instrumentations/src/playwright.js +112 -69
- package/packages/datadog-instrumentations/src/redis.js +3 -3
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/rhea.js +42 -54
- package/packages/datadog-instrumentations/src/router.js +22 -25
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +77 -28
- 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-aws-sdk/src/base.js +3 -2
- 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/dynamodb.js +24 -31
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +6 -6
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -5
- 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 +57 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +97 -27
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
- package/packages/datadog-plugin-cypress/src/support.js +24 -5
- 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 +26 -9
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/index.js +7 -6
- package/packages/datadog-plugin-graphql/src/resolve.js +2 -2
- 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 +18 -7
- package/packages/datadog-plugin-http2/src/client.js +20 -20
- package/packages/datadog-plugin-jest/src/index.js +23 -21
- 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 +33 -13
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +11 -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 +6 -5
- package/packages/datadog-plugin-openai/src/services.js +6 -10
- package/packages/datadog-plugin-openai/src/tracing.js +10 -14
- package/packages/datadog-plugin-oracledb/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +22 -2
- package/packages/datadog-plugin-redis/src/index.js +1 -1
- 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 +47 -31
- 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/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +4 -6
- 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 +4 -6
- 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 +6 -13
- 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 +1 -7
- 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 +5 -7
- 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 +6 -6
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -1
- 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 -24
- 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/vulnerability-reporter.js +9 -11
- package/packages/dd-trace/src/appsec/index.js +1 -1
- 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 +233 -40
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- 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 +2 -2
- package/packages/dd-trace/src/azure_metadata.js +2 -7
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
- 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 +2 -2
- 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 +1 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -1
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +8 -5
- 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 +1 -1
- package/packages/dd-trace/src/config.js +82 -51
- package/packages/dd-trace/src/config_stable.js +3 -3
- package/packages/dd-trace/src/datastreams/encoding.js +9 -9
- package/packages/dd-trace/src/datastreams/fnv.js +1 -1
- 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 +1 -1
- 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 +74 -67
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +6 -8
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +7 -1
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +8 -10
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +3 -3
- 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/dogstatsd.js +5 -4
- package/packages/dd-trace/src/encode/0.4.js +9 -9
- package/packages/dd-trace/src/encode/0.5.js +1 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +3 -3
- 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 +6 -6
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
- package/packages/dd-trace/src/exporters/common/docker.js +1 -1
- package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/common/util.js +1 -1
- 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 +12 -6
- package/packages/dd-trace/src/iitm.js +10 -22
- package/packages/dd-trace/src/lambda/handler.js +6 -6
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
- 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/index.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +2 -2
- package/packages/dd-trace/src/llmobs/tagger.js +110 -96
- 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 +4 -4
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/log/writer.js +2 -2
- package/packages/dd-trace/src/msgpack/chunk.js +3 -3
- package/packages/dd-trace/src/msgpack/encoder.js +28 -28
- package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
- package/packages/dd-trace/src/noop/span.js +3 -5
- 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 +6 -5
- package/packages/dd-trace/src/opentracing/propagation/log.js +6 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +27 -23
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
- package/packages/dd-trace/src/opentracing/span.js +9 -14
- package/packages/dd-trace/src/opentracing/tracer.js +9 -6
- 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/plugins/ci_plugin.js +62 -10
- 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 +23 -15
- package/packages/dd-trace/src/plugins/util/git.js +165 -11
- 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 +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +311 -48
- 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 +12 -3
- package/packages/dd-trace/src/plugins/util/web.js +5 -4
- package/packages/dd-trace/src/priority_sampler.js +22 -22
- package/packages/dd-trace/src/profiling/config.js +44 -8
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +5 -5
- package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +37 -2
- 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/tagger.js +3 -5
- package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
- package/packages/dd-trace/src/proxy.js +7 -9
- 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 +4 -4
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +2 -2
- package/packages/dd-trace/src/sampler.js +33 -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/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 +3 -3
- package/packages/dd-trace/src/span_sampler.js +4 -1
- package/packages/dd-trace/src/standalone/tracesource.js +1 -1
- package/packages/dd-trace/src/startup-log.js +2 -2
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- 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 +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +23 -24
- package/packages/dd-trace/src/util.js +1 -1
- 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
|
@@ -4,46 +4,34 @@ const { channel, addHook, AsyncResource } = require('./helpers/instrument')
|
|
|
4
4
|
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
6
6
|
|
|
7
|
+
const commandAddCh = channel('apm:mariadb:command:add')
|
|
7
8
|
const startCh = channel('apm:mariadb:query:start')
|
|
8
9
|
const finishCh = channel('apm:mariadb:query:finish')
|
|
9
10
|
const errorCh = channel('apm:mariadb:query:error')
|
|
10
11
|
const skipCh = channel('apm:mariadb:pool:skip')
|
|
11
|
-
const unskipCh = channel('apm:mariadb:pool:unskip')
|
|
12
12
|
|
|
13
|
-
function wrapCommandStart (start,
|
|
13
|
+
function wrapCommandStart (start, ctx) {
|
|
14
14
|
return shimmer.wrapFunction(start, start => function () {
|
|
15
15
|
if (!startCh.hasSubscribers) return start.apply(this, arguments)
|
|
16
16
|
|
|
17
|
-
const resolve =
|
|
18
|
-
const reject = callbackResource.bind(this.reject)
|
|
19
|
-
|
|
20
|
-
const asyncResource = callbackResource.runInAsyncScope(() => new AsyncResource('bound-anonymous-fn'))
|
|
21
|
-
|
|
17
|
+
const { reject, resolve } = this
|
|
22
18
|
shimmer.wrap(this, 'resolve', function wrapResolve () {
|
|
23
19
|
return function () {
|
|
24
|
-
|
|
25
|
-
finishCh.publish()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return resolve.apply(this, arguments)
|
|
20
|
+
return finishCh.runStores(ctx, resolve, this, ...arguments)
|
|
29
21
|
}
|
|
30
22
|
})
|
|
31
23
|
|
|
32
24
|
shimmer.wrap(this, 'reject', function wrapReject () {
|
|
33
25
|
return function (error) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
26
|
+
ctx.error = error
|
|
27
|
+
|
|
28
|
+
errorCh.publish(ctx)
|
|
38
29
|
|
|
39
|
-
return
|
|
30
|
+
return finishCh.runStores(ctx, reject, this, ...arguments)
|
|
40
31
|
}
|
|
41
32
|
})
|
|
42
33
|
|
|
43
|
-
return
|
|
44
|
-
startCh.publish({ sql: this.sql, conf: this.opts })
|
|
45
|
-
return start.apply(this, arguments)
|
|
46
|
-
})
|
|
34
|
+
return startCh.runStores(ctx, start, this, ...arguments)
|
|
47
35
|
})
|
|
48
36
|
}
|
|
49
37
|
|
|
@@ -52,11 +40,13 @@ function wrapCommand (Command) {
|
|
|
52
40
|
constructor (...args) {
|
|
53
41
|
super(...args)
|
|
54
42
|
|
|
55
|
-
|
|
43
|
+
if (!this.start) return
|
|
56
44
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
const ctx = { sql: this.sql, conf: this.opts }
|
|
46
|
+
|
|
47
|
+
commandAddCh.publish(ctx)
|
|
48
|
+
|
|
49
|
+
this.start = wrapCommandStart(this.start, ctx)
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
52
|
}
|
|
@@ -66,21 +56,19 @@ function createWrapQuery (options) {
|
|
|
66
56
|
return function (sql) {
|
|
67
57
|
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
68
58
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
}, 'bound-anonymous-fn')
|
|
59
|
+
const ctx = { sql, conf: options }
|
|
60
|
+
|
|
61
|
+
return startCh.runStores(ctx, query, this, ...arguments)
|
|
62
|
+
.then(result => {
|
|
63
|
+
ctx.result = result
|
|
64
|
+
finishCh.publish(ctx)
|
|
65
|
+
return result
|
|
66
|
+
}, error => {
|
|
67
|
+
ctx.error
|
|
68
|
+
errorCh.publish(ctx)
|
|
69
|
+
finishCh.publish(ctx)
|
|
70
|
+
throw error
|
|
71
|
+
})
|
|
84
72
|
}
|
|
85
73
|
}
|
|
86
74
|
}
|
|
@@ -91,30 +79,24 @@ function createWrapQueryCallback (options) {
|
|
|
91
79
|
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
92
80
|
|
|
93
81
|
const cb = arguments[arguments.length - 1]
|
|
94
|
-
const
|
|
95
|
-
const callbackResource = new AsyncResource('bound-anonymous-fn')
|
|
82
|
+
const ctx = { sql, conf: options }
|
|
96
83
|
|
|
97
84
|
if (typeof cb !== 'function') {
|
|
98
85
|
arguments.length = arguments.length + 1
|
|
99
86
|
}
|
|
100
87
|
|
|
101
|
-
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb =>
|
|
88
|
+
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function (err) {
|
|
102
89
|
if (err) {
|
|
103
|
-
|
|
90
|
+
ctx.error = err
|
|
91
|
+
errorCh.publish(ctx)
|
|
104
92
|
}
|
|
105
93
|
|
|
106
|
-
|
|
94
|
+
return typeof cb === 'function'
|
|
95
|
+
? finishCh.runStores(ctx, cb, this, ...arguments)
|
|
96
|
+
: finishCh.publish(ctx)
|
|
97
|
+
})
|
|
107
98
|
|
|
108
|
-
|
|
109
|
-
return callbackResource.runInAsyncScope(() => cb.apply(this, arguments))
|
|
110
|
-
}
|
|
111
|
-
}))
|
|
112
|
-
|
|
113
|
-
return asyncResource.runInAsyncScope(() => {
|
|
114
|
-
startCh.publish({ sql, conf: options })
|
|
115
|
-
|
|
116
|
-
return query.apply(this, arguments)
|
|
117
|
-
}, 'bound-anonymous-fn')
|
|
99
|
+
return startCh.runStores(ctx, query, this, ...arguments)
|
|
118
100
|
}
|
|
119
101
|
}
|
|
120
102
|
}
|
|
@@ -144,12 +126,7 @@ function wrapPoolBase (PoolBase) {
|
|
|
144
126
|
// and/or orphan spans.
|
|
145
127
|
function wrapPoolMethod (createConnection) {
|
|
146
128
|
return function () {
|
|
147
|
-
skipCh.
|
|
148
|
-
try {
|
|
149
|
-
return createConnection.apply(this, arguments)
|
|
150
|
-
} finally {
|
|
151
|
-
unskipCh.publish()
|
|
152
|
-
}
|
|
129
|
+
return skipCh.runStores({}, createConnection, this, ...arguments)
|
|
153
130
|
}
|
|
154
131
|
}
|
|
155
132
|
|
|
@@ -66,6 +66,7 @@ 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
68
|
const testManagementTestsCh = channel('ci:mocha:test-management-tests')
|
|
69
|
+
const impactedTestsCh = channel('ci:mocha:modified-tests')
|
|
69
70
|
const workerReportTraceCh = channel('ci:mocha:worker-report:trace')
|
|
70
71
|
const testSessionStartCh = channel('ci:mocha:session:start')
|
|
71
72
|
const testSessionFinishCh = channel('ci:mocha:session:finish')
|
|
@@ -175,7 +176,7 @@ function getOnEndHandler (isParallel) {
|
|
|
175
176
|
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
176
177
|
}
|
|
177
178
|
testCodeCoverageLinesTotal = originalCoverageMap.getCoverageSummary().lines.pct
|
|
178
|
-
} catch
|
|
179
|
+
} catch {
|
|
179
180
|
// ignore errors
|
|
180
181
|
}
|
|
181
182
|
// restore the original coverage
|
|
@@ -209,6 +210,26 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
209
210
|
} else {
|
|
210
211
|
config.testManagementTests = receivedTestManagementTests
|
|
211
212
|
}
|
|
213
|
+
if (config.isImpactedTestsEnabled) {
|
|
214
|
+
impactedTestsCh.publish({
|
|
215
|
+
onDone: mochaRunAsyncResource.bind(onReceivedImpactedTests)
|
|
216
|
+
})
|
|
217
|
+
} else if (config.isSuitesSkippingEnabled) {
|
|
218
|
+
skippableSuitesCh.publish({
|
|
219
|
+
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
220
|
+
})
|
|
221
|
+
} else {
|
|
222
|
+
onFinishRequest()
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const onReceivedImpactedTests = ({ err, modifiedTests: receivedModifiedTests }) => {
|
|
227
|
+
if (err) {
|
|
228
|
+
config.modifiedTests = []
|
|
229
|
+
config.isImpactedTestsEnabled = false
|
|
230
|
+
} else {
|
|
231
|
+
config.modifiedTests = receivedModifiedTests
|
|
232
|
+
}
|
|
212
233
|
if (config.isSuitesSkippingEnabled) {
|
|
213
234
|
skippableSuitesCh.publish({
|
|
214
235
|
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
@@ -237,7 +258,7 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
237
258
|
|
|
238
259
|
runner.suite.suites = suitesToRun
|
|
239
260
|
|
|
240
|
-
skippedSuites =
|
|
261
|
+
skippedSuites = [...filteredSuites.skippedSuites]
|
|
241
262
|
|
|
242
263
|
onFinishRequest()
|
|
243
264
|
}
|
|
@@ -254,6 +275,10 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
254
275
|
testManagementTestsCh.publish({
|
|
255
276
|
onDone: mochaRunAsyncResource.bind(onReceivedTestManagementTests)
|
|
256
277
|
})
|
|
278
|
+
} if (config.isImpactedTestsEnabled) {
|
|
279
|
+
impactedTestsCh.publish({
|
|
280
|
+
onDone: mochaRunAsyncResource.bind(onReceivedImpactedTests)
|
|
281
|
+
})
|
|
257
282
|
} else if (config.isSuitesSkippingEnabled) {
|
|
258
283
|
skippableSuitesCh.publish({
|
|
259
284
|
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
@@ -274,6 +299,7 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
274
299
|
config.isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
275
300
|
config.isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
276
301
|
config.testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
302
|
+
config.isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
277
303
|
// ITR and auto test retries are not supported in parallel mode yet
|
|
278
304
|
config.isSuitesSkippingEnabled = !isParallel && libraryConfig.isSuitesSkippingEnabled
|
|
279
305
|
config.isFlakyTestRetriesEnabled = !isParallel && libraryConfig.isFlakyTestRetriesEnabled
|
|
@@ -287,6 +313,10 @@ function getExecutionConfiguration (runner, isParallel, onFinishRequest) {
|
|
|
287
313
|
testManagementTestsCh.publish({
|
|
288
314
|
onDone: mochaRunAsyncResource.bind(onReceivedTestManagementTests)
|
|
289
315
|
})
|
|
316
|
+
} else if (config.isImpactedTestsEnabled) {
|
|
317
|
+
impactedTestsCh.publish({
|
|
318
|
+
onDone: mochaRunAsyncResource.bind(onReceivedImpactedTests)
|
|
319
|
+
})
|
|
290
320
|
} else if (config.isSuitesSkippingEnabled) {
|
|
291
321
|
skippableSuitesCh.publish({
|
|
292
322
|
onDone: mochaRunAsyncResource.bind(onReceivedSkippableSuites)
|
|
@@ -441,7 +471,7 @@ addHook({
|
|
|
441
471
|
itrCorrelationId
|
|
442
472
|
}
|
|
443
473
|
testFileToSuiteCtx.set(suite.file, ctx)
|
|
444
|
-
testSuiteStartCh.runStores(ctx, () => {
|
|
474
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
445
475
|
}
|
|
446
476
|
})
|
|
447
477
|
|
|
@@ -485,7 +515,7 @@ addHook({
|
|
|
485
515
|
|
|
486
516
|
const ctx = testFileToSuiteCtx.get(suite.file)
|
|
487
517
|
if (ctx) {
|
|
488
|
-
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {
|
|
518
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
489
519
|
} else {
|
|
490
520
|
log.warn(() => `No AsyncResource found for suite ${suite.file}`)
|
|
491
521
|
}
|
|
@@ -505,6 +535,15 @@ addHook({
|
|
|
505
535
|
file: 'lib/runnable.js'
|
|
506
536
|
}, (runnablePackage) => runnableWrapper(runnablePackage, config))
|
|
507
537
|
|
|
538
|
+
function onMessage (message) {
|
|
539
|
+
if (Array.isArray(message)) {
|
|
540
|
+
const [messageCode, payload] = message
|
|
541
|
+
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
542
|
+
workerReportTraceCh.publish(payload)
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
508
547
|
// Only used in parallel mode (--parallel flag is passed)
|
|
509
548
|
// Used to generate suite events and receive test payloads from workers
|
|
510
549
|
addHook({
|
|
@@ -523,42 +562,33 @@ addHook({
|
|
|
523
562
|
return exec.apply(this, arguments)
|
|
524
563
|
}
|
|
525
564
|
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
|
-
}
|
|
565
|
+
const testSuiteContext = {}
|
|
536
566
|
|
|
537
567
|
this.worker.on('message', onMessage)
|
|
538
568
|
|
|
539
569
|
testSuiteContext.testSuiteAbsolutePath = testSuiteAbsolutePath
|
|
540
|
-
testSuiteStartCh.runStores(testSuiteContext, () => {
|
|
570
|
+
testSuiteStartCh.runStores(testSuiteContext, () => {})
|
|
541
571
|
|
|
542
572
|
try {
|
|
543
573
|
const promise = exec.apply(this, arguments)
|
|
544
574
|
promise.then(
|
|
545
575
|
(result) => {
|
|
546
576
|
const status = result.failureCount === 0 ? 'pass' : 'fail'
|
|
547
|
-
testSuiteFinishCh.publish({ status, ...testSuiteContext.currentStore }, () => {
|
|
577
|
+
testSuiteFinishCh.publish({ status, ...testSuiteContext.currentStore }, () => {})
|
|
548
578
|
this.worker.off('message', onMessage)
|
|
549
579
|
},
|
|
550
580
|
(err) => {
|
|
551
581
|
testSuiteContext.error = err
|
|
552
|
-
testSuiteErrorCh.runStores(testSuiteContext, () => {
|
|
553
|
-
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {
|
|
582
|
+
testSuiteErrorCh.runStores(testSuiteContext, () => {})
|
|
583
|
+
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {})
|
|
554
584
|
this.worker.off('message', onMessage)
|
|
555
585
|
}
|
|
556
586
|
)
|
|
557
587
|
return promise
|
|
558
588
|
} catch (err) {
|
|
559
589
|
testSuiteContext.error = err
|
|
560
|
-
testSuiteErrorCh.runStores(testSuiteContext, () => {
|
|
561
|
-
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {
|
|
590
|
+
testSuiteErrorCh.runStores(testSuiteContext, () => {})
|
|
591
|
+
testSuiteFinishCh.publish({ status: 'fail', ...testSuiteContext.currentStore }, () => {})
|
|
562
592
|
this.worker.off('message', onMessage)
|
|
563
593
|
throw err
|
|
564
594
|
}
|
|
@@ -616,7 +646,10 @@ addHook({
|
|
|
616
646
|
const { BufferedWorkerPool } = BufferedWorkerPoolPackage
|
|
617
647
|
|
|
618
648
|
shimmer.wrap(BufferedWorkerPool.prototype, 'run', run => async function (testSuiteAbsolutePath, workerArgs) {
|
|
619
|
-
if (!testFinishCh.hasSubscribers ||
|
|
649
|
+
if (!testFinishCh.hasSubscribers ||
|
|
650
|
+
(!config.isKnownTestsEnabled &&
|
|
651
|
+
!config.isTestManagementTestsEnabled &&
|
|
652
|
+
!config.isImpactedTestsEnabled)) {
|
|
620
653
|
return run.apply(this, arguments)
|
|
621
654
|
}
|
|
622
655
|
|
|
@@ -649,6 +682,12 @@ addHook({
|
|
|
649
682
|
}
|
|
650
683
|
}
|
|
651
684
|
|
|
685
|
+
if (config.isImpactedTestsEnabled) {
|
|
686
|
+
const testSuiteImpactedTests = config.modifiedTests || {}
|
|
687
|
+
newWorkerArgs._ddIsImpactedTestsEnabled = true
|
|
688
|
+
newWorkerArgs._ddModifiedTests = testSuiteImpactedTests
|
|
689
|
+
}
|
|
690
|
+
|
|
652
691
|
// We pass the known tests for the test file to the worker
|
|
653
692
|
const testFileResult = await run.apply(
|
|
654
693
|
this,
|
|
@@ -669,10 +708,10 @@ addHook({
|
|
|
669
708
|
const testFullName = getTestFullName(test)
|
|
670
709
|
const tests = newTests[testFullName]
|
|
671
710
|
|
|
672
|
-
if (
|
|
673
|
-
newTests[testFullName] = [test]
|
|
674
|
-
} else {
|
|
711
|
+
if (tests) {
|
|
675
712
|
tests.push(test)
|
|
713
|
+
} else {
|
|
714
|
+
newTests[testFullName] = [test]
|
|
676
715
|
}
|
|
677
716
|
}
|
|
678
717
|
// `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, AsyncResource } = 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
|
}
|
|
@@ -79,22 +70,15 @@ addHook({ name: 'mysql', file: 'lib/Pool.js', versions: ['>=2'] }, Pool => {
|
|
|
79
70
|
return query.apply(this, arguments)
|
|
80
71
|
}
|
|
81
72
|
|
|
82
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
83
|
-
|
|
84
73
|
const sql = arguments[0].sql || arguments[0]
|
|
74
|
+
const ctx = { sql }
|
|
75
|
+
const finish = () => finishPoolQueryCh.publish(ctx)
|
|
85
76
|
|
|
86
|
-
return
|
|
87
|
-
startPoolQueryCh.publish({ sql })
|
|
88
|
-
|
|
89
|
-
const finish = asyncResource.bind(function () {
|
|
90
|
-
finishPoolQueryCh.publish()
|
|
91
|
-
})
|
|
92
|
-
|
|
77
|
+
return startPoolQueryCh.runStores(ctx, () => {
|
|
93
78
|
const cb = arguments[arguments.length - 1]
|
|
94
79
|
if (typeof cb === 'function') {
|
|
95
80
|
arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function () {
|
|
96
|
-
|
|
97
|
-
return cb.apply(this, arguments)
|
|
81
|
+
return finishPoolQueryCh.runStores(ctx, cb, this, ...arguments)
|
|
98
82
|
})
|
|
99
83
|
}
|
|
100
84
|
|