dd-trace 5.53.0 → 5.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +2 -1
- package/index.d.ts +33 -16
- package/initialize.mjs +3 -4
- package/package.json +36 -34
- package/packages/datadog-core/src/utils/src/get.js +1 -1
- package/packages/datadog-core/src/utils/src/has.js +1 -1
- package/packages/datadog-core/src/utils/src/kebabcase.js +4 -6
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-core/src/utils/src/pick.js +2 -2
- package/packages/datadog-core/src/utils/src/set.js +1 -1
- package/packages/datadog-core/src/utils/src/uniq.js +1 -1
- package/packages/datadog-instrumentations/src/amqp10.js +19 -17
- package/packages/datadog-instrumentations/src/amqplib.js +52 -35
- package/packages/datadog-instrumentations/src/apollo.js +2 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +5 -4
- package/packages/datadog-instrumentations/src/child_process.js +1 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +88 -73
- package/packages/datadog-instrumentations/src/couchbase.js +3 -3
- package/packages/datadog-instrumentations/src/cucumber.js +87 -40
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +28 -34
- package/packages/datadog-instrumentations/src/graphql.js +7 -10
- package/packages/datadog-instrumentations/src/grpc/client.js +11 -23
- package/packages/datadog-instrumentations/src/grpc/server.js +7 -20
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +16 -10
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
- package/packages/datadog-instrumentations/src/helpers/register.js +5 -7
- package/packages/datadog-instrumentations/src/http/client.js +14 -20
- package/packages/datadog-instrumentations/src/jest.js +137 -48
- package/packages/datadog-instrumentations/src/kafkajs.js +52 -44
- package/packages/datadog-instrumentations/src/knex.js +4 -4
- package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
- package/packages/datadog-instrumentations/src/mariadb.js +38 -61
- package/packages/datadog-instrumentations/src/mocha/main.js +63 -24
- package/packages/datadog-instrumentations/src/mocha/utils.js +36 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +6 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +20 -36
- package/packages/datadog-instrumentations/src/mysql2.js +53 -47
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -0
- package/packages/datadog-instrumentations/src/nyc.js +1 -1
- package/packages/datadog-instrumentations/src/openai.js +21 -23
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +1 -2
- package/packages/datadog-instrumentations/src/playwright.js +112 -69
- package/packages/datadog-instrumentations/src/redis.js +3 -3
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/rhea.js +42 -54
- package/packages/datadog-instrumentations/src/router.js +22 -25
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +77 -28
- package/packages/datadog-plugin-amqp10/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqp10/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/client.js +6 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/util.js +1 -1
- package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -6
- package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +13 -13
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +24 -31
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +6 -6
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -5
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +5 -6
- package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
- package/packages/datadog-plugin-child_process/src/index.js +4 -4
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +23 -23
- package/packages/datadog-plugin-cucumber/src/index.js +57 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +97 -27
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
- package/packages/datadog-plugin-cypress/src/support.js +24 -5
- package/packages/datadog-plugin-express/src/code_origin.js +30 -0
- package/packages/datadog-plugin-express/src/index.js +10 -12
- package/packages/datadog-plugin-express/src/tracing.js +19 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +7 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +12 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +6 -2
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +26 -9
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/index.js +7 -6
- package/packages/datadog-plugin-graphql/src/resolve.js +2 -2
- package/packages/datadog-plugin-graphql/src/tools/index.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-grpc/src/client.js +2 -2
- package/packages/datadog-plugin-grpc/src/util.js +2 -2
- package/packages/datadog-plugin-http/src/client.js +18 -7
- package/packages/datadog-plugin-http2/src/client.js +20 -20
- package/packages/datadog-plugin-jest/src/index.js +23 -21
- package/packages/datadog-plugin-jest/src/util.js +8 -8
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +3 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -5
- package/packages/datadog-plugin-kafkajs/src/producer.js +8 -3
- package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +7 -7
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -2
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +6 -4
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +5 -4
- package/packages/datadog-plugin-langchain/src/tracing.js +11 -10
- package/packages/datadog-plugin-mariadb/src/index.js +3 -9
- package/packages/datadog-plugin-mocha/src/index.js +33 -13
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +11 -9
- package/packages/datadog-plugin-mysql2/src/index.js +16 -0
- package/packages/datadog-plugin-net/src/tcp.js +1 -1
- package/packages/datadog-plugin-next/src/index.js +6 -5
- package/packages/datadog-plugin-openai/src/services.js +6 -10
- package/packages/datadog-plugin-openai/src/tracing.js +10 -14
- package/packages/datadog-plugin-oracledb/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +22 -2
- package/packages/datadog-plugin-redis/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +8 -6
- package/packages/datadog-plugin-rhea/src/producer.js +5 -2
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/datadog-plugin-selenium/src/index.js +1 -6
- package/packages/datadog-plugin-vitest/src/index.js +47 -31
- package/packages/datadog-shimmer/src/shimmer.js +4 -8
- package/packages/dd-trace/src/appsec/api_security_sampler.js +2 -2
- package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
- package/packages/dd-trace/src/appsec/blocking.js +6 -20
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +4 -6
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +7 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +4 -6
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +9 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +5 -4
- package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +2 -3
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +102 -7
- package/packages/dd-trace/src/appsec/iast/path-line.js +7 -8
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +6 -13
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +6 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +4 -28
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -7
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +3 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -7
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +6 -6
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +7 -7
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +23 -24
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +6 -11
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +9 -11
- package/packages/dd-trace/src/appsec/index.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/index.js +15 -15
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
- package/packages/dd-trace/src/appsec/reporter.js +233 -40
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -5
- package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -5
- package/packages/dd-trace/src/appsec/user_tracking.js +3 -5
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
- package/packages/dd-trace/src/azure_metadata.js +2 -7
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +6 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +0 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -1
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +8 -5
- package/packages/dd-trace/src/ci-visibility/telemetry.js +4 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/config.js +82 -51
- package/packages/dd-trace/src/config_stable.js +3 -3
- package/packages/dd-trace/src/datastreams/encoding.js +9 -9
- package/packages/dd-trace/src/datastreams/fnv.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +4 -4
- package/packages/dd-trace/src/datastreams/processor.js +5 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +4 -6
- package/packages/dd-trace/src/datastreams/size.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +74 -67
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +6 -8
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +7 -1
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +8 -10
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +3 -3
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +2 -10
- package/packages/dd-trace/src/debugger/devtools_client/state.js +10 -3
- package/packages/dd-trace/src/dogstatsd.js +5 -4
- package/packages/dd-trace/src/encode/0.4.js +9 -9
- package/packages/dd-trace/src/encode/0.5.js +1 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +3 -3
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/tags-processors.js +1 -1
- package/packages/dd-trace/src/exporter.js +6 -6
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
- package/packages/dd-trace/src/exporters/common/docker.js +1 -1
- package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/common/util.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +5 -5
- package/packages/dd-trace/src/flare/file.js +1 -5
- package/packages/dd-trace/src/format.js +1 -1
- package/packages/dd-trace/src/git_properties.js +1 -1
- package/packages/dd-trace/src/id.js +12 -6
- package/packages/dd-trace/src/iitm.js +10 -22
- package/packages/dd-trace/src/lambda/handler.js +6 -6
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +2 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +2 -2
- package/packages/dd-trace/src/llmobs/tagger.js +110 -96
- package/packages/dd-trace/src/llmobs/util.js +9 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -1
- package/packages/dd-trace/src/log/index.js +4 -4
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/log/writer.js +2 -2
- package/packages/dd-trace/src/msgpack/chunk.js +3 -3
- package/packages/dd-trace/src/msgpack/encoder.js +28 -28
- package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
- package/packages/dd-trace/src/noop/span.js +3 -5
- package/packages/dd-trace/src/noop/tracer.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span_processor.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +6 -5
- package/packages/dd-trace/src/opentracing/propagation/log.js +6 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +27 -23
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
- package/packages/dd-trace/src/opentracing/span.js +9 -14
- package/packages/dd-trace/src/opentracing/tracer.js +9 -6
- package/packages/dd-trace/src/payload-tagging/index.js +1 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +6 -6
- package/packages/dd-trace/src/pkg.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +62 -10
- package/packages/dd-trace/src/plugins/consumer.js +2 -2
- package/packages/dd-trace/src/plugins/inbound.js +5 -1
- package/packages/dd-trace/src/plugins/index.js +0 -1
- package/packages/dd-trace/src/plugins/outbound.js +4 -5
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +2 -2
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/util/ci.js +23 -15
- package/packages/dd-trace/src/plugins/util/git.js +165 -11
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -1
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +27 -10
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +311 -48
- package/packages/dd-trace/src/plugins/util/url.js +1 -1
- package/packages/dd-trace/src/plugins/util/urlfilter.js +13 -17
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +12 -3
- package/packages/dd-trace/src/plugins/util/web.js +5 -4
- package/packages/dd-trace/src/priority_sampler.js +22 -22
- package/packages/dd-trace/src/profiling/config.js +44 -8
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +5 -5
- package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +37 -2
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -17
- package/packages/dd-trace/src/profiling/profilers/shared.js +6 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +6 -7
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -5
- package/packages/dd-trace/src/profiling/tagger.js +3 -5
- package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
- package/packages/dd-trace/src/proxy.js +7 -9
- package/packages/dd-trace/src/random_sampler.js +40 -0
- package/packages/dd-trace/src/rate_limiter.js +4 -4
- package/packages/dd-trace/src/remote_config/index.js +3 -7
- package/packages/dd-trace/src/remote_config/manager.js +25 -13
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +4 -4
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +2 -2
- package/packages/dd-trace/src/sampler.js +33 -4
- package/packages/dd-trace/src/sampling_rule.js +12 -3
- package/packages/dd-trace/src/scope.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
- package/packages/dd-trace/src/span_processor.js +3 -3
- package/packages/dd-trace/src/span_sampler.js +4 -1
- package/packages/dd-trace/src/standalone/tracesource.js +1 -1
- package/packages/dd-trace/src/startup-log.js +2 -2
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +9 -10
- package/packages/dd-trace/src/telemetry/metrics.js +10 -5
- package/packages/dd-trace/src/telemetry/send-data.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +23 -24
- package/packages/dd-trace/src/util.js +1 -1
- package/version.js +1 -0
- package/packages/datadog-instrumentations/src/paperplane.js +0 -77
- package/packages/datadog-plugin-paperplane/src/index.js +0 -25
- package/packages/datadog-plugin-paperplane/src/logger.js +0 -11
- package/packages/datadog-plugin-paperplane/src/server.js +0 -24
|
@@ -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,89 +90,84 @@ 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
173
|
// need to update the condtion of the breakpoint.
|
|
@@ -180,7 +176,7 @@ async function updateBreakpoint (breakpoint, 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 {
|
|
@@ -235,6 +231,17 @@ function stop () {
|
|
|
235
231
|
return session.post('Debugger.disable')
|
|
236
232
|
}
|
|
237
233
|
|
|
234
|
+
function lock (fn) {
|
|
235
|
+
return async function (...args) {
|
|
236
|
+
const release = await mutex()
|
|
237
|
+
try {
|
|
238
|
+
return await fn(...args)
|
|
239
|
+
} finally {
|
|
240
|
+
release()
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
238
245
|
// Only if all probes have a condition can we use a compound condition.
|
|
239
246
|
// Otherwise, we need to evaluate each probe individually once the breakpoint is hit.
|
|
240
247
|
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'
|
|
@@ -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) {
|
|
@@ -155,7 +161,7 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
155
161
|
|
|
156
162
|
log.debug(
|
|
157
163
|
'[debugger:devtools_client] Finished processing breakpoints - main thread paused for: %d ms',
|
|
158
|
-
Number(diff) /
|
|
164
|
+
Number(diff) / 1_000_000
|
|
159
165
|
)
|
|
160
166
|
|
|
161
167
|
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
|
}
|
|
@@ -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
|
|
@@ -238,16 +238,14 @@ function toArrayBuffer (type, bytes, maxLength) {
|
|
|
238
238
|
|
|
239
239
|
const size = bytes.length
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return { type, value: arrayBufferToString(bytes, size) }
|
|
250
|
-
}
|
|
241
|
+
return size > maxLength
|
|
242
|
+
? {
|
|
243
|
+
type,
|
|
244
|
+
value: arrayBufferToString(bytes, maxLength),
|
|
245
|
+
truncated: true,
|
|
246
|
+
size: bytes.length
|
|
247
|
+
}
|
|
248
|
+
: { type, value: arrayBufferToString(bytes, size) }
|
|
251
249
|
}
|
|
252
250
|
|
|
253
251
|
function arrayBufferToString (bytes, size) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const config = require('../config')
|
|
4
4
|
|
|
5
|
-
const excludedIdentifiers = config.dynamicInstrumentation.redactionExcludedIdentifiers
|
|
6
|
-
.map((name) => normalizeName(name))
|
|
5
|
+
const excludedIdentifiers = new Set(config.dynamicInstrumentation.redactionExcludedIdentifiers
|
|
6
|
+
.map((name) => normalizeName(name)))
|
|
7
7
|
|
|
8
8
|
const REDACTED_IDENTIFIERS = new Set(
|
|
9
9
|
[
|
|
@@ -98,7 +98,7 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
98
98
|
...config.dynamicInstrumentation.redactedIdentifiers
|
|
99
99
|
]
|
|
100
100
|
.map((name) => normalizeName(name))
|
|
101
|
-
.filter((name) => excludedIdentifiers.
|
|
101
|
+
.filter((name) => excludedIdentifiers.has(name) === false)
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
function normalizeName (name, isSymbol) {
|
|
@@ -4,7 +4,6 @@ const { join, dirname } = require('path')
|
|
|
4
4
|
const { readFileSync } = require('fs')
|
|
5
5
|
const { readFile } = require('fs/promises')
|
|
6
6
|
const { SourceMapConsumer } = require('source-map')
|
|
7
|
-
const { NODE_MAJOR } = require('../../../../../version')
|
|
8
7
|
|
|
9
8
|
const cache = new Map()
|
|
10
9
|
let cacheTimer = null
|
|
@@ -35,14 +34,7 @@ const self = module.exports = {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
// The version check inside this function is to guard against a bug Node.js version 18, in which calls to `setTimeout`
|
|
39
|
-
// might throw an uncatchable error from within `AsyncLocalStorage._propagate` with the following error message:
|
|
40
|
-
//
|
|
41
|
-
// TypeError: Cannot read properties of undefined (reading 'Symbol(kResourceStore)')
|
|
42
|
-
//
|
|
43
|
-
// Source: https://github.com/nodejs/node/blob/v18.20.6/lib/async_hooks.js#L312
|
|
44
37
|
function cacheIt (key, value) {
|
|
45
|
-
if (NODE_MAJOR < 20) return value
|
|
46
38
|
cacheTime = Date.now()
|
|
47
39
|
setCacheTTL()
|
|
48
40
|
cache.set(key, value)
|
|
@@ -54,7 +46,7 @@ function setCacheTTL () {
|
|
|
54
46
|
|
|
55
47
|
cacheTimer = setTimeout(function () {
|
|
56
48
|
cacheTimer = null
|
|
57
|
-
if (Date.now() - cacheTime <
|
|
49
|
+
if (Date.now() - cacheTime < 2500) {
|
|
58
50
|
// If the last cache entry was added recently, keep the cache alive
|
|
59
51
|
setCacheTTL()
|
|
60
52
|
} else {
|
|
@@ -62,7 +54,7 @@ function setCacheTTL () {
|
|
|
62
54
|
// Clear cache a few seconds after it was last used
|
|
63
55
|
cache.clear()
|
|
64
56
|
}
|
|
65
|
-
},
|
|
57
|
+
}, 5000).unref()
|
|
66
58
|
}
|
|
67
59
|
|
|
68
60
|
function loadInlineSourceMap (data) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { join, dirname } = require('path')
|
|
4
|
+
const { normalize } = require('source-map/lib/util')
|
|
4
5
|
const { loadSourceMapSync } = require('./source-maps')
|
|
5
6
|
const session = require('./session')
|
|
6
7
|
const log = require('../../log')
|
|
@@ -92,7 +93,7 @@ module.exports = {
|
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
return maxMatchLength
|
|
96
|
+
return maxMatchLength === -1 ? null : bestMatch
|
|
96
97
|
},
|
|
97
98
|
|
|
98
99
|
getStackFromCallFrames (callFrames) {
|
|
@@ -102,7 +103,7 @@ module.exports = {
|
|
|
102
103
|
// the `scriptUrls` map. That might result in this the `scriptUrls.get` call above returning `undefined`, which
|
|
103
104
|
// will throw when `startsWith` is called on it.
|
|
104
105
|
let fileName = scriptUrls.get(frame.location.scriptId)
|
|
105
|
-
if (fileName.startsWith('file://')) fileName = fileName.
|
|
106
|
+
if (fileName.startsWith('file://')) fileName = fileName.slice(7) // TODO: This might not be required
|
|
106
107
|
return {
|
|
107
108
|
fileName,
|
|
108
109
|
function: frame.functionName,
|
|
@@ -151,7 +152,13 @@ session.on('Debugger.scriptParsed', ({ params }) => {
|
|
|
151
152
|
...params,
|
|
152
153
|
sourceUrl: params.url,
|
|
153
154
|
url: new URL(join(dir, source), 'file:').href,
|
|
154
|
-
source
|
|
155
|
+
// The source url provided by V8 unfortunately doesn't always match the source url used internally in the
|
|
156
|
+
// `source-map` dependency. Both read the same source maps, but the `source-map` dependency iterates over all
|
|
157
|
+
// the `sources` and normalize them using an internal `normalize` function. If these two strings don't match,
|
|
158
|
+
// the `source-map` dependency will not be able to find the generated position. Below we use the same
|
|
159
|
+
// internal `normalize` function, to ensure compatibility.
|
|
160
|
+
// TODO: Consider swapping out the `source-map` dependency for something better so we don't have to do this.
|
|
161
|
+
source: normalize(source)
|
|
155
162
|
})
|
|
156
163
|
}
|
|
157
164
|
} else {
|
|
@@ -94,13 +94,13 @@ class DogStatsDClient {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
_sendUdp (queue) {
|
|
97
|
-
if (this._family
|
|
98
|
-
this._sendUdpFromQueue(queue, this._host, this._family)
|
|
99
|
-
} else {
|
|
97
|
+
if (this._family === 0) {
|
|
100
98
|
lookup(this._host, (err, address, family) => {
|
|
101
99
|
if (err) return log.error('DogStatsDClient: Host not found', err)
|
|
102
100
|
this._sendUdpFromQueue(queue, address, family)
|
|
103
101
|
})
|
|
102
|
+
} else {
|
|
103
|
+
this._sendUdpFromQueue(queue, this._host, this._family)
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -116,7 +116,8 @@ class DogStatsDClient {
|
|
|
116
116
|
_add (stat, value, type, tags) {
|
|
117
117
|
const message = `${this._prefix + stat}:${value}|${type}`
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
// Don't manipulate this._tags as it is still used
|
|
120
|
+
tags = tags ? [...this._tags, ...tags] : this._tags
|
|
120
121
|
|
|
121
122
|
if (tags.length > 0) {
|
|
122
123
|
this._write(`${message}|#${tags.join(',')}\n`)
|
|
@@ -13,11 +13,11 @@ function formatSpan (span, config) {
|
|
|
13
13
|
span = normalizeSpan(truncateSpan(span, false))
|
|
14
14
|
if (span.span_events) {
|
|
15
15
|
// ensure span events are encoded as tags if agent doesn't support native top level span events
|
|
16
|
-
if (
|
|
16
|
+
if (config?.trace?.nativeSpanEvents) {
|
|
17
|
+
formatSpanEvents(span)
|
|
18
|
+
} else {
|
|
17
19
|
span.meta.events = JSON.stringify(span.span_events)
|
|
18
20
|
delete span.span_events
|
|
19
|
-
} else {
|
|
20
|
-
formatSpanEvents(span)
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
return span
|
|
@@ -175,7 +175,7 @@ class AgentEncoder {
|
|
|
175
175
|
|
|
176
176
|
id = id.toArray()
|
|
177
177
|
|
|
178
|
-
bytes.buffer[offset] =
|
|
178
|
+
bytes.buffer[offset] = 0xCF
|
|
179
179
|
bytes.buffer[offset + 1] = id[0]
|
|
180
180
|
bytes.buffer[offset + 2] = id[1]
|
|
181
181
|
bytes.buffer[offset + 3] = id[2]
|
|
@@ -266,7 +266,7 @@ class AgentEncoder {
|
|
|
266
266
|
|
|
267
267
|
// we should do it after encoding the object to know the real length
|
|
268
268
|
const length = bytes.length - offset - prefixLength
|
|
269
|
-
bytes.buffer[offset] =
|
|
269
|
+
bytes.buffer[offset] = 0xC6
|
|
270
270
|
bytes.buffer[offset + 1] = length >> 24
|
|
271
271
|
bytes.buffer[offset + 2] = length >> 16
|
|
272
272
|
bytes.buffer[offset + 3] = length >> 8
|
|
@@ -326,7 +326,7 @@ class AgentEncoder {
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
_writeArrayPrefix (buffer, offset, count) {
|
|
329
|
-
buffer[offset++] =
|
|
329
|
+
buffer[offset++] = 0xDD
|
|
330
330
|
buffer.writeUInt32BE(count, offset)
|
|
331
331
|
|
|
332
332
|
return offset + 4
|
|
@@ -351,10 +351,10 @@ function formatSpanEvents (span) {
|
|
|
351
351
|
if (spanEvent.attributes) {
|
|
352
352
|
for (const [key, value] of Object.entries(spanEvent.attributes)) {
|
|
353
353
|
const newValue = convertSpanEventAttributeValues(key, value)
|
|
354
|
-
if (newValue
|
|
355
|
-
spanEvent.attributes[key] = newValue
|
|
356
|
-
} else {
|
|
354
|
+
if (newValue === undefined) {
|
|
357
355
|
delete spanEvent.attributes[key] // delete from attributes if undefined
|
|
356
|
+
} else {
|
|
357
|
+
spanEvent.attributes[key] = newValue
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
if (Object.keys(spanEvent.attributes).length === 0) {
|
|
@@ -4,7 +4,7 @@ const { truncateSpan, normalizeSpan } = require('./tags-processors')
|
|
|
4
4
|
const { AgentEncoder: BaseEncoder } = require('./0.4')
|
|
5
5
|
|
|
6
6
|
const ARRAY_OF_TWO = 0x92
|
|
7
|
-
const ARRAY_OF_TWELVE =
|
|
7
|
+
const ARRAY_OF_TWELVE = 0x9C
|
|
8
8
|
|
|
9
9
|
function formatSpan (span) {
|
|
10
10
|
span = normalizeSpan(truncateSpan(span, false))
|
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
} = require('../ci-visibility/telemetry')
|
|
12
12
|
|
|
13
13
|
const ENCODING_VERSION = 1
|
|
14
|
-
const ALLOWED_CONTENT_TYPES = ['test_session_end', 'test_module_end', 'test_suite_end', 'test']
|
|
14
|
+
const ALLOWED_CONTENT_TYPES = new Set(['test_session_end', 'test_module_end', 'test_suite_end', 'test'])
|
|
15
15
|
|
|
16
16
|
const TEST_SUITE_KEYS_LENGTH = 12
|
|
17
17
|
const TEST_MODULE_KEYS_LENGTH = 11
|
|
@@ -26,7 +26,7 @@ function formatSpan (span) {
|
|
|
26
26
|
encodingVersion = 2
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
29
|
-
type: ALLOWED_CONTENT_TYPES.
|
|
29
|
+
type: ALLOWED_CONTENT_TYPES.has(span.type) ? span.type : 'span',
|
|
30
30
|
version: encodingVersion,
|
|
31
31
|
content: normalizeSpan(truncateSpan(span))
|
|
32
32
|
}
|
|
@@ -292,7 +292,7 @@ class AgentlessCiVisibilityEncoder extends AgentEncoder {
|
|
|
292
292
|
const eventsOffset = this._eventsOffset
|
|
293
293
|
const eventsCount = this._eventCount
|
|
294
294
|
|
|
295
|
-
bytes.buffer[eventsOffset] =
|
|
295
|
+
bytes.buffer[eventsOffset] = 0xDD
|
|
296
296
|
bytes.buffer[eventsOffset + 1] = eventsCount >> 24
|
|
297
297
|
bytes.buffer[eventsOffset + 2] = eventsCount >> 16
|
|
298
298
|
bytes.buffer[eventsOffset + 3] = eventsCount >> 8
|
|
@@ -92,7 +92,7 @@ class CoverageCIVisibilityEncoder extends AgentEncoder {
|
|
|
92
92
|
const coveragesCount = this._coveragesCount
|
|
93
93
|
|
|
94
94
|
// update with number of coverages
|
|
95
|
-
bytes.buffer[coveragesOffset] =
|
|
95
|
+
bytes.buffer[coveragesOffset] = 0xDD
|
|
96
96
|
bytes.buffer[coveragesOffset + 1] = coveragesCount >> 24
|
|
97
97
|
bytes.buffer[coveragesOffset + 2] = coveragesCount >> 16
|
|
98
98
|
bytes.buffer[coveragesOffset + 3] = coveragesCount >> 8
|
|
@@ -6,7 +6,7 @@ const MAX_RESOURCE_NAME_LENGTH = 5000
|
|
|
6
6
|
// MAX_META_KEY_LENGTH the maximum length of metadata key
|
|
7
7
|
const MAX_META_KEY_LENGTH = 200
|
|
8
8
|
// MAX_META_VALUE_LENGTH the maximum length of metadata value
|
|
9
|
-
const MAX_META_VALUE_LENGTH =
|
|
9
|
+
const MAX_META_VALUE_LENGTH = 25_000
|
|
10
10
|
// MAX_METRIC_KEY_LENGTH the maximum length of a metric name key
|
|
11
11
|
const MAX_METRIC_KEY_LENGTH = MAX_META_KEY_LENGTH
|
|
12
12
|
|
|
@@ -4,10 +4,7 @@ const exporters = require('../../../ext/exporters')
|
|
|
4
4
|
const fs = require('fs')
|
|
5
5
|
const constants = require('./constants')
|
|
6
6
|
|
|
7
|
-
module.exports = name
|
|
8
|
-
const inAWSLambda = process.env.AWS_LAMBDA_FUNCTION_NAME !== undefined
|
|
9
|
-
const usingLambdaExtension = inAWSLambda && fs.existsSync(constants.DATADOG_LAMBDA_EXTENSION_PATH)
|
|
10
|
-
|
|
7
|
+
module.exports = function getExporter (name) {
|
|
11
8
|
switch (name) {
|
|
12
9
|
case exporters.LOG:
|
|
13
10
|
return require('./exporters/log')
|
|
@@ -22,7 +19,10 @@ module.exports = name => {
|
|
|
22
19
|
case exporters.MOCHA_WORKER:
|
|
23
20
|
case exporters.PLAYWRIGHT_WORKER:
|
|
24
21
|
return require('./ci-visibility/exporters/test-worker')
|
|
25
|
-
default:
|
|
26
|
-
|
|
22
|
+
default: {
|
|
23
|
+
const inAWSLambda = process.env.AWS_LAMBDA_FUNCTION_NAME !== undefined
|
|
24
|
+
const usingLambdaExtension = inAWSLambda && fs.existsSync(constants.DATADOG_LAMBDA_EXTENSION_PATH)
|
|
25
|
+
return require(inAWSLambda && !usingLambdaExtension ? './exporters/log' : './exporters/agent')
|
|
26
|
+
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -69,11 +69,7 @@ function setHeader (headers, key, value) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function getEncoder (protocolVersion) {
|
|
72
|
-
|
|
73
|
-
return require('../../encode/0.5').AgentEncoder
|
|
74
|
-
} else {
|
|
75
|
-
return require('../../encode/0.4').AgentEncoder
|
|
76
|
-
}
|
|
72
|
+
return require(`../../encode/${protocolVersion === '0.5' ? '0.5' : '0.4'}`).AgentEncoder
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
function makeRequest (version, data, count, url, headers, lookup, needsStartupLog, cb) {
|