dd-trace 5.134.0 → 5.136.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 +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
* missing: { path: ArgumentPath, valueNode: { name: { value: string } } }[],
|
|
25
25
|
* values: Record<string, unknown>
|
|
26
26
|
* }} CompiledArguments
|
|
27
|
+
* @typedef {(
|
|
28
|
+
* value: Record<string, unknown>,
|
|
29
|
+
* hoist: (value: unknown) => string
|
|
30
|
+
* ) => string} StringifyArguments
|
|
27
31
|
* @typedef {{
|
|
28
32
|
* baseTypeName: string,
|
|
29
33
|
* resource: string,
|
|
@@ -36,6 +40,7 @@
|
|
|
36
40
|
* collapsedPathSegments: string[],
|
|
37
41
|
* staticArguments?: Record<string, unknown>,
|
|
38
42
|
* hasArgumentVariables?: boolean,
|
|
43
|
+
* literals?: Record<string, unknown>,
|
|
39
44
|
* fieldName: string,
|
|
40
45
|
* fieldNode: import('graphql').FieldNode,
|
|
41
46
|
* fieldNodes: [import('graphql').FieldNode, ...import('graphql').FieldNode[]],
|
|
@@ -70,7 +75,8 @@
|
|
|
70
75
|
* ) => FieldMetadata} CreateFieldMetadata
|
|
71
76
|
* @typedef {(
|
|
72
77
|
* variableValues: Record<string, unknown> | undefined,
|
|
73
|
-
* cloneValue?: (value: unknown) => unknown
|
|
78
|
+
* cloneValue?: (value: unknown) => unknown,
|
|
79
|
+
* literalContext?: JitFieldDescriptor
|
|
74
80
|
* ) => Record<string, unknown>} ArgumentFactory
|
|
75
81
|
* @typedef {(
|
|
76
82
|
* rootCtx: object,
|
|
@@ -132,7 +138,7 @@
|
|
|
132
138
|
* fieldNodes: [import('graphql').FieldNode, ...import('graphql').FieldNode[]],
|
|
133
139
|
* originPaths: string[],
|
|
134
140
|
* args: CompiledArguments,
|
|
135
|
-
*
|
|
141
|
+
* stringifyArguments: StringifyArguments,
|
|
136
142
|
* compiledField: string
|
|
137
143
|
* ) => string,
|
|
138
144
|
* finalizeCompilation: (
|
|
@@ -251,7 +257,7 @@ function createGraphqlJitRuntime ({
|
|
|
251
257
|
* @param {[import('graphql').FieldNode, ...import('graphql').FieldNode[]]} fieldNodes
|
|
252
258
|
* @param {string[]} originPaths
|
|
253
259
|
* @param {CompiledArguments} args
|
|
254
|
-
* @param {
|
|
260
|
+
* @param {StringifyArguments} stringifyArguments
|
|
255
261
|
* @param {string} compiledField
|
|
256
262
|
*/
|
|
257
263
|
function compileDefaultField (
|
|
@@ -262,7 +268,7 @@ function createGraphqlJitRuntime ({
|
|
|
262
268
|
fieldNodes,
|
|
263
269
|
originPaths,
|
|
264
270
|
args,
|
|
265
|
-
|
|
271
|
+
stringifyArguments,
|
|
266
272
|
compiledField
|
|
267
273
|
) {
|
|
268
274
|
const parentPath = originPaths.join('.')
|
|
@@ -284,7 +290,7 @@ function createGraphqlJitRuntime ({
|
|
|
284
290
|
}, fieldNodes[0], createFieldMetadata)
|
|
285
291
|
descriptor.staticArguments = args.values
|
|
286
292
|
descriptor.hasArgumentVariables = args.missing.length !== 0
|
|
287
|
-
const argumentFactory = compileArgumentFactory(context, descriptor, args.missing,
|
|
293
|
+
const argumentFactory = compileArgumentFactory(context, descriptor, args.missing, stringifyArguments)
|
|
288
294
|
|
|
289
295
|
const shouldTrace = '__context.ddTrace !== undefined && ' +
|
|
290
296
|
'(__context.ddTrace.jitTraceAll || ' +
|
|
@@ -354,6 +360,7 @@ function createDescriptor (context, compilerPath, input, fieldNode, createFieldM
|
|
|
354
360
|
fieldNode,
|
|
355
361
|
fieldNodes: input.fieldNodes,
|
|
356
362
|
hasArgumentVariables: undefined,
|
|
363
|
+
literals: undefined,
|
|
357
364
|
parentId: undefined,
|
|
358
365
|
parentPathKey: compilerPath.parentPathKey,
|
|
359
366
|
parentTypeName,
|
|
@@ -374,13 +381,20 @@ function createDescriptor (context, compilerPath, input, fieldNode, createFieldM
|
|
|
374
381
|
* @param {ConfiguredJitCompilationContext} context
|
|
375
382
|
* @param {JitFieldDescriptor} descriptor
|
|
376
383
|
* @param {CompiledArguments['missing']} missing
|
|
377
|
-
* @param {
|
|
384
|
+
* @param {StringifyArguments} stringifyArguments
|
|
378
385
|
*/
|
|
379
|
-
function compileArgumentFactory (context, descriptor, missing,
|
|
386
|
+
function compileArgumentFactory (context, descriptor, missing, stringifyArguments) {
|
|
387
|
+
let literalIndex = 0
|
|
388
|
+
const argumentSource = stringifyArguments(descriptor.staticArguments, hoist)
|
|
380
389
|
if (missing.length === 0 && argumentSource === '{}') return 'undefined'
|
|
381
390
|
|
|
382
391
|
const name = `ddTraceArguments${descriptor.id}`
|
|
383
|
-
|
|
392
|
+
const hasLiterals = descriptor.literals !== undefined
|
|
393
|
+
const parameters = hasLiterals ? 'variableValues, cloneValue, __context' : 'variableValues, cloneValue'
|
|
394
|
+
let source = `function ${name} (${parameters}) {\n const args = `
|
|
395
|
+
source += hasLiterals
|
|
396
|
+
? `cloneValue === undefined ? ${argumentSource} : cloneValue(${argumentSource})\n`
|
|
397
|
+
: `${argumentSource}\n`
|
|
384
398
|
const pathsByVariable = new Map()
|
|
385
399
|
|
|
386
400
|
for (const { path, valueNode } of missing) {
|
|
@@ -411,6 +425,14 @@ function compileArgumentFactory (context, descriptor, missing, argumentSource) {
|
|
|
411
425
|
source += ' return args\n}\n'
|
|
412
426
|
context.hoistedFunctions.push(source)
|
|
413
427
|
return name
|
|
428
|
+
|
|
429
|
+
/** @param {unknown} value */
|
|
430
|
+
function hoist (value) {
|
|
431
|
+
const name = `literal${literalIndex++}`
|
|
432
|
+
descriptor.literals ??= {}
|
|
433
|
+
descriptor.literals[name] = value
|
|
434
|
+
return name
|
|
435
|
+
}
|
|
414
436
|
}
|
|
415
437
|
|
|
416
438
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { setTimeout } = require('node:timers')
|
|
3
4
|
const path = require('path')
|
|
4
5
|
|
|
5
6
|
const iitm = require('../../../dd-trace/src/iitm')
|
|
@@ -8,6 +9,8 @@ const log = require('../../../dd-trace/src/log')
|
|
|
8
9
|
const requirePackageJson = require('../../../dd-trace/src/require-package-json')
|
|
9
10
|
const { isNodeBuiltinModuleName } = require('./shared-utils')
|
|
10
11
|
|
|
12
|
+
const VERSION_CACHE_IDLE_TIMEOUT_MS = 1000
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* @param {string} moduleBaseDir
|
|
13
16
|
* @returns {string|undefined}
|
|
@@ -49,6 +52,10 @@ function Hook (modules, hookOptions, onrequire) {
|
|
|
49
52
|
|
|
50
53
|
this._patched = Object.create(null)
|
|
51
54
|
const patched = new WeakMap()
|
|
55
|
+
/** @type {Map<string|undefined, string|undefined>|undefined} */
|
|
56
|
+
let versions
|
|
57
|
+
/** @type {ReturnType<typeof setTimeout>|undefined} */
|
|
58
|
+
let clearVersionsTimer
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
61
|
* @param {object|Function|undefined} moduleExports
|
|
@@ -80,7 +87,28 @@ function Hook (modules, hookOptions, onrequire) {
|
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
try {
|
|
83
|
-
|
|
90
|
+
if (!moduleVersion) {
|
|
91
|
+
moduleVersion = versions?.get(moduleBaseDir)
|
|
92
|
+
if (!moduleVersion) {
|
|
93
|
+
moduleVersion = getVersion(moduleBaseDir)
|
|
94
|
+
if (moduleBaseDir) {
|
|
95
|
+
versions ??= new Map()
|
|
96
|
+
versions.set(moduleBaseDir, moduleVersion)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (versions) {
|
|
100
|
+
if (clearVersionsTimer) {
|
|
101
|
+
clearVersionsTimer.refresh()
|
|
102
|
+
} else {
|
|
103
|
+
const cache = versions
|
|
104
|
+
clearVersionsTimer = setTimeout(() => {
|
|
105
|
+
cache.clear()
|
|
106
|
+
clearVersionsTimer = undefined
|
|
107
|
+
}, VERSION_CACHE_IDLE_TIMEOUT_MS)
|
|
108
|
+
clearVersionsTimer.unref?.()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
84
112
|
} catch (error) {
|
|
85
113
|
log.error('Error getting version for "%s": %s', moduleName, error.message, error)
|
|
86
114
|
return moduleExports
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
+
'@elevenlabs/elevenlabs-js': () => require('../elevenlabs'),
|
|
4
5
|
// Only list unprefixed node modules. They will automatically be instrumented as prefixed and unprefixed.
|
|
5
6
|
child_process: () => require('../child_process'),
|
|
6
7
|
crypto: () => require('../crypto'),
|
|
@@ -48,7 +49,7 @@ module.exports = {
|
|
|
48
49
|
'@koa/router': () => require('../koa'),
|
|
49
50
|
'@node-redis/client': () => require('../redis'),
|
|
50
51
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
51
|
-
'@opentelemetry/sdk-trace': () => require('../otel-sdk-trace'),
|
|
52
|
+
'@opentelemetry/sdk-trace': { esmFirst: true, fn: () => require('../otel-sdk-trace') },
|
|
52
53
|
'@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
|
|
53
54
|
'@prisma/client': { esmFirst: true, fn: () => require('../prisma') },
|
|
54
55
|
'./runtime/library.js': () => require('../prisma'),
|
|
@@ -56,10 +57,6 @@ module.exports = {
|
|
|
56
57
|
'@smithy/core': () => require('../aws-sdk'),
|
|
57
58
|
'@smithy/smithy-client': () => require('../aws-sdk'),
|
|
58
59
|
'@vitest/runner': { esmFirst: true, fn: () => require('../vitest') },
|
|
59
|
-
'@wdio/cli': { esmFirst: true, fn: () => require('../webdriverio') },
|
|
60
|
-
'@wdio/jasmine-framework': { esmFirst: true, fn: () => require('../webdriverio') },
|
|
61
|
-
'@wdio/local-runner': { esmFirst: true, fn: () => require('../webdriverio') },
|
|
62
|
-
'@wdio/utils': { esmFirst: true, fn: () => require('../webdriverio') },
|
|
63
60
|
aerospike: () => require('../aerospike'),
|
|
64
61
|
ai: () => require('../ai'),
|
|
65
62
|
amqp10: () => require('../amqp10'),
|
|
@@ -85,8 +82,8 @@ module.exports = {
|
|
|
85
82
|
fastify: () => require('../fastify'),
|
|
86
83
|
'find-my-way': () => require('../find-my-way'),
|
|
87
84
|
'generic-pool': () => require('../generic-pool'),
|
|
88
|
-
graphql: () => require('../graphql'),
|
|
89
|
-
'graphql-jit': () => require('../graphql'),
|
|
85
|
+
graphql: { esmFirst: true, fn: () => require('../graphql') },
|
|
86
|
+
'graphql-jit': { esmFirst: true, fn: () => require('../graphql') },
|
|
90
87
|
grpc: () => require('../grpc'),
|
|
91
88
|
handlebars: () => require('../handlebars'),
|
|
92
89
|
hapi: () => require('../hapi'),
|
|
@@ -154,7 +151,6 @@ module.exports = {
|
|
|
154
151
|
tinypool: { esmFirst: true, fn: () => require('../vitest') },
|
|
155
152
|
undici: () => require('../undici'),
|
|
156
153
|
vitest: { esmFirst: true, fn: () => require('../vitest') },
|
|
157
|
-
webdriverio: { esmFirst: true, fn: () => require('../webdriverio') },
|
|
158
154
|
when: () => require('../when'),
|
|
159
155
|
winston: () => require('../winston'),
|
|
160
156
|
workerpool: () => require('../mocha'),
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { EventEmitter } = require('node:events')
|
|
4
|
+
const { types: { isProxy } } = require('node:util')
|
|
5
|
+
|
|
6
|
+
const HANDLER_STREAMING = Symbol.for('aws.lambda.runtime.handler.streaming')
|
|
7
|
+
const HANDLER_HIGHWATERMARK = Symbol.for('aws.lambda.runtime.handler.streaming.highWaterMark')
|
|
8
|
+
const STREAM_RESPONSE = 'response'
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* MIGRATION SCOPE (#10488): move the existing datadog-lambda-js completion policy as-is.
|
|
12
|
+
* Source: https://github.com/DataDog/datadog-lambda-js/blob/bb5266a00e72eba0edcfe8d73256fe70461547c4/src/utils/handler.ts
|
|
13
|
+
* Only TypeScript types, module syntax and repository formatting are changed in promisifiedHandler below.
|
|
14
|
+
*
|
|
15
|
+
* Known legacy corner cases intentionally left for separate behavior changes:
|
|
16
|
+
* - Callback intent is inferred from handler.length and the returned value. Rest/default parameters can
|
|
17
|
+
* hide callback intent; undefined and server/socket/emitter-like returns can leave completion pending.
|
|
18
|
+
* - Promise.race selects the adapter result, not AWS's native response timing. Callback/context methods
|
|
19
|
+
* are not forwarded to their originals or restored, and outer wrappers can observe that shared mutation.
|
|
20
|
+
* - A handler or then getter can throw synchronously, including after calling a completion method.
|
|
21
|
+
* A callback Promise abandoned by a synchronous return/throw can later reject without an observer.
|
|
22
|
+
* - Metadata, then and artifact detection read properties directly, so getters/Proxy traps can run.
|
|
23
|
+
* A null return can throw during these checks. These are the upstream checks, not a new type policy.
|
|
24
|
+
* - The adapter installs methods on the supplied context. Frozen/read-only contexts, replacement methods
|
|
25
|
+
* and freezing after installation retain the shim's existing behavior; there is no defensive context view.
|
|
26
|
+
* - Buffered calls use (event, context, syntheticCallback); streaming calls use (event, stream, context).
|
|
27
|
+
* Custom receivers, additional arguments and alternative buffered argument positions are not preserved.
|
|
28
|
+
*
|
|
29
|
+
* Record newly identified legacy completion concerns here rather than expanding this migration's policy.
|
|
30
|
+
* Fixes to those behaviors belong in a separate change. A difference introduced by this port is still a bug.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {Function} handler Customer Lambda handler.
|
|
35
|
+
* @returns {Function} Existing shim completion adapter.
|
|
36
|
+
*/
|
|
37
|
+
// Keep the upstream completion policy recognizable for this as-is migration.
|
|
38
|
+
/* eslint-disable unicorn/consistent-function-scoping, no-useless-assignment, unicorn/no-duplicate-if-branches */
|
|
39
|
+
/* eslint-disable sonarjs/prefer-immediate-return, unicorn/no-negated-condition */
|
|
40
|
+
function promisifiedHandler (handler) {
|
|
41
|
+
// Response Stream Lambda function.
|
|
42
|
+
if (handler[HANDLER_STREAMING] !== undefined && handler[HANDLER_STREAMING] === STREAM_RESPONSE) {
|
|
43
|
+
return (event, responseStream, context) => {
|
|
44
|
+
// This handler will always be a promise.
|
|
45
|
+
const promise = handler(event, responseStream, context)
|
|
46
|
+
return promise
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Buffered Lambda function.
|
|
50
|
+
return (event, context) => {
|
|
51
|
+
// Lambda functions in node complete in one of two possible ways.
|
|
52
|
+
// 1. By calling the "callback" function with a result.
|
|
53
|
+
// 2. Returning a value directly from the function using a promise.
|
|
54
|
+
let modifiedCallback = () => {}
|
|
55
|
+
let modifiedLegacyDoneCallback = () => {}
|
|
56
|
+
let modifiedLegacySucceedCallback = () => {}
|
|
57
|
+
let modifiedLegacyFailCallback = () => {}
|
|
58
|
+
const callbackProm = new Promise((resolve, reject) => {
|
|
59
|
+
modifiedCallback = (err, result) => {
|
|
60
|
+
if (err !== undefined && err !== null) {
|
|
61
|
+
reject(err)
|
|
62
|
+
} else {
|
|
63
|
+
resolve(result)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Legacy done callback finished immediately, and doesn't wait for pending
|
|
67
|
+
// event loop
|
|
68
|
+
modifiedLegacyDoneCallback = (err, result) => {
|
|
69
|
+
context.callbackWaitsForEmptyEventLoop = false
|
|
70
|
+
if (err !== undefined && err !== null) {
|
|
71
|
+
reject(err)
|
|
72
|
+
} else {
|
|
73
|
+
resolve(result)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
modifiedLegacySucceedCallback = (result) => {
|
|
77
|
+
context.callbackWaitsForEmptyEventLoop = false
|
|
78
|
+
resolve(result)
|
|
79
|
+
}
|
|
80
|
+
modifiedLegacyFailCallback = (err) => {
|
|
81
|
+
context.callbackWaitsForEmptyEventLoop = false
|
|
82
|
+
reject(err)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
context.done = modifiedLegacyDoneCallback
|
|
86
|
+
context.succeed = modifiedLegacySucceedCallback
|
|
87
|
+
context.fail = modifiedLegacyFailCallback
|
|
88
|
+
const asyncProm = handler(event, context, modifiedCallback)
|
|
89
|
+
let promise = callbackProm
|
|
90
|
+
if (asyncProm !== undefined && typeof asyncProm.then === 'function') {
|
|
91
|
+
// Mimics behaviour of lambda runtime, the first method of returning a result always wins.
|
|
92
|
+
promise = Promise.race([callbackProm, asyncProm])
|
|
93
|
+
} else if (handler.length >= 3) {
|
|
94
|
+
// Handler takes a callback, wait for the callback to be called
|
|
95
|
+
promise = callbackProm
|
|
96
|
+
} else if (asyncProm === undefined) {
|
|
97
|
+
// Handler returned nothing (implicit `undefined`) and doesn't take a callback parameter.
|
|
98
|
+
// It must be relying on `context.succeed` / `context.done` / `context.fail` to signal
|
|
99
|
+
// completion (e.g. `aws-serverless-express`'s `proxy()` with the default
|
|
100
|
+
// `CONTEXT_SUCCEED` resolution mode, or any other fire-and-forget pattern that finishes
|
|
101
|
+
// asynchronously). Wait for callbackProm rather than resolving immediately, otherwise
|
|
102
|
+
// the wrapper would shortcut the function before its work finishes, which causes the
|
|
103
|
+
// Lambda runtime to return an empty response and freeze the worker before any pending
|
|
104
|
+
// stdout writes are flushed to CloudWatch.
|
|
105
|
+
promise = callbackProm
|
|
106
|
+
} else {
|
|
107
|
+
// Handler returned a value directly
|
|
108
|
+
// Distinguish between:
|
|
109
|
+
// - ordinary sync return value -> resolve immediately
|
|
110
|
+
// - side-effect artifact (e.g. aws-serverless-express server) -> wait for context.done
|
|
111
|
+
// Heuristic: trying to detect common types of side-effect artifacts
|
|
112
|
+
const looksLikeArtifact = asyncProm !== undefined &&
|
|
113
|
+
typeof asyncProm === 'object' &&
|
|
114
|
+
// 1. Node.js http.Server or similar
|
|
115
|
+
((typeof asyncProm.listen === 'function' && typeof asyncProm.close === 'function') ||
|
|
116
|
+
// 2. EventEmitter-like (has .on and .emit)
|
|
117
|
+
(typeof asyncProm.on === 'function' && typeof asyncProm.emit === 'function') ||
|
|
118
|
+
// 3. Instance of EventEmitter (covers Server, Socket, etc.)
|
|
119
|
+
asyncProm instanceof EventEmitter ||
|
|
120
|
+
// 4. Constructor name hint
|
|
121
|
+
(asyncProm.constructor && /Server|Socket|Emitter/i.test(asyncProm.constructor.name)))
|
|
122
|
+
if (looksLikeArtifact) {
|
|
123
|
+
// Wait for callbackProm instead (the context.done/succeed/fail will resolve it)
|
|
124
|
+
promise = callbackProm
|
|
125
|
+
} else {
|
|
126
|
+
// Return the value directly
|
|
127
|
+
promise = Promise.resolve(asyncProm)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return promise
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* eslint-enable unicorn/consistent-function-scoping, no-useless-assignment, unicorn/no-duplicate-if-branches */
|
|
135
|
+
/* eslint-enable sonarjs/prefer-immediate-return, unicorn/no-negated-condition */
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Reads metadata without executing application getters or Proxy traps.
|
|
139
|
+
*
|
|
140
|
+
* @param {unknown} target
|
|
141
|
+
* @param {string | symbol} name
|
|
142
|
+
*/
|
|
143
|
+
function getDataProperty (target, name) {
|
|
144
|
+
if (target === null || (typeof target !== 'object' && typeof target !== 'function')) return
|
|
145
|
+
while (target !== null && !isProxy(target)) {
|
|
146
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, name)
|
|
147
|
+
if (descriptor) return descriptor.value
|
|
148
|
+
target = Object.getPrototypeOf(target)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Copies data properties without running customer metadata getters or Proxy traps.
|
|
154
|
+
*
|
|
155
|
+
* @param {Function} handler Original handler.
|
|
156
|
+
* @param {Function} wrapped Wrapper to receive safe metadata.
|
|
157
|
+
*/
|
|
158
|
+
function copyHandlerMetadata (handler, wrapped) {
|
|
159
|
+
// datadog-lambda-js uses arity and the runtime's streaming metadata to choose how to invoke the handler.
|
|
160
|
+
Object.defineProperty(wrapped, 'length', { value: getDataProperty(handler, 'length') ?? 0 })
|
|
161
|
+
for (const name of [HANDLER_STREAMING, HANDLER_HIGHWATERMARK, '_ddWrapped']) {
|
|
162
|
+
const value = getDataProperty(handler, name)
|
|
163
|
+
if (value !== undefined) wrapped[name] = value
|
|
164
|
+
}
|
|
165
|
+
if (!isProxy(handler)) {
|
|
166
|
+
for (const name of Reflect.ownKeys(handler)) {
|
|
167
|
+
if (name === 'arguments' || name === 'caller') continue
|
|
168
|
+
const descriptor = Object.getOwnPropertyDescriptor(handler, name)
|
|
169
|
+
if (!Object.hasOwn(descriptor, 'value')) continue
|
|
170
|
+
const existing = Object.getOwnPropertyDescriptor(wrapped, name)
|
|
171
|
+
if (existing?.configurable === false) {
|
|
172
|
+
// Intrinsic function slots such as prototype cannot change their descriptor shape.
|
|
173
|
+
if (existing.writable) {
|
|
174
|
+
Object.defineProperty(wrapped, name, { value: descriptor.value, writable: descriptor.writable })
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
Object.defineProperty(wrapped, name, descriptor)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = {
|
|
184
|
+
HANDLER_STREAMING,
|
|
185
|
+
copyHandlerMetadata,
|
|
186
|
+
getDataProperty,
|
|
187
|
+
STREAM_RESPONSE,
|
|
188
|
+
promisifiedHandler,
|
|
189
|
+
}
|
|
@@ -19,7 +19,8 @@ const { getRewriteTarget } = require('./targets')
|
|
|
19
19
|
* { code: string, map?: string|object }} transform
|
|
20
20
|
*
|
|
21
21
|
* @typedef {(content: string|Buffer|ArrayBuffer|Uint8Array, filename: string, format?: string,
|
|
22
|
-
* target?: { moduleName: string, filePath: string, activate?: boolean
|
|
22
|
+
* target?: { moduleName: string, filePath: string, activate?: boolean, sourceMatch?: string },
|
|
23
|
+
* sourceMap?: string|object) =>
|
|
23
24
|
* { code: string|Buffer|ArrayBuffer|Uint8Array, map?: string|object }} BundlerRewriter
|
|
24
25
|
*/
|
|
25
26
|
|
|
@@ -62,7 +63,7 @@ function normalizeFilename (filename) {
|
|
|
62
63
|
* @param {string|Buffer|ArrayBuffer|Uint8Array} content
|
|
63
64
|
* @param {string} filename
|
|
64
65
|
* @param {string} [format]
|
|
65
|
-
* @param {{ moduleName: string, filePath: string, activate?: boolean }} [target]
|
|
66
|
+
* @param {{ moduleName: string, filePath: string, activate?: boolean, sourceMatch?: string }} [target]
|
|
66
67
|
* @returns {string|Buffer|ArrayBuffer|Uint8Array}
|
|
67
68
|
*/
|
|
68
69
|
function rewrite (content, filename, format, target) {
|
|
@@ -74,17 +75,20 @@ function rewrite (content, filename, format, target) {
|
|
|
74
75
|
if (!target) return content
|
|
75
76
|
|
|
76
77
|
const moduleType = format === 'module' ? 'esm' : 'cjs'
|
|
77
|
-
const { moduleName, filePath, activate } = target
|
|
78
|
+
const { moduleName, filePath, activate, sourceMatch } = target
|
|
78
79
|
if (disabled.has(moduleName)) return content
|
|
79
80
|
|
|
80
81
|
const version = getVersion(filename, filePath)
|
|
81
82
|
if (!version) return content
|
|
82
83
|
|
|
84
|
+
const matchedSource = sourceMatch && getSourceText(content)
|
|
85
|
+
if (sourceMatch && !matchedSource?.includes(sourceMatch)) return content
|
|
86
|
+
|
|
83
87
|
const transformer = getMatcher(moduleType).getTransformer(moduleName, version, filePath)
|
|
84
88
|
|
|
85
89
|
if (!transformer && !activate) return content
|
|
86
90
|
|
|
87
|
-
const source = getSourceText(content)
|
|
91
|
+
const source = matchedSource ?? getSourceText(content)
|
|
88
92
|
|
|
89
93
|
if (!transformer) {
|
|
90
94
|
return appendOrchestrionLoad(
|
|
@@ -139,14 +143,20 @@ function createBundlerRewriter (dcModule) {
|
|
|
139
143
|
if (!target) return { code: content, map: sourceMap }
|
|
140
144
|
|
|
141
145
|
const moduleType = format === 'module' ? 'esm' : 'cjs'
|
|
142
|
-
const { moduleName, filePath } = target
|
|
146
|
+
const { moduleName, filePath, sourceMatch } = target
|
|
143
147
|
const version = getVersion(filename, filePath)
|
|
144
148
|
if (!version) return { code: content, map: sourceMap }
|
|
145
149
|
|
|
150
|
+
let matchedSource
|
|
151
|
+
if (sourceMatch) {
|
|
152
|
+
matchedSource = getSourceText(content)
|
|
153
|
+
if (!matchedSource.includes(sourceMatch)) return { code: content, map: sourceMap }
|
|
154
|
+
}
|
|
155
|
+
|
|
146
156
|
const transformer = matcher.getTransformer(moduleName, version, filePath)
|
|
147
157
|
if (!transformer) return { code: content, map: sourceMap }
|
|
148
158
|
|
|
149
|
-
return transformer.transform(getSourceText(content), moduleType, sourceMap)
|
|
159
|
+
return transformer.transform(matchedSource ?? getSourceText(content), moduleType, sourceMap)
|
|
150
160
|
} catch (error) {
|
|
151
161
|
log.error(error)
|
|
152
162
|
return { code: content, map: sourceMap }
|
|
@@ -185,6 +195,7 @@ function createMatcher (dcModule) {
|
|
|
185
195
|
configureGraphqlJitRuntime,
|
|
186
196
|
configureMercuriusRequest,
|
|
187
197
|
publishDurableOrchestrationFailure,
|
|
198
|
+
publishTrpcRequestInfo,
|
|
188
199
|
waitForAsyncEnd,
|
|
189
200
|
} = require('./transforms')
|
|
190
201
|
const {
|
|
@@ -206,6 +217,7 @@ function createMatcher (dcModule) {
|
|
|
206
217
|
matcher.addTransform('configureMercuriusRequest', configureMercuriusRequest)
|
|
207
218
|
matcher.addTransform('publishDurableOrchestrationFailure', publishDurableOrchestrationFailure)
|
|
208
219
|
matcher.addTransform('postgresQueryAcquire', postgresQueryAcquire)
|
|
220
|
+
matcher.addTransform('publishTrpcRequestInfo', publishTrpcRequestInfo)
|
|
209
221
|
matcher.addTransform('postgresQueryHandlers', postgresQueryHandlers)
|
|
210
222
|
matcher.addTransform('postgresQueryLifecycle', postgresQueryLifecycle)
|
|
211
223
|
matcher.addTransform('postgresQueryPreparation', postgresQueryPreparation)
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
/** @satisfies {InstrumentationRegistryEntry[]} */
|
|
24
24
|
const registry = [
|
|
25
25
|
{ instrumentations: require('./instrumentations/ai') },
|
|
26
|
+
{ activate: true, instrumentations: require('./instrumentations/async-mutex') },
|
|
26
27
|
{ activate: true, instrumentations: require('./instrumentations/azure-cosmos') },
|
|
27
28
|
{ instrumentations: require('./instrumentations/azure-durable-functions') },
|
|
28
29
|
{ activate: true, instrumentations: require('./instrumentations/bullmq') },
|
|
@@ -30,6 +31,10 @@ const registry = [
|
|
|
30
31
|
activate: { setup: () => require('../../claude-agent-sdk') },
|
|
31
32
|
instrumentations: require('./instrumentations/claude-agent-sdk'),
|
|
32
33
|
},
|
|
34
|
+
{
|
|
35
|
+
activate: { setup: () => require('../../elevenlabs') },
|
|
36
|
+
instrumentations: require('./instrumentations/elevenlabs'),
|
|
37
|
+
},
|
|
33
38
|
{ instrumentations: require('./instrumentations/graphql') },
|
|
34
39
|
{ instrumentations: require('./instrumentations/graphql-jit') },
|
|
35
40
|
{ instrumentations: require('./instrumentations/jest') },
|
|
@@ -37,16 +42,36 @@ const registry = [
|
|
|
37
42
|
{ activate: true, instrumentations: require('./instrumentations/langgraph') },
|
|
38
43
|
{ activate: true, instrumentations: require('./instrumentations/mercurius') },
|
|
39
44
|
{ instrumentations: require('./instrumentations/modelcontextprotocol-sdk') },
|
|
45
|
+
{ instrumentations: require('./instrumentations/next') },
|
|
40
46
|
{ instrumentations: require('./instrumentations/openai-agents') },
|
|
47
|
+
{
|
|
48
|
+
activate: { setup: () => require('../../openai-agents-realtime') },
|
|
49
|
+
instrumentations: require('./instrumentations/openai-agents-realtime'),
|
|
50
|
+
},
|
|
41
51
|
{ instrumentations: require('./instrumentations/playwright') },
|
|
42
52
|
{ activate: true, instrumentations: require('./instrumentations/postgres') },
|
|
53
|
+
{
|
|
54
|
+
activate: /** @type {ActivationConfig} */ ({ setup: () => require('../../react-router') }),
|
|
55
|
+
instrumentations: require('./instrumentations/react-router'),
|
|
56
|
+
},
|
|
43
57
|
{ instrumentations: require('./instrumentations/vitest') },
|
|
44
|
-
{
|
|
58
|
+
{
|
|
59
|
+
activate: {
|
|
60
|
+
modules: ['@wdio/cli', '@wdio/jasmine-framework', '@wdio/local-runner', '@wdio/utils', 'webdriverio'],
|
|
61
|
+
setup: activation => require('../../webdriverio').recordLocalRunnerVersion(activation),
|
|
62
|
+
},
|
|
63
|
+
instrumentations: require('./instrumentations/webdriverio'),
|
|
64
|
+
},
|
|
45
65
|
{
|
|
46
66
|
activate: { setup: () => require('../../aws-durable-execution-sdk-js') },
|
|
47
67
|
instrumentations: require('./instrumentations/aws-durable-execution-sdk-js'),
|
|
48
68
|
},
|
|
49
69
|
{ activate: true, instrumentations: require('./instrumentations/supabase') },
|
|
70
|
+
{
|
|
71
|
+
activate: { setup: () => require('../../typesafe') },
|
|
72
|
+
instrumentations: require('./instrumentations/typesafe'),
|
|
73
|
+
},
|
|
74
|
+
{ activate: true, instrumentations: require('./instrumentations/trpc') },
|
|
50
75
|
]
|
|
51
76
|
|
|
52
77
|
const activatedModules = new Set()
|
package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
module: {
|
|
6
|
+
name: 'async-mutex',
|
|
7
|
+
versionRange: '>=0.5.0',
|
|
8
|
+
filePath: 'lib/Semaphore.js',
|
|
9
|
+
},
|
|
10
|
+
functionQuery: {
|
|
11
|
+
expressionName: 'acquire',
|
|
12
|
+
kind: 'Async',
|
|
13
|
+
},
|
|
14
|
+
channelName: 'Semaphore_acquire',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
module: {
|
|
18
|
+
name: 'async-mutex',
|
|
19
|
+
versionRange: '>=0.5.0',
|
|
20
|
+
filePath: 'es6/Semaphore.js',
|
|
21
|
+
},
|
|
22
|
+
functionQuery: {
|
|
23
|
+
expressionName: 'acquire',
|
|
24
|
+
kind: 'Async',
|
|
25
|
+
},
|
|
26
|
+
channelName: 'Semaphore_acquire',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
module: {
|
|
30
|
+
name: 'async-mutex',
|
|
31
|
+
versionRange: '>=0.5.0',
|
|
32
|
+
filePath: 'index.mjs',
|
|
33
|
+
},
|
|
34
|
+
functionQuery: {
|
|
35
|
+
className: 'Semaphore',
|
|
36
|
+
methodName: 'acquire',
|
|
37
|
+
kind: 'Async',
|
|
38
|
+
},
|
|
39
|
+
channelName: 'Semaphore_acquire',
|
|
40
|
+
},
|
|
41
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// The published Node SDK is CommonJS; ESM imports resolve to these same files.
|
|
4
|
+
// Public message callbacks run after tool dispatch, and startSession resolves after audio startup.
|
|
5
|
+
// These version-gated funnels preserve those earlier observation points; real-SDK CJS/ESM tests cover them.
|
|
6
|
+
module.exports = [
|
|
7
|
+
...['startSession', '_onWebSocketOpen', '_handleMessage', '_onWebSocketClose', 'endSession'].map(methodName => ({
|
|
8
|
+
module: {
|
|
9
|
+
name: '@elevenlabs/elevenlabs-js',
|
|
10
|
+
versionRange: '>=2.75.0 <3',
|
|
11
|
+
filePath: 'api/resources/conversationalAi/conversation/Conversation.js',
|
|
12
|
+
},
|
|
13
|
+
functionQuery: { className: 'Conversation', methodName, kind: methodName === 'startSession' ? 'Async' : 'Sync' },
|
|
14
|
+
channelName: methodName,
|
|
15
|
+
})),
|
|
16
|
+
...['register', 'executeToolAsync'].map(methodName => ({
|
|
17
|
+
module: {
|
|
18
|
+
name: '@elevenlabs/elevenlabs-js',
|
|
19
|
+
versionRange: '>=2.75.0 <3',
|
|
20
|
+
filePath: 'api/resources/conversationalAi/conversation/ClientTools.js',
|
|
21
|
+
},
|
|
22
|
+
functionQuery: { className: 'ClientTools', methodName },
|
|
23
|
+
channelName: methodName,
|
|
24
|
+
})),
|
|
25
|
+
]
|
package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
// Match the private closure only while its captured identifiers retain the verified
|
|
4
|
-
// 0.
|
|
4
|
+
// 0.7–0.9 contract. A future rewrite then misses safely instead of injecting stale names.
|
|
5
5
|
const CREATE_BOUND_QUERY = 'FunctionDeclaration[id.name="createBoundQuery"]' +
|
|
6
6
|
'[params.0.name="compilationContext"][params.1.name="document"][params.4.name="operationName"]'
|
|
7
7
|
const WRAP_QUERY = `${CREATE_BOUND_QUERY} ` +
|
|
@@ -78,5 +78,7 @@ addInstrumentations('>=0.7.0 <0.8.5 || >=0.8.7 <0.9.0', 'dist/execution.js')
|
|
|
78
78
|
addInstrumentations('>=0.8.5 <0.8.7', 'dist/cjs/execution.js')
|
|
79
79
|
addInstrumentations('>=0.8.5 <0.8.7', 'dist/esm/execution.js')
|
|
80
80
|
addInstrumentations('>=0.8.7 <0.9.0', 'dist/execution.mjs')
|
|
81
|
+
addInstrumentations('>=0.9.1 <0.10.0', 'dist/cjs/execution.js')
|
|
82
|
+
addInstrumentations('>=0.9.1 <0.10.0', 'dist/esm/execution.js')
|
|
81
83
|
|
|
82
84
|
module.exports = instrumentations
|