dd-trace 5.52.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/README.md +5 -0
- package/index.d.ts +87 -22
- 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 +57 -37
- 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 +3 -3
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +92 -62
- package/packages/datadog-instrumentations/src/couchbase.js +5 -4
- package/packages/datadog-instrumentations/src/cucumber.js +126 -84
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +2 -6
- package/packages/datadog-instrumentations/src/fs.js +7 -6
- 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 +1 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
- package/packages/datadog-instrumentations/src/helpers/register.js +21 -18
- package/packages/datadog-instrumentations/src/http/client.js +16 -21
- package/packages/datadog-instrumentations/src/iovalkey.js +51 -0
- package/packages/datadog-instrumentations/src/jest.js +184 -87
- package/packages/datadog-instrumentations/src/kafkajs.js +65 -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 +85 -59
- package/packages/datadog-instrumentations/src/mocha/utils.js +103 -82
- 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 +55 -47
- package/packages/datadog-instrumentations/src/net.js +4 -2
- package/packages/datadog-instrumentations/src/next.js +7 -14
- 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 +6 -13
- package/packages/datadog-instrumentations/src/playwright.js +170 -136
- 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/url.js +9 -17
- package/packages/datadog-instrumentations/src/vitest.js +126 -97
- 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 +86 -20
- 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-iovalkey/src/index.js +18 -0
- package/packages/datadog-plugin-jest/src/index.js +36 -28
- 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 +15 -7
- 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 +88 -48
- 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 +48 -22
- package/packages/datadog-plugin-redis/src/index.js +9 -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 +99 -72
- package/packages/datadog-shimmer/src/shimmer.js +163 -36
- 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/graphql.js +2 -2
- 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 +15 -12
- package/packages/dd-trace/src/appsec/rasp/index.js +19 -17
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
- package/packages/dd-trace/src/appsec/rasp/utils.js +11 -6
- 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/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- package/packages/dd-trace/src/appsec/telemetry/index.js +1 -2
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -14
- 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 -8
- 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 +131 -72
- 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 +17 -27
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/send.js +8 -7
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +16 -8
- 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 +31 -4
- package/packages/dd-trace/src/dogstatsd.js +7 -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 +113 -99
- 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 +1 -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 -13
- 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/serverless.js +0 -48
- package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -0
- 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
|
@@ -28,7 +28,10 @@ const {
|
|
|
28
28
|
DI_DEBUG_ERROR_SNAPSHOT_ID_SUFFIX,
|
|
29
29
|
DI_DEBUG_ERROR_FILE_SUFFIX,
|
|
30
30
|
DI_DEBUG_ERROR_LINE_SUFFIX,
|
|
31
|
-
getLibraryCapabilitiesTags
|
|
31
|
+
getLibraryCapabilitiesTags,
|
|
32
|
+
getPullRequestDiff,
|
|
33
|
+
getModifiedTestsFromDiff,
|
|
34
|
+
getPullRequestBaseBranch
|
|
32
35
|
} = require('./util/test')
|
|
33
36
|
const Plugin = require('./plugin')
|
|
34
37
|
const { COMPONENT } = require('../constants')
|
|
@@ -45,10 +48,23 @@ const {
|
|
|
45
48
|
GIT_COMMIT_SHA,
|
|
46
49
|
GIT_BRANCH,
|
|
47
50
|
CI_WORKSPACE_PATH,
|
|
48
|
-
GIT_COMMIT_MESSAGE
|
|
51
|
+
GIT_COMMIT_MESSAGE,
|
|
52
|
+
GIT_TAG,
|
|
53
|
+
GIT_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
54
|
+
GIT_COMMIT_HEAD_SHA,
|
|
55
|
+
GIT_PULL_REQUEST_BASE_BRANCH
|
|
49
56
|
} = require('./util/tags')
|
|
50
57
|
const { OS_VERSION, OS_PLATFORM, OS_ARCHITECTURE, RUNTIME_NAME, RUNTIME_VERSION } = require('./util/env')
|
|
51
58
|
const getDiClient = require('../ci-visibility/dynamic-instrumentation')
|
|
59
|
+
const { DD_MAJOR } = require('../../../../version')
|
|
60
|
+
|
|
61
|
+
const FRAMEWORK_TO_TRIMMED_COMMAND = {
|
|
62
|
+
vitest: 'vitest run',
|
|
63
|
+
mocha: 'mocha',
|
|
64
|
+
cucumber: 'cucumber-js',
|
|
65
|
+
playwright: 'playwright test',
|
|
66
|
+
jest: 'jest'
|
|
67
|
+
}
|
|
52
68
|
|
|
53
69
|
module.exports = class CiPlugin extends Plugin {
|
|
54
70
|
constructor (...args) {
|
|
@@ -103,7 +119,11 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
103
119
|
// only for playwright
|
|
104
120
|
this.rootDir = rootDir
|
|
105
121
|
|
|
106
|
-
const testSessionName = getTestSessionName(
|
|
122
|
+
const testSessionName = getTestSessionName(
|
|
123
|
+
this.config,
|
|
124
|
+
DD_MAJOR < 6 ? this.command : FRAMEWORK_TO_TRIMMED_COMMAND[this.constructor.id],
|
|
125
|
+
this.testEnvironmentMetadata
|
|
126
|
+
)
|
|
107
127
|
|
|
108
128
|
const metadataTags = {}
|
|
109
129
|
for (const testLevel of TEST_LEVEL_EVENT_TYPES) {
|
|
@@ -194,6 +214,27 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
194
214
|
onDone({ err, testManagementTests })
|
|
195
215
|
})
|
|
196
216
|
})
|
|
217
|
+
|
|
218
|
+
this.addSub(`ci:${this.constructor.id}:modified-tests`, ({ onDone }) => {
|
|
219
|
+
const {
|
|
220
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: pullRequestBaseBranch,
|
|
221
|
+
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseBranchSha,
|
|
222
|
+
[GIT_COMMIT_HEAD_SHA]: commitHeadSha
|
|
223
|
+
} = this.testEnvironmentMetadata
|
|
224
|
+
|
|
225
|
+
const baseBranchSha = pullRequestBaseBranchSha || getPullRequestBaseBranch(pullRequestBaseBranch)
|
|
226
|
+
|
|
227
|
+
if (baseBranchSha) {
|
|
228
|
+
const diff = getPullRequestDiff(baseBranchSha, commitHeadSha)
|
|
229
|
+
const modifiedTests = getModifiedTestsFromDiff(diff)
|
|
230
|
+
if (modifiedTests) {
|
|
231
|
+
return onDone({ err: null, modifiedTests })
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// TODO: Add telemetry for this type of error
|
|
236
|
+
return onDone({ err: new Error('No modified tests could have been retrieved') })
|
|
237
|
+
})
|
|
197
238
|
}
|
|
198
239
|
|
|
199
240
|
get telemetry () {
|
|
@@ -240,7 +281,10 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
240
281
|
[GIT_BRANCH]: branch,
|
|
241
282
|
[CI_PROVIDER_NAME]: ciProviderName,
|
|
242
283
|
[CI_WORKSPACE_PATH]: repositoryRoot,
|
|
243
|
-
[GIT_COMMIT_MESSAGE]: commitMessage
|
|
284
|
+
[GIT_COMMIT_MESSAGE]: commitMessage,
|
|
285
|
+
[GIT_TAG]: tag,
|
|
286
|
+
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseSha,
|
|
287
|
+
[GIT_COMMIT_HEAD_SHA]: commitHeadSha
|
|
244
288
|
} = this.testEnvironmentMetadata
|
|
245
289
|
|
|
246
290
|
this.repositoryRoot = repositoryRoot || process.cwd()
|
|
@@ -259,7 +303,10 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
259
303
|
runtimeVersion,
|
|
260
304
|
branch,
|
|
261
305
|
testLevel: 'suite',
|
|
262
|
-
commitMessage
|
|
306
|
+
commitMessage,
|
|
307
|
+
tag,
|
|
308
|
+
pullRequestBaseSha,
|
|
309
|
+
commitHeadSha
|
|
263
310
|
}
|
|
264
311
|
}
|
|
265
312
|
|
|
@@ -372,11 +419,12 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
372
419
|
return Promise.resolve()
|
|
373
420
|
}
|
|
374
421
|
log.debug('Removing all Dynamic Instrumentation probes')
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
422
|
+
const promises = []
|
|
423
|
+
for (const fileLine of this.fileLineToProbeId.keys()) {
|
|
424
|
+
const [file, line] = fileLine.split(':')
|
|
425
|
+
promises.push(this.removeDiProbe({ file, line }))
|
|
426
|
+
}
|
|
427
|
+
return Promise.all(promises)
|
|
380
428
|
}
|
|
381
429
|
|
|
382
430
|
removeDiProbe ({ file, line }) {
|
|
@@ -387,6 +435,10 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
387
435
|
}
|
|
388
436
|
|
|
389
437
|
addDiProbe (err) {
|
|
438
|
+
if (!err?.stack) {
|
|
439
|
+
log.warn('Can not add breakpoint if the test error does not have a stack')
|
|
440
|
+
return
|
|
441
|
+
}
|
|
390
442
|
const [file, line, stackIndex] = getFileAndLineNumberFromError(err, this.repositoryRoot)
|
|
391
443
|
|
|
392
444
|
if (!file || !Number.isInteger(line)) {
|
|
@@ -7,14 +7,14 @@ class ConsumerPlugin extends InboundPlugin {
|
|
|
7
7
|
static get kind () { return 'consumer' }
|
|
8
8
|
static get type () { return 'messaging' }
|
|
9
9
|
|
|
10
|
-
startSpan (options) {
|
|
10
|
+
startSpan (options, enterOrCtx) {
|
|
11
11
|
if (!options.service) {
|
|
12
12
|
options.service = this.config.service || this.serviceName()
|
|
13
13
|
}
|
|
14
14
|
if (!options.kind) {
|
|
15
15
|
options.kind = this.constructor.kind
|
|
16
16
|
}
|
|
17
|
-
return super.startSpan(this.operationName(), options)
|
|
17
|
+
return super.startSpan(this.operationName(), options, enterOrCtx)
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -48,6 +48,7 @@ module.exports = {
|
|
|
48
48
|
get http2 () { return require('../../../datadog-plugin-http2/src') },
|
|
49
49
|
get https () { return require('../../../datadog-plugin-http/src') },
|
|
50
50
|
get ioredis () { return require('../../../datadog-plugin-ioredis/src') },
|
|
51
|
+
get iovalkey () { return require('../../../datadog-plugin-iovalkey/src') },
|
|
51
52
|
get 'jest-circus' () { return require('../../../datadog-plugin-jest/src') },
|
|
52
53
|
get 'jest-config' () { return require('../../../datadog-plugin-jest/src') },
|
|
53
54
|
get 'jest-environment-node' () { return require('../../../datadog-plugin-jest/src') },
|
|
@@ -83,7 +84,6 @@ module.exports = {
|
|
|
83
84
|
get nyc () { return require('../../../datadog-plugin-nyc/src') },
|
|
84
85
|
get oracledb () { return require('../../../datadog-plugin-oracledb/src') },
|
|
85
86
|
get openai () { return require('../../../datadog-plugin-openai/src') },
|
|
86
|
-
get paperplane () { return require('../../../datadog-plugin-paperplane/src') },
|
|
87
87
|
get pg () { return require('../../../datadog-plugin-pg/src') },
|
|
88
88
|
get pino () { return require('../../../datadog-plugin-pino/src') },
|
|
89
89
|
get 'pino-pretty' () { return require('../../../datadog-plugin-pino/src') },
|
|
@@ -26,6 +26,10 @@ class OutboundPlugin extends TracingPlugin {
|
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
bindFinish (ctx) {
|
|
30
|
+
return ctx.parentStore
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
startSpan (...args) {
|
|
30
34
|
const span = super.startSpan(...args)
|
|
31
35
|
if (
|
|
@@ -67,7 +71,6 @@ class OutboundPlugin extends TracingPlugin {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
return undefined
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
getPeerServiceRemap (peerData) {
|
|
@@ -87,10 +90,6 @@ class OutboundPlugin extends TracingPlugin {
|
|
|
87
90
|
return peerData
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
bindFinish (ctx) {
|
|
91
|
-
return ctx.parentStore
|
|
92
|
-
}
|
|
93
|
-
|
|
94
93
|
finish (ctx) {
|
|
95
94
|
const span = ctx?.currentStore?.span || this.activeSpan
|
|
96
95
|
this.tagPeerService(span)
|
|
@@ -7,7 +7,7 @@ class ProducerPlugin extends OutboundPlugin {
|
|
|
7
7
|
static get kind () { return 'producer' }
|
|
8
8
|
static get type () { return 'messaging' }
|
|
9
9
|
|
|
10
|
-
startSpan (options) {
|
|
10
|
+
startSpan (options, enterOrCtx) {
|
|
11
11
|
const spanDefaults = {
|
|
12
12
|
kind: this.constructor.kind
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@ class ProducerPlugin extends OutboundPlugin {
|
|
|
19
19
|
if (!options[key]) options[key] = spanDefaults[key]
|
|
20
20
|
}
|
|
21
21
|
)
|
|
22
|
-
return super.startSpan(this.operationName(), options)
|
|
22
|
+
return super.startSpan(this.operationName(), options, enterOrCtx)
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -11,12 +11,12 @@ class StoragePlugin extends ClientPlugin {
|
|
|
11
11
|
this.system = this.constructor.system || this.component
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
startSpan (name, options) {
|
|
14
|
+
startSpan (name, options, ctx) {
|
|
15
15
|
if (!options.service && this.system) {
|
|
16
16
|
options.service = `${this.tracer._service}-${this.system}`
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
return super.startSpan(name, options)
|
|
19
|
+
return super.startSpan(name, options, ctx)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -128,7 +128,7 @@ module.exports = {
|
|
|
128
128
|
try {
|
|
129
129
|
nodeLabels = JSON.stringify(NODE_LABELS.split(' '))
|
|
130
130
|
tags[CI_NODE_LABELS] = nodeLabels
|
|
131
|
-
} catch
|
|
131
|
+
} catch {
|
|
132
132
|
// ignore errors
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -143,11 +143,9 @@ module.exports = {
|
|
|
143
143
|
if (JOB_NAME) {
|
|
144
144
|
// Job names can contain parameters, e.g. jobName/KEY1=VALUE1,KEY2=VALUE2/branchName
|
|
145
145
|
const jobNameAndParams = JOB_NAME.split('/')
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
finalPipelineName = JOB_NAME.replace(`/${ref}`, '')
|
|
150
|
-
}
|
|
146
|
+
finalPipelineName = jobNameAndParams.length > 1 && jobNameAndParams[1].includes('=')
|
|
147
|
+
? jobNameAndParams[0]
|
|
148
|
+
: JOB_NAME.replace(`/${ref}`, '')
|
|
151
149
|
tags[CI_PIPELINE_NAME] = finalPipelineName
|
|
152
150
|
}
|
|
153
151
|
}
|
|
@@ -172,7 +170,9 @@ module.exports = {
|
|
|
172
170
|
CI_PROJECT_URL: GITLAB_PROJECT_URL,
|
|
173
171
|
CI_JOB_ID: GITLAB_CI_JOB_ID,
|
|
174
172
|
CI_RUNNER_ID,
|
|
175
|
-
CI_RUNNER_TAGS
|
|
173
|
+
CI_RUNNER_TAGS,
|
|
174
|
+
CI_MERGE_REQUEST_TARGET_BRANCH_NAME,
|
|
175
|
+
CI_MERGE_REQUEST_TARGET_BRANCH_SHA
|
|
176
176
|
} = env
|
|
177
177
|
|
|
178
178
|
const { name, email } = parseEmailAndName(CI_COMMIT_AUTHOR)
|
|
@@ -201,7 +201,9 @@ module.exports = {
|
|
|
201
201
|
CI_JOB_ID: GITLAB_CI_JOB_ID
|
|
202
202
|
}),
|
|
203
203
|
[CI_NODE_LABELS]: CI_RUNNER_TAGS,
|
|
204
|
-
[CI_NODE_NAME]: CI_RUNNER_ID
|
|
204
|
+
[CI_NODE_NAME]: CI_RUNNER_ID,
|
|
205
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: CI_MERGE_REQUEST_TARGET_BRANCH_NAME,
|
|
206
|
+
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: CI_MERGE_REQUEST_TARGET_BRANCH_SHA
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
|
|
@@ -295,7 +297,7 @@ module.exports = {
|
|
|
295
297
|
const eventContent = getGitHubEventPayload()
|
|
296
298
|
tags[GIT_PULL_REQUEST_BASE_BRANCH_SHA] = eventContent.pull_request.base.sha
|
|
297
299
|
tags[GIT_COMMIT_HEAD_SHA] = eventContent.pull_request.head.sha
|
|
298
|
-
} catch
|
|
300
|
+
} catch {
|
|
299
301
|
// ignore malformed event content
|
|
300
302
|
}
|
|
301
303
|
}
|
|
@@ -330,7 +332,8 @@ module.exports = {
|
|
|
330
332
|
[CI_WORKSPACE_PATH]: APPVEYOR_BUILD_FOLDER,
|
|
331
333
|
[GIT_COMMIT_AUTHOR_NAME]: APPVEYOR_REPO_COMMIT_AUTHOR,
|
|
332
334
|
[GIT_COMMIT_AUTHOR_EMAIL]: APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL,
|
|
333
|
-
[GIT_COMMIT_MESSAGE]: APPVEYOR_REPO_COMMIT_MESSAGE + '\n' + APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED
|
|
335
|
+
[GIT_COMMIT_MESSAGE]: APPVEYOR_REPO_COMMIT_MESSAGE + '\n' + APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED,
|
|
336
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: APPVEYOR_REPO_BRANCH
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
if (APPVEYOR_REPO_PROVIDER === 'github') {
|
|
@@ -411,7 +414,8 @@ module.exports = {
|
|
|
411
414
|
BITBUCKET_GIT_HTTP_ORIGIN,
|
|
412
415
|
BITBUCKET_TAG,
|
|
413
416
|
BITBUCKET_PIPELINE_UUID,
|
|
414
|
-
BITBUCKET_CLONE_DIR
|
|
417
|
+
BITBUCKET_CLONE_DIR,
|
|
418
|
+
BITBUCKET_PR_DESTINATION_BRANCH
|
|
415
419
|
} = env
|
|
416
420
|
|
|
417
421
|
const url =
|
|
@@ -428,7 +432,8 @@ module.exports = {
|
|
|
428
432
|
[GIT_TAG]: BITBUCKET_TAG,
|
|
429
433
|
[GIT_REPOSITORY_URL]: BITBUCKET_GIT_SSH_ORIGIN || BITBUCKET_GIT_HTTP_ORIGIN,
|
|
430
434
|
[CI_WORKSPACE_PATH]: BITBUCKET_CLONE_DIR,
|
|
431
|
-
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replace(/{|}/gm, '')
|
|
435
|
+
[CI_PIPELINE_ID]: BITBUCKET_PIPELINE_UUID && BITBUCKET_PIPELINE_UUID.replace(/{|}/gm, ''),
|
|
436
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: BITBUCKET_PR_DESTINATION_BRANCH
|
|
432
437
|
}
|
|
433
438
|
}
|
|
434
439
|
|
|
@@ -459,7 +464,8 @@ module.exports = {
|
|
|
459
464
|
[CI_WORKSPACE_PATH]: BITRISE_SOURCE_DIR,
|
|
460
465
|
[GIT_TAG]: BITRISE_GIT_TAG,
|
|
461
466
|
[GIT_BRANCH]: BITRISEIO_GIT_BRANCH_DEST || BITRISE_GIT_BRANCH,
|
|
462
|
-
[GIT_COMMIT_MESSAGE]: BITRISE_GIT_MESSAGE
|
|
467
|
+
[GIT_COMMIT_MESSAGE]: BITRISE_GIT_MESSAGE,
|
|
468
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: BITRISEIO_GIT_BRANCH_DEST
|
|
463
469
|
}
|
|
464
470
|
}
|
|
465
471
|
|
|
@@ -555,7 +561,8 @@ module.exports = {
|
|
|
555
561
|
BUDDY_EXECUTION_URL,
|
|
556
562
|
BUDDY_PIPELINE_ID,
|
|
557
563
|
BUDDY_PIPELINE_NAME,
|
|
558
|
-
BUDDY_SCM_URL
|
|
564
|
+
BUDDY_SCM_URL,
|
|
565
|
+
BUDDY_RUN_PR_BASE_BRANCH
|
|
559
566
|
} = env
|
|
560
567
|
tags = {
|
|
561
568
|
[CI_PROVIDER_NAME]: 'buddy',
|
|
@@ -569,7 +576,8 @@ module.exports = {
|
|
|
569
576
|
[GIT_TAG]: BUDDY_EXECUTION_TAG,
|
|
570
577
|
[GIT_COMMIT_MESSAGE]: BUDDY_EXECUTION_REVISION_MESSAGE,
|
|
571
578
|
[GIT_COMMIT_COMMITTER_NAME]: BUDDY_EXECUTION_REVISION_COMMITTER_NAME,
|
|
572
|
-
[GIT_COMMIT_COMMITTER_EMAIL]: BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL
|
|
579
|
+
[GIT_COMMIT_COMMITTER_EMAIL]: BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL,
|
|
580
|
+
[GIT_PULL_REQUEST_BASE_BRANCH]: BUDDY_RUN_PR_BASE_BRANCH
|
|
573
581
|
}
|
|
574
582
|
}
|
|
575
583
|
|
|
@@ -76,7 +76,7 @@ function isDirectory (path) {
|
|
|
76
76
|
try {
|
|
77
77
|
const stats = fs.statSync(path)
|
|
78
78
|
return stats.isDirectory()
|
|
79
|
-
} catch
|
|
79
|
+
} catch {
|
|
80
80
|
return false
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ function isGitAvailable () {
|
|
|
87
87
|
try {
|
|
88
88
|
cp.execFileSync(command, ['git'], { stdio: 'pipe' })
|
|
89
89
|
return true
|
|
90
|
-
} catch
|
|
90
|
+
} catch {
|
|
91
91
|
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'check_git', exitCode: 'missing' })
|
|
92
92
|
return false
|
|
93
93
|
}
|
|
@@ -108,11 +108,11 @@ function getGitVersion () {
|
|
|
108
108
|
const gitVersionMatches = gitVersionString.match(/git version (\d+)\.(\d+)\.(\d+)/)
|
|
109
109
|
try {
|
|
110
110
|
return {
|
|
111
|
-
major: parseInt(gitVersionMatches[1]),
|
|
112
|
-
minor: parseInt(gitVersionMatches[2]),
|
|
113
|
-
patch: parseInt(gitVersionMatches[3])
|
|
111
|
+
major: Number.parseInt(gitVersionMatches[1]),
|
|
112
|
+
minor: Number.parseInt(gitVersionMatches[2]),
|
|
113
|
+
patch: Number.parseInt(gitVersionMatches[3])
|
|
114
114
|
}
|
|
115
|
-
} catch
|
|
115
|
+
} catch {
|
|
116
116
|
return null
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -196,7 +196,7 @@ function getLatestCommits () {
|
|
|
196
196
|
const result = cp.execFileSync('git', ['log', '--format=%H', '-n 1000', '--since="1 month ago"'], { stdio: 'pipe' })
|
|
197
197
|
.toString()
|
|
198
198
|
.split('\n')
|
|
199
|
-
.filter(
|
|
199
|
+
.filter(Boolean)
|
|
200
200
|
distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'get_local_commits' }, Date.now() - startTime)
|
|
201
201
|
return result
|
|
202
202
|
} catch (err) {
|
|
@@ -209,6 +209,138 @@ function getLatestCommits () {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
function getGitDiff (baseCommit, targetCommit) {
|
|
213
|
+
const flags = ['diff', '-U0', '--word-diff=porcelain', baseCommit]
|
|
214
|
+
if (targetCommit) {
|
|
215
|
+
flags.push(targetCommit)
|
|
216
|
+
}
|
|
217
|
+
return sanitizedExec(
|
|
218
|
+
'git',
|
|
219
|
+
flags,
|
|
220
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'diff' } },
|
|
221
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'diff' } },
|
|
222
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'diff' } },
|
|
223
|
+
false // important not to trim or we'll lose the line breaks which we need to detect impacted tests
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function getGitRemoteName () {
|
|
228
|
+
const upstreamRemote = sanitizedExec(
|
|
229
|
+
'git',
|
|
230
|
+
['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
|
|
231
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_remote_name' } },
|
|
232
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_remote_name' } },
|
|
233
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_remote_name' } }
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
if (upstreamRemote) {
|
|
237
|
+
return upstreamRemote.split('/')[0]
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const remotes = sanitizedExec(
|
|
241
|
+
'git',
|
|
242
|
+
['remote'],
|
|
243
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_remote_name' } },
|
|
244
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_remote_name' } },
|
|
245
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_remote_name' } },
|
|
246
|
+
false
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
return remotes.split('\n')[0] || 'origin'
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function getSourceBranch () {
|
|
253
|
+
return sanitizedExec(
|
|
254
|
+
'git',
|
|
255
|
+
['rev-parse', '--abbrev-ref', 'HEAD'],
|
|
256
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_source_branch' } },
|
|
257
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_source_branch' } },
|
|
258
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_source_branch' } }
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function checkAndFetchBranch (branch, remoteName) {
|
|
263
|
+
try {
|
|
264
|
+
// `git show-ref --verify --quiet refs/remotes/${remoteName}/${branch}` will exit 0 if the branch exists
|
|
265
|
+
// Otherwise it will exit 1
|
|
266
|
+
cp.execFileSync(
|
|
267
|
+
'git',
|
|
268
|
+
['show-ref', '--verify', '--quiet', `refs/remotes/${remoteName}/${branch}`],
|
|
269
|
+
{ stdio: 'pipe' }
|
|
270
|
+
)
|
|
271
|
+
// branch exists locally, so we finish
|
|
272
|
+
} catch {
|
|
273
|
+
// branch does not exist locally, so we will check the remote
|
|
274
|
+
try {
|
|
275
|
+
// IMPORTANT: we use timeouts because these commands hang if the branch can't be found
|
|
276
|
+
// `git ls-remote --heads origin my-branch` will exit 0 even if the branch doesn't exist.
|
|
277
|
+
// The piece of information we need is whether the command outputs anything.
|
|
278
|
+
// `git ls-remote --heads origin my-branch` could exit an error code if the remote does not exist.
|
|
279
|
+
const remoteHeads = cp.execFileSync(
|
|
280
|
+
'git',
|
|
281
|
+
['ls-remote', '--heads', remoteName, branch],
|
|
282
|
+
{ stdio: 'pipe', timeout: 2000 }
|
|
283
|
+
)
|
|
284
|
+
if (remoteHeads) {
|
|
285
|
+
// branch exists, so we'll fetch it
|
|
286
|
+
cp.execFileSync(
|
|
287
|
+
'git',
|
|
288
|
+
['fetch', '--depth', '1', remoteName, branch],
|
|
289
|
+
{ stdio: 'pipe', timeout: 5000 }
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
} catch (e) {
|
|
293
|
+
// branch does not exist or couldn't be fetched, so we can't do anything
|
|
294
|
+
log.error('Git plugin error checking and fetching branch', e)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function getLocalBranches (remoteName) {
|
|
300
|
+
const localBranches = sanitizedExec(
|
|
301
|
+
'git',
|
|
302
|
+
['for-each-ref', '--format=%(refname:short)', `refs/remotes/${remoteName}`],
|
|
303
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_local_branches' } },
|
|
304
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_local_branches' } },
|
|
305
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_local_branches' } },
|
|
306
|
+
false
|
|
307
|
+
)
|
|
308
|
+
try {
|
|
309
|
+
return localBranches.split('\n').filter(Boolean)
|
|
310
|
+
} catch {
|
|
311
|
+
return []
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function getMergeBase (baseBranch, sourceBranch) {
|
|
316
|
+
return sanitizedExec(
|
|
317
|
+
'git',
|
|
318
|
+
['merge-base', baseBranch, sourceBranch],
|
|
319
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_merge_base' } },
|
|
320
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_merge_base' } },
|
|
321
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_merge_base' } }
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function getCounts (sourceBranch, candidateBranch) {
|
|
326
|
+
const counts = sanitizedExec(
|
|
327
|
+
'git',
|
|
328
|
+
['rev-list', '--left-right', '--count', `${candidateBranch}...${sourceBranch}`],
|
|
329
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_counts' } },
|
|
330
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_counts' } },
|
|
331
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_counts' } }
|
|
332
|
+
)
|
|
333
|
+
try {
|
|
334
|
+
if (!counts) {
|
|
335
|
+
return { behind: null, ahead: null }
|
|
336
|
+
}
|
|
337
|
+
const [behind, ahead] = counts.split(/\s+/).map(Number)
|
|
338
|
+
return { behind, ahead }
|
|
339
|
+
} catch {
|
|
340
|
+
return { behind: null, ahead: null }
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
212
344
|
function getCommitsRevList (commitsToExclude, commitsToInclude) {
|
|
213
345
|
let result = null
|
|
214
346
|
|
|
@@ -231,7 +363,7 @@ function getCommitsRevList (commitsToExclude, commitsToInclude) {
|
|
|
231
363
|
{ stdio: 'pipe', maxBuffer: GIT_REV_LIST_MAX_BUFFER })
|
|
232
364
|
.toString()
|
|
233
365
|
.split('\n')
|
|
234
|
-
.filter(
|
|
366
|
+
.filter(Boolean)
|
|
235
367
|
} catch (err) {
|
|
236
368
|
log.error('Get commits to upload failed: %s', err.message)
|
|
237
369
|
incrementCountMetric(
|
|
@@ -252,7 +384,7 @@ function generatePackFilesForCommits (commitsToUpload) {
|
|
|
252
384
|
return []
|
|
253
385
|
}
|
|
254
386
|
|
|
255
|
-
const randomPrefix = String(Math.floor(Math.random() *
|
|
387
|
+
const randomPrefix = String(Math.floor(Math.random() * 10_000))
|
|
256
388
|
const temporaryPath = path.join(tmpFolder, randomPrefix)
|
|
257
389
|
const cwdPath = path.join(process.cwd(), randomPrefix)
|
|
258
390
|
|
|
@@ -270,7 +402,7 @@ function generatePackFilesForCommits (commitsToUpload) {
|
|
|
270
402
|
targetPath
|
|
271
403
|
],
|
|
272
404
|
{ stdio: 'pipe', input: commitsToUpload.join('\n') }
|
|
273
|
-
).toString().split('\n').filter(
|
|
405
|
+
).toString().split('\n').filter(Boolean).map(commit => `${targetPath}-${commit}.pack`)
|
|
274
406
|
}
|
|
275
407
|
|
|
276
408
|
try {
|
|
@@ -362,6 +494,20 @@ function getGitMetadata (ciMetadata) {
|
|
|
362
494
|
return tags
|
|
363
495
|
}
|
|
364
496
|
|
|
497
|
+
function getGitInformationDiscrepancy () {
|
|
498
|
+
const gitRepositoryUrl = getRepositoryUrl()
|
|
499
|
+
|
|
500
|
+
const gitCommitSHA = sanitizedExec(
|
|
501
|
+
'git',
|
|
502
|
+
['rev-parse', 'HEAD'],
|
|
503
|
+
{ name: TELEMETRY_GIT_COMMAND, tags: { command: 'get_commit_sha' } },
|
|
504
|
+
{ name: TELEMETRY_GIT_COMMAND_MS, tags: { command: 'get_commit_sha' } },
|
|
505
|
+
{ name: TELEMETRY_GIT_COMMAND_ERRORS, tags: { command: 'get_commit_sha' } }
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
return { gitRepositoryUrl, gitCommitSHA }
|
|
509
|
+
}
|
|
510
|
+
|
|
365
511
|
module.exports = {
|
|
366
512
|
getGitMetadata,
|
|
367
513
|
getLatestCommits,
|
|
@@ -371,5 +517,13 @@ module.exports = {
|
|
|
371
517
|
GIT_REV_LIST_MAX_BUFFER,
|
|
372
518
|
isShallowRepository,
|
|
373
519
|
unshallowRepository,
|
|
374
|
-
isGitAvailable
|
|
520
|
+
isGitAvailable,
|
|
521
|
+
getGitInformationDiscrepancy,
|
|
522
|
+
getGitDiff,
|
|
523
|
+
getGitRemoteName,
|
|
524
|
+
getSourceBranch,
|
|
525
|
+
checkAndFetchBranch,
|
|
526
|
+
getLocalBranches,
|
|
527
|
+
getMergeBase,
|
|
528
|
+
getCounts
|
|
375
529
|
}
|
|
@@ -85,7 +85,7 @@ function extractInferredProxyContext (headers) {
|
|
|
85
85
|
|
|
86
86
|
return {
|
|
87
87
|
requestTime: headers[PROXY_HEADER_START_TIME_MS]
|
|
88
|
-
? parseInt(headers[PROXY_HEADER_START_TIME_MS], 10)
|
|
88
|
+
? Number.parseInt(headers[PROXY_HEADER_START_TIME_MS], 10)
|
|
89
89
|
: null,
|
|
90
90
|
method: headers[PROXY_HEADER_HTTPMETHOD],
|
|
91
91
|
path: headers[PROXY_HEADER_PATH],
|
|
@@ -33,7 +33,7 @@ const privateIPMatcher = new BlockList()
|
|
|
33
33
|
for (const cidr of privateCIDRs) {
|
|
34
34
|
const [address, prefix] = cidr.split('/')
|
|
35
35
|
|
|
36
|
-
privateIPMatcher.addSubnet(address, parseInt(prefix), net.isIPv6(address) ? 'ipv6' : 'ipv4')
|
|
36
|
+
privateIPMatcher.addSubnet(address, Number.parseInt(prefix), net.isIPv6(address) ? 'ipv6' : 'ipv4')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function extractIp (config, req) {
|
|
@@ -4,32 +4,49 @@ const RE_NEWLINE = /\n/g
|
|
|
4
4
|
const RE_TAB = /\t/g
|
|
5
5
|
|
|
6
6
|
function normalize (text, limit = 128) {
|
|
7
|
-
if (
|
|
8
|
-
|
|
7
|
+
if (typeof text !== 'string' || text.length === 0) return
|
|
8
|
+
|
|
9
|
+
if (text.length > limit) {
|
|
10
|
+
return text.slice(0, limit) + '...'
|
|
11
|
+
}
|
|
9
12
|
|
|
10
13
|
text = text
|
|
11
|
-
.replace(RE_NEWLINE,
|
|
12
|
-
.replace(RE_TAB,
|
|
14
|
+
.replace(RE_NEWLINE, String.raw`\n`)
|
|
15
|
+
.replace(RE_TAB, String.raw`\t`)
|
|
13
16
|
|
|
17
|
+
// In case the replace above matched, more characters were added that must now be considered.
|
|
14
18
|
if (text.length > limit) {
|
|
15
|
-
return text.
|
|
19
|
+
return text.slice(0, limit) + '...'
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
return text
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether a prompt completion should be sampled based on the configured sampling rate.
|
|
27
|
+
*
|
|
28
|
+
* @param {Sampler} sampler
|
|
29
|
+
* @param {import('index').Span|import('index').SpanContext} span
|
|
30
|
+
* @returns {boolean} `true` if the prompt completion should be sampled, otherwise `false`.
|
|
31
|
+
*/
|
|
32
|
+
function isPromptCompletionSampled (sampler, span) {
|
|
33
|
+
return sampler.isSampled(span)
|
|
23
34
|
}
|
|
24
35
|
|
|
25
|
-
module.exports = function (integrationName, tracerConfig) {
|
|
36
|
+
module.exports = function makeUtilities (integrationName, tracerConfig) {
|
|
26
37
|
const integrationConfig = tracerConfig[integrationName] || {}
|
|
27
38
|
const { spanCharLimit, spanPromptCompletionSampleRate } = integrationConfig
|
|
28
39
|
|
|
29
|
-
const sampler = new Sampler(spanPromptCompletionSampleRate ?? 1
|
|
40
|
+
const sampler = new Sampler(spanPromptCompletionSampleRate ?? 1)
|
|
30
41
|
|
|
31
42
|
return {
|
|
32
43
|
normalize: str => normalize(str, spanCharLimit),
|
|
33
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Determines whether a prompt completion should be sampled based on the configured sampling rate.
|
|
46
|
+
*
|
|
47
|
+
* @param {import('index').Span|import('index').SpanContext} span
|
|
48
|
+
* @returns {boolean} `true` if the prompt completion should be sampled, otherwise `false`.
|
|
49
|
+
*/
|
|
50
|
+
isPromptCompletionSampled: (span) => isPromptCompletionSampled(sampler, span)
|
|
34
51
|
}
|
|
35
52
|
}
|