dd-trace 5.109.0 → 5.111.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/README.md +13 -8
- package/ci/init.js +25 -5
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/tags.js +2 -0
- package/index.d.ts +79 -24
- package/initialize.mjs +5 -6
- package/loader-hook.mjs +154 -47
- package/package.json +20 -16
- package/packages/datadog-esbuild/index.js +26 -0
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/connect.js +4 -3
- package/packages/datadog-instrumentations/src/fastify.js +4 -12
- package/packages/datadog-instrumentations/src/fs.js +8 -6
- package/packages/datadog-instrumentations/src/graphql.js +26 -484
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +81 -8
- package/packages/datadog-instrumentations/src/helpers/instrument.js +27 -2
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -4
- package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/koa.js +3 -2
- package/packages/datadog-instrumentations/src/mariadb.js +4 -2
- package/packages/datadog-instrumentations/src/mocha/main.js +3 -3
- package/packages/datadog-instrumentations/src/mongoose.js +14 -2
- package/packages/datadog-instrumentations/src/next.js +10 -10
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +7 -6
- package/packages/datadog-instrumentations/src/playwright.js +1 -1
- package/packages/datadog-instrumentations/src/restify.js +4 -3
- package/packages/datadog-instrumentations/src/router.js +18 -5
- package/packages/datadog-instrumentations/src/selenium.js +1 -2
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1293 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1567 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +249 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +753 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1598
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +2 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +18 -10
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +47 -11
- package/packages/datadog-plugin-aws-sdk/src/base.js +13 -9
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +43 -6
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +83 -91
- package/packages/datadog-plugin-cucumber/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +19 -5
- package/packages/datadog-plugin-cypress/src/support.js +45 -1
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-graphql/src/execute.js +627 -11
- package/packages/datadog-plugin-graphql/src/index.js +20 -8
- package/packages/datadog-plugin-graphql/src/parse.js +24 -4
- package/packages/datadog-plugin-graphql/src/validate.js +16 -5
- package/packages/datadog-plugin-http/src/client.js +8 -3
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http2/src/client.js +5 -2
- package/packages/datadog-plugin-jest/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +7 -2
- package/packages/datadog-plugin-openai/src/services.js +2 -2
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -2
- package/packages/datadog-plugin-undici/src/index.js +5 -2
- package/packages/datadog-plugin-vitest/src/index.js +76 -64
- package/packages/datadog-shimmer/src/shimmer.js +37 -16
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/src/aiguard/sdk.js +15 -3
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/channels.js +3 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +4 -4
- package/packages/dd-trace/src/appsec/graphql.js +5 -5
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +26 -19
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/index.js +20 -7
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/reporter.js +50 -10
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/waf/index.js +16 -4
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +4 -4
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +21 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +2 -2
- 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/index.js +3 -2
- 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 +55 -13
- 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 +17 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +47 -26
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +64 -53
- package/packages/dd-trace/src/ci-visibility/requests/request.js +1 -17
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +3 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +23 -5
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +128 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +287 -0
- package/packages/dd-trace/src/config/defaults.js +25 -5
- package/packages/dd-trace/src/config/generated-config-types.d.ts +596 -58
- package/packages/dd-trace/src/config/helper.js +134 -33
- package/packages/dd-trace/src/config/index.js +39 -23
- package/packages/dd-trace/src/config/major-overrides.js +4 -2
- package/packages/dd-trace/src/config/parsers.js +19 -1
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +109 -57
- package/packages/dd-trace/src/constants.js +7 -0
- package/packages/dd-trace/src/datastreams/processor.js +11 -3
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +47 -35
- package/packages/dd-trace/src/debugger/devtools_client/index.js +31 -66
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -0
- package/packages/dd-trace/src/debugger/index.js +5 -0
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +77 -26
- package/packages/dd-trace/src/exporters/agent/index.js +1 -1
- package/packages/dd-trace/src/exporters/agentless/writer.js +4 -4
- package/packages/dd-trace/src/exporters/common/request.js +1 -20
- package/packages/dd-trace/src/exporters/common/url.js +34 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/guardrails/index.js +8 -5
- package/packages/dd-trace/src/index.js +6 -4
- package/packages/dd-trace/src/llmobs/constants/tags.js +6 -0
- package/packages/dd-trace/src/llmobs/index.js +17 -6
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +8 -6
- package/packages/dd-trace/src/llmobs/span_processor.js +5 -1
- package/packages/dd-trace/src/llmobs/tagger.js +58 -3
- package/packages/dd-trace/src/llmobs/telemetry.js +1 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/log/index.js +18 -20
- package/packages/dd-trace/src/openfeature/flagging_provider.js +2 -7
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +5 -4
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +54 -5
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +2 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +4 -3
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +44 -38
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +29 -13
- package/packages/dd-trace/src/opentelemetry/span.js +14 -3
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/trace/index.js +6 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +26 -13
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +3 -3
- package/packages/dd-trace/src/opentracing/span_context.js +17 -0
- package/packages/dd-trace/src/opentracing/tracer.js +6 -1
- package/packages/dd-trace/src/plugin_manager.js +14 -8
- package/packages/dd-trace/src/plugins/ci_plugin.js +21 -4
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/test.js +91 -9
- package/packages/dd-trace/src/plugins/util/url.js +68 -1
- package/packages/dd-trace/src/plugins/util/web.js +19 -36
- package/packages/dd-trace/src/priority_sampler.js +1 -13
- package/packages/dd-trace/src/profiling/config.js +129 -198
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +23 -16
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +35 -23
- package/packages/dd-trace/src/profiling/profilers/events.js +14 -7
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -18
- package/packages/dd-trace/src/profiling/profilers/wall.js +35 -25
- package/packages/dd-trace/src/proxy.js +8 -8
- package/packages/dd-trace/src/ritm.js +4 -2
- package/packages/dd-trace/src/serverless.js +1 -2
- package/packages/dd-trace/src/service-naming/schemas/util.js +36 -5
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +5 -3
- package/packages/dd-trace/src/span_format.js +2 -1
- package/packages/dd-trace/src/span_processor.js +11 -6
- package/packages/dd-trace/src/span_stats.js +96 -78
- package/packages/dd-trace/src/startup-log.js +2 -1
- package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
- package/packages/dd-trace/src/telemetry/endpoints.js +6 -4
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +20 -18
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +9 -9
- package/packages/dd-trace/src/tracer.js +15 -1
- package/packages/dd-trace/src/util.js +14 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -170
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
package/index.d.ts
CHANGED
|
@@ -426,7 +426,7 @@ declare namespace tracer {
|
|
|
426
426
|
*/
|
|
427
427
|
export interface SamplingRule {
|
|
428
428
|
/**
|
|
429
|
-
* Sampling rate for this rule.
|
|
429
|
+
* Sampling rate for this rule. A range between 0 and 1 representing the percent of traces sampled.
|
|
430
430
|
*/
|
|
431
431
|
sampleRate: number
|
|
432
432
|
|
|
@@ -439,6 +439,22 @@ declare namespace tracer {
|
|
|
439
439
|
* Operation name on which to apply this rule. The rule will apply to all operation names if not provided.
|
|
440
440
|
*/
|
|
441
441
|
name?: string | RegExp
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Resource name on which to apply this rule. The rule will apply to all resource names if not provided.
|
|
445
|
+
*/
|
|
446
|
+
resource?: string | RegExp
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Span tags on which to apply this rule, keyed by tag name. Each value is a glob pattern or regular
|
|
450
|
+
* expression, and the rule only applies when every entry matches the span's tags.
|
|
451
|
+
*/
|
|
452
|
+
tags?: { [key: string]: string | RegExp }
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Maximum number of traces matching this rule to sample per second.
|
|
456
|
+
*/
|
|
457
|
+
maxPerSecond?: number
|
|
442
458
|
}
|
|
443
459
|
|
|
444
460
|
/**
|
|
@@ -620,10 +636,10 @@ declare namespace tracer {
|
|
|
620
636
|
rateLimit?: number,
|
|
621
637
|
|
|
622
638
|
/**
|
|
623
|
-
* Sampling rules to apply to priority sampling. Each rule
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* specified, will defer to global sampling rate for all spans.
|
|
639
|
+
* Sampling rules to apply to priority sampling. Each rule matches against a trace's
|
|
640
|
+
* `service`, `name`, `resource`, and `tags`, and applies the rule's `sampleRate`. Use a
|
|
641
|
+
* `sampleRate` of `0` to drop matching traces (for example to filter out unwanted resources).
|
|
642
|
+
* If not specified, will defer to global sampling rate for all spans.
|
|
627
643
|
* @default []
|
|
628
644
|
* @env DD_TRACE_SAMPLING_RULES
|
|
629
645
|
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
@@ -660,25 +676,25 @@ declare namespace tracer {
|
|
|
660
676
|
*/
|
|
661
677
|
runtimeMetrics?: boolean | {
|
|
662
678
|
|
|
663
|
-
|
|
679
|
+
/**
|
|
664
680
|
* @env DD_RUNTIME_METRICS_ENABLED
|
|
665
681
|
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
666
682
|
*/
|
|
667
683
|
enabled?: boolean,
|
|
668
684
|
|
|
669
|
-
|
|
685
|
+
/**
|
|
670
686
|
* @env DD_RUNTIME_METRICS_GC_ENABLED
|
|
671
687
|
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
672
688
|
*/
|
|
673
689
|
gc?: boolean,
|
|
674
690
|
|
|
675
|
-
|
|
691
|
+
/**
|
|
676
692
|
* @env DD_RUNTIME_METRICS_EVENT_LOOP_ENABLED
|
|
677
693
|
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
678
694
|
*/
|
|
679
695
|
eventLoop?: boolean,
|
|
680
696
|
|
|
681
|
-
|
|
697
|
+
/**
|
|
682
698
|
* Whether to use native metrics. When set to false, forces the JS implementation
|
|
683
699
|
* @default true
|
|
684
700
|
* @env DD_RUNTIME_METRICS_NATIVE
|
|
@@ -2363,6 +2379,14 @@ declare namespace tracer {
|
|
|
2363
2379
|
* [aws-sdk](https://github.com/aws/aws-sdk-js) module.
|
|
2364
2380
|
*/
|
|
2365
2381
|
interface aws_sdk extends Instrumentation {
|
|
2382
|
+
/**
|
|
2383
|
+
* The service name to be used for this plugin. When a function is used it is called with the AWS
|
|
2384
|
+
* request parameters (e.g. `{ TableName }` for DynamoDB, `{ Bucket }` for S3) and its return value
|
|
2385
|
+
* is used as the service name. Returning a nullish value falls back to the default service name, so
|
|
2386
|
+
* individual resources can be mapped without renaming every call to the service.
|
|
2387
|
+
*/
|
|
2388
|
+
service?: string | ((params: anyObject) => string | undefined | null);
|
|
2389
|
+
|
|
2366
2390
|
/**
|
|
2367
2391
|
* Whether to inject all messages during batch AWS SQS, Kinesis, and SNS send operations. Normal
|
|
2368
2392
|
* behavior is to inject the first message in batch send operations.
|
|
@@ -2581,24 +2605,36 @@ declare namespace tracer {
|
|
|
2581
2605
|
* This plugin automatically instruments the
|
|
2582
2606
|
* [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
|
|
2583
2607
|
*/
|
|
2584
|
-
|
|
2608
|
+
interface google_cloud_vertexai extends Integration {}
|
|
2585
2609
|
|
|
2586
|
-
|
|
2610
|
+
/**
|
|
2587
2611
|
* This plugin automatically instruments the
|
|
2588
2612
|
* [@google-genai](https://github.com/googleapis/js-genai) module.
|
|
2589
2613
|
*/
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2614
|
+
interface google_genai extends Integration {}
|
|
2615
|
+
|
|
2616
|
+
/** @hidden */
|
|
2617
|
+
interface ExecutionArgs {
|
|
2618
|
+
schema: any,
|
|
2619
|
+
document: any,
|
|
2620
|
+
rootValue?: any,
|
|
2621
|
+
contextValue?: any,
|
|
2622
|
+
variableValues?: any,
|
|
2623
|
+
operationName?: string,
|
|
2624
|
+
fieldResolver?: any,
|
|
2625
|
+
typeResolver?: any,
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
/** Context object passed to the `hooks.resolve` callback for each instrumented field. */
|
|
2629
|
+
interface FieldContext {
|
|
2630
|
+
/** The field name being resolved */
|
|
2631
|
+
fieldName: string;
|
|
2632
|
+
/** The dot-separated field path (e.g. `'user.address.city'`) */
|
|
2633
|
+
path: string;
|
|
2634
|
+
/** The error from the resolver, or `null` if it succeeded */
|
|
2635
|
+
error: Error | null;
|
|
2636
|
+
/** The value returned by the resolver (sync resolvers only; `undefined` for async) */
|
|
2637
|
+
result: unknown;
|
|
2602
2638
|
}
|
|
2603
2639
|
|
|
2604
2640
|
/**
|
|
@@ -2679,6 +2715,7 @@ declare namespace tracer {
|
|
|
2679
2715
|
execute?: (span?: Span, args?: ExecutionArgs, res?: any) => void;
|
|
2680
2716
|
validate?: (span?: Span, document?: any, errors?: any) => void;
|
|
2681
2717
|
parse?: (span?: Span, source?: any, document?: any) => void;
|
|
2718
|
+
resolve?: (span?: Span, field?: FieldContext) => void;
|
|
2682
2719
|
}
|
|
2683
2720
|
}
|
|
2684
2721
|
|
|
@@ -3217,7 +3254,16 @@ declare namespace tracer {
|
|
|
3217
3254
|
* This plugin automatically instruments the
|
|
3218
3255
|
* [router](https://github.com/pillarjs/router) module.
|
|
3219
3256
|
*/
|
|
3220
|
-
interface router extends Integration {
|
|
3257
|
+
interface router extends Integration {
|
|
3258
|
+
/**
|
|
3259
|
+
* Whether to enable instrumentation of router.middleware spans.
|
|
3260
|
+
* When set to `false`, middleware spans are suppressed but route
|
|
3261
|
+
* tracking (resource name, `http.route` tag) is still performed.
|
|
3262
|
+
*
|
|
3263
|
+
* @default true
|
|
3264
|
+
*/
|
|
3265
|
+
middleware?: boolean;
|
|
3266
|
+
}
|
|
3221
3267
|
|
|
3222
3268
|
/**
|
|
3223
3269
|
* This plugin automatically instruments the
|
|
@@ -4201,6 +4247,15 @@ declare namespace tracer {
|
|
|
4201
4247
|
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
4202
4248
|
*/
|
|
4203
4249
|
agentlessEnabled?: boolean,
|
|
4250
|
+
|
|
4251
|
+
/**
|
|
4252
|
+
* The proportion of LLM Observability traces to sample, between `0` and `1` (inclusive).
|
|
4253
|
+
* The decision is computed once per trace, propagated across services, and recorded on every
|
|
4254
|
+
* span; spans are always sent and the decision is honored at ingestion time. Defaults to `1`.
|
|
4255
|
+
* @env DD_LLMOBS_SAMPLE_RATE
|
|
4256
|
+
* Programmatic configuration takes precedence over the environment variables listed above.
|
|
4257
|
+
*/
|
|
4258
|
+
sampleRate?: number,
|
|
4204
4259
|
}
|
|
4205
4260
|
/** @hidden */
|
|
4206
4261
|
type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
|
package/initialize.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { isMainThread } from 'worker_threads'
|
|
|
19
19
|
// This file must support Node.js 12.0.0 syntax
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
iitmExclusionRegExp,
|
|
23
23
|
load as hookLoad,
|
|
24
24
|
resolve as hookResolve,
|
|
25
25
|
} from './loader-hook.mjs'
|
|
@@ -67,8 +67,7 @@ const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number)
|
|
|
67
67
|
const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
|
|
68
68
|
|
|
69
69
|
export async function load (url, context, nextLoad) {
|
|
70
|
-
const
|
|
71
|
-
const loadHook = (brokenLoaders || iitmExclusionsMatch) ? nextLoad : hookLoad
|
|
70
|
+
const loadHook = (brokenLoaders || iitmExclusionRegExp.test(url)) ? nextLoad : hookLoad
|
|
72
71
|
return insertInit(await loadHook(url, context, nextLoad), url, context)
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -78,8 +77,8 @@ if (isMainThread) {
|
|
|
78
77
|
const require = Module.createRequire(import.meta.url)
|
|
79
78
|
require('./init.js')
|
|
80
79
|
if (Module.register) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// The loader builds its own include/exclude matcher in `initialize`, so no
|
|
81
|
+
// options need to cross the registration boundary.
|
|
82
|
+
Module.register('./loader-hook.mjs', import.meta.url)
|
|
84
83
|
}
|
|
85
84
|
}
|
package/loader-hook.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.registerHooks'] }] */
|
|
2
|
+
|
|
3
|
+
import * as Module from 'node:module'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
|
|
6
|
+
import { createHook, supportsSyncHooks } from 'import-in-the-middle/create-hook.mjs'
|
|
1
7
|
import { initialize as origInitialize, load as origLoad, resolve } from 'import-in-the-middle/hook.mjs'
|
|
2
8
|
import regexpEscapeModule from './vendor/dist/escape-string-regexp/index.js'
|
|
3
9
|
import hooks from './packages/datadog-instrumentations/src/helpers/hooks.js'
|
|
@@ -7,71 +13,172 @@ import { isRelativeRequire } from './packages/datadog-instrumentations/src/helpe
|
|
|
7
13
|
|
|
8
14
|
// This file must support Node.js 12.0.0 syntax
|
|
9
15
|
|
|
16
|
+
const { builtinModules } = Module
|
|
10
17
|
const regexpEscape = regexpEscapeModule.default
|
|
18
|
+
const require = Module.createRequire(import.meta.url)
|
|
19
|
+
let syncImportInTheMiddleHook
|
|
11
20
|
|
|
12
|
-
//
|
|
13
|
-
const
|
|
21
|
+
// The config helper's named exports aren't visible to ESM; destructure the default.
|
|
22
|
+
const { getValueFromEnvSources } = configHelper
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
// Substrings of resolved URLs that import-in-the-middle must never wrap: re-export
|
|
25
|
+
// shims and internal helper graphs that break when proxied, plus iitm's own files
|
|
26
|
+
// (via `middle`). One alternation so a single test() covers every excluded load.
|
|
27
|
+
export const iitmExclusionRegExp = /middle|langsmith|openai\/_shims|openai\/resources\/chat\/completions\/messages|openai\/agents-core\/dist\/shims|@anthropic-ai\/sdk\/_shims/
|
|
28
|
+
|
|
29
|
+
// Instrumented bare specifiers (`import 'express'`, builtins, symlinked or
|
|
30
|
+
// workspace packages) match against the specifier (the Set); their files inside
|
|
31
|
+
// node_modules match against the URL (the alternation). regexpEscape guards
|
|
32
|
+
// against a regex metacharacter entering a package name.
|
|
33
|
+
const includeModuleNames = new Set()
|
|
34
|
+
let moduleNameAlternation = ''
|
|
35
|
+
for (const moduleName of Object.keys(hooks)) {
|
|
36
|
+
// Relative hooks resolve outside node_modules and are not instrumented here.
|
|
37
|
+
if (isRelativeRequire(moduleName)) continue
|
|
38
|
+
includeModuleNames.add(moduleName)
|
|
39
|
+
// iitm matches a built-in by its node: specifier too, so mirror that and
|
|
40
|
+
// wrap `import 'node:crypto'` as well as `import 'crypto'`.
|
|
41
|
+
if (builtinModules.includes(moduleName)) includeModuleNames.add(`node:${moduleName}`)
|
|
42
|
+
if (moduleNameAlternation !== '') moduleNameAlternation += '|'
|
|
43
|
+
moduleNameAlternation += regexpEscape(moduleName)
|
|
44
|
+
}
|
|
18
45
|
|
|
19
|
-
|
|
20
|
-
addSecurityControls(data)
|
|
21
|
-
addExclusions(data)
|
|
46
|
+
const nodeModulesIncludeSource = `node_modules/(?:${moduleNameAlternation})/(?!node_modules).+`
|
|
22
47
|
|
|
48
|
+
function initialize (data = {}) {
|
|
49
|
+
prepareImportInTheMiddleOptions(data)
|
|
23
50
|
return origInitialize(data)
|
|
24
51
|
}
|
|
25
52
|
|
|
53
|
+
function prepareImportInTheMiddleOptions (data = {}) {
|
|
54
|
+
// A consumer-owned shouldInclude predicate takes over the wrapping decision, so
|
|
55
|
+
// iitm ignores the include/exclude arrays. Building the matcher here keeps the
|
|
56
|
+
// synchronous and asynchronous loaders on one matching implementation.
|
|
57
|
+
data.shouldInclude = createShouldInclude(getValueFromEnvSources('DD_IAST_SECURITY_CONTROLS_CONFIGURATION'))
|
|
58
|
+
|
|
59
|
+
return data
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Builds the import-in-the-middle `shouldInclude(url, specifier)` predicate. iitm
|
|
64
|
+
* calls it for every resolved module and wraps the module when the result is
|
|
65
|
+
* truthy; supplying it replaces iitm's include/exclude list scan.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} [securityControlsConfig] Raw `DD_IAST_SECURITY_CONTROLS_CONFIGURATION`;
|
|
68
|
+
* each entry's module path is instrumented in addition to the hook table.
|
|
69
|
+
*/
|
|
70
|
+
function createShouldInclude (securityControlsConfig) {
|
|
71
|
+
const includeRegExp = new RegExp(buildIncludeSource(securityControlsConfig))
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} url Resolved module URL (`file:`, `node:`, ...).
|
|
75
|
+
* @param {string} specifier Original import specifier.
|
|
76
|
+
*/
|
|
77
|
+
return function shouldInclude (url, specifier) {
|
|
78
|
+
return (includeModuleNames.has(specifier) || includeRegExp.test(url)) && !iitmExclusionRegExp.test(url)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Appends each `DD_IAST_SECURITY_CONTROLS_CONFIGURATION` module path — the third
|
|
84
|
+
* `:`-separated segment of every `;`-separated `<type>:<marks>:<module>:<...>` entry —
|
|
85
|
+
* to the include alternation, escaped.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} [securityControlsConfig] Raw `DD_IAST_SECURITY_CONTROLS_CONFIGURATION`.
|
|
88
|
+
*/
|
|
89
|
+
function buildIncludeSource (securityControlsConfig) {
|
|
90
|
+
if (!securityControlsConfig) return nodeModulesIncludeSource
|
|
91
|
+
|
|
92
|
+
let includeSource = nodeModulesIncludeSource
|
|
93
|
+
for (const entry of securityControlsConfig.split(';')) {
|
|
94
|
+
if (!entry) continue
|
|
95
|
+
const first = entry.indexOf(':')
|
|
96
|
+
if (first === -1) continue
|
|
97
|
+
const second = entry.indexOf(':', first + 1)
|
|
98
|
+
if (second === -1) continue
|
|
99
|
+
const third = entry.indexOf(':', second + 1)
|
|
100
|
+
|
|
101
|
+
const subpath = entry.slice(second + 1, third === -1 ? undefined : third).trim()
|
|
102
|
+
if (subpath) includeSource += `|${regexpEscape(subpath)}`
|
|
103
|
+
}
|
|
104
|
+
return includeSource
|
|
105
|
+
}
|
|
106
|
+
|
|
26
107
|
function load (url, context, nextLoad) {
|
|
27
108
|
return rewriterLoader.load(url, context, (url, context) => origLoad(url, context, nextLoad))
|
|
28
109
|
}
|
|
29
110
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (const moduleName of instrumentations) {
|
|
34
|
-
// Skip instrumentation hooks with relative module names
|
|
35
|
-
// since there is no current business need of instrumenting imports outside of the node_modules folder
|
|
36
|
-
if (!isRelativeRequire(moduleName)) {
|
|
37
|
-
data.include.push(new RegExp(`node_modules/${moduleName}/(?!node_modules).+`), moduleName)
|
|
38
|
-
}
|
|
111
|
+
function loadSync (url, context, nextLoad) {
|
|
112
|
+
if (isCommonJSLoad(context)) {
|
|
113
|
+
return getSyncImportInTheMiddleHook().loadSync(url, context, nextLoad)
|
|
39
114
|
}
|
|
115
|
+
|
|
116
|
+
return rewriterLoader.loadSync(url, context, (url, context) => {
|
|
117
|
+
return getSyncImportInTheMiddleHook().loadSync(url, context, nextLoad)
|
|
118
|
+
})
|
|
40
119
|
}
|
|
41
120
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (second === -1) continue
|
|
54
|
-
const third = entry.indexOf(':', second + 1)
|
|
55
|
-
|
|
56
|
-
const subpath = entry.slice(second + 1, third === -1 ? undefined : third).trim()
|
|
57
|
-
if (subpath) {
|
|
58
|
-
data.include.push(new RegExp(regexpEscape(subpath)))
|
|
59
|
-
}
|
|
60
|
-
}
|
|
121
|
+
function isCommonJSLoad (context) {
|
|
122
|
+
if (context.format) return context.format === 'commonjs'
|
|
123
|
+
|
|
124
|
+
// Sync hooks report CommonJS require() dependency loads with a `require`
|
|
125
|
+
// condition but no format. If a format is present, trust it instead: ESM
|
|
126
|
+
// loaded through require() reports `format: 'module'` and still needs rewrite.
|
|
127
|
+
const conditions = context.conditions
|
|
128
|
+
if (!conditions) return false
|
|
129
|
+
|
|
130
|
+
for (let i = 0; i < conditions.length; i++) {
|
|
131
|
+
if (conditions[i] === 'require') return true
|
|
61
132
|
}
|
|
133
|
+
|
|
134
|
+
return false
|
|
62
135
|
}
|
|
63
136
|
|
|
64
|
-
function
|
|
65
|
-
|
|
137
|
+
function getSyncImportInTheMiddleHook () {
|
|
138
|
+
if (syncImportInTheMiddleHook) {
|
|
139
|
+
return syncImportInTheMiddleHook
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const importInTheMiddleRegisterHooksUrl = pathToFileURL(
|
|
143
|
+
require.resolve('import-in-the-middle/register-hooks.mjs')
|
|
144
|
+
).href
|
|
145
|
+
syncImportInTheMiddleHook = createHook({ url: importInTheMiddleRegisterHooksUrl })
|
|
146
|
+
return syncImportInTheMiddleHook
|
|
66
147
|
}
|
|
67
148
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
149
|
+
function registerSyncLoaderHooks (data = {}) {
|
|
150
|
+
// The synchronous loader strips the source of a require() pulled into the iitm
|
|
151
|
+
// ESM graph so Node loads it natively, but module.registerHooks rejected that
|
|
152
|
+
// nullish CommonJS source until nodejs/node#59929 (released in 22.22.3, 24.11.1,
|
|
153
|
+
// 25.1.0 and 26.0.0). On versions that ship registerHooks but predate the fix,
|
|
154
|
+
// fall back to the asynchronous loader instead of crashing mid-graph.
|
|
155
|
+
if (!supportsSyncHooks()) {
|
|
156
|
+
return false
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const syncHook = getSyncImportInTheMiddleHook()
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
typeof Module.registerHooks !== 'function' ||
|
|
163
|
+
typeof syncHook.applyOptions !== 'function' ||
|
|
164
|
+
typeof syncHook.loadSync !== 'function' ||
|
|
165
|
+
typeof syncHook.resolveSync !== 'function'
|
|
166
|
+
) {
|
|
167
|
+
return false
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Node built-ins are instrumented under the synchronous loader as well: iitm
|
|
171
|
+
// reads a built-in's exports through process.getBuiltinModule(), which
|
|
172
|
+
// bypasses the registered hooks and therefore cannot re-enter them. The
|
|
173
|
+
// synchronous and asynchronous loaders share the same option preparation so
|
|
174
|
+
// that `import http from 'node:http'` is wrapped on both paths.
|
|
175
|
+
syncHook.applyOptions(prepareImportInTheMiddleOptions(data))
|
|
176
|
+
Module.registerHooks({
|
|
177
|
+
resolve: syncHook.resolveSync,
|
|
178
|
+
load: loadSync,
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
76
183
|
|
|
77
|
-
export { initialize, load, resolve }
|
|
184
|
+
export { initialize, load, registerSyncLoaderHooks, resolve }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.111.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"lint:inspect": "npx @eslint/config-inspector@latest",
|
|
24
24
|
"lint:codeowners": "codeowners-audit",
|
|
25
25
|
"lint:codeowners:ci": "codeowners-audit --glob='**/*.spec.js' --glob='benchmark/sirun/**' --glob='.agents/**' --glob='.claude/**'",
|
|
26
|
+
"lint:editorconfig": "editorconfig-checker",
|
|
26
27
|
"release:proposal": "node scripts/release/proposal",
|
|
27
28
|
"services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
|
|
28
29
|
"test": "echo '\nError: The root \"npm test\" command is intentionally disabled.\n\nInstead, run specific test suites:\n - npm run test:trace:core\n - npm run test:appsec\n - etc.\n\nOr run individual test files:\n npx mocha path/to/test.spec.js\n\nSee CONTRIBUTING.md (Testing section) for more details.\n' && exit 1",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"test:webpack:ci": "nyc --silent node init && nyc -- npm run test:webpack",
|
|
46
47
|
"test:instrumentations": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\"",
|
|
47
48
|
"test:instrumentations:ci": "yarn services && nyc --silent node init && nyc -- npm run test:instrumentations",
|
|
48
|
-
"test:instrumentations:misc": "mocha \"packages/datadog-instrumentations/test/*/**/*.spec.js\"",
|
|
49
|
+
"test:instrumentations:misc": "mocha \"packages/datadog-instrumentations/test/*/**/*.spec.{js,mjs}\"",
|
|
49
50
|
"test:instrumentations:misc:ci": "nyc --silent node init && nyc -- npm run test:instrumentations:misc",
|
|
50
51
|
"test:core": "node scripts/mocha-parallel-files.js --expose-gc --timeout 30000 -- \"packages/datadog-core/test/**/*.spec.js\"",
|
|
51
52
|
"test:core:ci": "nyc --silent node init && nyc -- npm run test:core",
|
|
@@ -103,6 +104,7 @@
|
|
|
103
104
|
"test:integration:plugins:coverage": "yarn services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
|
|
104
105
|
"test:unit:plugins": "mocha \"packages/datadog-instrumentations/test/@(${PLUGINS}).spec.js\" \"packages/datadog-plugin-@(${PLUGINS})/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/*.spec.js\"",
|
|
105
106
|
"test:release": "mocha \"scripts/release/**/*.spec.js\"",
|
|
107
|
+
"test:scripts": "mocha \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
|
|
106
108
|
"test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
|
|
107
109
|
"test:shimmer:ci": "nyc --silent node init && nyc -- npm run test:shimmer",
|
|
108
110
|
"verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
|
|
@@ -129,8 +131,9 @@
|
|
|
129
131
|
},
|
|
130
132
|
"homepage": "https://github.com/DataDog/dd-trace-js#readme",
|
|
131
133
|
"engines": {
|
|
132
|
-
"node": ">=18
|
|
134
|
+
"node": ">=18"
|
|
133
135
|
},
|
|
136
|
+
"nodeMaxMajor": 27,
|
|
134
137
|
"files": [
|
|
135
138
|
"/package.json",
|
|
136
139
|
"ci/**/*",
|
|
@@ -161,7 +164,7 @@
|
|
|
161
164
|
],
|
|
162
165
|
"dependencies": {
|
|
163
166
|
"dc-polyfill": "^0.1.11",
|
|
164
|
-
"import-in-the-middle": "^3.0
|
|
167
|
+
"import-in-the-middle": "^3.2.0",
|
|
165
168
|
"opentracing": ">=0.14.7"
|
|
166
169
|
},
|
|
167
170
|
"optionalDependencies": {
|
|
@@ -170,7 +173,7 @@
|
|
|
170
173
|
"@datadog/native-iast-taint-tracking": "4.2.0",
|
|
171
174
|
"@datadog/native-metrics": "3.1.2",
|
|
172
175
|
"@datadog/openfeature-node-server": "2.0.0",
|
|
173
|
-
"@datadog/pprof": "5.15.
|
|
176
|
+
"@datadog/pprof": "5.15.1",
|
|
174
177
|
"@datadog/wasm-js-rewriter": "5.0.1",
|
|
175
178
|
"@opentelemetry/api": ">=1.0.0 <1.10.0",
|
|
176
179
|
"@opentelemetry/api-logs": "<1.0.0",
|
|
@@ -179,33 +182,34 @@
|
|
|
179
182
|
"devDependencies": {
|
|
180
183
|
"@actions/core": "^3.0.1",
|
|
181
184
|
"@actions/github": "^9.1.1",
|
|
182
|
-
"@babel/helpers": "^
|
|
185
|
+
"@babel/helpers": "^8.0.0",
|
|
183
186
|
"@eslint/eslintrc": "^3.3.5",
|
|
184
187
|
"@eslint/js": "^9.39.2",
|
|
185
188
|
"@msgpack/msgpack": "^3.1.3",
|
|
186
|
-
"@openfeature/core": "^1.
|
|
187
|
-
"@openfeature/server-sdk": "~1.
|
|
189
|
+
"@openfeature/core": "^1.11.0",
|
|
190
|
+
"@openfeature/server-sdk": "~1.22.0",
|
|
188
191
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
189
192
|
"@types/mocha": "^10.0.10",
|
|
190
193
|
"@types/node": "^18.19.106",
|
|
191
194
|
"@types/sinon": "^21.0.1",
|
|
192
|
-
"axios": "^1.
|
|
195
|
+
"axios": "^1.18.1",
|
|
193
196
|
"benchmark": "^2.1.4",
|
|
194
|
-
"body-parser": "^2.
|
|
197
|
+
"body-parser": "^2.3.0",
|
|
195
198
|
"bun": "1.3.14",
|
|
196
199
|
"codeowners-audit": "^2.9.0",
|
|
200
|
+
"editorconfig-checker": "^6.1.1",
|
|
197
201
|
"eslint": "^9.39.2",
|
|
198
202
|
"eslint-plugin-cypress": "^6.4.1",
|
|
199
203
|
"eslint-plugin-import": "^2.32.0",
|
|
200
|
-
"eslint-plugin-jsdoc": "^63.0.
|
|
204
|
+
"eslint-plugin-jsdoc": "^63.0.8",
|
|
201
205
|
"eslint-plugin-mocha": "^11.3.0",
|
|
202
|
-
"eslint-plugin-n": "^18.0
|
|
206
|
+
"eslint-plugin-n": "^18.2.0",
|
|
203
207
|
"eslint-plugin-promise": "^7.3.0",
|
|
204
|
-
"eslint-plugin-sonarjs": "^4.0
|
|
208
|
+
"eslint-plugin-sonarjs": "^4.1.0",
|
|
205
209
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
206
210
|
"express": "^5.1.0",
|
|
207
211
|
"glob": "^10.4.5",
|
|
208
|
-
"globals": "^17.
|
|
212
|
+
"globals": "^17.7.0",
|
|
209
213
|
"graphql": "*",
|
|
210
214
|
"husky": "^9.1.7",
|
|
211
215
|
"istanbul-lib-report": "^3.0.0",
|
|
@@ -214,7 +218,7 @@
|
|
|
214
218
|
"mocha": "^11.7.6",
|
|
215
219
|
"mocha-junit-reporter": "^2.2.1",
|
|
216
220
|
"mocha-multi-reporters": "^1.5.1",
|
|
217
|
-
"multer": "^2.
|
|
221
|
+
"multer": "^2.2.0",
|
|
218
222
|
"nock": "^14.0.15",
|
|
219
223
|
"node-preload": "^0.2.1",
|
|
220
224
|
"nyc": "^18.0.0",
|
|
@@ -223,7 +227,7 @@
|
|
|
223
227
|
"proxyquire": "^2.1.3",
|
|
224
228
|
"retry": "^0.13.1",
|
|
225
229
|
"semifies": "^1.0.0",
|
|
226
|
-
"semver": "^7.8.
|
|
230
|
+
"semver": "^7.8.5",
|
|
227
231
|
"sinon": "^22.0.0",
|
|
228
232
|
"tiktoken": "^1.0.21",
|
|
229
233
|
"typescript": "^6.0.3",
|
|
@@ -8,6 +8,11 @@ const { pathToFileURL, fileURLToPath } = require('node:url')
|
|
|
8
8
|
const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations')
|
|
9
9
|
const extractPackageAndModulePath = require('../datadog-instrumentations/src/helpers/extract-package-and-module-path')
|
|
10
10
|
const hooks = require('../datadog-instrumentations/src/helpers/hooks')
|
|
11
|
+
const {
|
|
12
|
+
OPTIONAL_PEER_FILTER,
|
|
13
|
+
matchesOptionalPeerFile,
|
|
14
|
+
rewriteOptionalPeerLoads,
|
|
15
|
+
} = require('../datadog-instrumentations/src/helpers/optional-peer-bundler')
|
|
11
16
|
const { processModule, isESMFile } = require('./src/utils')
|
|
12
17
|
const log = require('./src/log')
|
|
13
18
|
|
|
@@ -128,6 +133,11 @@ module.exports.setup = function (build) {
|
|
|
128
133
|
${build.initialOptions.banner.js}`
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
// Keep the build from failing on the optional `@openfeature/core` peer of
|
|
137
|
+
// `@openfeature/server-sdk` when it is not installed (#8635). esbuild follows the chain
|
|
138
|
+
// whenever `@openfeature/server-sdk` is reachable -- the app importing it directly, or the
|
|
139
|
+
// bundled provider when the optional peer is present -- so mark `@openfeature/core` external
|
|
140
|
+
// when it is absent rather than erroring at bundle time.
|
|
131
141
|
try {
|
|
132
142
|
// eslint-disable-next-line n/no-unpublished-require
|
|
133
143
|
require.resolve('@openfeature/core')
|
|
@@ -172,6 +182,22 @@ ${build.initialOptions.banner.js}`
|
|
|
172
182
|
log.warn('No git metadata available - skipping injection')
|
|
173
183
|
}
|
|
174
184
|
|
|
185
|
+
// Rewrite optional-peer loads so installed peers get bundled and survive the bundle being
|
|
186
|
+
// relocated without them on disk (#8980). Registered before the generic onLoad so it wins for
|
|
187
|
+
// these files. Absent peers stay opaque, so a build that does not opt into the feature does not
|
|
188
|
+
// follow their dependency chain (#8635).
|
|
189
|
+
build.onLoad({ filter: OPTIONAL_PEER_FILTER }, args => {
|
|
190
|
+
const normalizedPath = args.path.replaceAll('\\', '/')
|
|
191
|
+
if (!matchesOptionalPeerFile(normalizedPath)) return
|
|
192
|
+
|
|
193
|
+
log.debug('INLINE: optional-peer loader applied to %s', normalizedPath)
|
|
194
|
+
return {
|
|
195
|
+
contents: rewriteOptionalPeerLoads(fs.readFileSync(args.path, 'utf8'), path.dirname(args.path)),
|
|
196
|
+
loader: 'js',
|
|
197
|
+
resolveDir: path.dirname(args.path),
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
175
201
|
// first time is intercepted, proxy should be created, next time the original should be loaded
|
|
176
202
|
const interceptedESMModules = new Set()
|
|
177
203
|
|