dd-trace 6.12.0 → 6.13.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.
Files changed (97) hide show
  1. package/ci/test-optimization-validation/framework-adapters/cypress.js +9 -11
  2. package/ci/test-optimization-validation/scenarios/ci-wiring.js +5 -4
  3. package/index.d.ts +127 -26
  4. package/package.json +10 -10
  5. package/packages/datadog-instrumentations/src/bunyan.js +4 -2
  6. package/packages/datadog-instrumentations/src/helpers/bunyan.js +12 -3
  7. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +1 -0
  8. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +28 -0
  9. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +1 -0
  10. package/packages/datadog-instrumentations/src/jest.js +140 -18
  11. package/packages/datadog-instrumentations/src/mariadb-bundle.js +1597 -0
  12. package/packages/datadog-instrumentations/src/mariadb.js +7 -0
  13. package/packages/datadog-instrumentations/src/pino.js +15 -4
  14. package/packages/datadog-instrumentations/src/playwright.js +34 -20
  15. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +7 -4
  16. package/packages/datadog-instrumentations/src/vitest-worker.js +11 -0
  17. package/packages/datadog-instrumentations/src/webdriverio.js +26 -0
  18. package/packages/datadog-instrumentations/src/winston.js +6 -3
  19. package/packages/datadog-plugin-cypress/src/support.js +1 -0
  20. package/packages/datadog-plugin-http/src/client.js +2 -15
  21. package/packages/datadog-plugin-http2/src/client.js +2 -15
  22. package/packages/datadog-plugin-openai-agents/src/integration.js +15 -11
  23. package/packages/datadog-plugin-playwright/src/index.js +9 -1
  24. package/packages/datadog-plugin-undici/src/index.js +2 -15
  25. package/packages/dd-trace/src/aiguard/evaluation.js +94 -20
  26. package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +2 -3
  27. package/packages/dd-trace/src/aiguard/messages/anthropic.js +21 -9
  28. package/packages/dd-trace/src/aiguard/noop.js +9 -1
  29. package/packages/dd-trace/src/aiguard/redaction.js +183 -0
  30. package/packages/dd-trace/src/aiguard/sdk.js +7 -2
  31. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  32. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +10 -9
  33. package/packages/dd-trace/src/appsec/rule_manager.js +2 -0
  34. package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +51 -26
  35. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +5 -11
  36. package/packages/dd-trace/src/ci-visibility/final-flush.js +20 -0
  37. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +196 -29
  38. package/packages/dd-trace/src/config/generated-config-types.d.ts +6 -0
  39. package/packages/dd-trace/src/config/index.js +2 -1
  40. package/packages/dd-trace/src/config/supported-configurations.json +27 -0
  41. package/packages/dd-trace/src/debugger/devtools_client/send.js +4 -3
  42. package/packages/dd-trace/src/dogstatsd.js +45 -18
  43. package/packages/dd-trace/src/encode/agentless-json.js +5 -4
  44. package/packages/dd-trace/src/exporters/agent/index.js +22 -2
  45. package/packages/dd-trace/src/exporters/agent/writer.js +4 -4
  46. package/packages/dd-trace/src/exporters/common/writer.js +24 -2
  47. package/packages/dd-trace/src/exporters/span-stats/index.js +23 -4
  48. package/packages/dd-trace/src/external-logger/src/index.js +4 -3
  49. package/packages/dd-trace/src/flush.js +102 -0
  50. package/packages/dd-trace/src/llmobs/experiments/client.js +4 -0
  51. package/packages/dd-trace/src/llmobs/experiments/dataset.js +51 -2
  52. package/packages/dd-trace/src/llmobs/experiments/experiment.js +420 -105
  53. package/packages/dd-trace/src/llmobs/experiments/index.js +54 -42
  54. package/packages/dd-trace/src/llmobs/experiments/noop.js +39 -8
  55. package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
  56. package/packages/dd-trace/src/llmobs/experiments/util.js +21 -0
  57. package/packages/dd-trace/src/llmobs/index.js +80 -17
  58. package/packages/dd-trace/src/llmobs/noop.js +2 -1
  59. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +8 -4
  60. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +6 -3
  61. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +13 -6
  62. package/packages/dd-trace/src/llmobs/plugins/openai-agents/utils.js +5 -7
  63. package/packages/dd-trace/src/llmobs/writers/base.js +60 -24
  64. package/packages/dd-trace/src/noop/span.js +5 -0
  65. package/packages/dd-trace/src/openfeature/writers/exposures.js +8 -1
  66. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +45 -3
  67. package/packages/dd-trace/src/opentelemetry/logs/index.js +4 -1
  68. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +7 -4
  69. package/packages/dd-trace/src/opentelemetry/metrics/index.js +3 -1
  70. package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +8 -0
  71. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +4 -2
  72. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -2
  73. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +25 -5
  74. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +61 -25
  75. package/packages/dd-trace/src/opentelemetry/tracer.js +26 -2
  76. package/packages/dd-trace/src/opentracing/propagation/text_map.js +410 -342
  77. package/packages/dd-trace/src/opentracing/span.js +28 -0
  78. package/packages/dd-trace/src/otel-thread-ctx.js +23 -5
  79. package/packages/dd-trace/src/plugin_manager.js +2 -0
  80. package/packages/dd-trace/src/plugins/util/status-validator.js +98 -0
  81. package/packages/dd-trace/src/plugins/util/test.js +74 -21
  82. package/packages/dd-trace/src/plugins/util/web.js +2 -65
  83. package/packages/dd-trace/src/profiling/oom.js +4 -3
  84. package/packages/dd-trace/src/profiling/profiler.js +7 -0
  85. package/packages/dd-trace/src/profiling/profilers/events.js +3 -3
  86. package/packages/dd-trace/src/profiling/profilers/wall.js +14 -14
  87. package/packages/dd-trace/src/proxy.js +36 -8
  88. package/packages/dd-trace/src/runtime_metrics/index.js +5 -0
  89. package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +5 -0
  90. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +17 -6
  91. package/packages/dd-trace/src/serverless/telemetry-delivery-tracker.js +55 -0
  92. package/packages/dd-trace/src/serverless/vercel.js +122 -0
  93. package/packages/dd-trace/src/serverless.js +37 -20
  94. package/packages/dd-trace/src/span_stats.js +40 -3
  95. package/packages/dd-trace/src/tracer.js +22 -0
  96. package/packages/dd-trace/src/web-tags-cache.js +67 -13
  97. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
@@ -40,20 +40,18 @@ function getTestExtension (filename) {
40
40
  * @returns {string} canonical generated Cypress source
41
41
  */
42
42
  function getGeneratedTestContent ({ scenarioId, testName }) {
43
- const lines = []
43
+ let content = ''
44
44
  if (scenarioId === 'atr-fail-once') {
45
- lines.push('let attempt = 0', '')
45
+ content = 'let attempt = 0\n\n'
46
46
  }
47
- lines.push(
48
- "describe('dd-test-optimization-validation', () => {",
49
- ` it(${JSON.stringify(testName)}, () => {`,
50
- scenarioId === 'atr-fail-once'
51
- ? ' expect(attempt++).to.equal(1)'
52
- : ' expect(true).to.equal(true)',
53
- ' })',
47
+ content += "describe('dd-test-optimization-validation', () => {\n" +
48
+ ` it(${JSON.stringify(testName)}, () => {\n` +
49
+ (scenarioId === 'atr-fail-once'
50
+ ? ' expect(attempt++).to.equal(1)\n'
51
+ : ' expect(true).to.equal(true)\n') +
52
+ ' })\n' +
54
53
  '})'
55
- )
56
- return lines.join('\n')
54
+ return content
57
55
  }
58
56
 
59
57
  /**
@@ -184,12 +184,13 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
184
184
  }
185
185
 
186
186
  if (resolution.status !== 'confirmed') {
187
- const visibleFacts = []
187
+ let visibleFacts = ''
188
188
  if (initialization.status === 'missing') {
189
- visibleFacts.push('The selected job has no visible dd-trace/ci/init preload.')
189
+ visibleFacts = 'The selected job has no visible dd-trace/ci/init preload.'
190
190
  }
191
191
  if (ciFacts.transport.status === 'missing') {
192
- visibleFacts.push('The recorded review found no visible Datadog Agent or agentless reporting transport.')
192
+ if (visibleFacts) visibleFacts += ' '
193
+ visibleFacts += 'The recorded review found no visible Datadog Agent or agentless reporting transport.'
193
194
  }
194
195
  const recommendation = /working directory/i.test(resolution.reason)
195
196
  ? 'Keep the CI job\'s actual working directory. Resolve the repository-root wrapper to the selected test ' +
@@ -199,7 +200,7 @@ function runCiWiring ({ manifest, framework, projectFileSources }) {
199
200
  return getIncomplete(
200
201
  framework,
201
202
  'The CI audit remains incomplete because the selected command could not be resolved to the ' +
202
- `${framework.framework} runner: ${resolution.reason}. ${visibleFacts.join(' ')}`.trim(),
203
+ `${framework.framework} runner: ${resolution.reason}. ${visibleFacts}`.trim(),
203
204
  {
204
205
  ...evidence,
205
206
  recommendation,
package/index.d.ts CHANGED
@@ -356,6 +356,16 @@ declare namespace tracer {
356
356
  links?: { context: SpanContext, attributes?: Object }[]
357
357
  }
358
358
 
359
+ export interface Exception {
360
+ message: string;
361
+ name?: string;
362
+ stack?: string;
363
+ }
364
+
365
+ export type SpanEventAttributeValue =
366
+ string | number | boolean | Array<string> | Array<number> | Array<boolean>;
367
+ export type SpanEventAttributes = Record<string, SpanEventAttributeValue>;
368
+
359
369
  /**
360
370
  * Span represents a logical unit of work as part of a broader Trace.
361
371
  * Examples of span might include remote procedure calls or a in-process
@@ -366,6 +376,14 @@ declare namespace tracer {
366
376
  export interface Span extends opentracing.Span {
367
377
  context (): SpanContext;
368
378
 
379
+ /**
380
+ * Records an exception as a span event without marking the span as failed.
381
+ *
382
+ * @param exception The exception to record.
383
+ * @param attributes Additional attributes for the exception event.
384
+ */
385
+ recordException (exception: Exception, attributes?: SpanEventAttributes): void;
386
+
369
387
  /**
370
388
  * Adds a single link to the span.
371
389
  *
@@ -789,6 +807,13 @@ declare namespace tracer {
789
807
  * Programmatic configuration takes precedence over the environment variables listed above.
790
808
  */
791
809
  maxMessagesLength?: number,
810
+ /**
811
+ * Whether AI Guard applies backend-provided sensitive-data redaction replacements.
812
+ * @default true
813
+ * @env DD_AI_GUARD_REDACTION_ENABLED
814
+ * Programmatic configuration takes precedence over the environment variables listed above.
815
+ */
816
+ redactionEnabled?: boolean,
792
817
  /**
793
818
  * Max size of the content property set in the meta-struct
794
819
  * @env DD_AI_GUARD_MAX_CONTENT_SIZE
@@ -1706,6 +1731,25 @@ declare namespace tracer {
1706
1731
  };
1707
1732
  }
1708
1733
 
1734
+ /**
1735
+ * A structured content part in an AI Guard message.
1736
+ */
1737
+ export interface ContentPart {
1738
+ type: string;
1739
+ text?: string;
1740
+ image_url?: { url: string };
1741
+ }
1742
+
1743
+ /**
1744
+ * A conversational message whose content is represented by structured parts.
1745
+ */
1746
+ export interface ContentPartsMessage {
1747
+ role: string;
1748
+ content: ContentPart[];
1749
+ tool_call_id?: string;
1750
+ tool_calls?: ToolCall[];
1751
+ }
1752
+
1709
1753
  /**
1710
1754
  * A standard conversational message exchanged with a Large Language Model (LLM).
1711
1755
  */
@@ -1777,10 +1821,25 @@ declare namespace tracer {
1777
1821
 
1778
1822
  export type Message =
1779
1823
  | TextMessage
1824
+ | ContentPartsMessage
1780
1825
  | AssistantTextMessage
1781
1826
  | AssistantToolCallMessage
1782
1827
  | ToolMessage;
1783
1828
 
1829
+ /**
1830
+ * A sensitive data replacement the AI Guard service determined for the evaluated conversation.
1831
+ */
1832
+ export interface RedactionReplacement {
1833
+ /**
1834
+ * Location of the replaced value within the evaluated conversation (e.g. `messages[0].content`).
1835
+ */
1836
+ path: string;
1837
+ /**
1838
+ * The value that replaces the sensitive data found at `path`.
1839
+ */
1840
+ replacement: string;
1841
+ }
1842
+
1784
1843
  /**
1785
1844
  * The result returned by AI Guard after evaluating a conversation.
1786
1845
  */
@@ -1808,6 +1867,16 @@ declare namespace tracer {
1808
1867
  * Sensitive Data Scanner findings from the evaluation.
1809
1868
  */
1810
1869
  sds: Object[];
1870
+ /**
1871
+ * The evaluated conversation, redacted when required by the AI Guard service.
1872
+ * This may contain sensitive data when redaction is disabled or no replacement was applied.
1873
+ */
1874
+ messages: Message[];
1875
+ /**
1876
+ * The replacements the AI Guard service determined for the evaluated conversation, reported whether or not
1877
+ * the tracer applied them. Empty when the service determined no replacement.
1878
+ */
1879
+ redactionReplacements: RedactionReplacement[];
1811
1880
  }
1812
1881
 
1813
1882
  /**
@@ -2189,7 +2258,7 @@ declare namespace tracer {
2189
2258
  * This plugin automatically instruments the
2190
2259
  * [Vercel AI SDK](https://ai-sdk.dev/docs/introduction) module.
2191
2260
  */
2192
- interface ai extends Instrumentation {}
2261
+ interface ai extends Instrumentation, LLMObsIntegration {}
2193
2262
 
2194
2263
  /**
2195
2264
  * This plugin automatically instruments the
@@ -2207,13 +2276,13 @@ declare namespace tracer {
2207
2276
  * This plugin automatically instruments the
2208
2277
  * [anthropic](https://www.npmjs.com/package/@anthropic-ai/sdk) module.
2209
2278
  */
2210
- interface anthropic extends Instrumentation {}
2279
+ interface anthropic extends Instrumentation, LLMObsIntegration {}
2211
2280
 
2212
2281
  /**
2213
2282
  * This plugin automatically instruments the
2214
2283
  * [@anthropic-ai/claude-agent-sdk](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) module.
2215
2284
  */
2216
- interface claude_agent_sdk extends Instrumentation {}
2285
+ interface claude_agent_sdk extends Instrumentation, LLMObsIntegration {}
2217
2286
 
2218
2287
  /**
2219
2288
  * Currently this plugin automatically instruments
@@ -2274,7 +2343,7 @@ declare namespace tracer {
2274
2343
  * This plugin automatically instruments the
2275
2344
  * [aws-sdk](https://github.com/aws/aws-sdk-js) module.
2276
2345
  */
2277
- interface aws_sdk extends Instrumentation {
2346
+ interface aws_sdk extends Instrumentation, LLMObsIntegration {
2278
2347
  /**
2279
2348
  * The service name to be used for this plugin. When a function is used it is called with the AWS
2280
2349
  * request parameters (e.g. `{ TableName }` for DynamoDB, `{ Bucket }` for S3) and its return value
@@ -2503,13 +2572,13 @@ declare namespace tracer {
2503
2572
  * This plugin automatically instruments the
2504
2573
  * [@google-cloud/vertexai](https://github.com/googleapis/nodejs-vertexai) module.
2505
2574
  */
2506
- interface google_cloud_vertexai extends Integration {}
2575
+ interface google_cloud_vertexai extends Integration, LLMObsIntegration {}
2507
2576
 
2508
2577
  /**
2509
2578
  * This plugin automatically instruments the
2510
2579
  * [@google-genai](https://github.com/googleapis/js-genai) module.
2511
2580
  */
2512
- interface google_genai extends Integration {}
2581
+ interface google_genai extends Integration, LLMObsIntegration {}
2513
2582
 
2514
2583
  /** @hidden */
2515
2584
  interface ExecutionArgs {
@@ -2831,7 +2900,7 @@ declare namespace tracer {
2831
2900
  * This plugin automatically instruments the
2832
2901
  * [langgraph](https://github.com/npmjs/package/langgraph) library.
2833
2902
  */
2834
- interface langgraph extends Instrumentation {}
2903
+ interface langgraph extends Instrumentation, LLMObsIntegration {}
2835
2904
 
2836
2905
  /**
2837
2906
  * This plugin automatically instruments the
@@ -2991,13 +3060,13 @@ declare namespace tracer {
2991
3060
  * [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent#setup)
2992
3061
  * in the agent.
2993
3062
  */
2994
- interface openai extends Instrumentation {}
3063
+ interface openai extends Instrumentation, LLMObsIntegration {}
2995
3064
 
2996
3065
  /**
2997
3066
  * This plugin automatically instruments the
2998
3067
  * [@openai/agents](https://www.npmjs.com/package/@openai/agents) library.
2999
3068
  */
3000
- interface openai_agents extends Instrumentation {}
3069
+ interface openai_agents extends Instrumentation, LLMObsIntegration {}
3001
3070
 
3002
3071
  /**
3003
3072
  * This plugin automatically instruments the
@@ -3610,7 +3679,7 @@ declare namespace tracer {
3610
3679
  *
3611
3680
  * @deprecated Enabling LLM Observability via `llmobs.enable()` is deprecated and will be removed in dd-trace@7.0.0. Please instantiate LLM Observability via DD_LLMOBS_ENABLED or `tracer.init({ llmobs: ...options })`.
3612
3681
  */
3613
- enable (options: LLMObsEnableOptions): void,
3682
+ enable (options: LLMObsRuntimeEnableOptions): void,
3614
3683
 
3615
3684
  /**
3616
3685
  * Disable LLM Observability tracing.
@@ -3798,21 +3867,35 @@ declare namespace tracer {
3798
3867
  metadata?: Array<Record<string, any>>
3799
3868
  ) => any | Promise<any>
3800
3869
 
3870
+ interface DatasetRecord {
3871
+ id: string | null
3872
+ input: JSONType
3873
+ expectedOutput: JSONType
3874
+ metadata: Record<string, JSONType>
3875
+ tags: string[]
3876
+ }
3877
+
3878
+ interface DatasetRecordNew {
3879
+ id?: string
3880
+ inputData: JSONType
3881
+ expectedOutput?: JSONType
3882
+ metadata?: Record<string, JSONType>
3883
+ tags?: string[]
3884
+ }
3885
+
3801
3886
  interface CreateDatasetOptions {
3887
+ /** Override the configured project for this dataset. */
3888
+ projectName?: string
3802
3889
  description?: string
3803
- records?: Array<{
3804
- id?: string,
3805
- inputData: JSONType,
3806
- expectedOutput?: JSONType,
3807
- metadata?: Record<string, JSONType>,
3808
- tags?: string[]
3809
- }>
3890
+ records?: DatasetRecordNew[]
3810
3891
  }
3811
3892
 
3812
3893
  interface ExperimentOptions {
3813
3894
  name: string
3814
3895
  dataset: Dataset
3815
3896
  task: ExperimentTask
3897
+ /** Override the configured project for this experiment. */
3898
+ projectName?: string
3816
3899
  /** Evaluators keyed by metric label, or named functions. */
3817
3900
  evaluators?: Record<string, ExperimentEvaluator> | ExperimentEvaluator[]
3818
3901
  /** Summary evaluators keyed by metric label, or named functions. */
@@ -3820,6 +3903,8 @@ declare namespace tracer {
3820
3903
  description?: string
3821
3904
  config?: Record<string, JSONType>
3822
3905
  tags?: Record<string, string>
3906
+ /** Number of full experiment runs to execute. Default 1. */
3907
+ runs?: number
3823
3908
  }
3824
3909
 
3825
3910
  interface ExperimentRunOptions {
@@ -3829,9 +3914,13 @@ declare namespace tracer {
3829
3914
  retryDelay?: (attempt: number) => number
3830
3915
  /** Reject on the first task/evaluator error instead of capturing it. Default false. */
3831
3916
  throwOnErrors?: boolean
3917
+ /** Maximum number of task/evaluator executions to process concurrently. Default 10. */
3918
+ concurrency?: number
3832
3919
  }
3833
3920
 
3834
3921
  interface PullDatasetOptions {
3922
+ /** Override the configured project for this dataset pull. */
3923
+ projectName?: string
3835
3924
  /** Dataset version to pull. Defaults to latest. */
3836
3925
  version?: number
3837
3926
  /** Wait until at least this many records are readable (absorbs write lag). */
@@ -3860,17 +3949,21 @@ declare namespace tracer {
3860
3949
 
3861
3950
  interface ExperimentRun {
3862
3951
  runId: string
3952
+ /** 1-based run iteration. */
3863
3953
  runIteration: number
3954
+ /** Whether this run had a task, row-evaluator, or summary-evaluator error. */
3955
+ hasError: boolean
3864
3956
  rows: ExperimentResultRow[]
3865
3957
  summaryEvaluations: Record<string, { value: any, error: string | null }>
3866
3958
  }
3867
3959
 
3868
3960
  interface ExperimentResult {
3869
3961
  experimentId: string
3962
+ /** Rows from the first run, kept as a compatibility alias. */
3870
3963
  rows: ExperimentResultRow[]
3871
- /** Single-run summary evaluator results. */
3964
+ /** Summary evaluator results from the first run, kept as a compatibility alias. */
3872
3965
  summaryEvaluations: Record<string, { value: any, error: string | null }>
3873
- /** Experiment runs. P0 Node experiments currently return one run. */
3966
+ /** All experiment runs. */
3874
3967
  runs: ExperimentRun[]
3875
3968
  /** Dashboard URL for the experiment. */
3876
3969
  url: string
@@ -3963,6 +4056,8 @@ declare namespace tracer {
3963
4056
  metadata?: Record<string, JSONType>,
3964
4057
  tags?: string[]
3965
4058
  ): Dataset
4059
+ /** Add multiple records to the dataset. */
4060
+ addRecords (records: DatasetRecordNew[]): Dataset
3966
4061
  /** Update fields on an existing dataset record. */
3967
4062
  update (index: number, fields: {
3968
4063
  input?: JSONType
@@ -3983,15 +4078,11 @@ declare namespace tracer {
3983
4078
  description (): string
3984
4079
  id (): string | null
3985
4080
  projectId (): string | null
4081
+ /** Project associated with the client used to create or pull this dataset. */
4082
+ projectName (): string | null | undefined
3986
4083
  version (): number | null
3987
4084
  latestVersion (): number | null
3988
- records (): Array<{
3989
- id: string | null,
3990
- input: JSONType,
3991
- expectedOutput: JSONType,
3992
- metadata: Record<string, JSONType>,
3993
- tags: string[]
3994
- }>
4085
+ records (): DatasetRecord[]
3995
4086
  /** Return the tags used to filter this dataset. */
3996
4087
  filterTags (): string[]
3997
4088
  /** Dashboard URL for the dataset, or null until pushed. */
@@ -4507,6 +4598,13 @@ declare namespace tracer {
4507
4598
  * Options for enabling LLM Observability tracing.
4508
4599
  */
4509
4600
  interface LLMObsEnableOptions {
4601
+ /**
4602
+ * The name of the LLM Observability project used for experiments.
4603
+ * @env DD_LLMOBS_PROJECT_NAME
4604
+ * Programmatic configuration takes precedence over the environment variables listed above.
4605
+ */
4606
+ projectName?: string,
4607
+
4510
4608
  /**
4511
4609
  * The name of your ML application.
4512
4610
  * @env DD_LLMOBS_ML_APP
@@ -4531,6 +4629,9 @@ declare namespace tracer {
4531
4629
  sampleRate?: number,
4532
4630
  }
4533
4631
 
4632
+ /** Options accepted by the deprecated runtime `llmobs.enable()` method. */
4633
+ type LLMObsRuntimeEnableOptions = Omit<LLMObsEnableOptions, 'projectName'>
4634
+
4534
4635
  /** @hidden */
4535
4636
  type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
4536
4637
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "6.12.0",
3
+ "version": "6.13.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -115,7 +115,7 @@
115
115
  "test:integration:plugins:coverage": "yarn services && node ./integration-tests/coverage/run-suite.js \"packages/datadog-plugin-@(${PLUGINS})/test/integration-test/**/${SPEC:-*}*.spec.js\"",
116
116
  "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\"",
117
117
  "test:release": "mocha \"scripts/release/**/*.spec.js\"",
118
- "test:scripts": "mocha \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
118
+ "test:scripts": "mocha \"benchmark/e2e-test-optimization/*.spec.js\" \"benchmark/sirun/*.spec.js\" \"scripts/helpers/**/*.spec.js\" \"scripts/*.spec.mjs\"",
119
119
  "test:shimmer": "mocha \"packages/datadog-shimmer/test/**/*.spec.js\"",
120
120
  "test:shimmer:ci": "node scripts/c8-ci.js test:shimmer",
121
121
  "verify:workflow-job-names": "node scripts/verify-workflow-job-names.js",
@@ -184,11 +184,11 @@
184
184
  },
185
185
  "optionalDependencies": {
186
186
  "@datadog/libdatadog": "0.12.1",
187
- "@datadog/native-appsec": "11.0.1",
188
- "@datadog/native-iast-taint-tracking": "4.2.0",
189
- "@datadog/native-metrics": "3.1.2",
187
+ "@datadog/native-appsec": "11.0.2",
188
+ "@datadog/native-iast-taint-tracking": "4.2.1",
189
+ "@datadog/native-metrics": "4.0.0",
190
190
  "@datadog/pprof": "5.18.1",
191
- "@datadog/wasm-js-rewriter": "5.0.3",
191
+ "@datadog/wasm-js-rewriter": "5.0.4",
192
192
  "@opentelemetry/api": ">=1.0.0 <1.10.0",
193
193
  "@opentelemetry/api-logs": "<1.0.0",
194
194
  "oxc-parser": "^0.132.0"
@@ -200,7 +200,7 @@
200
200
  "@eslint/eslintrc": "^3.3.6",
201
201
  "@eslint/js": "^10.0.1",
202
202
  "@eslint/plugin-kit": "^0.7.2",
203
- "@datadog/openfeature-node-server": "2.1.0",
203
+ "@datadog/openfeature-node-server": "2.2.0",
204
204
  "@msgpack/msgpack": "^3.1.3",
205
205
  "@openfeature/core": "^1.12.0",
206
206
  "@openfeature/server-sdk": "~1.23.0",
@@ -208,18 +208,18 @@
208
208
  "@types/mocha": "^10.0.10",
209
209
  "@types/node": "^18.19.106",
210
210
  "@types/sinon": "^22.0.0",
211
- "@vercel/nft": "^1.10.2",
211
+ "@vercel/nft": "^1.11.0",
212
212
  "@yarnpkg/lockfile": "^1.1.0",
213
213
  "axios": "^1.19.0",
214
214
  "benchmark": "^2.1.4",
215
215
  "body-parser": "^2.3.0",
216
- "bun": "1.3.14",
216
+ "bun": "1.4.0",
217
217
  "c8": "^12.0.0",
218
218
  "codeowners-audit": "^2.9.0",
219
219
  "eslint": "^10.8.1",
220
220
  "eslint-plugin-cypress": "^7.0.0",
221
221
  "eslint-plugin-import-x": "^4.16.2",
222
- "eslint-plugin-jsdoc": "^64.2.0",
222
+ "eslint-plugin-jsdoc": "^64.2.1",
223
223
  "eslint-plugin-mocha": "^11.3.0",
224
224
  "eslint-plugin-n": "^18.3.0",
225
225
  "eslint-plugin-promise": "^7.3.0",
@@ -1,9 +1,11 @@
1
1
  'use strict'
2
2
 
3
3
  const wrapLogger = require('./helpers/bunyan')
4
- const { addHook } = require('./helpers/instrument')
4
+ const { addHook, channel } = require('./helpers/instrument')
5
+
6
+ const logSubmissionCh = channel('ci:log-submission:log')
5
7
 
6
8
  addHook({ name: 'bunyan', versions: ['>=1'] }, Logger => {
7
- wrapLogger(Logger, 'bunyan')
9
+ wrapLogger(Logger, 'bunyan', logSubmissionCh)
8
10
  return Logger
9
11
  })
@@ -6,17 +6,26 @@ const { channel } = require('./instrument')
6
6
  /**
7
7
  * @param {{ prototype: object }} Logger
8
8
  * @param {string} id
9
+ * @param {import('node:diagnostics_channel').Channel} [logSubmissionCh]
9
10
  */
10
- module.exports = function wrapLogger (Logger, id) {
11
+ module.exports = function wrapLogger (Logger, id, logSubmissionCh) {
11
12
  const logCh = channel(`apm:${id}:log`)
13
+ // The record must be replaceable before Bunyan emits it, while the serialized line is only available afterward.
14
+ // This before-and-after contract requires the existing runtime wrapper rather than an Orchestrion subscriber.
12
15
  shimmer.wrap(Logger.prototype, '_emit', emit => {
13
16
  return function wrappedEmit (rec) {
14
17
  if (logCh.hasSubscribers) {
15
18
  const payload = { message: rec }
16
19
  logCh.publish(payload)
17
- arguments[0] = payload.message
20
+ rec = arguments[0] = payload.message
18
21
  }
19
- return emit.apply(this, arguments)
22
+
23
+ // Reuse Bunyan's cycle-safe serialization instead of serializing the record again.
24
+ const line = emit.apply(this, arguments)
25
+ if (logSubmissionCh?.hasSubscribers && logCh.hasSubscribers && !arguments[1]) {
26
+ logSubmissionCh.publish({ source: id, message: line ?? rec })
27
+ }
28
+ return line
20
29
  }
21
30
  })
22
31
  }
@@ -621,6 +621,7 @@ module.exports = {
621
621
  clearPoolWaitTime,
622
622
  dispatchesAcquireSynchronously,
623
623
  isPoolQueryAcquire,
624
+ reportPoolAcquireError,
624
625
  runOutsidePoolQueryAcquire,
625
626
  runPoolAcquireError,
626
627
  runWithPoolWait,
@@ -54,6 +54,34 @@ module.exports = [
54
54
  channelName: 'LocalRunner_shutdown',
55
55
  transform: 'waitForAsyncEnd',
56
56
  },
57
+ {
58
+ module: {
59
+ name: '@wdio/runner',
60
+ versionRange: '>=9.0.0',
61
+ filePath: 'build/index.js',
62
+ },
63
+ functionQuery: {
64
+ className: 'BaseReporter',
65
+ methodName: 'waitForSync',
66
+ kind: 'Async',
67
+ },
68
+ channelName: 'BaseReporter_waitForSync',
69
+ },
70
+ {
71
+ module: {
72
+ name: '@wdio/runner',
73
+ versionRange: '>=9.0.0',
74
+ filePath: 'build/index.js',
75
+ },
76
+ astQuery: 'VariableDeclarator[id.name="BaseReporter"] > ClassExpression > ClassBody > ' +
77
+ 'MethodDefinition[key.name="waitForSync"] ReturnStatement > ' +
78
+ 'CallExpression[callee.object.name="promise"][callee.property.name="then"], ' +
79
+ 'ClassDeclaration[id.name="BaseReporter"] > ClassBody > ' +
80
+ 'MethodDefinition[key.name="waitForSync"] ReturnStatement > ' +
81
+ 'CallExpression[callee.object.name="promise"][callee.property.name="then"]',
82
+ channelName: 'BaseReporter_waitForSync',
83
+ transform: 'waitForAsyncEnd',
84
+ },
57
85
  {
58
86
  module: {
59
87
  name: '@wdio/jasmine-framework',
@@ -33,6 +33,7 @@
33
33
  "@wdio/cli/build/index.js": "@wdio/cli",
34
34
  "@wdio/jasmine-framework/build/index.js": "@wdio/jasmine-framework",
35
35
  "@wdio/local-runner/build/index.js": "@wdio/local-runner",
36
+ "@wdio/runner/build/index.js": "@wdio/runner",
36
37
  "@wdio/utils/build/index.js": "@wdio/utils",
37
38
  "ai/dist/index.js": "ai",
38
39
  "ai/dist/index.mjs": "ai",