dd-trace 5.67.0 → 5.69.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 (132) hide show
  1. package/LICENSE-3rdparty.csv +6 -4
  2. package/README.md +0 -2
  3. package/ci/init.js +52 -54
  4. package/ext/exporters.d.ts +2 -1
  5. package/ext/exporters.js +2 -1
  6. package/index.d.ts +240 -3
  7. package/initialize.mjs +1 -1
  8. package/package.json +17 -11
  9. package/packages/datadog-core/src/storage.js +14 -13
  10. package/packages/datadog-esbuild/index.js +118 -26
  11. package/packages/datadog-instrumentations/src/aws-sdk.js +42 -4
  12. package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
  13. package/packages/datadog-instrumentations/src/azure-service-bus.js +1 -1
  14. package/packages/datadog-instrumentations/src/cassandra-driver.js +2 -2
  15. package/packages/datadog-instrumentations/src/connect.js +6 -2
  16. package/packages/datadog-instrumentations/src/cucumber.js +31 -6
  17. package/packages/datadog-instrumentations/src/express.js +5 -6
  18. package/packages/datadog-instrumentations/src/fastify.js +3 -3
  19. package/packages/datadog-instrumentations/src/helpers/hook.js +28 -15
  20. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
  21. package/packages/datadog-instrumentations/src/helpers/instrument.js +15 -5
  22. package/packages/datadog-instrumentations/src/helpers/register.js +10 -3
  23. package/packages/datadog-instrumentations/src/http2/client.js +1 -0
  24. package/packages/datadog-instrumentations/src/http2/server.js +0 -1
  25. package/packages/datadog-instrumentations/src/ioredis.js +12 -1
  26. package/packages/datadog-instrumentations/src/jest.js +48 -36
  27. package/packages/datadog-instrumentations/src/limitd-client.js +2 -1
  28. package/packages/datadog-instrumentations/src/mocha/main.js +15 -7
  29. package/packages/datadog-instrumentations/src/mocha/utils.js +3 -0
  30. package/packages/datadog-instrumentations/src/mongoose.js +2 -1
  31. package/packages/datadog-instrumentations/src/oracledb.js +19 -13
  32. package/packages/datadog-instrumentations/src/pg.js +9 -5
  33. package/packages/datadog-instrumentations/src/pino.js +18 -6
  34. package/packages/datadog-instrumentations/src/playwright.js +15 -1
  35. package/packages/datadog-instrumentations/src/sequelize.js +1 -1
  36. package/packages/datadog-instrumentations/src/vitest.js +155 -62
  37. package/packages/datadog-plugin-ai/src/tracing.js +3 -3
  38. package/packages/datadog-plugin-aws-sdk/src/base.js +23 -8
  39. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
  40. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +101 -2
  41. package/packages/datadog-plugin-aws-sdk/src/util.js +1 -1
  42. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +6 -0
  43. package/packages/datadog-plugin-cucumber/src/index.js +4 -56
  44. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +6 -3
  45. package/packages/datadog-plugin-cypress/src/support.js +4 -0
  46. package/packages/datadog-plugin-express/src/code_origin.js +2 -2
  47. package/packages/datadog-plugin-fastify/src/code_origin.js +1 -2
  48. package/packages/datadog-plugin-jest/src/index.js +0 -21
  49. package/packages/datadog-plugin-mocha/src/index.js +3 -57
  50. package/packages/datadog-plugin-mongodb-core/src/index.js +38 -12
  51. package/packages/datadog-plugin-playwright/src/index.js +11 -5
  52. package/packages/datadog-plugin-vitest/src/index.js +5 -1
  53. package/packages/datadog-plugin-ws/src/close.js +1 -1
  54. package/packages/datadog-plugin-ws/src/producer.js +6 -1
  55. package/packages/datadog-plugin-ws/src/receiver.js +6 -1
  56. package/packages/dd-trace/src/aiguard/client.js +25 -0
  57. package/packages/dd-trace/src/aiguard/noop.js +9 -0
  58. package/packages/dd-trace/src/aiguard/sdk.js +173 -0
  59. package/packages/dd-trace/src/aiguard/tags.js +11 -0
  60. package/packages/dd-trace/src/appsec/iast/path-line.js +21 -4
  61. package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +1 -1
  62. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +6 -3
  63. package/packages/dd-trace/src/appsec/stack_trace.js +20 -1
  64. package/packages/dd-trace/src/appsec/telemetry/waf.js +2 -2
  65. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -4
  66. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +11 -3
  67. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +10 -1
  68. package/packages/dd-trace/src/config-helper.js +8 -1
  69. package/packages/dd-trace/src/config.js +92 -304
  70. package/packages/dd-trace/src/config_defaults.js +191 -0
  71. package/packages/dd-trace/src/crashtracking/crashtracker.js +2 -1
  72. package/packages/dd-trace/src/datastreams/fnv.js +2 -2
  73. package/packages/dd-trace/src/datastreams/index.js +23 -1
  74. package/packages/dd-trace/src/datastreams/writer.js +3 -2
  75. package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -1
  76. package/packages/dd-trace/src/dogstatsd.js +4 -3
  77. package/packages/dd-trace/src/encode/0.4.js +1 -5
  78. package/packages/dd-trace/src/exporter.js +1 -0
  79. package/packages/dd-trace/src/exporters/agent/index.js +3 -2
  80. package/packages/dd-trace/src/exporters/agent/writer.js +1 -1
  81. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +3 -2
  82. package/packages/dd-trace/src/exporters/common/request.js +2 -1
  83. package/packages/dd-trace/src/exporters/span-stats/index.js +3 -2
  84. package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
  85. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +15 -4
  86. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +20 -7
  87. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +40 -13
  88. package/packages/dd-trace/src/llmobs/plugins/openai.js +7 -1
  89. package/packages/dd-trace/src/llmobs/tagger.js +8 -0
  90. package/packages/dd-trace/src/llmobs/telemetry.js +2 -1
  91. package/packages/dd-trace/src/log/index.js +27 -16
  92. package/packages/dd-trace/src/log/log.js +29 -5
  93. package/packages/dd-trace/src/log/writer.js +5 -5
  94. package/packages/dd-trace/src/noop/proxy.js +4 -0
  95. package/packages/dd-trace/src/noop/span.js +1 -0
  96. package/packages/dd-trace/src/opentelemetry/span.js +14 -3
  97. package/packages/dd-trace/src/opentracing/span.js +19 -5
  98. package/packages/dd-trace/src/payload-tagging/config/index.js +16 -0
  99. package/packages/dd-trace/src/payload-tagging/index.js +26 -15
  100. package/packages/dd-trace/src/payload-tagging/tagging.js +17 -8
  101. package/packages/dd-trace/src/pkg.js +3 -1
  102. package/packages/dd-trace/src/plugin_manager.js +20 -2
  103. package/packages/dd-trace/src/plugins/ci_plugin.js +97 -3
  104. package/packages/dd-trace/src/plugins/composite.js +3 -0
  105. package/packages/dd-trace/src/plugins/index.js +2 -0
  106. package/packages/dd-trace/src/plugins/plugin.js +67 -0
  107. package/packages/dd-trace/src/plugins/util/git-cache.js +129 -0
  108. package/packages/dd-trace/src/plugins/util/git.js +41 -27
  109. package/packages/dd-trace/src/plugins/util/test.js +56 -27
  110. package/packages/dd-trace/src/plugins/util/web.js +1 -1
  111. package/packages/dd-trace/src/priority_sampler.js +70 -46
  112. package/packages/dd-trace/src/profiler.js +4 -1
  113. package/packages/dd-trace/src/profiling/config.js +73 -42
  114. package/packages/dd-trace/src/profiling/profiler.js +3 -1
  115. package/packages/dd-trace/src/profiling/profilers/events.js +3 -8
  116. package/packages/dd-trace/src/profiling/profilers/space.js +1 -0
  117. package/packages/dd-trace/src/profiling/profilers/wall.js +196 -117
  118. package/packages/dd-trace/src/proxy.js +15 -0
  119. package/packages/dd-trace/src/rate_limiter.js +26 -1
  120. package/packages/dd-trace/src/remote_config/capabilities.js +5 -0
  121. package/packages/dd-trace/src/remote_config/manager.js +3 -2
  122. package/packages/dd-trace/src/sampling_rule.js +124 -2
  123. package/packages/dd-trace/src/span_sampler.js +19 -0
  124. package/packages/dd-trace/src/standalone/product.js +9 -0
  125. package/packages/dd-trace/src/standalone/tracesource.js +16 -1
  126. package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +13 -0
  127. package/packages/dd-trace/src/startup-log.js +21 -2
  128. package/packages/dd-trace/src/supported-configurations.json +9 -0
  129. package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
  130. package/packages/dd-trace/src/util.js +1 -1
  131. package/register.js +1 -1
  132. package/version.js +4 -2
@@ -4,18 +4,53 @@ const { globMatch } = require('../src/util')
4
4
  const RateLimiter = require('./rate_limiter')
5
5
  const Sampler = require('./sampler')
6
6
 
7
+ /**
8
+ * Typedefs for clarity when matching spans.
9
+ *
10
+ * @typedef {import('./opentracing/span')} DatadogSpan
11
+ * @typedef {import('./opentracing/span_context')} DatadogSpanContext
12
+ *
13
+ * @callback Locator
14
+ * A function that derives a string subject from a span.
15
+ * @param {DatadogSpan} span
16
+ * @returns {string|undefined}
17
+ *
18
+ * @typedef {object} RuleMatcher
19
+ * @property {(span: DatadogSpan) => boolean} match - Returns true if the span matches.
20
+ */
21
+
22
+ /**
23
+ * Matcher that always returns true.
24
+ * Implements the minimal `RuleMatcher` interface.
25
+ * @implements {RuleMatcher}
26
+ */
7
27
  class AlwaysMatcher {
8
- match () {
28
+ /**
29
+ * @param {DatadogSpan} span
30
+ * @returns {boolean}
31
+ */
32
+ match (span) {
9
33
  return true
10
34
  }
11
35
  }
12
36
 
37
+ /**
38
+ * Matcher that evaluates a glob pattern against a derived subject.
39
+ */
13
40
  class GlobMatcher {
41
+ /**
42
+ * @param {string} pattern - Glob pattern used to match the subject.
43
+ * @param {Locator} locator - Function extracting the subject to match.
44
+ */
14
45
  constructor (pattern, locator) {
15
46
  this.pattern = pattern
16
47
  this.locator = locator
17
48
  }
18
49
 
50
+ /**
51
+ * @param {DatadogSpan} span
52
+ * @returns {boolean}
53
+ */
19
54
  match (span) {
20
55
  const subject = this.locator(span)
21
56
  if (!subject) return false
@@ -23,12 +58,23 @@ class GlobMatcher {
23
58
  }
24
59
  }
25
60
 
61
+ /**
62
+ * Matcher that evaluates a regular expression against a derived subject.
63
+ */
26
64
  class RegExpMatcher {
65
+ /**
66
+ * @param {RegExp} pattern - Regular expression used to test the subject.
67
+ * @param {Locator} locator - Function extracting the subject to test.
68
+ */
27
69
  constructor (pattern, locator) {
28
70
  this.pattern = pattern
29
71
  this.locator = locator
30
72
  }
31
73
 
74
+ /**
75
+ * @param {DatadogSpan} span
76
+ * @returns {boolean}
77
+ */
32
78
  match (span) {
33
79
  const subject = this.locator(span)
34
80
  if (!subject) return false
@@ -36,6 +82,15 @@ class RegExpMatcher {
36
82
  }
37
83
  }
38
84
 
85
+ /**
86
+ * Creates a matcher for the provided pattern and locator.
87
+ * Returns a glob matcher for non-trivial strings, a regexp matcher for RegExp,
88
+ * or an always-true matcher for wildcard or missing patterns.
89
+ *
90
+ * @param {string|RegExp|undefined} pattern
91
+ * @param {Locator} locator
92
+ * @returns {RuleMatcher}
93
+ */
39
94
  function matcher (pattern, locator) {
40
95
  if (pattern instanceof RegExp) {
41
96
  return new RegExpMatcher(pattern, locator)
@@ -47,14 +102,32 @@ function matcher (pattern, locator) {
47
102
  return new AlwaysMatcher()
48
103
  }
49
104
 
105
+ /**
106
+ * Creates a locator that reads a specific tag from the span context.
107
+ *
108
+ * @param {string} tag
109
+ * @returns {Locator}
110
+ */
50
111
  function makeTagLocator (tag) {
51
112
  return (span) => span.context()._tags[tag]
52
113
  }
53
114
 
115
+ /**
116
+ * Extracts the operation name from the span context.
117
+ *
118
+ * @param {DatadogSpan} span
119
+ * @returns {string|undefined}
120
+ */
54
121
  function nameLocator (span) {
55
122
  return span.context()._name
56
123
  }
57
124
 
125
+ /**
126
+ * Extracts the service name from the span context or tracer configuration.
127
+ *
128
+ * @param {DatadogSpan} span
129
+ * @returns {string|undefined}
130
+ */
58
131
  function serviceLocator (span) {
59
132
  const { _tags: tags } = span.context()
60
133
  return tags.service ||
@@ -62,13 +135,39 @@ function serviceLocator (span) {
62
135
  span.tracer()._service
63
136
  }
64
137
 
138
+ /**
139
+ * Extracts the resource name from the span context.
140
+ *
141
+ * @param {DatadogSpan} span
142
+ * @returns {string|undefined}
143
+ */
65
144
  function resourceLocator (span) {
66
145
  const { _tags: tags } = span.context()
67
146
  return tags.resource ||
68
147
  tags['resource.name']
69
148
  }
70
149
 
150
+ /**
151
+ * Configuration options for a sampling rule.
152
+ *
153
+ * @typedef {object} SamplingRuleConfig
154
+ * @property {string|RegExp} [name] - Match on span operation name.
155
+ * @property {string|RegExp} [service] - Match on service name.
156
+ * @property {string|RegExp} [resource] - Match on resource name.
157
+ * @property {Record<string, string|RegExp>} [tags] - Match on specific tag values by key.
158
+ * @property {number} [sampleRate=1] - Deterministic sampling rate in [0, 1].
159
+ * @property {string} [provenance] - Optional provenance/metadata for this rule.
160
+ * @property {number} [maxPerSecond] - Maximum samples per second (rate limit).
161
+ */
162
+
163
+ /**
164
+ * SamplingRule encapsulates matching criteria and sampling/limiting behavior
165
+ * to decide whether a span should be sampled.
166
+ */
71
167
  class SamplingRule {
168
+ /**
169
+ * @param {SamplingRuleConfig} [config]
170
+ */
72
171
  constructor ({ name, service, resource, tags, sampleRate = 1, provenance, maxPerSecond } = {}) {
73
172
  this.matchers = []
74
173
 
@@ -94,22 +193,45 @@ class SamplingRule {
94
193
  }
95
194
  }
96
195
 
196
+ /**
197
+ * Constructs a SamplingRule from the given configuration.
198
+ * @param {SamplingRuleConfig} config
199
+ * @returns {SamplingRule}
200
+ */
97
201
  static from (config) {
98
202
  return new SamplingRule(config)
99
203
  }
100
204
 
205
+ /**
206
+ * Deterministic sampling rate in [0, 1].
207
+ * @returns {number}
208
+ */
101
209
  get sampleRate () {
102
210
  return this._sampler.rate()
103
211
  }
104
212
 
213
+ /**
214
+ * Effective rate applied by the rate limiter, if configured.
215
+ * @returns {number|undefined}
216
+ */
105
217
  get effectiveRate () {
106
218
  return this._limiter && this._limiter.effectiveRate()
107
219
  }
108
220
 
221
+ /**
222
+ * Maximum samples per second if a limiter is present.
223
+ * @returns {number|undefined}
224
+ */
109
225
  get maxPerSecond () {
110
226
  return this._limiter && this._limiter._rateLimit
111
227
  }
112
228
 
229
+ /**
230
+ * Checks whether the provided span matches all configured criteria.
231
+ *
232
+ * @param {DatadogSpan} span
233
+ * @returns {boolean}
234
+ */
113
235
  match (span) {
114
236
  for (const matcher of this.matchers) {
115
237
  // Rule is a special object with a .match() property.
@@ -126,7 +248,7 @@ class SamplingRule {
126
248
  /**
127
249
  * Determines whether a span should be sampled based on the configured sampling rule.
128
250
  *
129
- * @param {Span|SpanContext} span - The span or span context to evaluate.
251
+ * @param {DatadogSpan|DatadogSpanContext} span - The span or span context to evaluate.
130
252
  * @returns {boolean} `true` if the span should be sampled, otherwise `false`.
131
253
  */
132
254
  sample (span) {
@@ -3,11 +3,23 @@
3
3
  const { USER_KEEP, AUTO_KEEP } = require('../../../ext').priority
4
4
  const SamplingRule = require('./sampling_rule')
5
5
 
6
+ /**
7
+ * Samples individual spans within a trace using span-level rules.
8
+ */
6
9
  class SpanSampler {
10
+ /**
11
+ * @param {{ spanSamplingRules?: Array<import('./sampling_rule')>|Array<Record<string, unknown>> }} [config]
12
+ */
7
13
  constructor ({ spanSamplingRules = [] } = {}) {
8
14
  this._rules = spanSamplingRules.map(SamplingRule.from)
9
15
  }
10
16
 
17
+ /**
18
+ * Finds the first matching span sampling rule for the given span.
19
+ *
20
+ * @param {import('./opentracing/span')} context
21
+ * @returns {import('./sampling_rule')|undefined}
22
+ */
11
23
  findRule (context) {
12
24
  for (const rule of this._rules) {
13
25
  // Rule is a special object with a .match() property.
@@ -19,6 +31,13 @@ class SpanSampler {
19
31
  }
20
32
  }
21
33
 
34
+ /**
35
+ * Applies span sampling to spans in the trace, tagging matching spans with
36
+ * span sampling metadata when appropriate.
37
+ *
38
+ * @param {import('./opentracing/span_context')} spanContext
39
+ * @returns {void}
40
+ */
22
41
  sample (spanContext) {
23
42
  const decision = spanContext._sampling.priority
24
43
  if (decision === USER_KEEP || decision === AUTO_KEEP) return
@@ -3,6 +3,12 @@
3
3
  const { SAMPLING_MECHANISM_APPSEC } = require('../constants')
4
4
  const RateLimiter = require('../rate_limiter')
5
5
 
6
+ /**
7
+ * Returns a rate limiter tuned for the provided product configuration.
8
+ *
9
+ * @param {{ appsec?: { enabled?: boolean }, iast?: { enabled?: boolean } } | undefined} config
10
+ * @returns {import('../rate_limiter')}
11
+ */
6
12
  function getProductRateLimiter (config) {
7
13
  if (config?.appsec?.enabled || config?.iast?.enabled) {
8
14
  return new RateLimiter(1, 'minute') // onePerMinute
@@ -11,6 +17,9 @@ function getProductRateLimiter (config) {
11
17
  return new RateLimiter(0) // dropAll
12
18
  }
13
19
 
20
+ /**
21
+ * Available products and their identifiers/mechanisms.
22
+ */
14
23
  const PRODUCTS = {
15
24
  APM: { id: 1 << 0 },
16
25
  ASM: { id: 1 << 1, mechanism: SAMPLING_MECHANISM_APPSEC },
@@ -2,15 +2,30 @@
2
2
 
3
3
  const { TRACE_SOURCE_PROPAGATION_KEY } = require('../constants')
4
4
 
5
+ /**
6
+ * Adds or updates the trace source propagation tag with the given product bit.
7
+ *
8
+ * @param {Record<string, unknown>|undefined} tags
9
+ * @param {{ id: number }|undefined} product
10
+ * @returns {Record<string, unknown>|undefined}
11
+ */
5
12
  function addTraceSourceTag (tags, product) {
6
13
  if (tags && product) {
7
- const actual = tags[TRACE_SOURCE_PROPAGATION_KEY] ? Number.parseInt(tags[TRACE_SOURCE_PROPAGATION_KEY], 16) : 0
14
+ const actual = tags[TRACE_SOURCE_PROPAGATION_KEY]
15
+ ? Number.parseInt(String(tags[TRACE_SOURCE_PROPAGATION_KEY]), 16)
16
+ : 0
8
17
  tags[TRACE_SOURCE_PROPAGATION_KEY] = ((actual | product.id) >>> 0).toString(16).padStart(2, '0')
9
18
  }
10
19
 
11
20
  return tags
12
21
  }
13
22
 
23
+ /**
24
+ * Returns true when the trace source propagation tag exists on the given tags object.
25
+ *
26
+ * @param {Record<string, unknown>} tags
27
+ * @returns {boolean}
28
+ */
14
29
  function hasTraceSourcePropagationTag (tags) {
15
30
  return Object.hasOwn(tags, TRACE_SOURCE_PROPAGATION_KEY)
16
31
  }
@@ -8,12 +8,19 @@ const { addTraceSourceTag, hasTraceSourcePropagationTag } = require('./tracesour
8
8
  const { getProductRateLimiter } = require('./product')
9
9
 
10
10
  class TraceSourcePrioritySampler extends PrioritySampler {
11
+ /**
12
+ * @override
13
+ */
11
14
  configure (env, sampler, config) {
12
15
  // rules not supported
13
16
  this._env = env
14
17
  this._limiter = getProductRateLimiter(config)
15
18
  }
16
19
 
20
+ /**
21
+ * @override
22
+ * @returns {import('../priority_sampler').SamplingPriority|undefined}
23
+ */
17
24
  _getPriorityFromTags (tags, context) {
18
25
  if (Object.hasOwn(tags, MANUAL_KEEP) &&
19
26
  tags[MANUAL_KEEP] !== false &&
@@ -23,6 +30,9 @@ class TraceSourcePrioritySampler extends PrioritySampler {
23
30
  }
24
31
  }
25
32
 
33
+ /**
34
+ * @override
35
+ */
26
36
  _getPriorityFromAuto (span) {
27
37
  const context = this._getContext(span)
28
38
 
@@ -35,6 +45,9 @@ class TraceSourcePrioritySampler extends PrioritySampler {
35
45
  return this._isSampledByRateLimit(context) ? AUTO_KEEP : AUTO_REJECT
36
46
  }
37
47
 
48
+ /**
49
+ * @override
50
+ */
38
51
  setPriority (span, samplingPriority, product) {
39
52
  super.setPriority(span, samplingPriority, product)
40
53
 
@@ -4,6 +4,7 @@ const { info, warn } = require('./log/writer')
4
4
 
5
5
  const os = require('os')
6
6
  const { inspect } = require('util')
7
+ const defaults = require('./config_defaults')
7
8
  const tracerVersion = require('../../../package.json').version
8
9
 
9
10
  const errors = {}
@@ -12,12 +13,18 @@ let pluginManager
12
13
  let samplingRules = []
13
14
  let alreadyRan = false
14
15
 
16
+ /**
17
+ * @returns {Record<string, unknown>}
18
+ */
15
19
  function getIntegrationsAndAnalytics () {
16
20
  return {
17
21
  integrations_loaded: Object.keys(pluginManager._pluginsByName)
18
22
  }
19
23
  }
20
24
 
25
+ /**
26
+ * @param {{ agentError: { code: string, message: string } }} [options]
27
+ */
21
28
  function startupLog ({ agentError } = {}) {
22
29
  if (!config || !pluginManager) {
23
30
  return
@@ -33,7 +40,7 @@ function startupLog ({ agentError } = {}) {
33
40
  return
34
41
  }
35
42
 
36
- const out = tracerInfo({ agentError })
43
+ const out = tracerInfo()
37
44
 
38
45
  if (agentError) {
39
46
  out.agent_error = agentError.message
@@ -49,8 +56,11 @@ function startupLog ({ agentError } = {}) {
49
56
  }
50
57
  }
51
58
 
59
+ /**
60
+ * @returns {Record<string, unknown>}
61
+ */
52
62
  function tracerInfo () {
53
- const url = config.url || `http://${config.hostname || 'localhost'}:${config.port}`
63
+ const url = config.url || `http://${config.hostname || defaults.hostname}:${config.port}`
54
64
 
55
65
  const out = {
56
66
  [inspect.custom] () {
@@ -93,14 +103,23 @@ function tracerInfo () {
93
103
  return out
94
104
  }
95
105
 
106
+ /**
107
+ * @param {import('./config')} aConfig
108
+ */
96
109
  function setStartupLogConfig (aConfig) {
97
110
  config = aConfig
98
111
  }
99
112
 
113
+ /**
114
+ * @param {import('./plugin_manager')} thePluginManager
115
+ */
100
116
  function setStartupLogPluginManager (thePluginManager) {
101
117
  pluginManager = thePluginManager
102
118
  }
103
119
 
120
+ /**
121
+ * @param {import('./sampling_rule')} theRules
122
+ */
104
123
  function setSamplingRules (theRules) {
105
124
  samplingRules = theRules
106
125
  }
@@ -5,6 +5,11 @@
5
5
  "DD_AGENT_HOST": ["A"],
6
6
  "DD_AGENTLESS_LOG_SUBMISSION_ENABLED": ["A"],
7
7
  "DD_AGENTLESS_LOG_SUBMISSION_URL": ["A"],
8
+ "DD_AI_GUARD_ENABLED": ["A"],
9
+ "DD_AI_GUARD_ENDPOINT": ["A"],
10
+ "DD_AI_GUARD_MAX_CONTENT_SIZE": ["A"],
11
+ "DD_AI_GUARD_MAX_MESSAGES_LENGTH": ["A"],
12
+ "DD_AI_GUARD_TIMEOUT": ["A"],
8
13
  "DD_API_KEY": ["A"],
9
14
  "DD_API_SECURITY_ENABLED": ["A"],
10
15
  "DD_API_SECURITY_SAMPLE_DELAY": ["A"],
@@ -12,6 +17,7 @@
12
17
  "DD_API_SECURITY_ENDPOINT_COLLECTION_MESSAGE_LIMIT": ["A"],
13
18
  "DD_APM_FLUSH_DEADLINE_MILLISECONDS": ["A"],
14
19
  "DD_APM_TRACING_ENABLED": ["A"],
20
+ "DD_APP_KEY": ["A"],
15
21
  "DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE": ["A"],
16
22
  "DD_APPSEC_COLLECT_ALL_HEADERS": ["A"],
17
23
  "DD_APPSEC_ENABLED": ["A"],
@@ -63,6 +69,8 @@
63
69
  "DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS": ["A"],
64
70
  "DD_ENV": ["A"],
65
71
  "DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED": ["A"],
72
+ "DD_EXPERIMENTAL_TEST_OPT_GIT_CACHE_ENABLED": ["A"],
73
+ "DD_EXPERIMENTAL_TEST_OPT_GIT_CACHE_DIR": ["A"],
66
74
  "DD_EXTERNAL_ENV": ["A"],
67
75
  "DD_GIT_BRANCH": ["A"],
68
76
  "DD_GIT_COMMIT_AUTHOR_DATE": ["A"],
@@ -117,6 +125,7 @@
117
125
  "DD_OPENAI_SPAN_CHAR_LIMIT": ["A"],
118
126
  "DD_PIPELINE_EXECUTION_ID": ["A"],
119
127
  "DD_PLAYWRIGHT_WORKER": ["A"],
128
+ "DD_PROFILING_ASYNC_CONTEXT_FRAME_ENABLED": ["A"],
120
129
  "DD_PROFILING_CODEHOTSPOTS_ENABLED": ["A"],
121
130
  "DD_PROFILING_CPU_ENABLED": ["A"],
122
131
  "DD_PROFILING_DEBUG_SOURCE_MAPS": ["A"],
@@ -35,8 +35,8 @@ function onLog (log) {
35
35
  }
36
36
 
37
37
  function onErrorLog (msg) {
38
- const { message, cause } = msg
39
- if (!message && !cause) return
38
+ const { message, cause, sendViaTelemetry } = msg
39
+ if (!sendViaTelemetry || (!message && !cause)) return
40
40
 
41
41
  const telLog = {
42
42
  level: 'ERROR',
@@ -88,7 +88,7 @@ module.exports = {
88
88
  isFalse,
89
89
  isError,
90
90
  globMatch,
91
- ddBasePath: calculateDDBasePath(__dirname),
91
+ ddBasePath: globalThis.__DD_ESBUILD_BASEPATH || calculateDDBasePath(__dirname),
92
92
  normalizeProfilingEnabledValue,
93
93
  normalizePluginEnvName
94
94
  }
package/register.js CHANGED
@@ -6,5 +6,5 @@ const { register } = require('node:module')
6
6
  const { pathToFileURL } = require('node:url')
7
7
 
8
8
  register('./loader-hook.mjs', pathToFileURL(__filename), {
9
- data: { exclude: [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/] }
9
+ data: { exclude: [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/, /openai\/agents-core\/dist\/shims/] }
10
10
  })
package/version.js CHANGED
@@ -1,8 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  var version = require('./package.json').version
4
- var ddMatches = version.match(/^(\d+)\.(\d+)\.(\d+)/)
5
- var nodeMatches = process.versions.node.match(/^(\d+)\.(\d+)\.(\d+)/)
4
+ // @ts-expect-error
5
+ var /** @type {RegExpMatchArray} */ ddMatches = version.match(/^(\d+)\.(\d+)\.(\d+)/)
6
+ // @ts-expect-error
7
+ var /** @type {RegExpMatchArray} */ nodeMatches = process.versions.node.match(/^(\d+)\.(\d+)\.(\d+)/)
6
8
 
7
9
  module.exports = {
8
10
  VERSION: version,