dd-trace 5.135.0 → 5.136.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 (250) hide show
  1. package/ci/init.js +2 -22
  2. package/ext/exporters.js +0 -1
  3. package/index.d.ts +105 -5
  4. package/initialize.mjs +5 -2
  5. package/lambda.d.ts +39 -0
  6. package/lambda.js +3 -0
  7. package/package.json +11 -9
  8. package/packages/datadog-esbuild/index.js +8 -55
  9. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  10. package/packages/datadog-instrumentations/src/cucumber.js +5 -2
  11. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  12. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  13. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  14. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  15. package/packages/datadog-instrumentations/src/graphql.js +20 -17
  16. package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
  17. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
  18. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  19. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  20. package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
  21. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  22. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
  23. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +18 -1
  24. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  25. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  26. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  27. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
  28. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  29. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  30. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +50 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -3
  32. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  33. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  34. package/packages/datadog-instrumentations/src/next.js +19 -6
  35. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  36. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  37. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  38. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  39. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  40. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  41. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  42. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  43. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  44. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  45. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +22 -11
  46. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  47. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
  48. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
  49. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
  50. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  51. package/packages/datadog-plugin-http/src/client.js +32 -9
  52. package/packages/datadog-plugin-http2/src/client.js +38 -13
  53. package/packages/datadog-plugin-next/src/index.js +112 -14
  54. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  55. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  56. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  57. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  58. package/packages/datadog-plugin-undici/src/index.js +22 -7
  59. package/packages/datadog-turbopack/index.js +4 -28
  60. package/packages/datadog-turbopack/src/loader.js +14 -452
  61. package/packages/datadog-webpack/index.js +3 -55
  62. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  63. package/packages/dd-trace/src/aiguard/sdk.js +8 -2
  64. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  65. package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
  66. package/packages/dd-trace/src/appsec/graphql.js +91 -6
  67. package/packages/dd-trace/src/appsec/recommended.json +1287 -90
  68. package/packages/dd-trace/src/before-exit.js +32 -0
  69. package/packages/dd-trace/src/bootstrap.js +5 -3
  70. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
  71. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
  72. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  73. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  74. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
  75. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
  76. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  77. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
  78. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  79. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  80. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  81. package/packages/dd-trace/src/config/defaults.js +5 -0
  82. package/packages/dd-trace/src/config/generated-config-types.d.ts +42 -2
  83. package/packages/dd-trace/src/config/index.js +17 -5
  84. package/packages/dd-trace/src/config/parsers.js +9 -0
  85. package/packages/dd-trace/src/config/supported-configurations.json +158 -4
  86. package/packages/dd-trace/src/constants.js +1 -0
  87. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
  88. package/packages/dd-trace/src/exporter.js +0 -11
  89. package/packages/dd-trace/src/exporters/common/request.js +81 -48
  90. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  91. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  92. package/packages/dd-trace/src/id.js +1 -1
  93. package/packages/dd-trace/src/lambda/facade.js +74 -0
  94. package/packages/dd-trace/src/lambda/handler.js +3 -41
  95. package/packages/dd-trace/src/lambda/index.js +38 -15
  96. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  97. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  98. package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
  99. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  100. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  101. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
  102. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  103. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  104. package/packages/dd-trace/src/llmobs/sdk.js +19 -0
  105. package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
  106. package/packages/dd-trace/src/llmobs/tagger.js +22 -0
  107. package/packages/dd-trace/src/log/channels.js +4 -0
  108. package/packages/dd-trace/src/log/writer.js +6 -1
  109. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +4 -0
  110. package/packages/dd-trace/src/openfeature/configuration_source.js +35 -27
  111. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  112. package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
  113. package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
  114. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  115. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  116. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  117. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  118. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  119. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  120. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  121. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  122. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  123. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  124. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  125. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  126. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  127. package/packages/dd-trace/src/opentracing/tracer.js +24 -0
  128. package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
  129. package/packages/dd-trace/src/plugin_manager.js +34 -7
  130. package/packages/dd-trace/src/plugins/ci_plugin.js +41 -10
  131. package/packages/dd-trace/src/plugins/index.js +6 -0
  132. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  133. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  134. package/packages/dd-trace/src/plugins/util/ci.js +18 -1
  135. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  136. package/packages/dd-trace/src/plugins/util/git.js +263 -82
  137. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +75 -46
  138. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  139. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  140. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  141. package/packages/dd-trace/src/plugins/util/test.js +64 -39
  142. package/packages/dd-trace/src/plugins/util/url.js +10 -2
  143. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
  144. package/packages/dd-trace/src/plugins/util/web.js +65 -10
  145. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  146. package/packages/dd-trace/src/proxy.js +33 -53
  147. package/packages/dd-trace/src/span_processor.js +20 -0
  148. package/packages/dd-trace/src/startup-log.js +8 -6
  149. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  150. package/packages/dd-trace/src/tracer.js +0 -2
  151. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  152. package/register.js +2 -1
  153. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  154. package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
  155. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  156. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  157. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  158. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  159. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  160. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  161. package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
  162. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  163. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  164. package/vendor/dist/esquery/LICENSE +2 -0
  165. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  166. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  167. package/vendor/dist/jest-docblock/LICENSE +16 -0
  168. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  169. package/vendor/dist/limiter/LICENSE +2 -0
  170. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  171. package/vendor/dist/lru-cache/LICENSE +13 -0
  172. package/vendor/dist/meriyah/LICENSE +13 -0
  173. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  174. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  175. package/vendor/dist/pprof-format/LICENSE +13 -0
  176. package/vendor/dist/pprof-format/index.js +1 -1
  177. package/vendor/dist/protobufjs/LICENSE +219 -0
  178. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  179. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  180. package/vendor/dist/retry/LICENSE +2 -0
  181. package/vendor/dist/rfdc/LICENSE +2 -0
  182. package/vendor/dist/semifies/LICENSE +3 -1
  183. package/vendor/dist/shell-quote/LICENSE +3 -1
  184. package/vendor/dist/source-map/LICENSE +1 -0
  185. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  186. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  187. package/vendor/dist/ttl-set/LICENSE +28 -0
  188. package/ci/diagnose.js +0 -2215
  189. package/ci/runbook.md +0 -299
  190. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  191. package/ci/test-optimization-validation/approval.js +0 -386
  192. package/ci/test-optimization-validation/artifact-id.js +0 -18
  193. package/ci/test-optimization-validation/blocker-category.js +0 -24
  194. package/ci/test-optimization-validation/bounded-json.js +0 -120
  195. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  196. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  197. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  198. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  199. package/ci/test-optimization-validation/cli.js +0 -954
  200. package/ci/test-optimization-validation/command-blocker.js +0 -377
  201. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  202. package/ci/test-optimization-validation/command-runner.js +0 -649
  203. package/ci/test-optimization-validation/environment.js +0 -88
  204. package/ci/test-optimization-validation/executable-approval.js +0 -47
  205. package/ci/test-optimization-validation/executable.js +0 -244
  206. package/ci/test-optimization-validation/execution-lock.js +0 -70
  207. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  208. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  209. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  210. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  211. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  212. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  213. package/ci/test-optimization-validation/generated-files.js +0 -425
  214. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  215. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  216. package/ci/test-optimization-validation/literal-environment.js +0 -56
  217. package/ci/test-optimization-validation/literal-glob.js +0 -52
  218. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  219. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  220. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  221. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  222. package/ci/test-optimization-validation/offline-output.js +0 -406
  223. package/ci/test-optimization-validation/package-check.js +0 -97
  224. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  225. package/ci/test-optimization-validation/plan-writer.js +0 -541
  226. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  227. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  228. package/ci/test-optimization-validation/redaction.js +0 -319
  229. package/ci/test-optimization-validation/report-writer.js +0 -666
  230. package/ci/test-optimization-validation/result-semantics.js +0 -103
  231. package/ci/test-optimization-validation/runner-command.js +0 -264
  232. package/ci/test-optimization-validation/runner-contract.js +0 -695
  233. package/ci/test-optimization-validation/safe-files.js +0 -202
  234. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  235. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  236. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  237. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  238. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  239. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  240. package/ci/test-optimization-validation/source-text.js +0 -84
  241. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  242. package/ci/test-optimization-validation/test-output.js +0 -120
  243. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  244. package/ci/validate-test-optimization.js +0 -3
  245. package/packages/datadog-esbuild/src/resolver.js +0 -284
  246. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
  247. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
  248. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
  249. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
  250. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
@@ -1,35 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  const fs = require('node:fs')
4
- const Module = require('node:module')
5
- const path = require('node:path')
6
4
 
7
- const extractPackageAndModulePath = require(
8
- '../../datadog-instrumentations/src/helpers/extract-package-and-module-path'
9
- )
10
- const hooks = require('../../datadog-instrumentations/src/helpers/hooks')
11
- const instrumentations = require('../../datadog-instrumentations/src/helpers/instrumentations')
12
- const { filename, matchesInstrumentation } = require('../../datadog-instrumentations/src/helpers/instrumentation-utils')
13
- const { createBundlerRewriter } = require('../../datadog-instrumentations/src/helpers/rewriter')
14
- const {
15
- getRewriteTarget,
16
- getRewriteTargetNames,
17
- } = require('../../datadog-instrumentations/src/helpers/rewriter/targets')
18
- const { isESMFile } = require('../../datadog-esbuild/src/utils')
5
+ const { instrument } = require('../../datadog-instrumentations/src/helpers/bundler-transform')
19
6
  const { SYNTHETIC_EXTENSION } = require('./constants')
20
7
 
21
- const CHANNEL = 'dd-trace:bundler:load'
22
- const ARGUMENTS_BINDING = 1
23
- const MODULE_BINDING = 2
24
- const REQUIRE_BINDING = 4
25
- const COMMONJS_BINDINGS = MODULE_BINDING | REQUIRE_BINDING
26
- const targetPackages = new Set(Object.keys(hooks))
27
- for (const name of getRewriteTargetNames()) targetPackages.add(name)
28
- const entrypoints = new Map()
29
- const loadedHooks = new Set()
30
- const packageCache = new Map()
31
- const rewriters = new Map()
32
-
33
8
  /**
34
9
  * @typedef {object} LoaderContext
35
10
  * @property {(error: Error|undefined, code?: string, sourceMap?: string|object) => void} callback
@@ -37,16 +12,6 @@ const rewriters = new Map()
37
12
  * @property {string} resourcePath
38
13
  */
39
14
 
40
- /**
41
- * @typedef {object} PackageInfo
42
- * @property {string} [entrypoint]
43
- * @property {boolean} esm
44
- * @property {string} moduleName
45
- * @property {string} name
46
- * @property {string} packageJsonPath
47
- * @property {string} version
48
- */
49
-
50
15
  /**
51
16
  * Instruments a resolved foreign Node.js module.
52
17
  *
@@ -55,71 +20,22 @@ const rewriters = new Map()
55
20
  * @param {string|object} [inputSourceMap]
56
21
  */
57
22
  module.exports = function loader (source, inputSourceMap) {
23
+ let result
58
24
  try {
59
- const nativeResourcePath = fs.realpathSync(getResourcePath(this))
60
- const resourcePath = nativeResourcePath.replaceAll('\\', '/')
61
- const extracted = extractPackageAndModulePath(resourcePath)
62
- if (!extracted.pkg || !targetPackages.has(extracted.pkg)) {
63
- this.callback(undefined, source, inputSourceMap)
64
- return
65
- }
66
-
67
- const rewriteTarget = getRewriteTarget(resourcePath)
68
- const packageInfo = getPackageInfo(
69
- nativeResourcePath,
70
- extracted.pkg,
71
- /** @type {string} */ (extracted.path),
72
- path.normalize(/** @type {string} */ (extracted.pkgJson))
73
- )
74
- const esm = packageInfo.esm
75
- const publications = esm ? [] : getPublications(resourcePath, packageInfo)
76
- if (!rewriteTarget && publications.length === 0) {
77
- this.callback(undefined, source, inputSourceMap)
78
- return
79
- }
80
- if (publications.length > 0 && hasUnsafeCommonJsBindings(source)) {
81
- this.emitWarning?.(new Error(`Skipped CommonJS publication for unsafe wrapper bindings in ${resourcePath}`))
82
- this.callback(undefined, source, inputSourceMap)
83
- return
84
- }
85
-
86
- const dcModule = relativeImport(path.dirname(nativeResourcePath), require.resolve('dc-polyfill'))
87
- let code = source
88
- let sourceMap = inputSourceMap
89
- let rewritten = false
90
- if (rewriteTarget) {
91
- const rewrite = getRewriter(dcModule)
92
- const result = rewrite(
93
- source,
94
- resourcePath,
95
- esm ? 'module' : 'commonjs',
96
- rewriteTarget,
97
- inputSourceMap
98
- )
99
- code = /** @type {string} */ (result.code)
100
- sourceMap = result.map
101
- rewritten = code !== source
102
- }
103
-
104
- if (publications.length > 0) code = appendCommonJsPublications(code, publications, dcModule)
105
- if (rewritten && publications.length === 0 && (rewriteTarget.activate || hooks[rewriteTarget.moduleName])) {
106
- if (!esm && hasUnsafeCommonJsBindings(code)) {
107
- this.emitWarning?.(new Error(`Skipped CommonJS activation for unsafe wrapper bindings in ${resourcePath}`))
108
- this.callback(undefined, source, inputSourceMap)
109
- return
110
- }
111
- code = appendActivation(code, {
112
- package: rewriteTarget.moduleName,
113
- path: filename(rewriteTarget.moduleName, rewriteTarget.filePath),
114
- version: packageInfo.version,
115
- }, dcModule, esm)
116
- }
117
- this.callback(undefined, code, sourceMap)
25
+ result = instrument({
26
+ source,
27
+ resourcePath: getResourcePath(this),
28
+ inputSourceMap,
29
+ warn: this.emitWarning?.bind(this),
30
+ })
118
31
  } catch (error) {
119
- const warning = error instanceof Error ? error : new Error(String(error))
120
- this.emitWarning?.(warning)
121
- this.callback(undefined, source, inputSourceMap)
32
+ try {
33
+ this.emitWarning?.(error instanceof Error ? error : new Error(String(error)))
34
+ } catch {
35
+ // A warning must not prevent the loader from returning the original source.
36
+ }
122
37
  }
38
+ this.callback(undefined, result?.code ?? source, result ? result.map : inputSourceMap)
123
39
  }
124
40
 
125
41
  /**
@@ -132,357 +48,3 @@ function getResourcePath (context) {
132
48
  const extensionlessPath = resourcePath.slice(0, -SYNTHETIC_EXTENSION.length)
133
49
  return fs.existsSync(extensionlessPath) ? extensionlessPath : resourcePath
134
50
  }
135
-
136
- /**
137
- * @param {string} nativeResourcePath
138
- * @param {string} name
139
- * @param {string} modulePath
140
- * @param {string} packageJsonPath
141
- * @returns {PackageInfo}
142
- */
143
- function getPackageInfo (nativeResourcePath, name, modulePath, packageJsonPath) {
144
- let cached = packageCache.get(packageJsonPath)
145
- if (!cached) {
146
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
147
- cached = { packageJson, version: packageJson.version }
148
- packageCache.set(packageJsonPath, cached)
149
- }
150
-
151
- return {
152
- esm: isESMFile(nativeResourcePath, packageJsonPath, cached.packageJson),
153
- moduleName: filename(name, modulePath),
154
- name,
155
- packageJsonPath,
156
- version: cached.version,
157
- }
158
- }
159
-
160
- /**
161
- * @param {string} resourcePath
162
- * @param {PackageInfo} packageInfo
163
- * @returns {Array<{ package: string, path: string, version: string }>}
164
- */
165
- function getPublications (resourcePath, packageInfo) {
166
- loadPackageHook(packageInfo.name)
167
- const entries = instrumentations[packageInfo.name]
168
- if (!entries) return []
169
-
170
- const publications = []
171
- const paths = new Set()
172
- for (const entry of entries) {
173
- if (!entry.file && !entry.filePattern) {
174
- packageInfo.entrypoint ??= getCommonJsEntrypoint(packageInfo.name, packageInfo.packageJsonPath)
175
- }
176
- const moduleName = entry.file || entry.filePattern
177
- ? packageInfo.moduleName
178
- : resourcePath === packageInfo.entrypoint ? packageInfo.name : undefined
179
- if (!moduleName || paths.has(moduleName) ||
180
- !matchesInstrumentation(packageInfo.name, packageInfo.version, moduleName, entry)) continue
181
-
182
- paths.add(moduleName)
183
- publications.push({ package: packageInfo.name, path: moduleName, version: packageInfo.version })
184
- }
185
- return publications
186
- }
187
-
188
- /**
189
- * @param {string} name
190
- * @param {string} packageJsonPath
191
- */
192
- function getCommonJsEntrypoint (name, packageJsonPath) {
193
- const cached = entrypoints.get(packageJsonPath)
194
- if (cached) return cached
195
-
196
- const packageRequire = Module.createRequire(packageJsonPath)
197
- let entrypoint
198
- try {
199
- entrypoint = packageRequire.resolve(name)
200
- } catch {
201
- entrypoint = packageRequire.resolve(path.dirname(packageJsonPath))
202
- }
203
- const resolved = fs.realpathSync(entrypoint).replaceAll('\\', '/')
204
- entrypoints.set(packageJsonPath, resolved)
205
- return resolved
206
- }
207
-
208
- /**
209
- * @param {string} name
210
- */
211
- function loadPackageHook (name) {
212
- if (loadedHooks.has(name)) return
213
- const hook = hooks[name]
214
- const load = hook?.fn ?? hook
215
- if (typeof load === 'function') load()
216
- loadedHooks.add(name)
217
- }
218
-
219
- /**
220
- * @param {string} dcModule
221
- * @returns {ReturnType<typeof createBundlerRewriter>}
222
- */
223
- function getRewriter (dcModule) {
224
- const cached = rewriters.get(dcModule)
225
- if (cached) return cached
226
- const rewrite = createBundlerRewriter(dcModule)
227
- rewriters.set(dcModule, rewrite)
228
- return rewrite
229
- }
230
-
231
- /**
232
- * @param {string} source
233
- */
234
- function hasUnsafeCommonJsBindings (source) {
235
- try {
236
- const { parse } = require('../../datadog-instrumentations/src/helpers/rewriter/compiler')
237
- if (source.startsWith('#!')) source = `//${source.slice(2)}`
238
- const program = parse(Module.wrap(source))
239
- const wrapper = program.body[0]?.expression
240
- return wrapper?.type !== 'FunctionExpression' || hasUnsafeNode(wrapper.body, 0, 0)
241
- } catch {
242
- return true
243
- }
244
- }
245
-
246
- /**
247
- * @param {object} node
248
- * @param {number} functionDepth
249
- * @param {number} shadowedBindings
250
- * @param {object} [parent]
251
- * @param {string} [parentKey]
252
- */
253
- function hasUnsafeNode (node, functionDepth, shadowedBindings, parent, parentKey) {
254
- if (functionDepth === 0 && hasCommonJsDeclaration(node, parent)) return true
255
- if (node.type === 'AssignmentExpression' && mutatesCommonJsBinding(node.left, shadowedBindings)) return true
256
- if (node.type === 'UpdateExpression' && mutatesCommonJsBinding(node.argument, shadowedBindings)) return true
257
- if ((node.type === 'ForInStatement' || node.type === 'ForOfStatement') &&
258
- mutatesCommonJsBinding(node.left, shadowedBindings)) return true
259
- if (node.type === 'CallExpression' && node.callee?.type === 'Identifier' && node.callee.name === 'eval') return true
260
- if (!(shadowedBindings & ARGUMENTS_BINDING) && node.type === 'Identifier' && node.name === 'arguments' &&
261
- isReferencedIdentifier(parent, parentKey)) return true
262
-
263
- const nestedFunction = node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' ||
264
- node.type === 'FunctionExpression'
265
- if (nestedFunction) {
266
- functionDepth++
267
- shadowedBindings |= getFunctionBindings(node)
268
- }
269
- shadowedBindings |= getLexicalBindings(node)
270
-
271
- for (const key of Object.keys(node)) {
272
- if ((node.type === 'VariableDeclarator' && key === 'id') ||
273
- (node.type === 'CatchClause' && key === 'param')) continue
274
- const value = node[key]
275
- if (Array.isArray(value)) {
276
- for (const child of value) {
277
- if (child?.type && hasUnsafeNode(child, functionDepth, shadowedBindings, node, key)) return true
278
- }
279
- } else if (value?.type && hasUnsafeNode(value, functionDepth, shadowedBindings, node, key)) {
280
- return true
281
- }
282
- }
283
- return false
284
- }
285
-
286
- /**
287
- * @param {object} node
288
- * @param {object} [parent]
289
- */
290
- function hasCommonJsDeclaration (node, parent) {
291
- if (node.type === 'VariableDeclarator') {
292
- return parent?.kind === 'var' && Boolean(getBindingMask(node.id) & COMMONJS_BINDINGS)
293
- }
294
- if (node.type === 'FunctionDeclaration') {
295
- return Boolean(getBindingMask(node.id) & COMMONJS_BINDINGS)
296
- }
297
- return false
298
- }
299
-
300
- /**
301
- * @param {object} node
302
- * @param {number} shadowedBindings
303
- */
304
- function mutatesCommonJsBinding (node, shadowedBindings) {
305
- return Boolean(getBindingMask(node) & COMMONJS_BINDINGS & ~shadowedBindings)
306
- }
307
-
308
- /**
309
- * @param {object} node
310
- */
311
- function getBindingMask (node) {
312
- if (!node) return 0
313
- if (node.type === 'Identifier') {
314
- if (node.name === 'arguments') return ARGUMENTS_BINDING
315
- if (node.name === 'module') return MODULE_BINDING
316
- return node.name === 'require' ? REQUIRE_BINDING : 0
317
- }
318
- if (node.type === 'AssignmentPattern') return getBindingMask(node.left)
319
- if (node.type === 'RestElement') return getBindingMask(node.argument)
320
- if (node.type === 'ArrayPattern') {
321
- let bindings = 0
322
- for (const element of node.elements) bindings |= getBindingMask(element)
323
- return bindings
324
- }
325
- if (node.type === 'ObjectPattern') {
326
- let bindings = 0
327
- for (const property of node.properties) {
328
- bindings |= getBindingMask(property.type === 'RestElement' ? property.argument : property.value)
329
- }
330
- return bindings
331
- }
332
- return 0
333
- }
334
-
335
- /**
336
- * @param {object} node
337
- */
338
- function getFunctionBindings (node) {
339
- let bindings = node.type === 'ArrowFunctionExpression' ? 0 : ARGUMENTS_BINDING
340
- bindings |= getBindingMask(node.id)
341
- for (const param of node.params) bindings |= getBindingMask(param)
342
- return bindings | getVarBindings(node.body)
343
- }
344
-
345
- /**
346
- * @param {object} node
347
- */
348
- function getVarBindings (node) {
349
- if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' ||
350
- node.type === 'FunctionExpression' || node.type === 'ClassDeclaration' || node.type === 'ClassExpression') return 0
351
-
352
- let bindings = 0
353
- if (node.type === 'VariableDeclaration' && node.kind === 'var') {
354
- for (const declaration of node.declarations) bindings |= getBindingMask(declaration.id)
355
- }
356
- for (const key of Object.keys(node)) {
357
- const value = node[key]
358
- if (Array.isArray(value)) {
359
- for (const child of value) {
360
- if (child?.type) bindings |= getVarBindings(child)
361
- }
362
- } else if (value?.type) {
363
- bindings |= getVarBindings(value)
364
- }
365
- }
366
- return bindings
367
- }
368
-
369
- /**
370
- * @param {object} node
371
- */
372
- function getLexicalBindings (node) {
373
- let bindings = 0
374
- if (node.type === 'BlockStatement') {
375
- for (const statement of node.body) bindings |= getStatementBindings(statement)
376
- } else if (node.type === 'SwitchStatement') {
377
- for (const switchCase of node.cases) {
378
- for (const statement of switchCase.consequent) bindings |= getStatementBindings(statement)
379
- }
380
- } else if (node.type === 'CatchClause') {
381
- bindings = getBindingMask(node.param)
382
- } else if (node.type === 'ForStatement') {
383
- bindings = getLexicalDeclarationBindings(node.init)
384
- } else if (node.type === 'ForInStatement' || node.type === 'ForOfStatement') {
385
- bindings = getLexicalDeclarationBindings(node.left)
386
- } else if (node.type === 'ClassExpression') {
387
- bindings = getBindingMask(node.id)
388
- }
389
- return bindings
390
- }
391
-
392
- /**
393
- * @param {object} node
394
- */
395
- function getStatementBindings (node) {
396
- if (node.type === 'VariableDeclaration') return getLexicalDeclarationBindings(node)
397
- if (node.type === 'FunctionDeclaration' || node.type === 'ClassDeclaration') return getBindingMask(node.id)
398
- return 0
399
- }
400
-
401
- /**
402
- * @param {object} [node]
403
- */
404
- function getLexicalDeclarationBindings (node) {
405
- if (node?.type !== 'VariableDeclaration' || node.kind === 'var') return 0
406
- let bindings = 0
407
- for (const declaration of node.declarations) bindings |= getBindingMask(declaration.id)
408
- return bindings
409
- }
410
-
411
- /**
412
- * @param {object} parent
413
- * @param {string} parentKey
414
- */
415
- function isReferencedIdentifier (parent, parentKey) {
416
- if (parent.type === 'MemberExpression' && parentKey === 'property' && !parent.computed) return false
417
- if ((parent.type === 'Property' || parent.type === 'MethodDefinition' || parent.type === 'PropertyDefinition') &&
418
- parentKey === 'key' && !parent.computed) {
419
- return parent.type === 'Property' && parent.shorthand
420
- }
421
- return parentKey !== 'label'
422
- }
423
-
424
- /**
425
- * @param {string} source
426
- * @param {Array<{ package: string, path: string, version: string }>} payloads
427
- * @param {string} dcModule
428
- */
429
- function appendCommonJsPublications (source, payloads, dcModule) {
430
- let publications = ''
431
- let index = 0
432
- for (const payload of payloads) {
433
- publications += ` const payload${index} = {
434
- module: module.exports,
435
- package: ${JSON.stringify(payload.package)},
436
- path: ${JSON.stringify(payload.path)},
437
- version: ${JSON.stringify(payload.version)},
438
- }
439
- channel.publish(payload${index})
440
- module.exports = payload${index++}.module
441
- `
442
- }
443
-
444
- return `${source}
445
- {
446
- const dc = require(${JSON.stringify(dcModule)})
447
- const channel = dc.channel('${CHANNEL}')
448
- if (channel.hasSubscribers) {
449
- ${publications} }
450
- }
451
- `
452
- }
453
-
454
- /**
455
- * @param {string} source
456
- * @param {{ package: string, path: string, version: string }} payload
457
- * @param {string} dcModule
458
- * @param {boolean} esm
459
- */
460
- function appendActivation (source, payload, dcModule, esm) {
461
- if (esm) {
462
- return `${source}
463
- import ddTraceTurbopackDc from ${JSON.stringify(dcModule)}
464
- {
465
- const channel = ddTraceTurbopackDc.channel('${CHANNEL}')
466
- if (channel.hasSubscribers) channel.publish(${JSON.stringify({ activate: true, ...payload })})
467
- }
468
- `
469
- }
470
-
471
- return `${source}
472
- {
473
- const dc = require(${JSON.stringify(dcModule)})
474
- const channel = dc.channel('${CHANNEL}')
475
- if (channel.hasSubscribers) channel.publish(${JSON.stringify({ activate: true, ...payload })})
476
- }
477
- `
478
- }
479
-
480
- /**
481
- * @param {string} from
482
- * @param {string} to
483
- */
484
- function relativeImport (from, to) {
485
- let value = path.relative(from, to).replaceAll('\\', '/')
486
- if (!value.startsWith('.')) value = `./${value}`
487
- return value
488
- }
@@ -1,13 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const { execSync } = require('node:child_process')
4
3
  const fs = require('node:fs')
5
4
 
6
5
  const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations')
6
+ const { getGitMetadataBanner, isESMFile } = require('../datadog-instrumentations/src/helpers/bundler-utils')
7
7
  const extractPackageAndModulePath = require('../datadog-instrumentations/src/helpers/extract-package-and-module-path')
8
8
  const hooks = require('../datadog-instrumentations/src/helpers/hooks')
9
9
  const { getRewriteTarget } = require('../datadog-instrumentations/src/helpers/rewriter/targets')
10
- const { isESMFile } = require('../datadog-esbuild/src/utils')
11
10
  const { getValueFromEnvSources } = require('../dd-trace/src/config/helper')
12
11
  const log = require('./src/log')
13
12
 
@@ -35,38 +34,6 @@ for (const [name, instrumentation] of Object.entries(instrumentations)) {
35
34
  }
36
35
  }
37
36
 
38
- /**
39
- * @returns {{ repositoryURL: string | null, commitSHA: string | null }}
40
- */
41
- function getGitMetadata () {
42
- const gitMetadata = {
43
- repositoryURL: null,
44
- commitSHA: null,
45
- }
46
-
47
- try {
48
- gitMetadata.repositoryURL = execSync('git config --get remote.origin.url', {
49
- encoding: 'utf8',
50
- stdio: ['pipe', 'pipe', 'ignore'],
51
- cwd: process.cwd(),
52
- }).trim()
53
- } catch (e) {
54
- log.warn('failed to get git repository URL:', e.message)
55
- }
56
-
57
- try {
58
- gitMetadata.commitSHA = execSync('git rev-parse HEAD', {
59
- encoding: 'utf8',
60
- stdio: ['pipe', 'pipe', 'ignore'],
61
- cwd: process.cwd(),
62
- }).trim()
63
- } catch (e) {
64
- log.warn('failed to get git commit SHA:', e.message)
65
- }
66
-
67
- return gitMetadata
68
- }
69
-
70
37
  class DatadogWebpackPlugin {
71
38
  /**
72
39
  * @param {object} compiler
@@ -86,19 +53,8 @@ class DatadogWebpackPlugin {
86
53
 
87
54
  // Bake DD_GIT_* into assets unless DD_BUNDLER_INJECT_GIT_METADATA=false (stable artifact hashes).
88
55
  if (DD_BUNDLER_INJECT_GIT_METADATA) {
89
- const gitMetadata = getGitMetadata()
90
- if (gitMetadata.repositoryURL || gitMetadata.commitSHA) {
91
- const banner =
92
- 'if (typeof process === \'object\' && process !== null &&\n' +
93
- ' process.env !== null && typeof process.env === \'object\') {\n' +
94
- (gitMetadata.repositoryURL
95
- ? ` process.env.DD_GIT_REPOSITORY_URL = ${JSON.stringify(gitMetadata.repositoryURL)};\n`
96
- : '') +
97
- (gitMetadata.commitSHA
98
- ? ` process.env.DD_GIT_COMMIT_SHA = ${JSON.stringify(gitMetadata.commitSHA)};\n`
99
- : '') +
100
- '}\n'
101
-
56
+ const banner = getGitMetadataBanner(log)
57
+ if (banner) {
102
58
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
103
59
  compilation.hooks.processAssets.tap(
104
60
  { name: PLUGIN_NAME, stage: -2000 },
@@ -122,14 +78,6 @@ class DatadogWebpackPlugin {
122
78
  }
123
79
  )
124
80
  })
125
-
126
- log.debug(
127
- 'Automatically injected git metadata (DD_GIT_REPOSITORY_URL: %s, DD_GIT_COMMIT_SHA: %s)',
128
- gitMetadata.repositoryURL || 'not available',
129
- gitMetadata.commitSHA || 'not available'
130
- )
131
- } else {
132
- log.warn('No git metadata available - skipping injection')
133
81
  }
134
82
  } else {
135
83
  log.debug('Skipping git metadata injection (DD_BUNDLER_INJECT_GIT_METADATA=false)')
@@ -18,6 +18,7 @@ const clone = createRfdc({ proto: false, circles: false })
18
18
  const { USER_ID, USER_SESSION_ID } = require('../appsec/addresses')
19
19
  const { getActiveRequest } = require('../appsec/store')
20
20
  const { ERROR_MESSAGE, ERROR_STACK, ERROR_TYPE, PROCESS_ID, SAMPLING_PRIORITY_KEY } = require('../constants')
21
+ const { MAX_META_KEY_LENGTH, MAX_META_VALUE_LENGTH } = require('../encode/tags-processors')
21
22
  const log = require('../log')
22
23
  const { keepTrace } = require('../priority_sampler')
23
24
  const { extractIp } = require('../plugins/util/ip_extractor')
@@ -82,6 +83,8 @@ const ALLOW = 'ALLOW'
82
83
  * @property {{ source: string, integration: string }} telemetryTags
83
84
  */
84
85
 
86
+ /** @typedef {{ [key: string]: string | number | boolean }} CustomTags */
87
+
85
88
  /**
86
89
  * Returns whether a value is a non-array object.
87
90
  *
@@ -124,6 +127,62 @@ function normalizeExtraEntries (field, entries) {
124
127
  return normalized.length === 0 ? NO_EXTRA_ENTRIES : normalized
125
128
  }
126
129
 
130
+ /**
131
+ * Returns whether a custom tag entry can be set on the AI Guard span.
132
+ *
133
+ * Only primitive values are accepted because the span flattens nested objects into dotted keys,
134
+ * which could otherwise smuggle reserved ai_guard.* keys in through a non-reserved parent key.
135
+ * Entries above the agent meta limits are dropped rather than truncated. The limits are checked in
136
+ * characters (UTF-16 code units), so the agent may still truncate values with multi-byte characters.
137
+ * A non-string service.name is dropped because the span formatter calls string methods on it when
138
+ * the trace is exported, after this function can catch the error.
139
+ *
140
+ * @param {string} key
141
+ * @param {unknown} value
142
+ */
143
+ function isValidCustomTag (key, value) {
144
+ if (
145
+ key.length === 0 ||
146
+ key.length > MAX_META_KEY_LENGTH ||
147
+ key === TAGS.RESERVED_TAG_KEY ||
148
+ key.startsWith(TAGS.RESERVED_TAG_PREFIX)
149
+ ) {
150
+ return false
151
+ }
152
+
153
+ if (typeof value === 'string') {
154
+ return value.length <= MAX_META_VALUE_LENGTH
155
+ }
156
+
157
+ if (key === SERVICE_NAME) return false
158
+
159
+ return typeof value === 'boolean' || Number.isFinite(value)
160
+ }
161
+
162
+ /**
163
+ * Sets caller-provided tags on the AI Guard span, dropping invalid or reserved entries.
164
+ *
165
+ * Must run after the service entry tags are copied: when the AI Guard span is the trace root, a
166
+ * custom usr.id or http.client_ip would otherwise be copied into the reserved ai_guard.* keys.
167
+ * Must also run before the verdict tags set in finish(): some of them are only set conditionally,
168
+ * and filtering reserved keys here is what keeps a caller value from misreporting the verdict.
169
+ *
170
+ * @param {Span} span
171
+ * @param {unknown} tags
172
+ */
173
+ function setCustomTags (span, tags) {
174
+ if (!isRecord(tags)) return
175
+
176
+ for (const key of Object.keys(tags)) {
177
+ const value = tags[key]
178
+ if (isValidCustomTag(key, value)) {
179
+ span.setTag(key, value)
180
+ } else {
181
+ log.debug('AIGuard: dropping invalid custom tag %s', key)
182
+ }
183
+ }
184
+ }
185
+
127
186
  /**
128
187
  * Parses the backend evaluation response into the tracer's internal contract.
129
188
  *
@@ -309,7 +368,7 @@ class EvaluationReporter {
309
368
  *
310
369
  * @param {Span} span
311
370
  * @param {Message[]} messages
312
- * @param {{ source: string, integration: string }} options
371
+ * @param {{ source: string, integration: string, tags?: CustomTags }} options
313
372
  * @returns {EvaluationReport}
314
373
  */
315
374
  start (span, messages, options) {
@@ -339,6 +398,8 @@ class EvaluationReporter {
339
398
  rootSpan.setTag(TAGS.EVENT_TAG_KEY, 'true')
340
399
  }
341
400
 
401
+ if (options.tags !== undefined) setCustomTags(span, options.tags)
402
+
342
403
  return {
343
404
  span,
344
405
  messages: evaluatedMessages,
@@ -28,12 +28,18 @@ class AIGuard extends NoopAIGuard {
28
28
  }
29
29
 
30
30
  evaluate (messages, opts) {
31
- const { block = true, source = TAGS.SOURCE_SDK, integration = TAGS.INTEGRATION_NONE, childOf } = opts ?? {}
31
+ const {
32
+ block = true,
33
+ source = TAGS.SOURCE_SDK,
34
+ integration = TAGS.INTEGRATION_NONE,
35
+ childOf,
36
+ tags: customTags,
37
+ } = opts ?? {}
32
38
  // Only pass `childOf` when truthy so `tracer.trace`'s default (`scope().active()`)
33
39
  // still applies for SDK callers that don't supply an explicit parent.
34
40
  const traceOpts = childOf ? { childOf } : {}
35
41
  return this.#tracer.trace(TAGS.RESOURCE, traceOpts, async (span) => {
36
- const report = this.#reporter.start(span, messages, { source, integration })
42
+ const report = this.#reporter.start(span, messages, { source, integration, tags: customTags })
37
43
  let evaluation
38
44
  try {
39
45
  evaluation = await this.#client.evaluate(report.messages, this.#meta)