dd-trace 5.53.0 → 5.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +2 -1
- package/ci/cypress/plugin.js +8 -0
- package/ci/cypress/polyfills.js +23 -0
- package/ci/init.js +8 -7
- package/index.d.ts +33 -16
- package/initialize.mjs +5 -6
- package/package.json +40 -38
- package/packages/datadog-code-origin/index.js +22 -4
- package/packages/datadog-core/src/utils/src/get.js +1 -1
- package/packages/datadog-core/src/utils/src/has.js +1 -1
- package/packages/datadog-core/src/utils/src/kebabcase.js +4 -6
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-core/src/utils/src/pick.js +2 -2
- package/packages/datadog-core/src/utils/src/set.js +1 -1
- package/packages/datadog-core/src/utils/src/uniq.js +1 -1
- package/packages/datadog-instrumentations/src/amqp10.js +19 -17
- package/packages/datadog-instrumentations/src/amqplib.js +52 -35
- package/packages/datadog-instrumentations/src/apollo.js +2 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +10 -10
- package/packages/datadog-instrumentations/src/child_process.js +1 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +89 -75
- package/packages/datadog-instrumentations/src/cookie-parser.js +1 -1
- package/packages/datadog-instrumentations/src/couchbase.js +6 -9
- package/packages/datadog-instrumentations/src/cucumber.js +108 -68
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +5 -5
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -10
- package/packages/datadog-instrumentations/src/fastify.js +7 -9
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +35 -43
- package/packages/datadog-instrumentations/src/graphql.js +7 -10
- package/packages/datadog-instrumentations/src/grpc/client.js +11 -23
- package/packages/datadog-instrumentations/src/grpc/server.js +7 -20
- package/packages/datadog-instrumentations/src/hapi.js +10 -11
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +16 -10
- package/packages/datadog-instrumentations/src/helpers/fetch.js +4 -5
- package/packages/datadog-instrumentations/src/helpers/hook.js +2 -3
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
- package/packages/datadog-instrumentations/src/helpers/register.js +11 -12
- package/packages/datadog-instrumentations/src/http/client.js +14 -20
- package/packages/datadog-instrumentations/src/jest.js +201 -143
- package/packages/datadog-instrumentations/src/kafkajs.js +52 -44
- package/packages/datadog-instrumentations/src/knex.js +4 -4
- package/packages/datadog-instrumentations/src/koa.js +2 -3
- package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
- package/packages/datadog-instrumentations/src/mariadb.js +49 -65
- package/packages/datadog-instrumentations/src/mocha/main.js +116 -73
- package/packages/datadog-instrumentations/src/mocha/utils.js +36 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +6 -0
- package/packages/datadog-instrumentations/src/mocha.js +3 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +30 -37
- package/packages/datadog-instrumentations/src/mysql2.js +53 -47
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -0
- package/packages/datadog-instrumentations/src/nyc.js +3 -2
- package/packages/datadog-instrumentations/src/openai.js +22 -24
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +4 -3
- package/packages/datadog-instrumentations/src/pg.js +3 -5
- package/packages/datadog-instrumentations/src/playwright.js +123 -83
- package/packages/datadog-instrumentations/src/protobufjs.js +3 -4
- package/packages/datadog-instrumentations/src/redis.js +4 -4
- package/packages/datadog-instrumentations/src/restify.js +9 -13
- package/packages/datadog-instrumentations/src/rhea.js +42 -54
- package/packages/datadog-instrumentations/src/router.js +30 -32
- package/packages/datadog-instrumentations/src/tedious.js +2 -3
- package/packages/datadog-instrumentations/src/vitest.js +87 -52
- package/packages/datadog-plugin-amqp10/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqp10/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/client.js +6 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/util.js +1 -1
- package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -6
- package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -3
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +12 -12
- package/packages/datadog-plugin-aws-sdk/src/base.js +15 -10
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +13 -13
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +28 -43
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +10 -11
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +4 -6
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -3
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +11 -15
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +5 -6
- package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
- package/packages/datadog-plugin-child_process/src/index.js +4 -4
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +23 -23
- package/packages/datadog-plugin-cucumber/src/index.js +60 -4
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +99 -28
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
- package/packages/datadog-plugin-cypress/src/support.js +24 -5
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-express/src/code_origin.js +30 -0
- package/packages/datadog-plugin-express/src/index.js +10 -12
- package/packages/datadog-plugin-express/src/tracing.js +19 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +7 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +12 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +6 -2
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +27 -10
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/index.js +10 -8
- package/packages/datadog-plugin-graphql/src/resolve.js +19 -12
- package/packages/datadog-plugin-graphql/src/tools/index.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-grpc/src/client.js +2 -2
- package/packages/datadog-plugin-grpc/src/util.js +2 -2
- package/packages/datadog-plugin-http/src/client.js +23 -13
- package/packages/datadog-plugin-http2/src/client.js +24 -25
- package/packages/datadog-plugin-jest/src/index.js +26 -23
- package/packages/datadog-plugin-jest/src/util.js +8 -8
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +3 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -5
- package/packages/datadog-plugin-kafkajs/src/producer.js +8 -3
- package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +7 -7
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -2
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +6 -4
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +5 -4
- package/packages/datadog-plugin-langchain/src/tracing.js +11 -10
- package/packages/datadog-plugin-mariadb/src/index.js +3 -9
- package/packages/datadog-plugin-mocha/src/index.js +39 -14
- package/packages/datadog-plugin-mongodb-core/src/index.js +3 -2
- package/packages/datadog-plugin-mysql/src/index.js +22 -9
- package/packages/datadog-plugin-mysql2/src/index.js +16 -0
- package/packages/datadog-plugin-net/src/tcp.js +1 -1
- package/packages/datadog-plugin-next/src/index.js +7 -6
- package/packages/datadog-plugin-openai/src/services.js +6 -10
- package/packages/datadog-plugin-openai/src/tracing.js +12 -18
- package/packages/datadog-plugin-oracledb/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +25 -4
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +8 -9
- package/packages/datadog-plugin-redis/src/index.js +2 -4
- package/packages/datadog-plugin-rhea/src/consumer.js +8 -6
- package/packages/datadog-plugin-rhea/src/producer.js +5 -2
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/datadog-plugin-selenium/src/index.js +1 -6
- package/packages/datadog-plugin-vitest/src/index.js +52 -35
- package/packages/datadog-shimmer/src/shimmer.js +4 -8
- package/packages/dd-trace/src/appsec/api_security_sampler.js +2 -2
- package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
- package/packages/dd-trace/src/appsec/blocking.js +6 -20
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +7 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +5 -8
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +9 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +5 -4
- package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +2 -3
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +102 -7
- package/packages/dd-trace/src/appsec/iast/path-line.js +7 -8
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +16 -24
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +6 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +4 -28
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -8
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +3 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +7 -8
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +7 -7
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +2 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +10 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +7 -7
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +23 -28
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +6 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +0 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +9 -11
- package/packages/dd-trace/src/appsec/index.js +5 -5
- package/packages/dd-trace/src/appsec/rasp/index.js +15 -15
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
- package/packages/dd-trace/src/appsec/reporter.js +232 -41
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -3
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- package/packages/dd-trace/src/appsec/telemetry/index.js +31 -1
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -5
- package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -5
- package/packages/dd-trace/src/appsec/user_tracking.js +3 -5
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +8 -4
- package/packages/dd-trace/src/azure_metadata.js +9 -9
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +9 -8
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +3 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +6 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +6 -5
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +7 -6
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +0 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +3 -2
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +5 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +12 -8
- package/packages/dd-trace/src/ci-visibility/telemetry.js +4 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +3 -2
- package/packages/dd-trace/src/config-helper.js +89 -0
- package/packages/dd-trace/src/config.js +159 -129
- package/packages/dd-trace/src/config_stable.js +10 -7
- package/packages/dd-trace/src/datastreams/encoding.js +9 -9
- package/packages/dd-trace/src/datastreams/fnv.js +2 -2
- package/packages/dd-trace/src/datastreams/pathway.js +4 -4
- package/packages/dd-trace/src/datastreams/processor.js +5 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +7 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +4 -6
- package/packages/dd-trace/src/datastreams/size.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +75 -69
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +7 -10
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +9 -2
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/send.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +11 -14
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +4 -4
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +2 -10
- package/packages/dd-trace/src/debugger/devtools_client/state.js +10 -3
- package/packages/dd-trace/src/debugger/index.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +7 -6
- package/packages/dd-trace/src/encode/0.4.js +14 -11
- package/packages/dd-trace/src/encode/0.5.js +4 -6
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +8 -8
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/tags-processors.js +1 -1
- package/packages/dd-trace/src/exporter.js +7 -6
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
- package/packages/dd-trace/src/exporters/common/docker.js +4 -3
- package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
- package/packages/dd-trace/src/exporters/common/request.js +5 -2
- package/packages/dd-trace/src/exporters/common/util.js +4 -2
- package/packages/dd-trace/src/external-logger/src/index.js +5 -5
- package/packages/dd-trace/src/flare/file.js +1 -5
- package/packages/dd-trace/src/format.js +1 -1
- package/packages/dd-trace/src/git_properties.js +1 -1
- package/packages/dd-trace/src/id.js +15 -9
- package/packages/dd-trace/src/iitm.js +10 -22
- package/packages/dd-trace/src/index.js +4 -3
- package/packages/dd-trace/src/lambda/handler.js +7 -6
- package/packages/dd-trace/src/lambda/index.js +2 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +7 -6
- package/packages/dd-trace/src/lambda/runtime/ritm.js +4 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +21 -5
- package/packages/dd-trace/src/llmobs/noop.js +18 -20
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +2 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +11 -13
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/openai.js +2 -3
- package/packages/dd-trace/src/llmobs/sdk.js +4 -3
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +129 -102
- package/packages/dd-trace/src/llmobs/util.js +9 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -1
- package/packages/dd-trace/src/log/index.js +9 -8
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/log/writer.js +3 -4
- package/packages/dd-trace/src/msgpack/chunk.js +3 -3
- package/packages/dd-trace/src/msgpack/encoder.js +31 -31
- package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
- package/packages/dd-trace/src/noop/span.js +4 -6
- package/packages/dd-trace/src/noop/tracer.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span_processor.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +7 -6
- package/packages/dd-trace/src/opentracing/propagation/log.js +10 -13
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +40 -37
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
- package/packages/dd-trace/src/opentracing/span.js +16 -20
- package/packages/dd-trace/src/opentracing/tracer.js +9 -6
- package/packages/dd-trace/src/payload-tagging/config/index.js +17 -21
- package/packages/dd-trace/src/payload-tagging/index.js +1 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +6 -6
- package/packages/dd-trace/src/pkg.js +1 -1
- package/packages/dd-trace/src/plugin_manager.js +4 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +87 -11
- package/packages/dd-trace/src/plugins/consumer.js +2 -2
- package/packages/dd-trace/src/plugins/inbound.js +5 -1
- package/packages/dd-trace/src/plugins/index.js +0 -1
- package/packages/dd-trace/src/plugins/outbound.js +4 -5
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +2 -2
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/util/ci.js +28 -20
- package/packages/dd-trace/src/plugins/util/git.js +166 -12
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -1
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +27 -10
- package/packages/dd-trace/src/plugins/util/stacktrace.js +9 -2
- package/packages/dd-trace/src/plugins/util/test.js +315 -51
- package/packages/dd-trace/src/plugins/util/url.js +1 -1
- package/packages/dd-trace/src/plugins/util/urlfilter.js +13 -17
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +14 -4
- package/packages/dd-trace/src/plugins/util/web.js +8 -8
- package/packages/dd-trace/src/priority_sampler.js +64 -53
- package/packages/dd-trace/src/profiling/config.js +51 -35
- package/packages/dd-trace/src/profiling/exporter_cli.js +20 -20
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +7 -6
- package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
- package/packages/dd-trace/src/profiling/index.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +44 -6
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -17
- package/packages/dd-trace/src/profiling/profilers/shared.js +6 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +6 -7
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -5
- package/packages/dd-trace/src/profiling/ssi-telemetry-mock-profiler.js +3 -1
- package/packages/dd-trace/src/profiling/tagger.js +21 -13
- package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
- package/packages/dd-trace/src/proxy.js +9 -10
- package/packages/dd-trace/src/random_sampler.js +40 -0
- package/packages/dd-trace/src/rate_limiter.js +4 -4
- package/packages/dd-trace/src/remote_config/index.js +3 -7
- package/packages/dd-trace/src/remote_config/manager.js +25 -13
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +8 -8
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +5 -4
- package/packages/dd-trace/src/sampler.js +41 -4
- package/packages/dd-trace/src/sampling_rule.js +12 -3
- package/packages/dd-trace/src/scope.js +1 -1
- package/packages/dd-trace/src/serverless.js +11 -4
- package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
- package/packages/dd-trace/src/span_processor.js +5 -4
- package/packages/dd-trace/src/span_sampler.js +4 -1
- package/packages/dd-trace/src/standalone/tracesource.js +2 -3
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +1 -2
- package/packages/dd-trace/src/startup-log.js +6 -18
- package/packages/dd-trace/src/supported-configurations.json +439 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +64 -59
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +9 -10
- package/packages/dd-trace/src/telemetry/metrics.js +10 -5
- package/packages/dd-trace/src/telemetry/send-data.js +8 -7
- package/packages/dd-trace/src/telemetry/telemetry.js +31 -45
- package/packages/dd-trace/src/tracer.js +3 -7
- package/packages/dd-trace/src/util.js +1 -6
- package/version.js +1 -0
- package/packages/datadog-instrumentations/src/paperplane.js +0 -77
- package/packages/datadog-plugin-paperplane/src/index.js +0 -25
- package/packages/datadog-plugin-paperplane/src/logger.js +0 -11
- package/packages/datadog-plugin-paperplane/src/server.js +0 -24
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +0 -122
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +0 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const os = require('os')
|
|
2
2
|
const fs = require('fs')
|
|
3
|
+
const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
|
|
3
4
|
|
|
4
5
|
class StableConfig {
|
|
5
6
|
constructor () {
|
|
@@ -27,7 +28,7 @@ class StableConfig {
|
|
|
27
28
|
try {
|
|
28
29
|
libdatadog = require('@datadog/libdatadog')
|
|
29
30
|
this.wasm_loaded = true
|
|
30
|
-
} catch
|
|
31
|
+
} catch {
|
|
31
32
|
this.warnings.push('Can\'t load libdatadog library')
|
|
32
33
|
return
|
|
33
34
|
}
|
|
@@ -40,6 +41,8 @@ class StableConfig {
|
|
|
40
41
|
|
|
41
42
|
try {
|
|
42
43
|
const configurator = new libconfig.JsConfigurator()
|
|
44
|
+
// Intentionally pass through the raw environment variables for reporting.
|
|
45
|
+
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
43
46
|
configurator.set_envp(Object.entries(process.env).map(([key, value]) => `${key}=${value}`))
|
|
44
47
|
configurator.set_args(process.argv)
|
|
45
48
|
configurator.get_configuration(localConfig.toString(), fleetConfig.toString()).forEach((entry) => {
|
|
@@ -78,19 +81,19 @@ class StableConfig {
|
|
|
78
81
|
fleetConfigPath = '/opt/datadog-agent/etc/managed/datadog-agent/stable/application_monitoring.yaml'
|
|
79
82
|
break
|
|
80
83
|
case 'win32':
|
|
81
|
-
localConfigPath =
|
|
82
|
-
fleetConfigPath =
|
|
84
|
+
localConfigPath = String.raw`C:\ProgramData\Datadog\application_monitoring.yaml`
|
|
85
|
+
fleetConfigPath = String.raw`C:\ProgramData\Datadog\managed\datadog-agent\stable\application_monitoring.yaml`
|
|
83
86
|
break
|
|
84
87
|
default:
|
|
85
88
|
break
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
// Allow overriding the paths for testing
|
|
89
|
-
if (
|
|
90
|
-
localConfigPath =
|
|
92
|
+
if (getEnvironmentVariable('DD_TEST_LOCAL_CONFIG_PATH') !== undefined) {
|
|
93
|
+
localConfigPath = getEnvironmentVariable('DD_TEST_LOCAL_CONFIG_PATH')
|
|
91
94
|
}
|
|
92
|
-
if (
|
|
93
|
-
fleetConfigPath =
|
|
95
|
+
if (getEnvironmentVariable('DD_TEST_FLEET_CONFIG_PATH') !== undefined) {
|
|
96
|
+
fleetConfigPath = getEnvironmentVariable('DD_TEST_FLEET_CONFIG_PATH')
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
return { localConfigPath, fleetConfigPath }
|
|
@@ -6,10 +6,10 @@ function encodeVarint (v) {
|
|
|
6
6
|
// we leave the least significant bit for the sign.
|
|
7
7
|
const double = Math.abs(v) * 2
|
|
8
8
|
if (double > Number.MAX_SAFE_INTEGER) {
|
|
9
|
-
return
|
|
9
|
+
return
|
|
10
10
|
}
|
|
11
|
-
const high = Math.floor(double /
|
|
12
|
-
const low = (double &
|
|
11
|
+
const high = Math.floor(double / 0x1_00_00_00_00)
|
|
12
|
+
const low = (double & 0xFF_FF_FF_FF) | sign
|
|
13
13
|
return encodeUvarint64(low, high)
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ function decodeVarint (b) {
|
|
|
21
21
|
return [undefined, bytes]
|
|
22
22
|
}
|
|
23
23
|
const positive = (low & 1) === 0
|
|
24
|
-
const abs = (low >>> 1) + high *
|
|
24
|
+
const abs = (low >>> 1) + high * 0x80_00_00_00
|
|
25
25
|
return [positive ? abs : -abs, bytes]
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -32,13 +32,13 @@ function encodeUvarint64 (low, high) {
|
|
|
32
32
|
let i = 0
|
|
33
33
|
// if first byte is 1, the number is negative in javascript, but we want to interpret it as positive
|
|
34
34
|
while ((high !== 0 || low < 0 || low > 0x80) && i < maxVarLen64 - 1) {
|
|
35
|
-
result[i] = (low &
|
|
35
|
+
result[i] = (low & 0x7F) | 0x80
|
|
36
36
|
low >>>= 7
|
|
37
|
-
low |= (high &
|
|
37
|
+
low |= (high & 0x7F) << 25
|
|
38
38
|
high >>>= 7
|
|
39
39
|
i++
|
|
40
40
|
}
|
|
41
|
-
result[i] = low &
|
|
41
|
+
result[i] = low & 0x7F
|
|
42
42
|
return result.slice(0, i + 1)
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -64,11 +64,11 @@ function decodeUvarint64 (
|
|
|
64
64
|
return [low, high, bytes]
|
|
65
65
|
}
|
|
66
66
|
if (s < 32) {
|
|
67
|
-
low |= (n &
|
|
67
|
+
low |= (n & 0x7F) << s
|
|
68
68
|
}
|
|
69
69
|
if (s > 0) {
|
|
70
70
|
high |=
|
|
71
|
-
s - 32 > 0 ? (n &
|
|
71
|
+
s - 32 > 0 ? (n & 0x7F) << (s - 32) : (n & 0x7F) >> (32 - s)
|
|
72
72
|
}
|
|
73
73
|
s += 7
|
|
74
74
|
}
|
|
@@ -5,14 +5,14 @@ function fnv (data, hvalInit, fnvPrime, fnvSize) {
|
|
|
5
5
|
let hval = hvalInit
|
|
6
6
|
for (const byte of data) {
|
|
7
7
|
hval = (hval * fnvPrime) % fnvSize
|
|
8
|
-
hval
|
|
8
|
+
hval ^= BigInt(byte)
|
|
9
9
|
}
|
|
10
10
|
return hval
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function fnv64 (data) {
|
|
14
14
|
if (!Buffer.isBuffer(data)) {
|
|
15
|
-
data = Buffer.from(data, '
|
|
15
|
+
data = Buffer.from(data, 'utf8')
|
|
16
16
|
}
|
|
17
17
|
const byteArray = new Uint8Array(data)
|
|
18
18
|
return fnv(byteArray, FNV1_64_INIT, FNV_64_PRIME, 2n ** 64n)
|
|
@@ -77,19 +77,19 @@ function decodePathwayContextBase64 (pathwayContext) {
|
|
|
77
77
|
return decodePathwayContext(encodedPathway)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const DsmPathwayCodec = {
|
|
81
81
|
// we use a class for encoding / decoding in case we update our encoding/decoding. A class will make updates easier
|
|
82
82
|
// instead of using individual functions.
|
|
83
|
-
|
|
83
|
+
encode (dataStreamsContext, carrier) {
|
|
84
84
|
if (!dataStreamsContext || !dataStreamsContext.hash) {
|
|
85
85
|
return
|
|
86
86
|
}
|
|
87
87
|
carrier[CONTEXT_PROPAGATION_KEY_BASE64] = encodePathwayContextBase64(dataStreamsContext)
|
|
88
88
|
|
|
89
89
|
log.debug(() => `Injected into DSM carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)
|
|
90
|
-
}
|
|
90
|
+
},
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
decode (carrier) {
|
|
93
93
|
log.debug(() => `Attempting extract from DSM carrier: ${JSON.stringify(pick(carrier, logKeys))}.`)
|
|
94
94
|
|
|
95
95
|
if (carrier == null) return
|
|
@@ -103,10 +103,8 @@ class StatsBucket {
|
|
|
103
103
|
forBacklog (backlogData) {
|
|
104
104
|
const backlog = new Backlog(backlogData)
|
|
105
105
|
const existingBacklog = this._backlogs.get(backlog.hash)
|
|
106
|
-
if (existingBacklog !== undefined) {
|
|
107
|
-
|
|
108
|
-
return existingBacklog
|
|
109
|
-
}
|
|
106
|
+
if (existingBacklog !== undefined && existingBacklog.offset > backlog.offset) {
|
|
107
|
+
return existingBacklog
|
|
110
108
|
}
|
|
111
109
|
this._backlogs.set(backlog.hash, backlog)
|
|
112
110
|
return backlog
|
|
@@ -205,7 +203,9 @@ class DataStreamsProcessor {
|
|
|
205
203
|
let parentHash = ENTRY_PARENT_HASH
|
|
206
204
|
let closestOppositeDirectionHash = ENTRY_PARENT_HASH
|
|
207
205
|
let closestOppositeDirectionEdgeStart = nowNs
|
|
208
|
-
if (ctx
|
|
206
|
+
if (ctx == null) {
|
|
207
|
+
log.debug(() => 'Setting DSM Checkpoint with empty parent context.')
|
|
208
|
+
} else {
|
|
209
209
|
pathwayStartNs = ctx.pathwayStartNs
|
|
210
210
|
edgeStartNs = ctx.edgeStartNs
|
|
211
211
|
parentHash = ctx.hash
|
|
@@ -229,8 +229,6 @@ class DataStreamsProcessor {
|
|
|
229
229
|
log.debug(
|
|
230
230
|
() => `Setting DSM Checkpoint from extracted parent context with hash: ${parentHash} and edge tags: ${edgeTags}`
|
|
231
231
|
)
|
|
232
|
-
} else {
|
|
233
|
-
log.debug(() => 'Setting DSM Checkpoint with empty parent context.')
|
|
234
232
|
}
|
|
235
233
|
const hash = computePathwayHash(this.service, this.env, edgeTags, parentHash)
|
|
236
234
|
const edgeLatencyNs = nowNs - edgeStartNs
|
|
@@ -20,7 +20,7 @@ class SchemaBuilder {
|
|
|
20
20
|
static getSchemaDefinition (schema) {
|
|
21
21
|
const noNones = convertToJsonCompatible(schema)
|
|
22
22
|
const definition = jsonStringify(noNones)
|
|
23
|
-
const id = fnv64(Buffer.from(definition, '
|
|
23
|
+
const id = fnv64(Buffer.from(definition, 'utf8')).toString()
|
|
24
24
|
return new Schema(definition, id)
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -117,12 +117,12 @@ function convertKey (key) {
|
|
|
117
117
|
function jsonStringify (obj, indent = 2) {
|
|
118
118
|
// made to stringify json exactly similar to python / java in order for hashing to be the same
|
|
119
119
|
const jsonString = JSON.stringify(obj, (_, value) => value, indent)
|
|
120
|
-
return jsonString.
|
|
121
|
-
.
|
|
122
|
-
.
|
|
123
|
-
.
|
|
124
|
-
.
|
|
125
|
-
.
|
|
120
|
+
return jsonString.replaceAll(/^ +/gm, ' ') // Replace leading spaces with single space
|
|
121
|
+
.replaceAll('\n', '') // Remove newlines
|
|
122
|
+
.replaceAll('{ ', '{') // Remove space after '{'
|
|
123
|
+
.replaceAll(' }', '}') // Remove space before '}'
|
|
124
|
+
.replaceAll('[ ', '[') // Remove space after '['
|
|
125
|
+
.replaceAll(' ]', ']') // Remove space before ']'
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
module.exports = {
|
|
@@ -8,12 +8,10 @@ class SchemaSampler {
|
|
|
8
8
|
|
|
9
9
|
trySample (currentTimeMs) {
|
|
10
10
|
if (currentTimeMs >= this.lastSampleMs + SAMPLE_INTERVAL_MILLIS) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return weight
|
|
16
|
-
}
|
|
11
|
+
this.lastSampleMs = currentTimeMs
|
|
12
|
+
const weight = this.weight
|
|
13
|
+
this.weight = 0
|
|
14
|
+
return weight
|
|
17
15
|
}
|
|
18
16
|
return 0
|
|
19
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const mutex = require('mutexify/promise')()
|
|
4
4
|
const { getGeneratedPosition } = require('./source-maps')
|
|
5
5
|
const session = require('./session')
|
|
6
6
|
const { compile: compileCondition, compileSegments, templateRequiresEvaluation } = require('./condition')
|
|
@@ -36,8 +36,9 @@ session.on('scriptLoadingStabilized', () => {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
module.exports = {
|
|
39
|
-
addBreakpoint,
|
|
40
|
-
removeBreakpoint
|
|
39
|
+
addBreakpoint: lock(addBreakpoint),
|
|
40
|
+
removeBreakpoint: lock(removeBreakpoint),
|
|
41
|
+
modifyBreakpoint: lock(modifyBreakpoint)
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
async function addBreakpoint (probe) {
|
|
@@ -89,98 +90,93 @@ async function addBreakpoint (probe) {
|
|
|
89
90
|
throw new Error(`Cannot compile expression: ${probe.when.dsl}`, { cause: err })
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
})
|
|
119
|
-
} catch (err) {
|
|
120
|
-
throw new Error(`Error setting breakpoint for probe ${probe.id}`, { cause: err })
|
|
121
|
-
}
|
|
122
|
-
probeToLocation.set(probe.id, locationKey)
|
|
123
|
-
locationToBreakpoint.set(locationKey, { id: result.breakpointId, location, locationKey })
|
|
124
|
-
breakpointToProbes.set(result.breakpointId, new Map([[probe.id, probe]]))
|
|
93
|
+
const locationKey = generateLocationKey(scriptId, lineNumber, columnNumber)
|
|
94
|
+
const breakpoint = locationToBreakpoint.get(locationKey)
|
|
95
|
+
|
|
96
|
+
log.debug(
|
|
97
|
+
'[debugger:devtools_client] %s breakpoint at %s:%d:%d (probe: %s, version: %d)',
|
|
98
|
+
breakpoint ? 'Updating' : 'Adding', url, lineNumber, columnNumber, probe.id, probe.version
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
if (breakpoint) {
|
|
102
|
+
// A breakpoint already exists at this location, so we need to add the probe to the existing breakpoint
|
|
103
|
+
await updateBreakpointInternal(breakpoint, probe)
|
|
104
|
+
} else {
|
|
105
|
+
// No breakpoint exists at this location, so we need to create a new one
|
|
106
|
+
const location = {
|
|
107
|
+
scriptId,
|
|
108
|
+
lineNumber: lineNumber - 1, // Beware! lineNumber is zero-indexed
|
|
109
|
+
columnNumber
|
|
110
|
+
}
|
|
111
|
+
let result
|
|
112
|
+
try {
|
|
113
|
+
result = await session.post('Debugger.setBreakpoint', {
|
|
114
|
+
location,
|
|
115
|
+
condition: probe.condition
|
|
116
|
+
})
|
|
117
|
+
} catch (err) {
|
|
118
|
+
throw new Error(`Error setting breakpoint for probe ${probe.id}`, { cause: err })
|
|
125
119
|
}
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
probeToLocation.set(probe.id, locationKey)
|
|
121
|
+
locationToBreakpoint.set(locationKey, { id: result.breakpointId, location, locationKey })
|
|
122
|
+
breakpointToProbes.set(result.breakpointId, new Map([[probe.id, probe]]))
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
|
|
131
126
|
async function removeBreakpoint ({ id }) {
|
|
132
127
|
if (!sessionStarted) {
|
|
133
128
|
// We should not get in this state, but abort if we do, so the code doesn't fail unexpected
|
|
134
|
-
throw Error(`Cannot remove probe ${id}: Debugger not started`)
|
|
129
|
+
throw new Error(`Cannot remove probe ${id}: Debugger not started`)
|
|
135
130
|
}
|
|
136
131
|
if (!probeToLocation.has(id)) {
|
|
137
|
-
throw Error(`Unknown probe id: ${id}`)
|
|
132
|
+
throw new Error(`Unknown probe id: ${id}`)
|
|
138
133
|
}
|
|
139
134
|
|
|
140
135
|
probes.delete(id)
|
|
141
136
|
|
|
142
|
-
const
|
|
137
|
+
const locationKey = probeToLocation.get(id)
|
|
138
|
+
const breakpoint = locationToBreakpoint.get(locationKey)
|
|
139
|
+
const probesAtLocation = breakpointToProbes.get(breakpoint.id)
|
|
143
140
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
locationToBreakpoint.delete(locationKey)
|
|
154
|
-
breakpointToProbes.delete(breakpoint.id)
|
|
155
|
-
if (breakpointToProbes.size === 0) {
|
|
156
|
-
await stop() // TODO: Will this actually delete the breakpoint?
|
|
157
|
-
} else {
|
|
158
|
-
try {
|
|
159
|
-
await session.post('Debugger.removeBreakpoint', { breakpointId: breakpoint.id })
|
|
160
|
-
} catch (err) {
|
|
161
|
-
throw new Error(`Error removing breakpoint for probe ${id}`, { cause: err })
|
|
162
|
-
}
|
|
163
|
-
}
|
|
141
|
+
probesAtLocation.delete(id)
|
|
142
|
+
probeToLocation.delete(id)
|
|
143
|
+
|
|
144
|
+
if (probesAtLocation.size === 0) {
|
|
145
|
+
locationToBreakpoint.delete(locationKey)
|
|
146
|
+
breakpointToProbes.delete(breakpoint.id)
|
|
147
|
+
// TODO: If anything below in this if-block throws, the state is out of sync.
|
|
148
|
+
if (breakpointToProbes.size === 0) {
|
|
149
|
+
await stop() // This will also remove the breakpoint
|
|
164
150
|
} else {
|
|
165
|
-
|
|
151
|
+
try {
|
|
152
|
+
await session.post('Debugger.removeBreakpoint', { breakpointId: breakpoint.id })
|
|
153
|
+
} catch (err) {
|
|
154
|
+
throw new Error(`Error removing breakpoint for probe ${id}`, { cause: err })
|
|
155
|
+
}
|
|
166
156
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
157
|
+
} else {
|
|
158
|
+
await updateBreakpointInternal(breakpoint)
|
|
169
159
|
}
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
|
|
162
|
+
// TODO: Modify existing probe instead of removing it (DEBUG-2817)
|
|
163
|
+
async function modifyBreakpoint (probe) {
|
|
164
|
+
await removeBreakpoint(probe)
|
|
165
|
+
await addBreakpoint(probe)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function updateBreakpointInternal (breakpoint, probe) {
|
|
173
169
|
const probesAtLocation = breakpointToProbes.get(breakpoint.id)
|
|
174
|
-
const conditionBeforeNewProbe = compileCompoundCondition(
|
|
170
|
+
const conditionBeforeNewProbe = compileCompoundCondition([...probesAtLocation.values()])
|
|
175
171
|
|
|
176
172
|
// If a probe is provided, add it to the breakpoint. If not, it's because we're removing a probe, but potentially
|
|
177
|
-
// need to update the
|
|
173
|
+
// need to update the condition of the breakpoint.
|
|
178
174
|
if (probe) {
|
|
179
175
|
probesAtLocation.set(probe.id, probe)
|
|
180
176
|
probeToLocation.set(probe.id, breakpoint.locationKey)
|
|
181
177
|
}
|
|
182
178
|
|
|
183
|
-
const condition = compileCompoundCondition(
|
|
179
|
+
const condition = compileCompoundCondition([...probesAtLocation.values()])
|
|
184
180
|
|
|
185
181
|
if (condition || conditionBeforeNewProbe !== condition) {
|
|
186
182
|
try {
|
|
@@ -198,7 +194,6 @@ async function updateBreakpoint (breakpoint, probe) {
|
|
|
198
194
|
} catch (err) {
|
|
199
195
|
throw new Error(`Error setting breakpoint for probe ${probe.id}`, { cause: err })
|
|
200
196
|
}
|
|
201
|
-
breakpoint.id = result.breakpointId
|
|
202
197
|
breakpointToProbes.set(result.breakpointId, probesAtLocation)
|
|
203
198
|
}
|
|
204
199
|
}
|
|
@@ -235,6 +230,17 @@ function stop () {
|
|
|
235
230
|
return session.post('Debugger.disable')
|
|
236
231
|
}
|
|
237
232
|
|
|
233
|
+
function lock (fn) {
|
|
234
|
+
return async function (...args) {
|
|
235
|
+
const release = await mutex()
|
|
236
|
+
try {
|
|
237
|
+
return await fn(...args)
|
|
238
|
+
} finally {
|
|
239
|
+
release()
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
238
244
|
// Only if all probes have a condition can we use a compound condition.
|
|
239
245
|
// Otherwise, we need to evaluate each probe individually once the breakpoint is hit.
|
|
240
246
|
function compileCompoundCondition (probes) {
|
|
@@ -51,9 +51,8 @@ function compileSegments (segments) {
|
|
|
51
51
|
let result = '['
|
|
52
52
|
for (let i = 0; i < segments.length; i++) {
|
|
53
53
|
const { str, dsl, json } = segments[i]
|
|
54
|
-
result += str
|
|
55
|
-
?
|
|
56
|
-
: `(() => {
|
|
54
|
+
result += str === undefined
|
|
55
|
+
? `(() => {
|
|
57
56
|
try {
|
|
58
57
|
const result = ${compile(json)}
|
|
59
58
|
return typeof result === 'string' ? result : $dd_inspect(result, $dd_segmentInspectOptions)
|
|
@@ -61,6 +60,7 @@ function compileSegments (segments) {
|
|
|
61
60
|
return { expr: ${JSON.stringify(dsl)}, message: \`\${e.name}: \${e.message}\` }
|
|
62
61
|
}
|
|
63
62
|
})()`
|
|
63
|
+
: JSON.stringify(str)
|
|
64
64
|
if (i !== segments.length - 1) {
|
|
65
65
|
result += ','
|
|
66
66
|
}
|
|
@@ -95,11 +95,9 @@ function compile (node) {
|
|
|
95
95
|
}
|
|
96
96
|
})()`
|
|
97
97
|
} else if (type === 'instanceof') {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return `Function.prototype[Symbol.hasInstance].call(${assertIdentifier(value[1])}, ${compile(value[0])})`
|
|
102
|
-
}
|
|
98
|
+
return isPrimitiveType(value[1])
|
|
99
|
+
? `(typeof ${compile(value[0])} === '${value[1]}')` // TODO: Is parenthesizing necessary?
|
|
100
|
+
: `Function.prototype[Symbol.hasInstance].call(${assertIdentifier(value[1])}, ${compile(value[0])})`
|
|
103
101
|
} else if (type === 'ref') {
|
|
104
102
|
if (value === '@it') {
|
|
105
103
|
return '$dd_it'
|
|
@@ -107,9 +105,8 @@ function compile (node) {
|
|
|
107
105
|
return '$dd_key'
|
|
108
106
|
} else if (value === '@value') {
|
|
109
107
|
return '$dd_value'
|
|
110
|
-
} else {
|
|
111
|
-
return assertIdentifier(value)
|
|
112
108
|
}
|
|
109
|
+
return assertIdentifier(value)
|
|
113
110
|
} else if (Array.isArray(value)) {
|
|
114
111
|
const args = value.map(compile)
|
|
115
112
|
switch (type) {
|
|
@@ -65,6 +65,12 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
65
65
|
for (let i = 0; i < params.hitBreakpoints.length; i++) {
|
|
66
66
|
const probesAtLocation = breakpointToProbes.get(params.hitBreakpoints[i])
|
|
67
67
|
|
|
68
|
+
if (probesAtLocation === undefined) {
|
|
69
|
+
// This might happen due to a race condition where the breakpoint is in the process of being removed
|
|
70
|
+
log.error('[debugger:devtools_client] No probes found for breakpoint %s', params.hitBreakpoints[i])
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
if (probesAtLocation.size !== 1) {
|
|
69
75
|
numberOfProbesOnBreakpoint = numberOfProbesOnBreakpoint + probesAtLocation.size - 1
|
|
70
76
|
if (numberOfProbesOnBreakpoint > snapshotProbeIndex.length) {
|
|
@@ -103,6 +109,7 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
103
109
|
if (probe.condition !== undefined) {
|
|
104
110
|
// TODO: Bundle all conditions and evaluate them in a single call
|
|
105
111
|
// TODO: Handle errors
|
|
112
|
+
// eslint-disable-next-line no-await-in-loop
|
|
106
113
|
const { result } = await session.post('Debugger.evaluateOnCallFrame', {
|
|
107
114
|
callFrameId: params.callFrames[0].callFrameId,
|
|
108
115
|
expression: probe.condition,
|
|
@@ -128,7 +135,7 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
128
135
|
|
|
129
136
|
const timestamp = Date.now()
|
|
130
137
|
|
|
131
|
-
let evalResults
|
|
138
|
+
let evalResults
|
|
132
139
|
const { result } = await session.post('Debugger.evaluateOnCallFrame', {
|
|
133
140
|
callFrameId: params.callFrames[0].callFrameId,
|
|
134
141
|
expression: templateExpressions.length === 0
|
|
@@ -155,7 +162,7 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
155
162
|
|
|
156
163
|
log.debug(
|
|
157
164
|
'[debugger:devtools_client] Finished processing breakpoints - main thread paused for: %d ms',
|
|
158
|
-
Number(diff) /
|
|
165
|
+
Number(diff) / 1_000_000
|
|
159
166
|
)
|
|
160
167
|
|
|
161
168
|
const logger = {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { workerData: { rcPort } } = require('node:worker_threads')
|
|
4
|
-
const
|
|
5
|
-
const { addBreakpoint, removeBreakpoint } = require('./breakpoints')
|
|
4
|
+
const { addBreakpoint, removeBreakpoint, modifyBreakpoint } = require('./breakpoints')
|
|
6
5
|
const { ackReceived, ackInstalled, ackError } = require('./status')
|
|
7
6
|
const log = require('../../log')
|
|
8
7
|
|
|
@@ -57,45 +56,26 @@ async function processMsg (action, probe) {
|
|
|
57
56
|
}
|
|
58
57
|
if (!probe.where.sourceFile && !probe.where.lines) {
|
|
59
58
|
throw new Error(
|
|
60
|
-
// eslint-disable-next-line @stylistic/
|
|
59
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
61
60
|
`Unsupported probe insertion point! Only line-based probes are supported (id: ${probe.id}, version: ${probe.version})`
|
|
62
61
|
)
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
break
|
|
82
|
-
case 'apply':
|
|
83
|
-
await addBreakpoint(probe)
|
|
84
|
-
ackInstalled(probe)
|
|
85
|
-
break
|
|
86
|
-
case 'modify':
|
|
87
|
-
// TODO: Modify existing probe instead of removing it (DEBUG-2817)
|
|
88
|
-
await removeBreakpoint(probe)
|
|
89
|
-
await addBreakpoint(probe)
|
|
90
|
-
ackInstalled(probe) // TODO: Should we also send ackInstalled when modifying a probe?
|
|
91
|
-
break
|
|
92
|
-
default:
|
|
93
|
-
throw new Error(
|
|
94
|
-
// eslint-disable-next-line @stylistic/js/max-len
|
|
95
|
-
`Cannot process probe ${probe.id} (version: ${probe.version}) - unknown remote configuration action: ${action}`
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
} finally {
|
|
99
|
-
release()
|
|
64
|
+
switch (action) {
|
|
65
|
+
case 'unapply':
|
|
66
|
+
await removeBreakpoint(probe)
|
|
67
|
+
break
|
|
68
|
+
case 'apply':
|
|
69
|
+
await addBreakpoint(probe)
|
|
70
|
+
ackInstalled(probe)
|
|
71
|
+
break
|
|
72
|
+
case 'modify':
|
|
73
|
+
await modifyBreakpoint(probe)
|
|
74
|
+
ackInstalled(probe)
|
|
75
|
+
break
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Cannot process probe ${probe.id} (version: ${probe.version}) - unknown remote configuration action: ${action}`
|
|
79
|
+
)
|
|
100
80
|
}
|
|
101
81
|
}
|
|
@@ -9,6 +9,7 @@ const request = require('../../exporters/common/request')
|
|
|
9
9
|
const { GIT_COMMIT_SHA, GIT_REPOSITORY_URL } = require('../../plugins/util/tags')
|
|
10
10
|
const log = require('../../log')
|
|
11
11
|
const { version } = require('../../../../../package.json')
|
|
12
|
+
const { getEnvironmentVariable } = require('../../config-helper')
|
|
12
13
|
|
|
13
14
|
module.exports = send
|
|
14
15
|
|
|
@@ -21,8 +22,8 @@ const hostname = getHostname()
|
|
|
21
22
|
const service = config.service
|
|
22
23
|
|
|
23
24
|
const ddtags = [
|
|
24
|
-
['env',
|
|
25
|
-
['version',
|
|
25
|
+
['env', getEnvironmentVariable('DD_ENV')],
|
|
26
|
+
['version', getEnvironmentVariable('DD_VERSION')],
|
|
26
27
|
['debugger_version', version],
|
|
27
28
|
['host_name', hostname],
|
|
28
29
|
[GIT_COMMIT_SHA, config.commitSHA],
|
|
@@ -77,9 +77,8 @@ function getObjectProperties (subtype, objectId, opts, depth) {
|
|
|
77
77
|
return getProxy(objectId, opts, depth)
|
|
78
78
|
} else if (subtype === 'arraybuffer') {
|
|
79
79
|
return getArrayBuffer(objectId, opts, depth)
|
|
80
|
-
} else {
|
|
81
|
-
return getObject(objectId, opts, depth + 1, subtype === 'array' || subtype === 'typedarray')
|
|
82
80
|
}
|
|
81
|
+
return getObject(objectId, opts, depth + 1, subtype === 'array' || subtype === 'typedarray')
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
// TODO: The following extra information from `internalProperties` might be relevant to include for functions:
|
|
@@ -40,7 +40,7 @@ async function getLocalStateForCallFrame (
|
|
|
40
40
|
return () => new Error('Error getting local state')
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
//
|
|
43
|
+
// Delay calling `processRawState` so the caller gets a chance to resume the main thread before processing `rawState`
|
|
44
44
|
return () => {
|
|
45
45
|
processedState = processedState ?? processRawState(rawState, maxLength)
|
|
46
46
|
return processedState
|