dd-trace 5.52.0 → 5.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +2 -1
- package/README.md +5 -0
- package/index.d.ts +87 -22
- package/initialize.mjs +3 -4
- package/package.json +36 -34
- package/packages/datadog-core/src/utils/src/get.js +1 -1
- package/packages/datadog-core/src/utils/src/has.js +1 -1
- package/packages/datadog-core/src/utils/src/kebabcase.js +4 -6
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-core/src/utils/src/pick.js +2 -2
- package/packages/datadog-core/src/utils/src/set.js +1 -1
- package/packages/datadog-core/src/utils/src/uniq.js +1 -1
- package/packages/datadog-instrumentations/src/amqp10.js +19 -17
- package/packages/datadog-instrumentations/src/amqplib.js +57 -37
- package/packages/datadog-instrumentations/src/apollo.js +2 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +5 -4
- package/packages/datadog-instrumentations/src/child_process.js +3 -3
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +92 -62
- package/packages/datadog-instrumentations/src/couchbase.js +5 -4
- package/packages/datadog-instrumentations/src/cucumber.js +126 -84
- package/packages/datadog-instrumentations/src/cypress.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +2 -6
- package/packages/datadog-instrumentations/src/fs.js +7 -6
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +28 -34
- package/packages/datadog-instrumentations/src/graphql.js +7 -10
- package/packages/datadog-instrumentations/src/grpc/client.js +11 -23
- package/packages/datadog-instrumentations/src/grpc/server.js +7 -20
- package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +16 -10
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
- package/packages/datadog-instrumentations/src/helpers/register.js +21 -18
- package/packages/datadog-instrumentations/src/http/client.js +16 -21
- package/packages/datadog-instrumentations/src/iovalkey.js +51 -0
- package/packages/datadog-instrumentations/src/jest.js +184 -87
- package/packages/datadog-instrumentations/src/kafkajs.js +65 -44
- package/packages/datadog-instrumentations/src/knex.js +4 -4
- package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
- package/packages/datadog-instrumentations/src/mariadb.js +38 -61
- package/packages/datadog-instrumentations/src/mocha/main.js +85 -59
- package/packages/datadog-instrumentations/src/mocha/utils.js +103 -82
- package/packages/datadog-instrumentations/src/mocha/worker.js +6 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +20 -36
- package/packages/datadog-instrumentations/src/mysql2.js +55 -47
- package/packages/datadog-instrumentations/src/net.js +4 -2
- package/packages/datadog-instrumentations/src/next.js +7 -14
- package/packages/datadog-instrumentations/src/nyc.js +1 -1
- package/packages/datadog-instrumentations/src/openai.js +21 -23
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +6 -13
- package/packages/datadog-instrumentations/src/playwright.js +170 -136
- package/packages/datadog-instrumentations/src/redis.js +3 -3
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/rhea.js +42 -54
- package/packages/datadog-instrumentations/src/router.js +22 -25
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/url.js +9 -17
- package/packages/datadog-instrumentations/src/vitest.js +126 -97
- package/packages/datadog-plugin-amqp10/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqp10/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/client.js +6 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/producer.js +7 -3
- package/packages/datadog-plugin-amqplib/src/util.js +1 -1
- package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -6
- package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +13 -13
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +24 -31
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +6 -6
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -5
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +5 -6
- package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
- package/packages/datadog-plugin-child_process/src/index.js +4 -4
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +23 -23
- package/packages/datadog-plugin-cucumber/src/index.js +86 -20
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +97 -27
- package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
- package/packages/datadog-plugin-cypress/src/support.js +24 -5
- package/packages/datadog-plugin-express/src/code_origin.js +30 -0
- package/packages/datadog-plugin-express/src/index.js +10 -12
- package/packages/datadog-plugin-express/src/tracing.js +19 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +7 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +12 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +6 -2
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +26 -9
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/index.js +7 -6
- package/packages/datadog-plugin-graphql/src/resolve.js +2 -2
- package/packages/datadog-plugin-graphql/src/tools/index.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-grpc/src/client.js +2 -2
- package/packages/datadog-plugin-grpc/src/util.js +2 -2
- package/packages/datadog-plugin-http/src/client.js +18 -7
- package/packages/datadog-plugin-http2/src/client.js +20 -20
- package/packages/datadog-plugin-iovalkey/src/index.js +18 -0
- package/packages/datadog-plugin-jest/src/index.js +36 -28
- package/packages/datadog-plugin-jest/src/util.js +8 -8
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +3 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -5
- package/packages/datadog-plugin-kafkajs/src/producer.js +15 -7
- package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +7 -7
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -2
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +6 -4
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +5 -4
- package/packages/datadog-plugin-langchain/src/tracing.js +11 -10
- package/packages/datadog-plugin-mariadb/src/index.js +3 -9
- package/packages/datadog-plugin-mocha/src/index.js +88 -48
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +11 -9
- package/packages/datadog-plugin-mysql2/src/index.js +16 -0
- package/packages/datadog-plugin-net/src/tcp.js +1 -1
- package/packages/datadog-plugin-next/src/index.js +6 -5
- package/packages/datadog-plugin-openai/src/services.js +6 -10
- package/packages/datadog-plugin-openai/src/tracing.js +10 -14
- package/packages/datadog-plugin-oracledb/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +48 -22
- package/packages/datadog-plugin-redis/src/index.js +9 -4
- package/packages/datadog-plugin-rhea/src/consumer.js +8 -6
- package/packages/datadog-plugin-rhea/src/producer.js +5 -2
- package/packages/datadog-plugin-router/src/index.js +1 -1
- package/packages/datadog-plugin-selenium/src/index.js +1 -6
- package/packages/datadog-plugin-vitest/src/index.js +99 -72
- package/packages/datadog-shimmer/src/shimmer.js +163 -36
- package/packages/dd-trace/src/appsec/api_security_sampler.js +2 -2
- package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
- package/packages/dd-trace/src/appsec/blocking.js +6 -20
- package/packages/dd-trace/src/appsec/graphql.js +2 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +4 -6
- package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +7 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +4 -6
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +9 -12
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +5 -4
- package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +2 -3
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +102 -7
- package/packages/dd-trace/src/appsec/iast/path-line.js +7 -8
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +6 -13
- package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +6 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +4 -28
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -7
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +3 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -7
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +6 -6
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +7 -7
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +23 -24
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +6 -11
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +9 -11
- package/packages/dd-trace/src/appsec/index.js +15 -12
- package/packages/dd-trace/src/appsec/rasp/index.js +19 -17
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
- package/packages/dd-trace/src/appsec/rasp/utils.js +11 -6
- package/packages/dd-trace/src/appsec/reporter.js +233 -40
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
- package/packages/dd-trace/src/appsec/telemetry/index.js +1 -2
- package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -14
- package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -5
- package/packages/dd-trace/src/appsec/user_tracking.js +3 -5
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +8 -8
- package/packages/dd-trace/src/azure_metadata.js +2 -7
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +6 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +0 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -1
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +8 -5
- package/packages/dd-trace/src/ci-visibility/telemetry.js +4 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/config.js +82 -51
- package/packages/dd-trace/src/config_stable.js +3 -3
- package/packages/dd-trace/src/datastreams/encoding.js +9 -9
- package/packages/dd-trace/src/datastreams/fnv.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +4 -4
- package/packages/dd-trace/src/datastreams/processor.js +5 -7
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +4 -6
- package/packages/dd-trace/src/datastreams/size.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +131 -72
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +6 -8
- package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +17 -27
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
- package/packages/dd-trace/src/debugger/devtools_client/send.js +8 -7
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +16 -8
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +8 -10
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +3 -3
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +2 -10
- package/packages/dd-trace/src/debugger/devtools_client/state.js +31 -4
- package/packages/dd-trace/src/dogstatsd.js +7 -4
- package/packages/dd-trace/src/encode/0.4.js +9 -9
- package/packages/dd-trace/src/encode/0.5.js +1 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +3 -3
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/tags-processors.js +1 -1
- package/packages/dd-trace/src/exporter.js +6 -6
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
- package/packages/dd-trace/src/exporters/common/docker.js +1 -1
- package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/common/util.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +5 -5
- package/packages/dd-trace/src/flare/file.js +1 -5
- package/packages/dd-trace/src/format.js +1 -1
- package/packages/dd-trace/src/git_properties.js +1 -1
- package/packages/dd-trace/src/id.js +12 -6
- package/packages/dd-trace/src/iitm.js +10 -22
- package/packages/dd-trace/src/lambda/handler.js +6 -6
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +2 -6
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +6 -6
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +2 -2
- package/packages/dd-trace/src/llmobs/tagger.js +113 -99
- package/packages/dd-trace/src/llmobs/util.js +9 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -1
- package/packages/dd-trace/src/log/index.js +4 -4
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/log/writer.js +2 -2
- package/packages/dd-trace/src/msgpack/chunk.js +3 -3
- package/packages/dd-trace/src/msgpack/encoder.js +28 -28
- package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
- package/packages/dd-trace/src/noop/span.js +3 -5
- package/packages/dd-trace/src/noop/tracer.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span_processor.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +6 -5
- package/packages/dd-trace/src/opentracing/propagation/log.js +6 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +27 -23
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
- package/packages/dd-trace/src/opentracing/span.js +9 -14
- package/packages/dd-trace/src/opentracing/tracer.js +9 -6
- package/packages/dd-trace/src/payload-tagging/index.js +1 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +6 -6
- package/packages/dd-trace/src/pkg.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +62 -10
- package/packages/dd-trace/src/plugins/consumer.js +2 -2
- package/packages/dd-trace/src/plugins/inbound.js +5 -1
- package/packages/dd-trace/src/plugins/index.js +1 -1
- package/packages/dd-trace/src/plugins/outbound.js +4 -5
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +2 -2
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/util/ci.js +23 -15
- package/packages/dd-trace/src/plugins/util/git.js +165 -11
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -1
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +27 -10
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +311 -48
- package/packages/dd-trace/src/plugins/util/url.js +1 -1
- package/packages/dd-trace/src/plugins/util/urlfilter.js +13 -17
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +12 -3
- package/packages/dd-trace/src/plugins/util/web.js +5 -4
- package/packages/dd-trace/src/priority_sampler.js +22 -22
- package/packages/dd-trace/src/profiling/config.js +44 -8
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +5 -5
- package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +37 -2
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -17
- package/packages/dd-trace/src/profiling/profilers/shared.js +6 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +6 -7
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -5
- package/packages/dd-trace/src/profiling/tagger.js +3 -5
- package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
- package/packages/dd-trace/src/proxy.js +7 -13
- package/packages/dd-trace/src/random_sampler.js +40 -0
- package/packages/dd-trace/src/rate_limiter.js +4 -4
- package/packages/dd-trace/src/remote_config/index.js +3 -7
- package/packages/dd-trace/src/remote_config/manager.js +25 -13
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +4 -4
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +2 -2
- package/packages/dd-trace/src/sampler.js +33 -4
- package/packages/dd-trace/src/sampling_rule.js +12 -3
- package/packages/dd-trace/src/scope.js +1 -1
- package/packages/dd-trace/src/serverless.js +0 -48
- package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -0
- package/packages/dd-trace/src/span_processor.js +3 -3
- package/packages/dd-trace/src/span_sampler.js +4 -1
- package/packages/dd-trace/src/standalone/tracesource.js +1 -1
- package/packages/dd-trace/src/startup-log.js +2 -2
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +9 -10
- package/packages/dd-trace/src/telemetry/metrics.js +10 -5
- package/packages/dd-trace/src/telemetry/send-data.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +23 -24
- package/packages/dd-trace/src/util.js +1 -1
- package/version.js +1 -0
- package/packages/datadog-instrumentations/src/paperplane.js +0 -77
- package/packages/datadog-plugin-paperplane/src/index.js +0 -25
- package/packages/datadog-plugin-paperplane/src/logger.js +0 -11
- package/packages/datadog-plugin-paperplane/src/server.js +0 -24
|
@@ -4,7 +4,7 @@ function convertToTextMap (bufferMap) {
|
|
|
4
4
|
if (!bufferMap) return null
|
|
5
5
|
|
|
6
6
|
// rdKafka returns an array of header maps
|
|
7
|
-
if (bufferMap
|
|
7
|
+
if (Array.isArray(bufferMap)) {
|
|
8
8
|
const headers = {}
|
|
9
9
|
for (const headerMap of bufferMap) {
|
|
10
10
|
for (const key of Object.keys(headerMap)) {
|
|
@@ -3,35 +3,35 @@
|
|
|
3
3
|
const LangChainHandler = require('./default')
|
|
4
4
|
|
|
5
5
|
class LangChainChainHandler extends LangChainHandler {
|
|
6
|
-
getSpanStartTags (ctx) {
|
|
6
|
+
getSpanStartTags (ctx, provider, span) {
|
|
7
7
|
const tags = {}
|
|
8
8
|
|
|
9
|
-
if (!this.isPromptCompletionSampled()) return tags
|
|
9
|
+
if (!this.isPromptCompletionSampled(span)) return tags
|
|
10
10
|
|
|
11
11
|
let inputs = ctx.args?.[0]
|
|
12
12
|
inputs = Array.isArray(inputs) ? inputs : [inputs]
|
|
13
13
|
|
|
14
14
|
for (const idx in inputs) {
|
|
15
15
|
const input = inputs[idx]
|
|
16
|
-
if (typeof input
|
|
17
|
-
tags[`langchain.request.inputs.${idx}`] = this.normalize(input)
|
|
18
|
-
} else {
|
|
16
|
+
if (typeof input === 'object') {
|
|
19
17
|
for (const [key, value] of Object.entries(input)) {
|
|
20
18
|
// these are mappings to the python client names, ie lc_kwargs
|
|
21
19
|
// only present on BaseMessage types
|
|
22
20
|
if (key.includes('lc_')) continue
|
|
23
21
|
tags[`langchain.request.inputs.${idx}.${key}`] = this.normalize(value)
|
|
24
22
|
}
|
|
23
|
+
} else {
|
|
24
|
+
tags[`langchain.request.inputs.${idx}`] = this.normalize(input)
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return tags
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
getSpanEndTags (ctx) {
|
|
31
|
+
getSpanEndTags (ctx, span) {
|
|
32
32
|
const tags = {}
|
|
33
33
|
|
|
34
|
-
if (!this.isPromptCompletionSampled()) return tags
|
|
34
|
+
if (!this.isPromptCompletionSampled(span)) return tags
|
|
35
35
|
|
|
36
36
|
let outputs = ctx.result
|
|
37
37
|
outputs = Array.isArray(outputs) ? outputs : [outputs]
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
const LangChainHandler = require('./default')
|
|
4
4
|
|
|
5
5
|
class LangChainEmbeddingHandler extends LangChainHandler {
|
|
6
|
-
getSpanStartTags (ctx) {
|
|
6
|
+
getSpanStartTags (ctx, provider, span) {
|
|
7
7
|
const tags = {}
|
|
8
8
|
|
|
9
9
|
const inputTexts = ctx.args?.[0]
|
|
10
10
|
|
|
11
|
-
const sampled = this.isPromptCompletionSampled()
|
|
11
|
+
const sampled = this.isPromptCompletionSampled(span)
|
|
12
12
|
if (typeof inputTexts === 'string') {
|
|
13
13
|
// embed query
|
|
14
14
|
if (sampled) {
|
|
@@ -5,7 +5,7 @@ const LangChainLanguageModelHandler = require('.')
|
|
|
5
5
|
const COMPLETIONS = 'langchain.response.completions'
|
|
6
6
|
|
|
7
7
|
class LangChainChatModelHandler extends LangChainLanguageModelHandler {
|
|
8
|
-
getSpanStartTags (ctx, provider) {
|
|
8
|
+
getSpanStartTags (ctx, provider, span) {
|
|
9
9
|
const tags = {}
|
|
10
10
|
|
|
11
11
|
const inputs = ctx.args?.[0]
|
|
@@ -15,7 +15,7 @@ class LangChainChatModelHandler extends LangChainLanguageModelHandler {
|
|
|
15
15
|
|
|
16
16
|
for (const messageIndex in messageSet) {
|
|
17
17
|
const message = messageSet[messageIndex]
|
|
18
|
-
if (this.isPromptCompletionSampled()) {
|
|
18
|
+
if (this.isPromptCompletionSampled(span)) {
|
|
19
19
|
tags[`langchain.request.messages.${messageSetIndex}.${messageIndex}.content`] =
|
|
20
20
|
this.normalize(message.content) || ''
|
|
21
21
|
}
|
|
@@ -39,11 +39,13 @@ class LangChainChatModelHandler extends LangChainLanguageModelHandler {
|
|
|
39
39
|
return tags
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
getSpanEndTags (ctx) {
|
|
42
|
+
getSpanEndTags (ctx, span) {
|
|
43
43
|
const { result } = ctx
|
|
44
44
|
|
|
45
45
|
const tags = {}
|
|
46
46
|
|
|
47
|
+
const sampled = this.isPromptCompletionSampled(span)
|
|
48
|
+
|
|
47
49
|
this.extractTokenMetrics(ctx.currentStore?.span, result)
|
|
48
50
|
|
|
49
51
|
for (const messageSetIdx in result?.generations) {
|
|
@@ -56,7 +58,7 @@ class LangChainChatModelHandler extends LangChainLanguageModelHandler {
|
|
|
56
58
|
const message = chatCompletion.message
|
|
57
59
|
let toolCalls = message.tool_calls
|
|
58
60
|
|
|
59
|
-
if (text &&
|
|
61
|
+
if (text && sampled) {
|
|
60
62
|
tags[
|
|
61
63
|
`${COMPLETIONS}.${messageSetIdx}.${chatCompletionIdx}.content`
|
|
62
64
|
] = this.normalize(text)
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
const LangChainLanguageModelHandler = require('.')
|
|
4
4
|
|
|
5
5
|
class LangChainLLMHandler extends LangChainLanguageModelHandler {
|
|
6
|
-
getSpanStartTags (ctx, provider) {
|
|
6
|
+
getSpanStartTags (ctx, provider, span) {
|
|
7
7
|
const tags = {}
|
|
8
8
|
|
|
9
9
|
const prompts = ctx.args?.[0]
|
|
10
10
|
for (const promptIdx in prompts) {
|
|
11
|
-
if (!this.isPromptCompletionSampled()) continue
|
|
11
|
+
if (!this.isPromptCompletionSampled(span)) continue
|
|
12
12
|
|
|
13
13
|
const prompt = prompts[promptIdx]
|
|
14
14
|
tags[`langchain.request.prompts.${promptIdx}.content`] = this.normalize(prompt) || ''
|
|
@@ -30,16 +30,17 @@ class LangChainLLMHandler extends LangChainLanguageModelHandler {
|
|
|
30
30
|
return tags
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
getSpanEndTags (ctx) {
|
|
33
|
+
getSpanEndTags (ctx, span) {
|
|
34
34
|
const { result } = ctx
|
|
35
35
|
|
|
36
36
|
const tags = {}
|
|
37
|
+
const sampled = this.isPromptCompletionSampled(span)
|
|
37
38
|
|
|
38
39
|
this.extractTokenMetrics(ctx.currentStore?.span, result)
|
|
39
40
|
|
|
40
41
|
for (const completionIdx in result?.generations) {
|
|
41
42
|
const completion = result.generations[completionIdx]
|
|
42
|
-
if (
|
|
43
|
+
if (sampled) {
|
|
43
44
|
tags[`langchain.response.completions.${completionIdx}.text`] = this.normalize(completion[0].text) || ''
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -49,23 +49,24 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
|
|
|
49
49
|
const provider = handler.extractProvider(instance)
|
|
50
50
|
const model = handler.extractModel(instance)
|
|
51
51
|
|
|
52
|
-
const tags = handler.getSpanStartTags(ctx, provider) || []
|
|
53
|
-
|
|
54
|
-
if (apiKey) tags[API_KEY] = apiKey
|
|
55
|
-
if (provider) tags[PROVIDER] = provider
|
|
56
|
-
if (model) tags[MODEL] = model
|
|
57
|
-
if (type) tags[TYPE] = type
|
|
58
|
-
|
|
59
52
|
const span = this.startSpan('langchain.request', {
|
|
60
53
|
service: this.config.service,
|
|
61
54
|
resource,
|
|
62
55
|
kind: 'client',
|
|
63
56
|
meta: {
|
|
64
|
-
[MEASURED]: 1
|
|
65
|
-
...tags
|
|
57
|
+
[MEASURED]: 1
|
|
66
58
|
}
|
|
67
59
|
}, false)
|
|
68
60
|
|
|
61
|
+
const tags = handler.getSpanStartTags(ctx, provider, span) || []
|
|
62
|
+
|
|
63
|
+
if (apiKey) tags[API_KEY] = apiKey
|
|
64
|
+
if (provider) tags[PROVIDER] = provider
|
|
65
|
+
if (model) tags[MODEL] = model
|
|
66
|
+
if (type) tags[TYPE] = type
|
|
67
|
+
|
|
68
|
+
span.addTags(tags)
|
|
69
|
+
|
|
69
70
|
const store = storage('legacy').getStore() || {}
|
|
70
71
|
ctx.currentStore = { ...store, span }
|
|
71
72
|
|
|
@@ -78,7 +79,7 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
|
|
|
78
79
|
const { type } = ctx
|
|
79
80
|
|
|
80
81
|
const handler = this.handlers[type]
|
|
81
|
-
const tags = handler.getSpanEndTags(ctx) || {}
|
|
82
|
+
const tags = handler.getSpanEndTags(ctx, span) || {}
|
|
82
83
|
|
|
83
84
|
span.addTags(tags)
|
|
84
85
|
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
const { storage } = require('../../datadog-core')
|
|
4
4
|
const MySQLPlugin = require('../../datadog-plugin-mysql/src')
|
|
5
5
|
|
|
6
|
-
let skippedStore
|
|
7
|
-
|
|
8
6
|
class MariadbPlugin extends MySQLPlugin {
|
|
9
7
|
static get id () { return 'mariadb' }
|
|
10
8
|
static get system () { return 'mariadb' }
|
|
@@ -12,14 +10,10 @@ class MariadbPlugin extends MySQLPlugin {
|
|
|
12
10
|
constructor (...args) {
|
|
13
11
|
super(...args)
|
|
14
12
|
|
|
15
|
-
this.
|
|
16
|
-
skippedStore = storage('legacy').getStore()
|
|
17
|
-
storage('legacy').enterWith({ noop: true })
|
|
18
|
-
})
|
|
13
|
+
this.addBind(`apm:${this.component}:pool:skip`, () => ({ noop: true }))
|
|
19
14
|
|
|
20
|
-
this.addSub(`apm:${this.component}:
|
|
21
|
-
storage('legacy').
|
|
22
|
-
skippedStore = undefined
|
|
15
|
+
this.addSub(`apm:${this.component}:command:add`, ctx => {
|
|
16
|
+
ctx.parentStore = storage('legacy').getStore()
|
|
23
17
|
})
|
|
24
18
|
}
|
|
25
19
|
}
|
|
@@ -37,7 +37,9 @@ const {
|
|
|
37
37
|
TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
|
|
38
38
|
TEST_HAS_FAILED_ALL_RETRIES,
|
|
39
39
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
40
|
-
TEST_RETRY_REASON_TYPES
|
|
40
|
+
TEST_RETRY_REASON_TYPES,
|
|
41
|
+
TEST_IS_MODIFIED,
|
|
42
|
+
isModifiedTest
|
|
41
43
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
42
44
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
43
45
|
const {
|
|
@@ -109,12 +111,9 @@ class MochaPlugin extends CiPlugin {
|
|
|
109
111
|
this.telemetry.distribution(TELEMETRY_CODE_COVERAGE_NUM_FILES, {}, relativeCoverageFiles.length)
|
|
110
112
|
})
|
|
111
113
|
|
|
112
|
-
this.
|
|
113
|
-
testSuiteAbsolutePath,
|
|
114
|
-
|
|
115
|
-
isForcedToRun,
|
|
116
|
-
itrCorrelationId
|
|
117
|
-
}) => {
|
|
114
|
+
this.addBind('ci:mocha:test-suite:start', (ctx) => {
|
|
115
|
+
const { testSuiteAbsolutePath, isUnskippable, isForcedToRun, itrCorrelationId } = ctx
|
|
116
|
+
|
|
118
117
|
// If the test module span is undefined, the plugin has not been initialized correctly and we bail out
|
|
119
118
|
if (!this.testModuleSpan) {
|
|
120
119
|
return
|
|
@@ -134,11 +133,9 @@ class MochaPlugin extends CiPlugin {
|
|
|
134
133
|
testSuiteMetadata[TEST_ITR_FORCED_RUN] = 'true'
|
|
135
134
|
this.telemetry.count(TELEMETRY_ITR_FORCED_TO_RUN, { testLevel: 'suite' })
|
|
136
135
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
testSuiteMetadata[TEST_SOURCE_FILE] = testSuite
|
|
141
|
-
}
|
|
136
|
+
testSuiteMetadata[TEST_SOURCE_FILE] = this.repositoryRoot !== this.sourceRoot && !!this.repositoryRoot
|
|
137
|
+
? getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
138
|
+
: testSuite
|
|
142
139
|
if (testSuiteMetadata[TEST_SOURCE_FILE]) {
|
|
143
140
|
testSuiteMetadata[TEST_SOURCE_START] = 1
|
|
144
141
|
}
|
|
@@ -164,38 +161,64 @@ class MochaPlugin extends CiPlugin {
|
|
|
164
161
|
testSuiteSpan.setTag(ITR_CORRELATION_ID, itrCorrelationId)
|
|
165
162
|
}
|
|
166
163
|
const store = storage('legacy').getStore()
|
|
167
|
-
|
|
164
|
+
ctx.parentStore = store
|
|
165
|
+
ctx.currentStore = { ...store, testSuiteSpan }
|
|
168
166
|
this._testSuites.set(testSuite, testSuiteSpan)
|
|
169
167
|
})
|
|
170
168
|
|
|
171
|
-
this.addSub('ci:mocha:test-suite:finish', (status) => {
|
|
172
|
-
|
|
173
|
-
if (store && store.span) {
|
|
174
|
-
const span = store.span
|
|
169
|
+
this.addSub('ci:mocha:test-suite:finish', ({ testSuiteSpan, status }) => {
|
|
170
|
+
if (testSuiteSpan) {
|
|
175
171
|
// the test status of the suite may have been set in ci:mocha:test-suite:error already
|
|
176
|
-
if (!
|
|
177
|
-
|
|
172
|
+
if (!testSuiteSpan.context()._tags[TEST_STATUS]) {
|
|
173
|
+
testSuiteSpan.setTag(TEST_STATUS, status)
|
|
178
174
|
}
|
|
179
|
-
|
|
175
|
+
testSuiteSpan.finish()
|
|
180
176
|
this.telemetry.ciVisEvent(TELEMETRY_EVENT_FINISHED, 'suite')
|
|
181
177
|
}
|
|
182
178
|
})
|
|
183
179
|
|
|
184
|
-
this.
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
this.addBind('ci:mocha:test-suite:error', (ctx) => {
|
|
181
|
+
const { error } = ctx
|
|
182
|
+
const testSuiteSpan = ctx.currentStore?.testSuiteSpan
|
|
183
|
+
|
|
184
|
+
if (testSuiteSpan) {
|
|
185
|
+
testSuiteSpan.setTag('error', error)
|
|
186
|
+
testSuiteSpan.setTag(TEST_STATUS, 'fail')
|
|
187
|
+
|
|
188
|
+
ctx.parentStore = ctx.currentStore
|
|
189
|
+
ctx.currentStore = { ...ctx.currentStore, testSuiteSpan }
|
|
190
190
|
}
|
|
191
|
+
|
|
192
|
+
return ctx.currentStore
|
|
191
193
|
})
|
|
192
194
|
|
|
193
|
-
this.addSub('ci:mocha:test:
|
|
195
|
+
this.addSub('ci:mocha:test:is-modified', ({ modifiedTests, file, onDone }) => {
|
|
196
|
+
const testPath = getTestSuitePath(file, this.repositoryRoot)
|
|
197
|
+
const isModified = isModifiedTest(
|
|
198
|
+
testPath,
|
|
199
|
+
null,
|
|
200
|
+
null,
|
|
201
|
+
modifiedTests,
|
|
202
|
+
this.constructor.id
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
onDone(isModified)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
this.addBind('ci:mocha:test:fn', (ctx) => {
|
|
209
|
+
return ctx.currentStore
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
this.addBind('ci:mocha:test:start', (ctx) => {
|
|
194
213
|
const store = storage('legacy').getStore()
|
|
195
|
-
const span = this.startTestSpan(
|
|
214
|
+
const span = this.startTestSpan(ctx)
|
|
215
|
+
|
|
216
|
+
ctx.parentStore = store
|
|
217
|
+
ctx.currentStore = { ...store, span }
|
|
196
218
|
|
|
197
|
-
this.enter(span, store)
|
|
198
219
|
this.activeTestSpan = span
|
|
220
|
+
|
|
221
|
+
return ctx.currentStore
|
|
199
222
|
})
|
|
200
223
|
|
|
201
224
|
this.addSub('ci:mocha:worker:finish', () => {
|
|
@@ -203,6 +226,7 @@ class MochaPlugin extends CiPlugin {
|
|
|
203
226
|
})
|
|
204
227
|
|
|
205
228
|
this.addSub('ci:mocha:test:finish', ({
|
|
229
|
+
span,
|
|
206
230
|
status,
|
|
207
231
|
hasBeenRetried,
|
|
208
232
|
isLastRetry,
|
|
@@ -212,9 +236,6 @@ class MochaPlugin extends CiPlugin {
|
|
|
212
236
|
isAttemptToFixRetry,
|
|
213
237
|
isAtrRetry
|
|
214
238
|
}) => {
|
|
215
|
-
const store = storage('legacy').getStore()
|
|
216
|
-
const span = store?.span
|
|
217
|
-
|
|
218
239
|
if (span) {
|
|
219
240
|
span.setTag(TEST_STATUS, status)
|
|
220
241
|
if (hasBeenRetried) {
|
|
@@ -260,19 +281,26 @@ class MochaPlugin extends CiPlugin {
|
|
|
260
281
|
}
|
|
261
282
|
})
|
|
262
283
|
|
|
263
|
-
this.
|
|
284
|
+
this.addBind('ci:mocha:test:skip', (ctx) => {
|
|
264
285
|
const store = storage('legacy').getStore()
|
|
265
286
|
// skipped through it.skip, so the span is not created yet
|
|
266
287
|
// for this test
|
|
267
288
|
if (!store) {
|
|
268
|
-
const
|
|
269
|
-
|
|
289
|
+
const span = this.startTestSpan(ctx)
|
|
290
|
+
|
|
291
|
+
ctx.parentStore = store
|
|
292
|
+
ctx.currentStore = { ...store, span }
|
|
293
|
+
|
|
294
|
+
this.activeTestSpan = span
|
|
270
295
|
}
|
|
296
|
+
|
|
297
|
+
return ctx.currentStore
|
|
271
298
|
})
|
|
272
299
|
|
|
273
|
-
this.
|
|
274
|
-
const
|
|
275
|
-
const span =
|
|
300
|
+
this.addBind('ci:mocha:test:error', (ctx) => {
|
|
301
|
+
const { err } = ctx
|
|
302
|
+
const span = ctx.currentStore?.span
|
|
303
|
+
|
|
276
304
|
if (err && span) {
|
|
277
305
|
if (err.constructor.name === 'Pending' && !this.forbidPending) {
|
|
278
306
|
span.setTag(TEST_STATUS, 'skip')
|
|
@@ -280,12 +308,17 @@ class MochaPlugin extends CiPlugin {
|
|
|
280
308
|
span.setTag(TEST_STATUS, 'fail')
|
|
281
309
|
span.setTag('error', err)
|
|
282
310
|
}
|
|
311
|
+
|
|
312
|
+
ctx.parentStore = ctx.currentStore
|
|
313
|
+
ctx.currentStore = { ...ctx.currentStore, span }
|
|
314
|
+
|
|
315
|
+
this.activeTestSpan = span
|
|
283
316
|
}
|
|
317
|
+
|
|
318
|
+
return ctx.currentStore
|
|
284
319
|
})
|
|
285
320
|
|
|
286
|
-
this.addSub('ci:mocha:test:retry', ({ isFirstAttempt, willBeRetried, err, test, isAtrRetry }) => {
|
|
287
|
-
const store = storage('legacy').getStore()
|
|
288
|
-
const span = store?.span
|
|
321
|
+
this.addSub('ci:mocha:test:retry', ({ span, isFirstAttempt, willBeRetried, err, test, isAtrRetry }) => {
|
|
289
322
|
if (span) {
|
|
290
323
|
span.setTag(TEST_STATUS, 'fail')
|
|
291
324
|
if (!isFirstAttempt) {
|
|
@@ -446,7 +479,8 @@ class MochaPlugin extends CiPlugin {
|
|
|
446
479
|
isParallel,
|
|
447
480
|
isAttemptToFix,
|
|
448
481
|
isDisabled,
|
|
449
|
-
isQuarantined
|
|
482
|
+
isQuarantined,
|
|
483
|
+
isModified
|
|
450
484
|
} = testInfo
|
|
451
485
|
|
|
452
486
|
const extraTags = {}
|
|
@@ -475,20 +509,26 @@ class MochaPlugin extends CiPlugin {
|
|
|
475
509
|
extraTags[TEST_MANAGEMENT_IS_QUARANTINED] = 'true'
|
|
476
510
|
}
|
|
477
511
|
|
|
512
|
+
if (isModified) {
|
|
513
|
+
extraTags[TEST_IS_MODIFIED] = 'true'
|
|
514
|
+
if (isEfdRetry) {
|
|
515
|
+
extraTags[TEST_IS_RETRY] = 'true'
|
|
516
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.efd
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
478
520
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, this.sourceRoot)
|
|
479
521
|
const testSuiteSpan = this._testSuites.get(testSuite)
|
|
480
522
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
extraTags[TEST_SOURCE_FILE] = testSuite
|
|
485
|
-
}
|
|
523
|
+
extraTags[TEST_SOURCE_FILE] = this.repositoryRoot !== this.sourceRoot && !!this.repositoryRoot
|
|
524
|
+
? getTestSuitePath(testSuiteAbsolutePath, this.repositoryRoot)
|
|
525
|
+
: testSuite
|
|
486
526
|
|
|
487
527
|
if (isNew) {
|
|
488
528
|
extraTags[TEST_IS_NEW] = 'true'
|
|
489
529
|
if (isEfdRetry) {
|
|
490
530
|
extraTags[TEST_IS_RETRY] = 'true'
|
|
491
|
-
extraTags[TEST_RETRY_REASON] =
|
|
531
|
+
extraTags[TEST_RETRY_REASON] = TEST_RETRY_REASON_TYPES.efd
|
|
492
532
|
}
|
|
493
533
|
}
|
|
494
534
|
|
|
@@ -103,7 +103,7 @@ function getResource (plugin, ns, query, operationName) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function truncate (input) {
|
|
106
|
-
return input.slice(0, Math.min(input.length,
|
|
106
|
+
return input.slice(0, Math.min(input.length, 10_000))
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function shouldSimplify (input) {
|
|
@@ -7,22 +7,24 @@ class MySQLPlugin extends DatabasePlugin {
|
|
|
7
7
|
static get id () { return 'mysql' }
|
|
8
8
|
static get system () { return 'mysql' }
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const service = this.serviceName({ pluginConfig: this.config, dbConfig:
|
|
10
|
+
bindStart (ctx) {
|
|
11
|
+
const service = this.serviceName({ pluginConfig: this.config, dbConfig: ctx.conf, system: this.system })
|
|
12
12
|
const span = this.startSpan(this.operationName(), {
|
|
13
13
|
service,
|
|
14
|
-
resource:
|
|
14
|
+
resource: ctx.sql,
|
|
15
15
|
type: 'sql',
|
|
16
16
|
kind: 'client',
|
|
17
17
|
meta: {
|
|
18
18
|
'db.type': this.system,
|
|
19
|
-
'db.user':
|
|
20
|
-
'db.name':
|
|
21
|
-
'out.host':
|
|
22
|
-
[CLIENT_PORT_KEY]:
|
|
19
|
+
'db.user': ctx.conf.user,
|
|
20
|
+
'db.name': ctx.conf.database,
|
|
21
|
+
'out.host': ctx.conf.host,
|
|
22
|
+
[CLIENT_PORT_KEY]: ctx.conf.port
|
|
23
23
|
}
|
|
24
|
-
})
|
|
25
|
-
|
|
24
|
+
}, ctx)
|
|
25
|
+
ctx.sql = this.injectDbmQuery(span, ctx.sql, service)
|
|
26
|
+
|
|
27
|
+
return ctx.currentStore
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { storage } = require('../../datadog-core')
|
|
3
4
|
const MySQLPlugin = require('../../datadog-plugin-mysql/src')
|
|
4
5
|
|
|
5
6
|
class MySQL2Plugin extends MySQLPlugin {
|
|
6
7
|
static get id () { return 'mysql2' }
|
|
8
|
+
|
|
9
|
+
constructor () {
|
|
10
|
+
super(...arguments)
|
|
11
|
+
|
|
12
|
+
this.addSub(`apm:${this.component}:command:add`, ctx => {
|
|
13
|
+
ctx.parentStore = storage('legacy').getStore()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
this.addBind(`apm:${this.component}:command:start`, ctx => ctx.parentStore)
|
|
17
|
+
this.addBind(`apm:${this.component}:command:finish`, ctx => ctx.parentStore)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
bindStart (ctx) {
|
|
21
|
+
return storage('legacy').run(ctx.parentStore, () => super.bindStart(ctx))
|
|
22
|
+
}
|
|
7
23
|
}
|
|
8
24
|
|
|
9
25
|
module.exports = MySQL2Plugin
|
|
@@ -31,7 +31,7 @@ class NetTCPPlugin extends ClientPlugin {
|
|
|
31
31
|
|
|
32
32
|
this.startSpan('tcp.connect', {
|
|
33
33
|
service: this.config.service,
|
|
34
|
-
resource: [host, port].filter(
|
|
34
|
+
resource: [host, port].filter(Boolean).join(':'),
|
|
35
35
|
kind: 'client',
|
|
36
36
|
meta: {
|
|
37
37
|
'tcp.remote.host': host,
|
|
@@ -6,7 +6,7 @@ const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
|
6
6
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
7
7
|
const web = require('../../dd-trace/src/plugins/util/web')
|
|
8
8
|
|
|
9
|
-
const errorPages = ['/404', '/500', '/_error', '/_not-found', '/_not-found/page']
|
|
9
|
+
const errorPages = new Set(['/404', '/500', '/_error', '/_not-found', '/_not-found/page'])
|
|
10
10
|
|
|
11
11
|
class NextPlugin extends ServerPlugin {
|
|
12
12
|
static get id () {
|
|
@@ -97,7 +97,7 @@ class NextPlugin extends ServerPlugin {
|
|
|
97
97
|
|
|
98
98
|
// Only use error page names if there's not already a name
|
|
99
99
|
const current = span.context()._tags['next.page']
|
|
100
|
-
const isErrorPage = errorPages.
|
|
100
|
+
const isErrorPage = errorPages.has(page)
|
|
101
101
|
|
|
102
102
|
if (current && isErrorPage) {
|
|
103
103
|
return
|
|
@@ -106,7 +106,7 @@ class NextPlugin extends ServerPlugin {
|
|
|
106
106
|
// remove ending /route or /page for appDir projects
|
|
107
107
|
// need to check if not an error page too, as those are marked as app directory
|
|
108
108
|
// in newer versions
|
|
109
|
-
if (isAppPath && !isErrorPage) page = page.
|
|
109
|
+
if (isAppPath && !isErrorPage) page = page.slice(0, Math.max(0, page.lastIndexOf('/')))
|
|
110
110
|
|
|
111
111
|
// handle static resource
|
|
112
112
|
if (isStatic) {
|
|
@@ -137,9 +137,10 @@ function normalizeConfig (config) {
|
|
|
137
137
|
return Object.assign({}, config, { hooks, validateStatus })
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
const noop = () => {}
|
|
141
|
+
|
|
140
142
|
function getHooks (config) {
|
|
141
|
-
const
|
|
142
|
-
const request = (config.hooks && config.hooks.request) || noop
|
|
143
|
+
const request = config.hooks?.request ?? noop
|
|
143
144
|
|
|
144
145
|
return { request }
|
|
145
146
|
}
|
|
@@ -11,8 +11,8 @@ let logger = null
|
|
|
11
11
|
let interval = null
|
|
12
12
|
|
|
13
13
|
module.exports.init = function (tracerConfig) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
metrics = tracerConfig && tracerConfig.dogstatsd
|
|
15
|
+
? new DogStatsDClient({
|
|
16
16
|
host: tracerConfig.dogstatsd.hostname,
|
|
17
17
|
port: tracerConfig.dogstatsd.port,
|
|
18
18
|
tags: [
|
|
@@ -21,21 +21,17 @@ module.exports.init = function (tracerConfig) {
|
|
|
21
21
|
`version:${tracerConfig.tags.version}`
|
|
22
22
|
]
|
|
23
23
|
})
|
|
24
|
-
|
|
25
|
-
metrics = new NoopDogStatsDClient()
|
|
26
|
-
}
|
|
24
|
+
: new NoopDogStatsDClient()
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
logger = tracerConfig && tracerConfig.apiKey
|
|
27
|
+
? new ExternalLogger({
|
|
30
28
|
ddsource: 'openai',
|
|
31
29
|
hostname: tracerConfig.hostname,
|
|
32
30
|
service: tracerConfig.service,
|
|
33
31
|
apiKey: tracerConfig.apiKey,
|
|
34
32
|
interval: FLUSH_INTERVAL
|
|
35
33
|
})
|
|
36
|
-
|
|
37
|
-
logger = new NoopExternalLogger()
|
|
38
|
-
}
|
|
34
|
+
: new NoopExternalLogger()
|
|
39
35
|
|
|
40
36
|
interval = setInterval(() => {
|
|
41
37
|
metrics.flush()
|
|
@@ -261,9 +261,11 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
261
261
|
if (error) {
|
|
262
262
|
this.metrics.increment('openai.request.error', 1, tags)
|
|
263
263
|
} else {
|
|
264
|
-
tags.push(
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
tags.push(
|
|
265
|
+
`org:${headers['openai-organization']}`,
|
|
266
|
+
`endpoint:${endpoint}`,
|
|
267
|
+
`model:${headers['openai-model'] || body.model}`
|
|
268
|
+
)
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
this.metrics.distribution('openai.request.duration', duration * 1000, tags)
|
|
@@ -329,7 +331,7 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
329
331
|
sendLog (methodName, span, tags, openaiStore, error) {
|
|
330
332
|
if (!openaiStore) return
|
|
331
333
|
if (!Object.keys(openaiStore).length) return
|
|
332
|
-
if (!this.sampler.isSampled()) return
|
|
334
|
+
if (!this.sampler.isSampled(span)) return
|
|
333
335
|
|
|
334
336
|
const log = {
|
|
335
337
|
status: error ? 'error' : 'info',
|
|
@@ -725,7 +727,7 @@ function commonCreateResponseExtraction (tags, body, openaiStore, methodName) {
|
|
|
725
727
|
const choice = body.choices[choiceIdx]
|
|
726
728
|
|
|
727
729
|
// logprobs can be null and we still want to tag it as 'returned' even when set to 'null'
|
|
728
|
-
const specifiesLogProb = Object.keys(choice).
|
|
730
|
+
const specifiesLogProb = Object.keys(choice).includes('logprobs')
|
|
729
731
|
|
|
730
732
|
tags[`openai.response.choices.${choiceIdx}.finish_reason`] = choice.finish_reason
|
|
731
733
|
tags[`openai.response.choices.${choiceIdx}.logprobs`] = specifiesLogProb ? 'returned' : undefined
|
|
@@ -790,7 +792,7 @@ function usageExtraction (tags, body, methodName, openaiStore) {
|
|
|
790
792
|
}
|
|
791
793
|
|
|
792
794
|
function truncateApiKey (apiKey) {
|
|
793
|
-
return apiKey && `sk-...${apiKey.
|
|
795
|
+
return apiKey && `sk-...${apiKey.slice(-4)}`
|
|
794
796
|
}
|
|
795
797
|
|
|
796
798
|
function tagChatCompletionRequestContent (contents, messageIdx, tags) {
|
|
@@ -989,15 +991,9 @@ function normalizeStringOrTokenArray (input, truncate) {
|
|
|
989
991
|
|
|
990
992
|
function defensiveArrayLength (maybeArray) {
|
|
991
993
|
if (maybeArray) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
} else {
|
|
995
|
-
// case of a singular item (ie body.training_file vs body.training_files)
|
|
996
|
-
return 1
|
|
997
|
-
}
|
|
994
|
+
// Detect singular item (ie body.training_file vs body.training_files)
|
|
995
|
+
return Array.isArray(maybeArray) ? maybeArray.length : 1
|
|
998
996
|
}
|
|
999
|
-
|
|
1000
|
-
return undefined
|
|
1001
997
|
}
|
|
1002
998
|
|
|
1003
999
|
module.exports = OpenAiTracingPlugin
|