dd-trace 6.26.0 → 6.27.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 (69) hide show
  1. package/index.d.ts +58 -1
  2. package/initialize.mjs +5 -3
  3. package/package.json +9 -8
  4. package/packages/datadog-instrumentations/src/ai.js +88 -127
  5. package/packages/datadog-instrumentations/src/aws-lambda.js +9 -0
  6. package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
  7. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -3
  8. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +4 -1
  9. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +2 -0
  10. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +5 -3
  11. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +26 -2
  12. package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +3 -1
  13. package/packages/datadog-instrumentations/src/path-to-regexp.js +11 -11
  14. package/packages/datadog-instrumentations/src/router.js +17 -1
  15. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1 -1
  16. package/packages/datadog-plugin-aws-lambda/src/context/events.js +167 -0
  17. package/packages/datadog-plugin-aws-lambda/src/context/extractor.js +153 -0
  18. package/packages/datadog-plugin-aws-lambda/src/context/http.js +50 -0
  19. package/packages/datadog-plugin-aws-lambda/src/context/span-context.js +26 -0
  20. package/packages/datadog-plugin-aws-lambda/src/context/step-functions.js +142 -0
  21. package/packages/datadog-plugin-aws-lambda/src/context/types.d.ts +17 -0
  22. package/packages/datadog-plugin-aws-lambda/src/context/xray.js +67 -0
  23. package/packages/datadog-plugin-aws-lambda/src/index.js +52 -4
  24. package/packages/datadog-plugin-azure-functions/src/index.js +68 -12
  25. package/packages/datadog-plugin-fetch/src/index.js +7 -0
  26. package/packages/datadog-plugin-http/src/client.js +12 -0
  27. package/packages/datadog-plugin-http/src/server.js +18 -4
  28. package/packages/dd-trace/src/aiguard/client.js +7 -9
  29. package/packages/dd-trace/src/aiguard/evaluation.js +7 -2
  30. package/packages/dd-trace/src/aiguard/messages/utils.js +2 -2
  31. package/packages/dd-trace/src/aiguard/sdk.js +7 -2
  32. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +273 -167
  33. package/packages/dd-trace/src/appsec/channels.js +1 -0
  34. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +21 -14
  35. package/packages/dd-trace/src/appsec/index.js +3 -0
  36. package/packages/dd-trace/src/appsec/rasp/index.js +57 -3
  37. package/packages/dd-trace/src/appsec/rasp/utils.js +14 -0
  38. package/packages/dd-trace/src/carrier.js +7 -1
  39. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +4 -2
  40. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +31 -19
  41. package/packages/dd-trace/src/config/generated-config-types.d.ts +10 -3
  42. package/packages/dd-trace/src/config/index.js +28 -2
  43. package/packages/dd-trace/src/config/parsers.js +25 -0
  44. package/packages/dd-trace/src/config/supported-configurations.json +27 -7
  45. package/packages/dd-trace/src/datastreams/http.js +57 -0
  46. package/packages/dd-trace/src/datastreams/index.js +24 -0
  47. package/packages/dd-trace/src/datastreams/pathway.js +33 -4
  48. package/packages/dd-trace/src/datastreams/processor.js +22 -3
  49. package/packages/dd-trace/src/lambda/handler-paths.js +1 -1
  50. package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
  51. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +33 -1
  52. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +102 -1
  53. package/packages/dd-trace/src/llmobs/span_processor.js +3 -0
  54. package/packages/dd-trace/src/llmobs/tagger.js +9 -0
  55. package/packages/dd-trace/src/noop/span.js +0 -4
  56. package/packages/dd-trace/src/openfeature/flagging_provider.js +17 -0
  57. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +2 -1
  58. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +2 -1
  59. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +16 -1
  60. package/packages/dd-trace/src/opentelemetry/trace/index.js +5 -4
  61. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +10 -6
  62. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +42 -26
  63. package/packages/dd-trace/src/opentracing/propagation/text_map.js +4 -4
  64. package/packages/dd-trace/src/plugin_manager.js +2 -0
  65. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +3 -5
  66. package/packages/dd-trace/src/plugins/util/url.js +1 -1
  67. package/packages/dd-trace/src/register-loader.js +43 -0
  68. package/register.js +10 -44
  69. package/register.mjs +27 -0
@@ -139,12 +139,12 @@ class TaintTrackingPlugin extends SourceIastPlugin {
139
139
  addDatabaseSubscriptions () {
140
140
  this.addSub(
141
141
  { channelName: 'datadog:sequelize:query:finish', tag: SQL_ROW_VALUE },
142
- ({ result }) => this._taintDatabaseResult(result, 'sequelize', getIastContext(storage('legacy').getStore()))
142
+ ({ result }) => this.#taintDatabaseResult(result, 'sequelize', getIastContext(storage('legacy').getStore()))
143
143
  )
144
144
 
145
145
  this.addSub(
146
146
  { channelName: 'apm:pg:query:finish', tag: SQL_ROW_VALUE },
147
- ({ result, currentStore }) => this._taintDatabaseResult(result, 'pg', getIastContext(currentStore))
147
+ ({ result, currentStore }) => this.#taintDatabaseResult(result, 'pg', getIastContext(currentStore))
148
148
  )
149
149
  }
150
150
 
@@ -263,25 +263,32 @@ class TaintTrackingPlugin extends SourceIastPlugin {
263
263
  this.taintUrl(req, iastContext)
264
264
  }
265
265
 
266
- _taintDatabaseResult (result, dbOrigin, iastContext, name) {
266
+ #taintDatabaseResult (result, dbOrigin, iastContext, name, visited) {
267
267
  if (!iastContext || this._rowsToTaint === 0) return result
268
268
 
269
+ if (typeof result === 'string') {
270
+ return newTaintedString(iastContext, result, name, SQL_ROW_VALUE)
271
+ }
272
+
273
+ // Binary views, such as pg bytea columns, only hold numbers.
274
+ if (result === null || typeof result !== 'object' || ArrayBuffer.isView(result)) return result
275
+
276
+ visited ??= new WeakSet()
277
+ if (visited.has(result)) return result
278
+ visited.add(result)
279
+
269
280
  if (Array.isArray(result)) {
270
281
  for (let i = 0; i < result.length && i < this._rowsToTaint; i++) {
271
282
  const nextName = name ? `${name}.${i}` : String(i)
272
- result[i] = this._taintDatabaseResult(result[i], dbOrigin, iastContext, nextName)
283
+ result[i] = this.#taintDatabaseResult(result[i], dbOrigin, iastContext, nextName, visited)
273
284
  }
274
- } else if (result && typeof result === 'object') {
275
- if (dbOrigin === 'sequelize' && result.dataValues) {
276
- result.dataValues = this._taintDatabaseResult(result.dataValues, dbOrigin, iastContext, name)
277
- } else {
278
- for (const key in result) {
279
- const nextName = name ? `${name}.${key}` : key
280
- result[key] = this._taintDatabaseResult(result[key], dbOrigin, iastContext, nextName)
281
- }
285
+ } else if (dbOrigin === 'sequelize' && result.dataValues) {
286
+ result.dataValues = this.#taintDatabaseResult(result.dataValues, dbOrigin, iastContext, name, visited)
287
+ } else {
288
+ for (const key of Object.keys(result)) {
289
+ const nextName = name ? `${name}.${key}` : key
290
+ result[key] = this.#taintDatabaseResult(result[key], dbOrigin, iastContext, nextName, visited)
282
291
  }
283
- } else if (typeof result === 'string') {
284
- result = newTaintedString(iastContext, result, name, SQL_ROW_VALUE)
285
292
  }
286
293
 
287
294
  return result
@@ -30,6 +30,7 @@ const {
30
30
  responseSetHeader,
31
31
  informationalResponse,
32
32
  routerParam,
33
+ routerRouteCreate,
33
34
  fastifyResponseChannel,
34
35
  fastifyPathParams,
35
36
  stripeCheckoutSessionCreate,
@@ -44,6 +45,7 @@ const UserTracking = require('./user_tracking')
44
45
  const graphql = require('./graphql')
45
46
  const lambda = require('./lambda')
46
47
  const rasp = require('./rasp')
48
+ const { onRouteCreate } = require('./api_security/normalized-route')
47
49
  const httpRequest = require('./handlers/http-request')
48
50
  const httpResponse = require('./handlers/http-response')
49
51
  const auth = require('./handlers/auth')
@@ -74,6 +76,7 @@ const channelHandlers = [
74
76
  [fastifyCookieParser, httpRequest.onRequestCookieParser],
75
77
  [fastifyPathParams, httpRequest.onRequestProcessParams],
76
78
  [routerParam, httpRequest.onRequestProcessParams],
79
+ [routerRouteCreate, onRouteCreate],
77
80
  [responseBody, httpResponse.onResponseBody],
78
81
  [fastifyResponseChannel, httpResponse.onResponseBody],
79
82
  [responseWriteHead, httpResponse.onResponseWriteHead],
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ const { types } = require('node:util')
4
+
3
5
  const web = require('../../plugins/util/web')
4
6
  const {
5
7
  setUncaughtExceptionCaptureCallbackStart,
@@ -15,7 +17,13 @@ const sqli = require('./sql_injection')
15
17
  const lfi = require('./lfi')
16
18
  const cmdi = require('./command_injection')
17
19
 
18
- const { DatadogRaspAbortError, markToBlockOnDetection } = require('./utils')
20
+ const { DatadogRaspAbortError, hasBlockingAbort, markToBlockOnDetection } = require('./utils')
21
+
22
+ // Same bound as the `cause` chain; libraries keep the abort error one or two errors deep.
23
+ const MAX_WRAPPING_ERRORS = 10
24
+
25
+ // Error.isError is available from Node.js 24, and util.types.isNativeError is deprecated from 24.2.0 (DEP0197).
26
+ const isError = Error.isError ?? types.isNativeError
19
27
 
20
28
  function removeAllListeners (emitter, event) {
21
29
  const listeners = emitter.listeners(event)
@@ -44,6 +52,52 @@ function findDatadogRaspAbortError (err, deep = 10) {
44
52
  }
45
53
  }
46
54
 
55
+ /**
56
+ * Finds the abort error of the request in the errors held by the own data properties of an error, for libraries that
57
+ * throw their own error and keep the original one outside of `cause` (sequelize's `parent`, typeorm's `driverError`).
58
+ * Only native errors are walked, and getters are not called.
59
+ *
60
+ * @param {unknown} error
61
+ * @param {import('http').IncomingMessage} req
62
+ * @returns {DatadogRaspAbortError | undefined}
63
+ */
64
+ function findWrappedDatadogRaspAbortError (error, req) {
65
+ if (!isError(error)) return
66
+
67
+ const errors = [error]
68
+ for (let i = 0; i < errors.length; i++) {
69
+ for (const key of Reflect.ownKeys(errors[i])) {
70
+ // Before Node.js 22, reading the descriptor of `stack` formats the stack trace and calls Error.prepareStackTrace.
71
+ if (key === 'stack') continue
72
+
73
+ const value = Reflect.getOwnPropertyDescriptor(errors[i], key)?.value
74
+ if (!isError(value)) continue
75
+
76
+ if (value instanceof DatadogRaspAbortError) {
77
+ if (value.req === req) return value
78
+ } else if (errors.length < MAX_WRAPPING_ERRORS) {
79
+ errors.push(value)
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Finds the abort error of the request in the error of a failed operation
87
+ *
88
+ * @param {unknown} error
89
+ * @param {import('http').IncomingMessage} [failedRequest]
90
+ * @returns {DatadogRaspAbortError | undefined}
91
+ */
92
+ function resolveAbortError (error, failedRequest) {
93
+ const directError = findDatadogRaspAbortError(error)
94
+ if (directError) return directError
95
+
96
+ if (!hasBlockingAbort(failedRequest)) return
97
+
98
+ return findWrappedDatadogRaspAbortError(error, failedRequest)
99
+ }
100
+
47
101
  function handleUncaughtExceptionMonitor (error) {
48
102
  if (!blockOnDatadogRaspAbortError({ error, isTopLevel: true })) return
49
103
 
@@ -85,8 +139,8 @@ function handleUncaughtExceptionMonitor (error) {
85
139
  }
86
140
  }
87
141
 
88
- function blockOnDatadogRaspAbortError ({ error, isTopLevel }) {
89
- const abortError = findDatadogRaspAbortError(error)
142
+ function blockOnDatadogRaspAbortError ({ error, req: failedRequest, isTopLevel }) {
143
+ const abortError = resolveAbortError(error, failedRequest)
90
144
  if (!abortError) return false
91
145
 
92
146
  const { req, res, blockingAction, raspRule, ruleTriggered } = abortError
@@ -27,6 +27,18 @@ const ALLOWED_ROOTSPAN_NAMES = new Set([
27
27
  /** @type {WeakMap<import('http').IncomingMessage, ((error: Error) => void) | undefined>} */
28
28
  const requestsToBlockOnDetection = new WeakMap()
29
29
 
30
+ /** @type {WeakSet<import('http').IncomingMessage>} */
31
+ const requestsWithBlockingAbort = new WeakSet()
32
+
33
+ /**
34
+ * Tells whether RASP aborted an operation of the request to block it.
35
+ *
36
+ * @param {import('http').IncomingMessage} req
37
+ */
38
+ function hasBlockingAbort (req) {
39
+ return requestsWithBlockingAbort.has(req)
40
+ }
41
+
30
42
  /**
31
43
  * @param {import('http').IncomingMessage} req
32
44
  * @param {(error: Error) => void} [ignoreError] Keeps the abort error of a blocked request out of the framework's
@@ -100,6 +112,7 @@ function handleResult (result, req, res, abortController, config, raspRule) {
100
112
  }
101
113
  }
102
114
 
115
+ requestsWithBlockingAbort.add(req)
103
116
  abortController.abort(abortError)
104
117
 
105
118
  return
@@ -113,6 +126,7 @@ function handleResult (result, req, res, abortController, config, raspRule) {
113
126
 
114
127
  module.exports = {
115
128
  handleResult,
129
+ hasBlockingAbort,
116
130
  markToBlockOnDetection,
117
131
  RULE_TYPES,
118
132
  DatadogRaspAbortError,
@@ -8,6 +8,7 @@ const FIELD_WRITE = 2
8
8
  const FIELD_HAS = 4
9
9
  const FIELD_DELETE = 8
10
10
  const FIELD_NAME_LENGTH = 16
11
+ const FIELD_NAME = 32
11
12
 
12
13
  const b3FlagsHeader = 'x-b3-flags'
13
14
  const b3Header = 'b3'
@@ -36,6 +37,7 @@ const carrierOperations = {}
36
37
  * @property {unknown} [has]
37
38
  * @property {unknown} [delete]
38
39
  * @property {unknown} [nameLength]
40
+ * @property {unknown} [name]
39
41
  */
40
42
 
41
43
  /**
@@ -47,6 +49,7 @@ const carrierOperations = {}
47
49
  * @property {(carrier: Carrier) => void} delete
48
50
  * @property {(carrier: Carrier, target: Carrier) => void} copy
49
51
  * @property {number} nameLength
52
+ * @property {string} name
50
53
  */
51
54
 
52
55
  /**
@@ -63,6 +66,7 @@ function defineCapability (name, operations, capability) {
63
66
  if (operations & FIELD_HAS) carrierOperations[`has${suffix}`] = capability.has
64
67
  if (operations & FIELD_DELETE) carrierOperations[`delete${suffix}`] = capability.delete
65
68
  if (operations & FIELD_NAME_LENGTH) carrierOperations[`${name}NameLength`] = capability.nameLength
69
+ if (operations & FIELD_NAME) carrierOperations[`${name}Name`] = capability.name
66
70
  return capability
67
71
  }
68
72
 
@@ -109,6 +113,7 @@ function defineField (fieldName, headerName, read, operations) {
109
113
  },
110
114
 
111
115
  nameLength: headerName.length,
116
+ name: headerName,
112
117
  })
113
118
  }
114
119
 
@@ -277,7 +282,7 @@ const dsmBase64 = defineField(
277
282
  'dsmBase64',
278
283
  dsmBase64Header,
279
284
  readDsmBase64,
280
- FIELD_READ | FIELD_WRITE | FIELD_HAS | FIELD_NAME_LENGTH
285
+ FIELD_READ | FIELD_WRITE | FIELD_HAS | FIELD_NAME_LENGTH | FIELD_NAME
281
286
  )
282
287
  const dsmBinary = defineField('dsmBinary', dsmBinaryHeader, readDsmBinary, FIELD_READ | FIELD_HAS)
283
288
 
@@ -363,6 +368,7 @@ function pickDsm (carrier) {
363
368
  /**
364
369
  * @typedef {object} CarrierOperations
365
370
  * @property {typeof datadogParentId.delete} deleteDatadogParentId
371
+ * @property {typeof dsmBase64.name} dsmBase64Name
366
372
  * @property {typeof dsmBase64.nameLength} dsmBase64NameLength
367
373
  * @property {typeof dsmBase64.has} hasDsmBase64
368
374
  * @property {typeof dsmBinary.has} hasDsmBinary
@@ -203,7 +203,8 @@ class TestVisDynamicInstrumentation {
203
203
  // Allow the parent to exit even if the worker is still running
204
204
  this.worker.unref?.()
205
205
 
206
- this.breakpointSetChannel.port2.on('message', (probeId) => {
206
+ this.breakpointSetChannel.port2.on('message', ({ probeId, error }) => {
207
+ if (error) log.error('Test Optimization - Dynamic Instrumentation failed to set probe', error)
207
208
  const probeState = this.#probeStateById.get(probeId)
208
209
  if (probeState?.resolveSet) {
209
210
  probeState.resolveSet()
@@ -230,7 +231,8 @@ class TestVisDynamicInstrumentation {
230
231
  }
231
232
  }).unref?.()
232
233
 
233
- this.breakpointRemoveChannel.port2.on('message', (probeId) => {
234
+ this.breakpointRemoveChannel.port2.on('message', ({ probeId, error }) => {
235
+ if (error) log.error('Test Optimization - Dynamic Instrumentation failed to remove probe', error)
234
236
  const probeState = this.#probeStateById.get(probeId)
235
237
  if (probeState?.resolveRemove) {
236
238
  probeState.resolveRemove()
@@ -155,16 +155,32 @@ breakpointHitChannel.on('message', ({ drainRequestId }) => {
155
155
  scheduleBreakpointHitDrain()
156
156
  })
157
157
 
158
- breakpointRemoveChannel.on('message', async (probeId) => {
159
- await removeBreakpoint(probeId)
160
- breakpointRemoveChannel.postMessage(probeId)
158
+ breakpointRemoveChannel.on('message', (probeId) => {
159
+ acknowledge(breakpointRemoveChannel, probeId, removeBreakpoint(probeId))
161
160
  })
162
161
 
163
- breakpointSetChannel.on('message', async (probe) => {
164
- await addBreakpoint(probe)
165
- breakpointSetChannel.postMessage(probe.id)
162
+ breakpointSetChannel.on('message', (probe) => {
163
+ acknowledge(breakpointSetChannel, probe.id, addBreakpoint(probe))
166
164
  })
167
165
 
166
+ /**
167
+ * Acknowledges a probe operation once it settles, along with its error if it failed. Rejecting instead would end the
168
+ * worker, and only the main thread's logs reach telemetry.
169
+ *
170
+ * @param {import('node:worker_threads').MessagePort} channel - The channel that requested the operation
171
+ * @param {string} probeId - The ID of the probe the operation was for
172
+ * @param {Promise<void>} operation - The pending operation
173
+ */
174
+ async function acknowledge (channel, probeId, operation) {
175
+ let error
176
+ try {
177
+ await operation
178
+ } catch (err) {
179
+ error = err
180
+ }
181
+ channel.postMessage({ probeId, error })
182
+ }
183
+
168
184
  async function removeBreakpoint (probeId) {
169
185
  if (!sessionStarted) {
170
186
  // We should not get in this state, but abort if we do, so the code doesn't fail unexpected
@@ -212,20 +228,16 @@ async function addBreakpoint (probe) {
212
228
  }
213
229
  }
214
230
 
215
- try {
216
- const { breakpointId } = await session.post('Debugger.setBreakpoint', {
217
- location: {
218
- scriptId,
219
- lineNumber: lineNumber - 1,
220
- columnNumber,
221
- },
222
- })
231
+ const { breakpointId } = await session.post('Debugger.setBreakpoint', {
232
+ location: {
233
+ scriptId,
234
+ lineNumber: lineNumber - 1,
235
+ columnNumber,
236
+ },
237
+ })
223
238
 
224
- breakpointIdToProbe.set(breakpointId, probe)
225
- probeIdToBreakpointId.set(probe.id, breakpointId)
226
- } catch (e) {
227
- log.error('Error setting breakpoint at %s:%s', url, line, e)
228
- }
239
+ breakpointIdToProbe.set(breakpointId, probe)
240
+ probeIdToBreakpointId.set(probe.id, breakpointId)
229
241
  }
230
242
 
231
243
  async function start () {
@@ -82,6 +82,7 @@ export interface GeneratedConfig {
82
82
  DD_CRASHTRACKING_ENABLED: boolean;
83
83
  DD_CUSTOM_PARENT_ID: string | undefined;
84
84
  DD_CUSTOM_TRACE_ID: string | undefined;
85
+ DD_DATA_STREAMS_HTTP_ENABLED: boolean;
85
86
  DD_DURABLE_CROSS_INVOCATION_TRACING_ENABLED: boolean;
86
87
  DD_ENABLE_LAGE_PACKAGE_NAME: boolean;
87
88
  DD_ENABLE_NX_SERVICE_NAME: boolean;
@@ -498,6 +499,9 @@ export interface GeneratedConfig {
498
499
  };
499
500
  logInjection: boolean;
500
501
  logLevel: "debug" | "info" | "warn" | "error";
502
+ mcp: {
503
+ DD_MCP_CAPTURE_INTENT: boolean;
504
+ };
501
505
  middlewareTracingEnabled: boolean;
502
506
  openai: {
503
507
  DD_OPENAI_LOGS_ENABLED: boolean;
@@ -523,12 +527,13 @@ export interface GeneratedConfig {
523
527
  OTEL_EXPORTER_OTLP_TIMEOUT: number;
524
528
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string;
525
529
  OTEL_EXPORTER_OTLP_TRACES_HEADERS: Record<string, string> | undefined;
526
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/json";
530
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "grpc" | "http/json" | "http/protobuf";
527
531
  OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: number;
528
532
  OTEL_LOGS_EXPORTER: "none" | "otlp" | undefined;
529
533
  OTEL_METRIC_EXPORT_INTERVAL: number;
530
534
  OTEL_METRIC_EXPORT_TIMEOUT: number;
531
535
  OTEL_METRICS_EXPORTER: "none" | "otlp" | undefined;
536
+ OTEL_PROPAGATORS: string[] | undefined;
532
537
  OTEL_RESOURCE_ATTRIBUTES: Record<string, string>;
533
538
  OTEL_SDK_DISABLED: boolean | undefined;
534
539
  OTEL_TRACES_EXPORTER: "none" | "otlp" | undefined;
@@ -722,6 +727,7 @@ export interface GeneratedEnvVarConfig {
722
727
  DD_CUSTOM_PARENT_ID: string | undefined;
723
728
  DD_CUSTOM_TRACE_ID: string | undefined;
724
729
  DD_DATA_STREAMS_ENABLED: boolean;
730
+ DD_DATA_STREAMS_HTTP_ENABLED: boolean;
725
731
  DD_DBM_INJECT_SQL_BASEHASH: boolean;
726
732
  DD_DBM_PROPAGATION_MODE: "disabled" | "service" | "full" | "dynamic_service";
727
733
  DD_DECODE_AUTHORIZER_CONTEXT: boolean;
@@ -825,6 +831,7 @@ export interface GeneratedEnvVarConfig {
825
831
  DD_LOG_LEVEL: "debug" | "info" | "warn" | "error";
826
832
  DD_LOGS_INJECTION: boolean;
827
833
  DD_LOGS_OTEL_ENABLED: boolean;
834
+ DD_MCP_CAPTURE_INTENT: boolean;
828
835
  DD_MERGE_XRAY_TRACES: boolean;
829
836
  DD_METRICS_OTEL_ENABLED: boolean;
830
837
  DD_MIN_COLD_START_DURATION: number;
@@ -1217,14 +1224,14 @@ export interface GeneratedEnvVarConfig {
1217
1224
  OTEL_EXPORTER_OTLP_TIMEOUT: number;
1218
1225
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string | undefined;
1219
1226
  OTEL_EXPORTER_OTLP_TRACES_HEADERS: Record<string, string> | undefined;
1220
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/json";
1227
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "grpc" | "http/json" | "http/protobuf";
1221
1228
  OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: number;
1222
1229
  OTEL_LOG_LEVEL: "debug" | "info" | "warn" | "error";
1223
1230
  OTEL_LOGS_EXPORTER: "none" | "otlp" | undefined;
1224
1231
  OTEL_METRIC_EXPORT_INTERVAL: number;
1225
1232
  OTEL_METRIC_EXPORT_TIMEOUT: number;
1226
1233
  OTEL_METRICS_EXPORTER: "none" | "otlp" | undefined;
1227
- OTEL_PROPAGATORS: string[];
1234
+ OTEL_PROPAGATORS: string[] | undefined;
1228
1235
  OTEL_RESOURCE_ATTRIBUTES: Record<string, string>;
1229
1236
  OTEL_SDK_DISABLED: boolean | undefined;
1230
1237
  OTEL_SERVICE_NAME: string | undefined;
@@ -32,6 +32,7 @@ const { createSiteUrl } = require('../exporters/common/url')
32
32
  const { getUnsupportedRuntime } = require('../debugger/unsupported-runtime')
33
33
  const ConfigBase = require('./config-base')
34
34
  const {
35
+ getConfiguredEnvName,
35
36
  getEnvironmentVariable,
36
37
  getEnvironmentVariables,
37
38
  getStableConfigSources,
@@ -713,6 +714,14 @@ class Config extends ConfigBase {
713
714
  setAndTrack(this, 'logInjection', false)
714
715
  }
715
716
 
717
+ // OTEL_PROPAGATORS is not an alias, as its values differ: an empty value is unset and `none` disables
718
+ // propagation on its own. A set DD_TRACE_PROPAGATION_STYLE takes precedence, even when its value is invalid
719
+ // and its own default applies. Runs before the fallbacks so the inject and extract styles inherit it.
720
+ if (trackedConfigOrigins.has('OTEL_PROPAGATORS') &&
721
+ getConfiguredEnvName('DD_TRACE_PROPAGATION_STYLE') === undefined) {
722
+ setAndTrack(this, 'DD_TRACE_PROPAGATION_STYLE', this.OTEL_PROPAGATORS)
723
+ }
724
+
716
725
  // Apply all fallbacks to the calculated config.
717
726
  for (const [configName, alias] of fallbackConfigurations) {
718
727
  if (!trackedConfigOrigins.has(configName) && trackedConfigOrigins.has(alias)) {
@@ -843,6 +852,24 @@ class Config extends ConfigBase {
843
852
 
844
853
  const unsupportedRuntime = getUnsupportedRuntime()
845
854
  if (unsupportedRuntime !== undefined) {
855
+ if (unsupportedRuntime === 'Bun') {
856
+ this.#deactivate(
857
+ 'runtimeMetrics.native',
858
+ 'Native runtime metrics are disabled, because they do not work on Bun.'
859
+ )
860
+ this.#deactivate(
861
+ 'DD_PROFILING_HEAP_ENABLED',
862
+ 'Heap profiling is disabled, because it does not work on Bun.'
863
+ )
864
+ // An unset heap flag inherits the legacy profiler list, which includes space by default.
865
+ if (this.DD_PROFILING_HEAP_ENABLED === undefined && this.DD_PROFILING_PROFILERS.includes('space')) {
866
+ setAndTrack(this, 'DD_PROFILING_HEAP_ENABLED', false)
867
+ }
868
+ this.#deactivate(
869
+ 'iast.DD_IAST_ENABLED',
870
+ 'IAST is disabled, because it does not work on Bun.'
871
+ )
872
+ }
846
873
  this.#deactivate(
847
874
  'dynamicInstrumentation.DD_DYNAMIC_INSTRUMENTATION_ENABLED',
848
875
  `Live Debugger/Dynamic Instrumentation is disabled, because it is not supported on ${unsupportedRuntime}.`
@@ -947,8 +974,7 @@ function warnWrongOtelSettings () {
947
974
  for (const [otelEnvVar, ddEnvVars, key = otelEnvVar] of /** @type {Array<[string, string[], string?]>} */ ([
948
975
  // eslint-disable-next-line eslint-rules/eslint-env-aliases
949
976
  ['OTEL_LOG_LEVEL', ['DD_TRACE_LOG_LEVEL'], 'logLevel'],
950
- // eslint-disable-next-line eslint-rules/eslint-env-aliases
951
- ['OTEL_PROPAGATORS', ['DD_TRACE_PROPAGATION_STYLE'], 'DD_TRACE_PROPAGATION_STYLE'],
977
+ ['OTEL_PROPAGATORS', ['DD_TRACE_PROPAGATION_STYLE']],
952
978
  // eslint-disable-next-line eslint-rules/eslint-env-aliases
953
979
  ['OTEL_SERVICE_NAME', ['DD_SERVICE'], 'service'],
954
980
  ['OTEL_TRACES_SAMPLER', ['DD_TRACE_SAMPLE_RATE']],
@@ -276,6 +276,31 @@ const transformers = {
276
276
  }
277
277
  return value
278
278
  },
279
+ /**
280
+ * Validates like `validatePropagationStyles`, with the OpenTelemetry semantics: an empty list resolves to
281
+ * unset, and `none` disables propagation even when combined with other propagators, as the OpenTelemetry
282
+ * JavaScript SDK does. `DD_TRACE_PROPAGATION_STYLE` keeps its own handling of both.
283
+ *
284
+ * @param {string[]} value
285
+ * @param {string} optionName
286
+ * @param {string} source
287
+ * @param {boolean} [reportInvalid]
288
+ * @returns {string[] | undefined}
289
+ */
290
+ validateOtelPropagators (value, optionName, source, reportInvalid = true) {
291
+ if (value.length === 0) return
292
+ value = transformers.toLowerCase(value)
293
+ if (value.includes('none')) {
294
+ if (reportInvalid && value.some(propagator => propagator !== 'none')) {
295
+ warnInvalidValue(
296
+ value.join(','), optionName, source, "'none' cannot be combined with other propagators",
297
+ undefined, 'disabled propagation'
298
+ )
299
+ }
300
+ return ['none']
301
+ }
302
+ return transformers.validatePropagationStyles(value, optionName, source, reportInvalid)
303
+ },
279
304
  }
280
305
 
281
306
  const telemetryTransformers = {
@@ -131,6 +131,14 @@
131
131
  "default": "false"
132
132
  }
133
133
  ],
134
+ "DD_MCP_CAPTURE_INTENT": [
135
+ {
136
+ "implementation": "A",
137
+ "type": "boolean",
138
+ "default": "false",
139
+ "namespace": "mcp"
140
+ }
141
+ ],
134
142
  "DD_MIN_COLD_START_DURATION": [
135
143
  {
136
144
  "implementation": "B",
@@ -903,6 +911,13 @@
903
911
  ]
904
912
  }
905
913
  ],
914
+ "DD_DATA_STREAMS_HTTP_ENABLED": [
915
+ {
916
+ "implementation": "A",
917
+ "type": "boolean",
918
+ "default": "true"
919
+ }
920
+ ],
906
921
  "DD_DBM_INJECT_SQL_BASEHASH": [
907
922
  {
908
923
  "implementation": "A",
@@ -4095,10 +4110,7 @@
4095
4110
  "implementation": "D",
4096
4111
  "type": "array",
4097
4112
  "default": "datadog,tracecontext,baggage",
4098
- "transform": "validatePropagationStyles",
4099
- "aliases": [
4100
- "OTEL_PROPAGATORS"
4101
- ]
4113
+ "transform": "validatePropagationStyles"
4102
4114
  }
4103
4115
  ],
4104
4116
  "DD_TRACE_PROPAGATION_STYLE_EXTRACT": [
@@ -4602,10 +4614,10 @@
4602
4614
  ],
4603
4615
  "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": [
4604
4616
  {
4605
- "implementation": "B",
4617
+ "implementation": "C",
4606
4618
  "type": "string",
4607
- "default": "http/json",
4608
- "allowed": "http/json",
4619
+ "default": "http/protobuf",
4620
+ "allowed": "grpc|http/json|http/protobuf",
4609
4621
  "transform": "toLowerCase",
4610
4622
  "aliases": [
4611
4623
  "OTEL_EXPORTER_OTLP_PROTOCOL"
@@ -4766,6 +4778,14 @@
4766
4778
  "default": "7500"
4767
4779
  }
4768
4780
  ],
4781
+ "OTEL_PROPAGATORS": [
4782
+ {
4783
+ "implementation": "A",
4784
+ "type": "array",
4785
+ "default": "",
4786
+ "transform": "validateOtelPropagators"
4787
+ }
4788
+ ],
4769
4789
  "OTEL_RESOURCE_ATTRIBUTES": [
4770
4790
  {
4771
4791
  "implementation": "A",
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const { DsmPathwayCodec } = require('./pathway')
4
+
5
+ // Same tag set as dd-trace-java's DataStreamsContext.forHttpClient/forHttpServer. Kept pre-sorted because
6
+ // computePathwayHash sorts edge tags in place.
7
+ const CLIENT_EDGE_TAGS = ['direction:out', 'type:http']
8
+ const SERVER_EDGE_TAGS = ['direction:in', 'type:http']
9
+
10
+ /**
11
+ * Records an outbound HTTP checkpoint and writes its pathway context into `headers`.
12
+ *
13
+ * The returned context belongs on the request's own store: storing it on the caller's store would make sibling
14
+ * requests chain from each other instead of from the caller's checkpoint.
15
+ *
16
+ * @param {import('../tracer')} tracer
17
+ * @param {import('../opentracing/span')} span
18
+ * @param {object | null | undefined} parentContext The caller's data streams context.
19
+ * @param {Record<string, unknown>} headers Outgoing request headers.
20
+ * @returns {object | undefined}
21
+ */
22
+ function setHttpClientCheckpoint (tracer, span, parentContext, headers) {
23
+ const ctx = tracer._dataStreamsProcessor.setCheckpoint(CLIENT_EDGE_TAGS, span, parentContext, 0, 0)
24
+ DsmPathwayCodec.encode(ctx, headers)
25
+ return ctx
26
+ }
27
+
28
+ /**
29
+ * Records an inbound HTTP checkpoint, parented on the pathway context in the request headers if there is one.
30
+ *
31
+ * @param {import('../tracer')} tracer
32
+ * @param {import('../opentracing/span')} span
33
+ * @param {Record<string, unknown>} headers Incoming request headers, with lowercase names.
34
+ * @returns {object | undefined}
35
+ */
36
+ function setHttpServerCheckpoint (tracer, span, headers) {
37
+ const parentContext = DsmPathwayCodec.decode(headers)
38
+ return tracer._dataStreamsProcessor.setCheckpoint(SERVER_EDGE_TAGS, span, parentContext, 0, 0)
39
+ }
40
+
41
+ /**
42
+ * dd-trace-java leaves requests sent by an AWS SDK out of HTTP propagation, and so without an HTTP checkpoint: they are
43
+ * signed, and a messaging call records its own checkpoint. SDK v3 marks every request with `amz-sdk-invocation-id`, and
44
+ * the aws-sdk plugin's span is the parent of v2 and v3 requests.
45
+ *
46
+ * @param {import('../opentracing/span') | null | undefined} parentSpan
47
+ * @param {unknown} invocationId The request's `amz-sdk-invocation-id` header value.
48
+ */
49
+ function isAwsSdkRequest (parentSpan, invocationId) {
50
+ return invocationId !== undefined || parentSpan?._integrationName === 'aws-sdk'
51
+ }
52
+
53
+ module.exports = {
54
+ isAwsSdkRequest,
55
+ setHttpClientCheckpoint,
56
+ setHttpServerCheckpoint,
57
+ }
@@ -116,6 +116,26 @@ const SchemaBuilder = lazyClass(() => require('./schemas/schema_builder').Schema
116
116
  'getSchema',
117
117
  ])
118
118
 
119
+ let http
120
+
121
+ /** @type {typeof import('./http').setHttpClientCheckpoint} */
122
+ function setHttpClientCheckpoint (tracer, span, parentContext, headers) {
123
+ http ??= require('./http')
124
+ return http.setHttpClientCheckpoint(tracer, span, parentContext, headers)
125
+ }
126
+
127
+ /** @type {typeof import('./http').isAwsSdkRequest} */
128
+ function isAwsSdkRequest (parentSpan, invocationId) {
129
+ http ??= require('./http')
130
+ return http.isAwsSdkRequest(parentSpan, invocationId)
131
+ }
132
+
133
+ /** @type {typeof import('./http').setHttpServerCheckpoint} */
134
+ function setHttpServerCheckpoint (tracer, span, headers) {
135
+ http ??= require('./http')
136
+ return http.setHttpServerCheckpoint(tracer, span, headers)
137
+ }
138
+
119
139
  module.exports = {
120
140
  DsmPathwayCodec,
121
141
  DataStreamsCheckpointer,
@@ -129,4 +149,8 @@ module.exports = {
129
149
  getHeadersSize,
130
150
  getMessageSize,
131
151
  getSizeOrZero,
152
+
153
+ isAwsSdkRequest,
154
+ setHttpClientCheckpoint,
155
+ setHttpServerCheckpoint,
132
156
  }