dd-trace 5.57.1 → 5.59.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 (206) hide show
  1. package/LICENSE-3rdparty.csv +3 -1
  2. package/ci/cypress/after-run.js +2 -0
  3. package/ci/cypress/after-spec.js +2 -0
  4. package/ci/cypress/plugin.js +2 -0
  5. package/ci/cypress/polyfills.js +2 -0
  6. package/ci/cypress/support.js +2 -0
  7. package/ci/init.js +2 -0
  8. package/index.d.ts +7 -0
  9. package/init.js +1 -6
  10. package/initialize.mjs +2 -0
  11. package/package.json +40 -9
  12. package/packages/datadog-code-origin/index.js +14 -9
  13. package/packages/datadog-instrumentations/src/apollo.js +7 -10
  14. package/packages/datadog-instrumentations/src/avsc.js +2 -0
  15. package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
  16. package/packages/datadog-instrumentations/src/child_process.js +22 -43
  17. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  18. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  19. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  20. package/packages/datadog-instrumentations/src/graphql.js +9 -0
  21. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  22. package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
  23. package/packages/datadog-instrumentations/src/hono.js +102 -0
  24. package/packages/datadog-instrumentations/src/jest.js +1 -1
  25. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  26. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  27. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  28. package/packages/datadog-instrumentations/src/mysql2.js +6 -6
  29. package/packages/datadog-instrumentations/src/next.js +3 -1
  30. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  31. package/packages/datadog-instrumentations/src/oracledb.js +24 -2
  32. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  33. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  34. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  35. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  36. package/packages/datadog-instrumentations/src/tedious.js +12 -17
  37. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  38. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  39. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  40. package/packages/datadog-plugin-aws-sdk/src/base.js +51 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  42. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  43. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
  44. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  45. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  46. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  47. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  48. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  49. package/packages/datadog-plugin-cypress/src/support.js +21 -25
  50. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  51. package/packages/datadog-plugin-graphql/src/tools/index.js +0 -2
  52. package/packages/datadog-plugin-graphql/src/tools/signature.js +0 -2
  53. package/packages/datadog-plugin-graphql/src/tools/transforms.js +0 -2
  54. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  55. package/packages/datadog-plugin-hono/src/index.js +28 -0
  56. package/packages/datadog-plugin-http/src/client.js +3 -4
  57. package/packages/datadog-plugin-http2/src/client.js +9 -8
  58. package/packages/datadog-plugin-jest/src/index.js +2 -0
  59. package/packages/datadog-plugin-jest/src/util.js +2 -0
  60. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  61. package/packages/datadog-plugin-langchain/src/handlers/chain.js +1 -1
  62. package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +1 -1
  63. package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +1 -1
  64. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  65. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  66. package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
  67. package/packages/datadog-plugin-oracledb/src/index.js +15 -17
  68. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  69. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  70. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  71. package/packages/datadog-plugin-tedious/src/index.js +10 -9
  72. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  73. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +6 -4
  74. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +9 -0
  75. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  76. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  77. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  78. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +5 -2
  79. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  80. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  81. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  82. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -0
  83. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  84. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  85. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  86. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  87. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  88. package/packages/dd-trace/src/appsec/reporter.js +68 -14
  89. package/packages/dd-trace/src/appsec/rule_manager.js +63 -171
  90. package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -5
  91. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  92. package/packages/dd-trace/src/appsec/telemetry/common.js +2 -2
  93. package/packages/dd-trace/src/appsec/telemetry/index.js +8 -0
  94. package/packages/dd-trace/src/appsec/telemetry/waf.js +5 -3
  95. package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
  96. package/packages/dd-trace/src/appsec/waf/index.js +47 -6
  97. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  98. package/packages/dd-trace/src/appsec/waf/waf_manager.js +22 -12
  99. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  100. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  101. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  102. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  103. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  104. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  105. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  106. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  107. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  108. package/packages/dd-trace/src/config.js +15 -4
  109. package/packages/dd-trace/src/config_stable.js +2 -0
  110. package/packages/dd-trace/src/constants.js +1 -2
  111. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  112. package/packages/dd-trace/src/datastreams/context.js +2 -0
  113. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  114. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  115. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  116. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  117. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  118. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  119. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  120. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  121. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  122. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  123. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  124. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  125. package/packages/dd-trace/src/debugger/index.js +36 -9
  126. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  127. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  128. package/packages/dd-trace/src/exporters/common/request.js +1 -1
  129. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  130. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  131. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  132. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  133. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  134. package/packages/dd-trace/src/git_properties.js +2 -0
  135. package/packages/dd-trace/src/guardrails/index.js +3 -4
  136. package/packages/dd-trace/src/guardrails/log.js +2 -2
  137. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  138. package/packages/dd-trace/src/guardrails/util.js +0 -2
  139. package/packages/dd-trace/src/heap_snapshots.js +58 -0
  140. package/packages/dd-trace/src/llmobs/noop.js +1 -1
  141. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  142. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  143. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  144. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  145. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  146. package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
  147. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  148. package/packages/dd-trace/src/log/log.js +1 -1
  149. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  150. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  151. package/packages/dd-trace/src/opentracing/span.js +1 -1
  152. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  153. package/packages/dd-trace/src/payload-tagging/index.js +3 -1
  154. package/packages/dd-trace/src/payload-tagging/tagging.js +4 -2
  155. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  156. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  157. package/packages/dd-trace/src/plugins/index.js +1 -0
  158. package/packages/dd-trace/src/plugins/outbound.js +7 -0
  159. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  160. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  161. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  162. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  163. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  164. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  165. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  166. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  167. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  168. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  169. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  170. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  171. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  172. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  173. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  174. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  175. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  176. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  177. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  178. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  179. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  180. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  181. package/packages/dd-trace/src/profiling/profilers/wall.js +2 -2
  182. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  183. package/packages/dd-trace/src/proxy.js +4 -0
  184. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  185. package/packages/dd-trace/src/remote_config/index.js +4 -0
  186. package/packages/dd-trace/src/service-naming/index.js +2 -0
  187. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -9
  188. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  189. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  190. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  191. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  192. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  193. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  194. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  195. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  196. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  197. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  198. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  199. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -1
  200. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  201. package/packages/dd-trace/src/span_stats.js +2 -0
  202. package/packages/dd-trace/src/supported-configurations.json +5 -0
  203. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  204. package/register.js +4 -0
  205. package/version.js +0 -3
  206. package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +0 -2094
@@ -42,15 +42,20 @@ function findWebSpan (startedSpans, spanId) {
42
42
  }
43
43
 
44
44
  class Profiler extends EventEmitter {
45
+ #compressionFn
46
+ #compressionOptions
47
+ #enabled = false
48
+ #endpointCounts = new Map()
49
+ #lastStart
50
+ #logger
51
+ #profileSeq = 0
52
+ #spanFinishListener
53
+ #timer
54
+
45
55
  constructor () {
46
56
  super()
47
- this._enabled = false
48
- this._logger = undefined
49
57
  this._config = undefined
50
- this._timer = undefined
51
- this._lastStart = undefined
52
58
  this._timeoutInterval = undefined
53
- this.endpointCounts = new Map()
54
59
  }
55
60
 
56
61
  start (options) {
@@ -61,17 +66,21 @@ class Profiler extends EventEmitter {
61
66
  })
62
67
  }
63
68
 
64
- _logError (err) {
65
- logError(this._logger, err)
69
+ get enabled () {
70
+ return this.#enabled
71
+ }
72
+
73
+ #logError (err) {
74
+ logError(this.#logger, err)
66
75
  }
67
76
 
68
77
  async _start (options) {
69
- if (this._enabled) return true
78
+ if (this.enabled) return true
70
79
 
71
80
  const config = this._config = new Config(options)
72
81
 
73
- this._logger = config.logger
74
- this._enabled = true
82
+ this.#logger = config.logger
83
+ this.#enabled = true
75
84
  this._setInterval()
76
85
 
77
86
  // Log errors if the source map finder fails, but don't prevent the rest
@@ -83,7 +92,7 @@ class Profiler extends EventEmitter {
83
92
 
84
93
  mapper = await maybeSourceMap(config.sourceMap, SourceMapper, config.debugSourceMaps)
85
94
  if (config.sourceMap && config.debugSourceMaps) {
86
- this._logger.debug(() => {
95
+ this.#logger.debug(() => {
87
96
  return mapper.infoMap.size === 0
88
97
  ? 'Found no source maps'
89
98
  : `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]`
@@ -93,18 +102,18 @@ class Profiler extends EventEmitter {
93
102
  const clevel = config.uploadCompression.level
94
103
  switch (config.uploadCompression.method) {
95
104
  case 'gzip':
96
- this._compressionFn = promisify(zlib.gzip)
105
+ this.#compressionFn = promisify(zlib.gzip)
97
106
  if (clevel !== undefined) {
98
- this._compressionOptions = {
107
+ this.#compressionOptions = {
99
108
  level: clevel
100
109
  }
101
110
  }
102
111
  break
103
112
  case 'zstd':
104
113
  if (typeof zlib.zstdCompress === 'function') {
105
- this._compressionFn = promisify(zlib.zstdCompress)
114
+ this.#compressionFn = promisify(zlib.zstdCompress)
106
115
  if (clevel !== undefined) {
107
- this._compressionOptions = {
116
+ this.#compressionOptions = {
108
117
  params: {
109
118
  [zlib.constants.ZSTD_c_compressionLevel]: clevel
110
119
  }
@@ -113,43 +122,44 @@ class Profiler extends EventEmitter {
113
122
  } else {
114
123
  const zstdCompress = require('@datadog/libdatadog').load('datadog-js-zstd').zstd_compress
115
124
  const level = clevel ?? 0 // 0 is zstd default compression level
116
- this._compressionFn = (buffer) => Promise.resolve(Buffer.from(zstdCompress(buffer, level)))
125
+ this.#compressionFn = (buffer) => Promise.resolve(Buffer.from(zstdCompress(buffer, level)))
117
126
  }
118
127
  break
119
128
  }
120
129
  } catch (err) {
121
- this._logError(err)
130
+ this.#logError(err)
122
131
  }
123
132
 
124
133
  try {
125
134
  const start = new Date()
135
+ const nearOOMCallback = this.#nearOOMExport.bind(this)
126
136
  for (const profiler of config.profilers) {
127
137
  // TODO: move this out of Profiler when restoring sourcemap support
128
138
  profiler.start({
129
139
  mapper,
130
- nearOOMCallback: this._nearOOMExport.bind(this)
140
+ nearOOMCallback
131
141
  })
132
- this._logger.debug(`Started ${profiler.type} profiler in ${threadNamePrefix} thread`)
142
+ this.#logger.debug(`Started ${profiler.type} profiler in ${threadNamePrefix} thread`)
133
143
  }
134
144
 
135
145
  if (config.endpointCollectionEnabled) {
136
- this._spanFinishListener = this._onSpanFinish.bind(this)
137
- spanFinishedChannel.subscribe(this._spanFinishListener)
146
+ this.#spanFinishListener = this.#onSpanFinish.bind(this)
147
+ spanFinishedChannel.subscribe(this.#spanFinishListener)
138
148
  }
139
149
 
140
150
  this._capture(this._timeoutInterval, start)
141
151
  return true
142
152
  } catch (e) {
143
- this._logError(e)
144
- this._stop()
153
+ this.#logError(e)
154
+ this.#stop()
145
155
  return false
146
156
  }
147
157
  }
148
158
 
149
- _nearOOMExport (profileType, encodedProfile) {
150
- const start = this._lastStart
159
+ #nearOOMExport (profileType, encodedProfile) {
160
+ const start = this.#lastStart
151
161
  const end = new Date()
152
- this._submit({
162
+ this.#submit({
153
163
  [profileType]: encodedProfile
154
164
  }, start, end, snapshotKinds.ON_OUT_OF_MEMORY)
155
165
  }
@@ -159,45 +169,45 @@ class Profiler extends EventEmitter {
159
169
  }
160
170
 
161
171
  stop () {
162
- if (!this._enabled) return
172
+ if (!this.enabled) return
163
173
 
164
174
  // collect and export current profiles
165
175
  // once collect returns, profilers can be safely stopped
166
176
  this._collect(snapshotKinds.ON_SHUTDOWN, false)
167
- this._stop()
177
+ this.#stop()
168
178
  }
169
179
 
170
- _stop () {
171
- if (!this._enabled) return
180
+ #stop () {
181
+ if (!this.enabled) return
172
182
 
173
- this._enabled = false
183
+ this.#enabled = false
174
184
 
175
- if (this._spanFinishListener !== undefined) {
176
- spanFinishedChannel.unsubscribe(this._spanFinishListener)
177
- this._spanFinishListener = undefined
185
+ if (this.#spanFinishListener !== undefined) {
186
+ spanFinishedChannel.unsubscribe(this.#spanFinishListener)
187
+ this.#spanFinishListener = undefined
178
188
  }
179
189
 
180
190
  for (const profiler of this._config.profilers) {
181
191
  profiler.stop()
182
- this._logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
192
+ this.#logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
183
193
  }
184
194
 
185
- clearTimeout(this._timer)
186
- this._timer = undefined
195
+ clearTimeout(this.#timer)
196
+ this.#timer = undefined
187
197
  }
188
198
 
189
199
  _capture (timeout, start) {
190
- if (!this._enabled) return
191
- this._lastStart = start
192
- if (!this._timer || timeout !== this._timeoutInterval) {
193
- this._timer = setTimeout(() => this._collect(snapshotKinds.PERIODIC), timeout)
194
- this._timer.unref()
200
+ if (!this.enabled) return
201
+ this.#lastStart = start
202
+ if (!this.#timer || timeout !== this._timeoutInterval) {
203
+ this.#timer = setTimeout(() => this._collect(snapshotKinds.PERIODIC), timeout)
204
+ this.#timer.unref()
195
205
  } else {
196
- this._timer.refresh()
206
+ this.#timer.refresh()
197
207
  }
198
208
  }
199
209
 
200
- _onSpanFinish (span) {
210
+ #onSpanFinish (span) {
201
211
  const context = span.context()
202
212
  const tags = context._tags
203
213
  if (!isWebServerSpan(tags)) return
@@ -208,19 +218,19 @@ class Profiler extends EventEmitter {
208
218
  // Make sure this is the outermost web span, just in case so we don't overcount
209
219
  if (findWebSpan(getStartedSpans(context), context._parentId)) return
210
220
 
211
- let counter = this.endpointCounts.get(endpointName)
221
+ let counter = this.#endpointCounts.get(endpointName)
212
222
  if (counter === undefined) {
213
223
  counter = { count: 1 }
214
- this.endpointCounts.set(endpointName, counter)
224
+ this.#endpointCounts.set(endpointName, counter)
215
225
  } else {
216
226
  counter.count++
217
227
  }
218
228
  }
219
229
 
220
230
  async _collect (snapshotKind, restart = true) {
221
- if (!this._enabled) return
231
+ if (!this.enabled) return
222
232
 
223
- const startDate = this._lastStart
233
+ const startDate = this.#lastStart
224
234
  const endDate = new Date()
225
235
  const profiles = []
226
236
  const encodedProfiles = {}
@@ -235,7 +245,7 @@ class Profiler extends EventEmitter {
235
245
  for (const profiler of this._config.profilers) {
236
246
  const profile = profiler.profile(restart, startDate, endDate)
237
247
  if (!restart) {
238
- this._logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
248
+ this.#logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
239
249
  }
240
250
  if (!profile) continue
241
251
  profiles.push({ profiler, profile })
@@ -252,11 +262,11 @@ class Profiler extends EventEmitter {
252
262
  await Promise.all(profiles.map(async ({ profiler, profile }) => {
253
263
  try {
254
264
  const encoded = await profiler.encode(profile)
255
- const compressed = encoded instanceof Buffer && this._compressionFn !== undefined
256
- ? await this._compressionFn(encoded, this._compressionOptions)
265
+ const compressed = encoded instanceof Buffer && this.#compressionFn !== undefined
266
+ ? await this.#compressionFn(encoded, this.#compressionOptions)
257
267
  : encoded
258
268
  encodedProfiles[profiler.type] = compressed
259
- this._logger.debug(() => {
269
+ this.#logger.debug(() => {
260
270
  const profileJson = JSON.stringify(profile, (key, value) => {
261
271
  return typeof value === 'bigint' ? value.toString() : value
262
272
  })
@@ -266,37 +276,38 @@ class Profiler extends EventEmitter {
266
276
  } catch (err) {
267
277
  // If encoding one of the profile types fails, we should still try to
268
278
  // encode and submit the other profile types.
269
- this._logError(err)
279
+ this.#logError(err)
270
280
  }
271
281
  }))
272
282
 
273
283
  if (hasEncoded) {
274
- await this._submit(encodedProfiles, startDate, endDate, snapshotKind)
284
+ await this.#submit(encodedProfiles, startDate, endDate, snapshotKind)
275
285
  profileSubmittedChannel.publish()
276
- this._logger.debug('Submitted profiles')
286
+ this.#logger.debug('Submitted profiles')
277
287
  }
278
288
  } catch (err) {
279
- this._logError(err)
280
- this._stop()
289
+ this.#logError(err)
290
+ this.#stop()
281
291
  }
282
292
  }
283
293
 
284
- _submit (profiles, start, end, snapshotKind) {
294
+ #submit (profiles, start, end, snapshotKind) {
285
295
  const { tags } = this._config
286
296
 
287
297
  // Flatten endpoint counts
288
298
  const endpointCounts = {}
289
- for (const [endpoint, { count }] of this.endpointCounts) {
299
+ for (const [endpoint, { count }] of this.#endpointCounts) {
290
300
  endpointCounts[endpoint] = count
291
301
  }
292
- this.endpointCounts.clear()
302
+ this.#endpointCounts.clear()
293
303
 
294
304
  tags.snapshot = snapshotKind
305
+ tags.profile_seq = this.#profileSeq++
295
306
  const exportSpec = { profiles, start, end, tags, endpointCounts }
296
307
  const tasks = this._config.exporters.map(exporter =>
297
308
  exporter.export(exportSpec).catch(err => {
298
- if (this._logger) {
299
- this._logger.warn(err)
309
+ if (this.#logger) {
310
+ this.#logger.warn(err)
300
311
  }
301
312
  })
302
313
  )
@@ -306,24 +317,32 @@ class Profiler extends EventEmitter {
306
317
  }
307
318
 
308
319
  class ServerlessProfiler extends Profiler {
320
+ #profiledIntervals = 0
321
+ #interval = 1 // seconds
322
+ #flushAfterIntervals
323
+
309
324
  constructor () {
310
325
  super()
311
- this._profiledIntervals = 0
312
- this._interval = 1
313
- this._flushAfterIntervals = undefined
326
+ this.#profiledIntervals = 0
327
+ this.#interval = 1
328
+ this.#flushAfterIntervals = undefined
329
+ }
330
+
331
+ get profiledIntervals () {
332
+ return this.#profiledIntervals
314
333
  }
315
334
 
316
335
  _setInterval () {
317
- this._timeoutInterval = this._interval * 1000
318
- this._flushAfterIntervals = this._config.flushInterval / 1000
336
+ this._timeoutInterval = this.#interval * 1000
337
+ this.#flushAfterIntervals = this._config.flushInterval / 1000
319
338
  }
320
339
 
321
340
  async _collect (snapshotKind, restart = true) {
322
- if (this._profiledIntervals >= this._flushAfterIntervals || !restart) {
323
- this._profiledIntervals = 0
341
+ if (this.#profiledIntervals >= this.#flushAfterIntervals || !restart) {
342
+ this.#profiledIntervals = 0
324
343
  await super._collect(snapshotKind, restart)
325
344
  } else {
326
- this._profiledIntervals += 1
345
+ this.#profiledIntervals += 1
327
346
  this._capture(this._timeoutInterval, new Date())
328
347
  // Don't submit profile until 65 (flushAfterIntervals) intervals have elapsed
329
348
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const EventPlugin = require('./event')
2
4
 
3
5
  class DNSPlugin extends EventPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const DNSPlugin = require('./dns')
2
4
 
3
5
  class DNSLookupPlugin extends DNSPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const DNSPlugin = require('./dns')
2
4
 
3
5
  class DNSLookupServicePlugin extends DNSPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const DNSPlugin = require('./dns')
2
4
 
3
5
  const queryNames = new Map()
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const DNSPlugin = require('./dns')
2
4
 
3
5
  class DNSReversePlugin extends DNSPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const TracingPlugin = require('../../../plugins/tracing')
2
4
  const { performance } = require('perf_hooks')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const EventPlugin = require('./event')
2
4
 
3
5
  // Values taken from parameter names in datadog-instrumentations/src/fs.js.
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const EventPlugin = require('./event')
2
4
 
3
5
  class NetPlugin extends EventPlugin {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { performance, constants, PerformanceObserver } = require('perf_hooks')
2
4
  const { END_TIMESTAMP_LABEL, SPAN_ID_LABEL, LOCAL_ROOT_SPAN_ID_LABEL, encodeProfileAsync } = require('./shared')
3
5
  const { Function, Label, Line, Location, Profile, Sample, StringTable, ValueType } = require('pprof-format')
@@ -213,10 +213,10 @@ class NativeWallProfiler {
213
213
  }
214
214
 
215
215
  _updateContext (context) {
216
- if (typeof context.spanId === 'object') {
216
+ if (context.spanId !== null && typeof context.spanId === 'object') {
217
217
  context.spanId = context.spanId.toString(10)
218
218
  }
219
- if (typeof context.rootSpanId === 'object') {
219
+ if (context.rootSpanId !== null && typeof context.rootSpanId === 'object') {
220
220
  context.rootSpanId = context.rootSpanId.toString(10)
221
221
  }
222
222
  if (context.webTags !== undefined && context.endpoint === undefined) {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { HTTP_METHOD, HTTP_ROUTE, RESOURCE_NAME, SPAN_TYPE } = require('../../../../ext/tags')
2
4
  const { WEB } = require('../../../../ext/types')
3
5
 
@@ -100,6 +100,10 @@ class Tracer extends NoopProxy {
100
100
  require('./crashtracking').start(config)
101
101
  }
102
102
 
103
+ if (config.heapSnapshot.count > 0) {
104
+ require('./heap_snapshots').start(config)
105
+ }
106
+
103
107
  telemetry.start(config, this._pluginManager)
104
108
 
105
109
  if (config.dogstatsd) {
@@ -16,6 +16,7 @@ module.exports = {
16
16
  APM_TRACING_LOGS_INJECTION: 1n << 13n,
17
17
  APM_TRACING_HTTP_HEADER_TAGS: 1n << 14n,
18
18
  APM_TRACING_CUSTOM_TAGS: 1n << 15n,
19
+ ASM_EXCLUSION_DATA: 1n << 18n,
19
20
  APM_TRACING_ENABLED: 1n << 19n,
20
21
  ASM_RASP_SQLI: 1n << 21n,
21
22
  ASM_RASP_LFI: 1n << 22n,
@@ -27,5 +28,6 @@ module.exports = {
27
28
  ASM_SESSION_FINGERPRINT: 1n << 33n,
28
29
  ASM_NETWORK_FINGERPRINT: 1n << 34n,
29
30
  ASM_HEADER_FINGERPRINT: 1n << 35n,
30
- ASM_RASP_CMDI: 1n << 37n
31
+ ASM_RASP_CMDI: 1n << 37n,
32
+ ASM_DD_MULTICONFIG: 1n << 42n
31
33
  }
@@ -89,10 +89,12 @@ function enableWafUpdate (appsecConfig) {
89
89
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_RULES, true)
90
90
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_BLOCKING_RESPONSE, true)
91
91
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_TRUSTED_IPS, true)
92
+ rc.updateCapabilities(RemoteConfigCapabilities.ASM_EXCLUSION_DATA, true)
92
93
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_ENDPOINT_FINGERPRINT, true)
93
94
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, true)
94
95
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, true)
95
96
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, true)
97
+ rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
96
98
 
97
99
  if (appsecConfig.rasp?.enabled) {
98
100
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, true)
@@ -124,10 +126,12 @@ function disableWafUpdate () {
124
126
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_RULES, false)
125
127
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_BLOCKING_RESPONSE, false)
126
128
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_TRUSTED_IPS, false)
129
+ rc.updateCapabilities(RemoteConfigCapabilities.ASM_EXCLUSION_DATA, false)
127
130
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_ENDPOINT_FINGERPRINT, false)
128
131
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, false)
129
132
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, false)
130
133
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, false)
134
+ rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, false)
131
135
 
132
136
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, false)
133
137
  rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SSRF, false)
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  class SchemaManager {
2
4
  constructor () {
3
5
  this.schemas = {}
@@ -1,22 +1,17 @@
1
+ 'use strict'
2
+
1
3
  class SchemaDefinition {
2
4
  constructor (schema) {
3
5
  this.schema = schema
4
6
  }
5
7
 
6
- getSchemaItem (type, kind, plugin) {
7
- const schema = this.schema
8
- if (schema && schema[type] && schema[type][kind] && schema[type][kind][plugin]) {
9
- return schema[type][kind][plugin]
10
- }
11
- }
12
-
13
8
  getOpName (type, kind, plugin, opts) {
14
- const item = this.getSchemaItem(type, kind, plugin)
9
+ const item = this.schema[type][kind][plugin]
15
10
  return item.opName(opts)
16
11
  }
17
12
 
18
13
  getServiceName (type, kind, plugin, opts) {
19
- const item = this.getSchemaItem(type, kind, plugin)
14
+ const item = this.schema[type][kind][plugin]
20
15
  return item.serviceName(opts)
21
16
  }
22
17
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function identityService ({ tracerService }) {
2
4
  return tracerService
3
5
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService } = require('../util')
2
4
 
3
5
  const graphql = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SchemaDefinition = require('../definition')
2
4
  const messaging = require('./messaging')
3
5
  const storage = require('./storage')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService, awsServiceV0 } = require('../util')
2
4
 
3
5
  function amqpServiceName ({ tracerService }) {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService } = require('../util')
2
4
 
3
5
  const serverless = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function getRedisService (pluginConfig, connectionName) {
2
4
  if (pluginConfig.splitByInstance && connectionName) {
3
5
  return pluginConfig.service
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService, httpPluginClientService, awsServiceV0 } = require('../util')
2
4
 
3
5
  const web = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService } = require('../util')
2
4
 
3
5
  const graphql = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SchemaDefinition = require('../definition')
2
4
  const messaging = require('./messaging')
3
5
  const storage = require('./storage')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService } = require('../util')
2
4
 
3
5
  const amqpInbound = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService } = require('../util')
2
4
 
3
5
  const serverless = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function configWithFallback ({ tracerService, pluginConfig }) {
2
4
  return pluginConfig.service || tracerService
3
5
  }
@@ -14,7 +16,8 @@ const mySQLNaming = {
14
16
 
15
17
  function withFunction ({ tracerService, pluginConfig, params }) {
16
18
  if (typeof pluginConfig.service === 'function') {
17
- return pluginConfig.service(params)
19
+ const result = pluginConfig.service(params)
20
+ return typeof result === 'string' && result.length > 0 ? result : tracerService
18
21
  }
19
22
  return configWithFallback({ tracerService, pluginConfig })
20
23
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { identityService, httpPluginClientService } = require('../util')
2
4
 
3
5
  const web = {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const os = require('os')
2
4
  const { version } = require('./pkg')
3
5
  const pkg = require('../../../package.json')
@@ -56,6 +56,7 @@
56
56
  "DD_DOGSTATSD_HOST": ["A"],
57
57
  "DD_DOGSTATSD_PORT": ["A"],
58
58
  "DD_DYNAMIC_INSTRUMENTATION_ENABLED": ["A"],
59
+ "DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE": ["A"],
59
60
  "DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS": ["A"],
60
61
  "DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS": ["A"],
61
62
  "DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS": ["A"],
@@ -78,6 +79,9 @@
78
79
  "DD_GIT_PULL_REQUEST_BASE_BRANCH_SHA": ["A"],
79
80
  "DD_GRPC_CLIENT_ERROR_STATUSES": ["A"],
80
81
  "DD_GRPC_SERVER_ERROR_STATUSES": ["A"],
82
+ "DD_HEAP_SNAPSHOT_COUNT": ["A"],
83
+ "DD_HEAP_SNAPSHOT_INTERVAL": ["A"],
84
+ "DD_HEAP_SNAPSHOT_DESTINATION": ["A"],
81
85
  "DD_IAST_DB_ROWS_TO_TAINT": ["A"],
82
86
  "DD_IAST_DEDUPLICATION_ENABLED": ["A"],
83
87
  "DD_IAST_ENABLED": ["A"],
@@ -274,6 +278,7 @@
274
278
  "DD_TRACE_HAPI_ENABLED": ["A"],
275
279
  "DD_TRACE_HAPI_HAPI_ENABLED": ["A"],
276
280
  "DD_TRACE_HEADER_TAGS": ["A"],
281
+ "DD_TRACE_HONO_ENABLED": ["A"],
277
282
  "DD_TRACE_HTTP_ENABLED": ["A"],
278
283
  "DD_TRACE_HTTP2_ENABLED": ["A"],
279
284
  "DD_TRACE_HTTPS_ENABLED": ["A"],
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const request = require('../exporters/common/request')
2
4
  const log = require('../log')
3
5
  const { isTrue } = require('../util')