@datadog/datadog-ci 3.3.1 → 3.5.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 (403) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/cloud-run/flare.js +14 -14
  4. package/dist/commands/cloud-run/flare.js.map +1 -1
  5. package/dist/commands/coverage/renderer.js +2 -2
  6. package/dist/commands/coverage/renderer.js.map +1 -1
  7. package/dist/commands/coverage/upload.js +10 -11
  8. package/dist/commands/coverage/upload.js.map +1 -1
  9. package/dist/commands/coverage/utils.js +2 -2
  10. package/dist/commands/coverage/utils.js.map +1 -1
  11. package/dist/commands/dsyms/renderer.js +3 -3
  12. package/dist/commands/dsyms/renderer.js.map +1 -1
  13. package/dist/commands/dsyms/upload.js +9 -9
  14. package/dist/commands/dsyms/upload.js.map +1 -1
  15. package/dist/commands/dsyms/utils.js +4 -4
  16. package/dist/commands/dsyms/utils.js.map +1 -1
  17. package/dist/commands/elf-symbols/upload.js +4 -4
  18. package/dist/commands/elf-symbols/upload.js.map +1 -1
  19. package/dist/commands/flutter-symbols/helpers.js +5 -25
  20. package/dist/commands/flutter-symbols/helpers.js.map +1 -1
  21. package/dist/commands/flutter-symbols/upload.js +2 -2
  22. package/dist/commands/flutter-symbols/upload.js.map +1 -1
  23. package/dist/commands/git-metadata/gitdb.js +4 -4
  24. package/dist/commands/git-metadata/gitdb.js.map +1 -1
  25. package/dist/commands/junit/api.js +2 -2
  26. package/dist/commands/junit/api.js.map +1 -1
  27. package/dist/commands/junit/renderer.js +2 -2
  28. package/dist/commands/junit/renderer.js.map +1 -1
  29. package/dist/commands/junit/upload.js +7 -7
  30. package/dist/commands/junit/upload.js.map +1 -1
  31. package/dist/commands/lambda/constants.d.ts +3 -0
  32. package/dist/commands/lambda/constants.js +5 -2
  33. package/dist/commands/lambda/constants.js.map +1 -1
  34. package/dist/commands/lambda/flare.js +18 -18
  35. package/dist/commands/lambda/flare.js.map +1 -1
  36. package/dist/commands/lambda/functions/instrument.js +10 -0
  37. package/dist/commands/lambda/functions/instrument.js.map +1 -1
  38. package/dist/commands/lambda/functions/uninstrument.js +3 -0
  39. package/dist/commands/lambda/functions/uninstrument.js.map +1 -1
  40. package/dist/commands/lambda/instrument.d.ts +1 -0
  41. package/dist/commands/lambda/instrument.js +5 -2
  42. package/dist/commands/lambda/instrument.js.map +1 -1
  43. package/dist/commands/lambda/interfaces.d.ts +3 -0
  44. package/dist/commands/pe-symbols/upload.js +2 -3
  45. package/dist/commands/pe-symbols/upload.js.map +1 -1
  46. package/dist/commands/react-native/codepush.js +7 -2
  47. package/dist/commands/react-native/codepush.js.map +1 -1
  48. package/dist/commands/react-native/utils.d.ts +1 -0
  49. package/dist/commands/react-native/utils.js +5 -1
  50. package/dist/commands/react-native/utils.js.map +1 -1
  51. package/dist/commands/react-native/xcode.js +1 -2
  52. package/dist/commands/react-native/xcode.js.map +1 -1
  53. package/dist/commands/sarif/renderer.js +3 -3
  54. package/dist/commands/sarif/renderer.js.map +1 -1
  55. package/dist/commands/sarif/upload.js +5 -6
  56. package/dist/commands/sarif/upload.js.map +1 -1
  57. package/dist/commands/sbom/constants.d.ts +1 -0
  58. package/dist/commands/sbom/constants.js +2 -1
  59. package/dist/commands/sbom/constants.js.map +1 -1
  60. package/dist/commands/sbom/payload.js +66 -0
  61. package/dist/commands/sbom/payload.js.map +1 -1
  62. package/dist/commands/sbom/types.d.ts +13 -0
  63. package/dist/commands/sourcemaps/upload.js +4 -5
  64. package/dist/commands/sourcemaps/upload.js.map +1 -1
  65. package/dist/commands/sourcemaps/utils.js +2 -2
  66. package/dist/commands/sourcemaps/utils.js.map +1 -1
  67. package/dist/commands/span/cli.js +5 -0
  68. package/dist/commands/span/cli.js.map +1 -0
  69. package/dist/commands/span/span.d.ts +10 -0
  70. package/dist/commands/span/span.js +112 -0
  71. package/dist/commands/span/span.js.map +1 -0
  72. package/dist/commands/synthetics/api.d.ts +1 -1
  73. package/dist/commands/synthetics/api.js +40 -12
  74. package/dist/commands/synthetics/api.js.map +1 -1
  75. package/dist/commands/synthetics/batch.js +12 -11
  76. package/dist/commands/synthetics/batch.js.map +1 -1
  77. package/dist/commands/synthetics/build-and-test.d.ts +20 -3
  78. package/dist/commands/synthetics/build-and-test.js +157 -63
  79. package/dist/commands/synthetics/build-and-test.js.map +1 -1
  80. package/dist/commands/synthetics/interfaces.d.ts +71 -35
  81. package/dist/commands/synthetics/interfaces.js.map +1 -1
  82. package/dist/commands/synthetics/multilocator.js +2 -2
  83. package/dist/commands/synthetics/multilocator.js.map +1 -1
  84. package/dist/commands/synthetics/reporters/default.js +10 -9
  85. package/dist/commands/synthetics/reporters/default.js.map +1 -1
  86. package/dist/commands/synthetics/reporters/junit.js +74 -63
  87. package/dist/commands/synthetics/reporters/junit.js.map +1 -1
  88. package/dist/commands/synthetics/run-tests-command.js +5 -2
  89. package/dist/commands/synthetics/run-tests-command.js.map +1 -1
  90. package/dist/commands/synthetics/test.d.ts +2 -2
  91. package/dist/commands/synthetics/utils/internal.d.ts +3 -5
  92. package/dist/commands/synthetics/utils/internal.js +2 -17
  93. package/dist/commands/synthetics/utils/internal.js.map +1 -1
  94. package/dist/commands/synthetics/utils/public.d.ts +4 -4
  95. package/dist/commands/synthetics/utils/public.js +22 -11
  96. package/dist/commands/synthetics/utils/public.js.map +1 -1
  97. package/dist/commands/trace/helper.d.ts +16 -0
  98. package/dist/commands/trace/helper.js +123 -0
  99. package/dist/commands/trace/helper.js.map +1 -0
  100. package/dist/commands/trace/test-utils.d.ts +4 -0
  101. package/dist/commands/trace/{__tests__/trace.test.js → test-utils.js} +15 -41
  102. package/dist/commands/trace/test-utils.js.map +1 -0
  103. package/dist/commands/trace/trace.d.ts +2 -12
  104. package/dist/commands/trace/trace.js +14 -93
  105. package/dist/commands/trace/trace.js.map +1 -1
  106. package/dist/commands/unity-symbols/upload.js +7 -7
  107. package/dist/commands/unity-symbols/upload.js.map +1 -1
  108. package/dist/helpers/file-finder.js +3 -3
  109. package/dist/helpers/file-finder.js.map +1 -1
  110. package/dist/helpers/flare.js +6 -5
  111. package/dist/helpers/flare.js.map +1 -1
  112. package/dist/helpers/fs.js +3 -3
  113. package/dist/helpers/fs.js.map +1 -1
  114. package/dist/helpers/glob.d.ts +12 -0
  115. package/dist/helpers/glob.js +70 -0
  116. package/dist/helpers/glob.js.map +1 -0
  117. package/dist/helpers/interfaces.d.ts +5 -6
  118. package/dist/helpers/renderer.js +3 -3
  119. package/dist/helpers/renderer.js.map +1 -1
  120. package/dist/helpers/tags.js +3 -3
  121. package/dist/helpers/tags.js.map +1 -1
  122. package/dist/helpers/utils.d.ts +0 -1
  123. package/dist/helpers/utils.js +1 -12
  124. package/dist/helpers/utils.js.map +1 -1
  125. package/package.json +6 -5
  126. package/dist/__tests__/cli.test.js +0 -93
  127. package/dist/__tests__/cli.test.js.map +0 -1
  128. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
  129. package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
  130. package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
  131. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
  132. package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
  133. package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
  134. package/dist/commands/coverage/__tests__/upload.test.d.ts +0 -1
  135. package/dist/commands/coverage/__tests__/upload.test.js +0 -291
  136. package/dist/commands/coverage/__tests__/upload.test.js.map +0 -1
  137. package/dist/commands/coverage/__tests__/utils.test.d.ts +0 -1
  138. package/dist/commands/coverage/__tests__/utils.test.js +0 -47
  139. package/dist/commands/coverage/__tests__/utils.test.js.map +0 -1
  140. package/dist/commands/deployment/__tests__/correlate.test.d.ts +0 -1
  141. package/dist/commands/deployment/__tests__/correlate.test.js +0 -106
  142. package/dist/commands/deployment/__tests__/correlate.test.js.map +0 -1
  143. package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
  144. package/dist/commands/deployment/__tests__/mark.test.js +0 -97
  145. package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
  146. package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
  147. package/dist/commands/dora/__tests__/deployment.test.js +0 -203
  148. package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
  149. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  150. package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
  151. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  152. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  153. package/dist/commands/dsyms/__tests__/utils.test.js +0 -100
  154. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  155. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
  156. package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -822
  157. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
  158. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
  159. package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -228
  160. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
  161. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  162. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
  163. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  164. package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
  165. package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
  166. package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
  167. package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
  168. package/dist/commands/gate/__tests__/scope.test.js +0 -29
  169. package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
  170. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  171. package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
  172. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  173. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
  174. package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
  175. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
  176. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  177. package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
  178. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  179. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  180. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
  181. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  182. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  183. package/dist/commands/junit/__tests__/upload.test.js +0 -495
  184. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  185. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
  186. package/dist/commands/lambda/__tests__/fixtures.js +0 -146
  187. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  188. package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
  189. package/dist/commands/lambda/__tests__/flare.test.js +0 -730
  190. package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
  191. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  192. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
  193. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  194. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  195. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -386
  196. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  197. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  198. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -728
  199. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  200. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  201. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -513
  202. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  203. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  204. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  205. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  206. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  207. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1599
  208. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  209. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  210. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
  211. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  212. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  213. package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
  214. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  215. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  216. package/dist/commands/lambda/__tests__/tags.test.js +0 -305
  217. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  218. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  219. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -722
  220. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  221. package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
  222. package/dist/commands/measure/__tests__/measure.test.js +0 -102
  223. package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
  224. package/dist/commands/pe-symbols/__tests__/pe.test.d.ts +0 -1
  225. package/dist/commands/pe-symbols/__tests__/pe.test.js +0 -81
  226. package/dist/commands/pe-symbols/__tests__/pe.test.js.map +0 -1
  227. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  228. package/dist/commands/react-native/__tests__/codepush.test.js +0 -161
  229. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  230. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  231. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
  232. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  233. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  234. package/dist/commands/react-native/__tests__/upload.test.js +0 -238
  235. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  236. package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
  237. package/dist/commands/react-native/__tests__/utils.test.js +0 -27
  238. package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
  239. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  240. package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
  241. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  242. package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
  243. package/dist/commands/sarif/__tests__/upload.test.js +0 -291
  244. package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
  245. package/dist/commands/sarif/__tests__/utils.test.d.ts +0 -1
  246. package/dist/commands/sarif/__tests__/utils.test.js +0 -26
  247. package/dist/commands/sarif/__tests__/utils.test.js.map +0 -1
  248. package/dist/commands/sarif/__tests__/validation.test.d.ts +0 -1
  249. package/dist/commands/sarif/__tests__/validation.test.js +0 -19
  250. package/dist/commands/sarif/__tests__/validation.test.js.map +0 -1
  251. package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
  252. package/dist/commands/sbom/__tests__/payload.test.js +0 -436
  253. package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
  254. package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
  255. package/dist/commands/sbom/__tests__/validation.test.js +0 -141
  256. package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
  257. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  258. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  259. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  260. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  261. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  262. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  263. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
  264. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -210
  265. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
  266. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
  267. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
  268. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
  269. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
  270. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
  271. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
  272. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
  273. package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -501
  274. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
  275. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
  276. package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
  277. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
  278. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
  279. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
  280. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
  281. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  282. package/dist/commands/synthetics/__tests__/api.test.js +0 -416
  283. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  284. package/dist/commands/synthetics/__tests__/batch.test.d.ts +0 -1
  285. package/dist/commands/synthetics/__tests__/batch.test.js +0 -907
  286. package/dist/commands/synthetics/__tests__/batch.test.js.map +0 -1
  287. package/dist/commands/synthetics/__tests__/build-and-test.test.d.ts +0 -1
  288. package/dist/commands/synthetics/__tests__/build-and-test.test.js +0 -133
  289. package/dist/commands/synthetics/__tests__/build-and-test.test.js.map +0 -1
  290. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  291. package/dist/commands/synthetics/__tests__/cli.test.js +0 -1407
  292. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  293. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.d.ts +0 -1
  294. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js +0 -112
  295. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js.map +0 -1
  296. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -123
  297. package/dist/commands/synthetics/__tests__/fixtures.js +0 -493
  298. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  299. package/dist/commands/synthetics/__tests__/import-tests-lib.test.d.ts +0 -1
  300. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js +0 -186
  301. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js.map +0 -1
  302. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  303. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
  304. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  305. package/dist/commands/synthetics/__tests__/multilocator.test.d.ts +0 -1
  306. package/dist/commands/synthetics/__tests__/multilocator.test.js +0 -142
  307. package/dist/commands/synthetics/__tests__/multilocator.test.js.map +0 -1
  308. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  309. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -410
  310. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  311. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  312. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -354
  313. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  314. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
  315. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
  316. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
  317. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
  318. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -698
  319. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
  320. package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
  321. package/dist/commands/synthetics/__tests__/test.test.js +0 -268
  322. package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
  323. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  324. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  325. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  326. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  327. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  328. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  329. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  330. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
  331. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  332. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
  333. package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -161
  334. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
  335. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
  336. package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -576
  337. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
  338. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  339. package/dist/commands/tag/__tests__/tag.test.js +0 -85
  340. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  341. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  342. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  343. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
  344. package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
  345. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
  346. package/dist/helpers/__tests__/app.test.d.ts +0 -1
  347. package/dist/helpers/__tests__/app.test.js +0 -31
  348. package/dist/helpers/__tests__/app.test.js.map +0 -1
  349. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  350. package/dist/helpers/__tests__/ci.test.js +0 -344
  351. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  352. package/dist/helpers/__tests__/env.test.d.ts +0 -1
  353. package/dist/helpers/__tests__/env.test.js +0 -74
  354. package/dist/helpers/__tests__/env.test.js.map +0 -1
  355. package/dist/helpers/__tests__/fips.test.d.ts +0 -1
  356. package/dist/helpers/__tests__/fips.test.js +0 -30
  357. package/dist/helpers/__tests__/fips.test.js.map +0 -1
  358. package/dist/helpers/__tests__/fixtures.d.ts +0 -41
  359. package/dist/helpers/__tests__/fixtures.js +0 -80
  360. package/dist/helpers/__tests__/fixtures.js.map +0 -1
  361. package/dist/helpers/__tests__/flare.test.d.ts +0 -1
  362. package/dist/helpers/__tests__/flare.test.js +0 -226
  363. package/dist/helpers/__tests__/flare.test.js.map +0 -1
  364. package/dist/helpers/__tests__/fs.test.d.ts +0 -1
  365. package/dist/helpers/__tests__/fs.test.js +0 -189
  366. package/dist/helpers/__tests__/fs.test.js.map +0 -1
  367. package/dist/helpers/__tests__/id.test.d.ts +0 -1
  368. package/dist/helpers/__tests__/id.test.js +0 -24
  369. package/dist/helpers/__tests__/id.test.js.map +0 -1
  370. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  371. package/dist/helpers/__tests__/plist.test.js +0 -43
  372. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  373. package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
  374. package/dist/helpers/__tests__/prompt.test.js +0 -71
  375. package/dist/helpers/__tests__/prompt.test.js.map +0 -1
  376. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  377. package/dist/helpers/__tests__/retry.test.js +0 -99
  378. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  379. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  380. package/dist/helpers/__tests__/tags.test.js +0 -362
  381. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  382. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  383. package/dist/helpers/__tests__/upload.test.js +0 -231
  384. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  385. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  386. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  387. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  388. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  389. package/dist/helpers/__tests__/utils.test.js +0 -429
  390. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  391. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  392. package/dist/helpers/__tests__/validation.test.js +0 -25
  393. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  394. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  395. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
  396. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  397. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  398. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
  399. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  400. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  401. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
  402. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
  403. /package/dist/{__tests__/cli.test.d.ts → commands/span/cli.d.ts} +0 -0
@@ -1,1599 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- jest.mock('fs');
36
- jest.mock('@aws-sdk/credential-providers', () => (Object.assign(Object.assign({}, jest.requireActual('@aws-sdk/credential-providers')), { fromIni: jest.fn() })));
37
- jest.mock('../prompt');
38
- jest.mock('../renderers/instrument-uninstrument-renderer');
39
- jest.mock('../../../helpers/prompt');
40
- jest.mock('../../../../package.json', () => ({ version: 'XXXX' }));
41
- const fs = __importStar(require("fs"));
42
- const client_lambda_1 = require("@aws-sdk/client-lambda");
43
- const credential_providers_1 = require("@aws-sdk/credential-providers");
44
- const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
45
- require("aws-sdk-client-mock-jest");
46
- const advanced_1 = require("clipanion/lib/advanced");
47
- const constants_1 = require("../../../constants");
48
- const fixtures_1 = require("../../../helpers/__tests__/fixtures");
49
- const prompt_1 = require("../../../helpers/prompt");
50
- const constants_2 = require("../constants");
51
- const instrument_1 = require("../instrument");
52
- const prompt_2 = require("../prompt");
53
- const fixtures_2 = require("./fixtures");
54
- describe('lambda', () => {
55
- const lambdaClientMock = (0, aws_sdk_client_mock_1.mockClient)(client_lambda_1.LambdaClient);
56
- describe('instrument', () => {
57
- describe('execute', () => {
58
- const OLD_ENV = process.env;
59
- beforeEach(() => {
60
- lambdaClientMock.reset();
61
- jest.resetModules();
62
- process.env = {};
63
- (0, fixtures_2.mockLambdaClientCommands)(lambdaClientMock);
64
- });
65
- afterAll(() => {
66
- process.env = OLD_ENV;
67
- });
68
- test('prints dry run data for lambda library layer', () => __awaiter(void 0, void 0, void 0, function* () {
69
- ;
70
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
71
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
72
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
73
- config: {
74
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
75
- Handler: 'index.handler',
76
- Runtime: 'nodejs22.x',
77
- },
78
- },
79
- });
80
- const cli = (0, fixtures_2.makeCli)();
81
- const context = (0, fixtures_1.createMockContext)();
82
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
83
- const code = yield cli.run([
84
- 'lambda',
85
- 'instrument',
86
- '-f',
87
- functionARN,
88
- '--dry-run',
89
- '--layerVersion',
90
- '10',
91
- '--logLevel',
92
- 'debug',
93
- '--service',
94
- 'middletier',
95
- '--env',
96
- 'staging',
97
- '--version',
98
- '0.2',
99
- '--extra-tags',
100
- 'layer:api,team:intake',
101
- '--no-source-code-integration',
102
- ], context);
103
- const output = context.stdout.toString();
104
- expect(code).toBe(0);
105
- expect(output).toMatchSnapshot();
106
- }));
107
- test('prints dry run data for lambda library and extension layers using kebab case args', () => __awaiter(void 0, void 0, void 0, function* () {
108
- ;
109
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
110
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
111
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
112
- config: {
113
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
114
- Handler: 'index.handler',
115
- Runtime: 'nodejs22.x',
116
- },
117
- },
118
- });
119
- const cli = (0, fixtures_2.makeCli)();
120
- const context = (0, fixtures_1.createMockContext)();
121
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
122
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
123
- const code = yield cli.run([
124
- 'lambda',
125
- 'instrument',
126
- '-f',
127
- functionARN,
128
- '--dry-run',
129
- '--service',
130
- 'middletier',
131
- '--env',
132
- 'staging',
133
- '--version',
134
- '0.2',
135
- '--extra-tags',
136
- 'layer:api,team:intake',
137
- '--layer-version',
138
- '10',
139
- '--extension-version',
140
- '5',
141
- '--merge-xray-traces',
142
- 'true',
143
- '--flush-metrics-to-logs',
144
- 'false',
145
- '--log-level',
146
- 'debug',
147
- '--no-source-code-integration',
148
- ], context);
149
- const output = context.stdout.toString();
150
- expect(code).toBe(0);
151
- expect(output).toMatchSnapshot();
152
- }));
153
- test('prints dry run data for lambda extension layer', () => __awaiter(void 0, void 0, void 0, function* () {
154
- ;
155
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
156
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
157
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
158
- config: {
159
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
160
- Handler: 'index.handler',
161
- Runtime: 'nodejs22.x',
162
- },
163
- },
164
- });
165
- const cli = (0, fixtures_2.makeCli)();
166
- const context = (0, fixtures_1.createMockContext)();
167
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
168
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
169
- const code = yield cli.run([
170
- 'lambda',
171
- 'instrument',
172
- '-f',
173
- functionARN,
174
- '--dry-run',
175
- '--extensionVersion',
176
- '6',
177
- '--service',
178
- 'middletier',
179
- '--env',
180
- 'staging',
181
- '--version',
182
- '0.2',
183
- '--extra-tags',
184
- 'layer:api,team:intake',
185
- '--no-source-code-integration',
186
- ], context);
187
- const output = context.stdout.toString();
188
- expect(code).toBe(0);
189
- expect(output).toMatchSnapshot();
190
- }));
191
- test('prints dry run data for lambda .NET layer', () => __awaiter(void 0, void 0, void 0, function* () {
192
- ;
193
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
194
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
195
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
196
- config: {
197
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
198
- Runtime: 'dotnet8',
199
- },
200
- },
201
- });
202
- const cli = (0, fixtures_2.makeCli)();
203
- const context = (0, fixtures_1.createMockContext)();
204
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
205
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
206
- const code = yield cli.run([
207
- 'lambda',
208
- 'instrument',
209
- '-f',
210
- functionARN,
211
- '--dry-run',
212
- '-v',
213
- '129',
214
- '--extra-tags',
215
- 'layer:api,team:intake',
216
- '--service',
217
- 'middletier',
218
- '--env',
219
- 'staging',
220
- '--version',
221
- '0.2',
222
- '--no-source-code-integration',
223
- ], context);
224
- const output = context.stdout.toString();
225
- expect(code).toBe(0);
226
- expect(output).toMatchSnapshot();
227
- }));
228
- test('instrumenting with source code integrations fails if not run within a git repo', () => __awaiter(void 0, void 0, void 0, function* () {
229
- ;
230
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
231
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
232
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
233
- config: {
234
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
235
- Handler: 'index.handler',
236
- Runtime: 'nodejs22.x',
237
- },
238
- },
239
- });
240
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
241
- const cli = (0, fixtures_2.makeCli)();
242
- const context = (0, fixtures_1.createMockContext)();
243
- yield cli.run([
244
- 'lambda',
245
- 'instrument',
246
- '--function',
247
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
248
- '--layerVersion',
249
- '10',
250
- '-s',
251
- '--service',
252
- 'dummy',
253
- '--env',
254
- 'dummy',
255
- '--version',
256
- '0.1',
257
- ], context);
258
- const output = context.stdout.toString();
259
- expect(output.replace('\n', '')).toMatch(/.*Error: Couldn't get local git status.*/);
260
- }));
261
- test('ensure the instrument command ran from a dirty git repo fails', () => __awaiter(void 0, void 0, void 0, function* () {
262
- ;
263
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
264
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
265
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
266
- config: {
267
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
268
- Handler: 'index.handler',
269
- Runtime: 'nodejs22.x',
270
- },
271
- },
272
- });
273
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
274
- const context = (0, fixtures_1.createMockContext)();
275
- const instrumentCommand = instrument_1.InstrumentCommand;
276
- const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
277
- mockGitStatus.mockImplementation(() => ({
278
- ahead: 0,
279
- isClean: false,
280
- }));
281
- const cli = new advanced_1.Cli();
282
- cli.register(instrumentCommand);
283
- yield cli.run([
284
- 'lambda',
285
- 'instrument',
286
- '--function',
287
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
288
- '--layerVersion',
289
- '10',
290
- '-s',
291
- '--service',
292
- 'dummy',
293
- '--env',
294
- 'dummy',
295
- '--version',
296
- '0.1',
297
- ], context);
298
- const output = context.stdout.toString();
299
- expect(output).toMatch('Error: Local git repository is dirty');
300
- }));
301
- test('ensure source code integration flag works from a clean repo', () => __awaiter(void 0, void 0, void 0, function* () {
302
- ;
303
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
304
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
305
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
306
- config: {
307
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
308
- Handler: 'index.handler',
309
- Runtime: 'nodejs22.x',
310
- },
311
- },
312
- });
313
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
314
- const context = (0, fixtures_1.createMockContext)();
315
- const instrumentCommand = instrument_1.InstrumentCommand;
316
- const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
317
- mockGitStatus.mockImplementation(() => ({
318
- ahead: 0,
319
- hash: '1be168ff837f043bde17c0314341c84271047b31',
320
- remote: 'git.repository_url:git@github.com:datadog/test.git',
321
- isClean: true,
322
- }));
323
- const mockUploadFunction = jest.spyOn(instrumentCommand.prototype, 'uploadGitData');
324
- mockUploadFunction.mockImplementation(() => {
325
- return;
326
- });
327
- const cli = new advanced_1.Cli();
328
- cli.register(instrumentCommand);
329
- yield cli.run([
330
- 'lambda',
331
- 'instrument',
332
- '--function',
333
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
334
- '--layerVersion',
335
- '10',
336
- '-s',
337
- '--service',
338
- 'dummy',
339
- '--env',
340
- 'dummy',
341
- '--version',
342
- '0.1',
343
- ], context);
344
- const output = context.stdout.toString();
345
- expect(output).toMatchSnapshot();
346
- expect(mockUploadFunction).toHaveBeenCalledTimes(1);
347
- }));
348
- test('ensure no git metadata upload flag works', () => __awaiter(void 0, void 0, void 0, function* () {
349
- ;
350
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
351
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
352
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
353
- config: {
354
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
355
- Handler: 'index.handler',
356
- Runtime: 'nodejs22.x',
357
- },
358
- },
359
- });
360
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
361
- const context = (0, fixtures_1.createMockContext)();
362
- const instrumentCommand = instrument_1.InstrumentCommand;
363
- const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
364
- mockGitStatus.mockImplementation(() => ({
365
- ahead: 0,
366
- hash: '1be168ff837f043bde17c0314341c84271047b31',
367
- remote: 'git.repository_url:git@github.com:datadog/test.git',
368
- isClean: true,
369
- }));
370
- const mockUploadFunction = jest.spyOn(instrumentCommand.prototype, 'uploadGitData');
371
- mockUploadFunction.mockImplementation(() => {
372
- return;
373
- });
374
- const cli = new advanced_1.Cli();
375
- cli.register(instrumentCommand);
376
- yield cli.run([
377
- 'lambda',
378
- 'instrument',
379
- '--function',
380
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
381
- '--layerVersion',
382
- '10',
383
- '--no-upload-git-metadata',
384
- '--service',
385
- 'dummy',
386
- '--env',
387
- 'dummy',
388
- '--version',
389
- '0.1',
390
- ], context);
391
- const output = context.stdout.toString();
392
- expect(mockUploadFunction).toHaveBeenCalledTimes(0);
393
- expect(output).toMatchSnapshot();
394
- }));
395
- test('ensure the instrument command ran from a local git repo ahead of the origin fails', () => __awaiter(void 0, void 0, void 0, function* () {
396
- ;
397
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
398
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
399
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
400
- config: {
401
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
402
- Handler: 'index.handler',
403
- Runtime: 'nodejs22.x',
404
- },
405
- },
406
- });
407
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
408
- const context = (0, fixtures_1.createMockContext)();
409
- const instrumentCommand = instrument_1.InstrumentCommand;
410
- const mockGitStatus = jest.spyOn(instrumentCommand.prototype, 'getCurrentGitStatus');
411
- mockGitStatus.mockImplementation(() => ({
412
- ahead: 1,
413
- isClean: true,
414
- }));
415
- const cli = new advanced_1.Cli();
416
- cli.register(instrumentCommand);
417
- yield cli.run([
418
- 'lambda',
419
- 'instrument',
420
- '--function',
421
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
422
- '--layerVersion',
423
- '10',
424
- '-s',
425
- '--service',
426
- 'dummy',
427
- '--env',
428
- 'dummy',
429
- '--version',
430
- '0.1',
431
- ], context);
432
- const output = context.stdout.toString();
433
- expect(output).toMatch('Error: Local changes have not been pushed remotely. Aborting git data tagging.');
434
- }));
435
- test('runs function update command for lambda library layer', () => __awaiter(void 0, void 0, void 0, function* () {
436
- ;
437
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
438
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
439
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
440
- config: {
441
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
442
- Handler: 'index.handler',
443
- Runtime: 'nodejs22.x',
444
- },
445
- },
446
- });
447
- const cli = (0, fixtures_2.makeCli)();
448
- const context = (0, fixtures_1.createMockContext)();
449
- yield cli.run([
450
- 'lambda',
451
- 'instrument',
452
- '--function',
453
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
454
- '--layerVersion',
455
- '10',
456
- '--no-source-code-integration',
457
- ], context);
458
- expect(lambdaClientMock).toHaveReceivedCommand(client_lambda_1.UpdateFunctionConfigurationCommand);
459
- }));
460
- test('runs function update command for lambda extension layer', () => __awaiter(void 0, void 0, void 0, function* () {
461
- ;
462
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
463
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
464
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
465
- config: {
466
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
467
- Handler: 'index.handler',
468
- Runtime: 'nodejs22.x',
469
- },
470
- },
471
- });
472
- const cli = (0, fixtures_2.makeCli)();
473
- const context = (0, fixtures_1.createMockContext)();
474
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
475
- yield cli.run([
476
- 'lambda',
477
- 'instrument',
478
- '--function',
479
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
480
- '--extensionVersion',
481
- '6',
482
- '--no-source-code-integration',
483
- ], context);
484
- expect(lambdaClientMock).toHaveReceivedCommand(client_lambda_1.UpdateFunctionConfigurationCommand);
485
- }));
486
- test('aborts early when no functions are specified', () => __awaiter(void 0, void 0, void 0, function* () {
487
- ;
488
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
489
- const cli = (0, fixtures_2.makeCli)();
490
- const context = (0, fixtures_1.createMockContext)();
491
- const code = yield cli.run([
492
- 'lambda',
493
- 'instrument',
494
- '--layerVersion',
495
- '10',
496
- '--service',
497
- 'middletier',
498
- '--env',
499
- 'staging',
500
- '--version',
501
- '0.2',
502
- ], context);
503
- const output = context.stdout.toString();
504
- expect(code).toBe(1);
505
- expect(output).toMatchInlineSnapshot(`
506
- "
507
- 🐶 Instrumenting Lambda function
508
- [Error] No functions specified to instrument.
509
- "
510
- `);
511
- }));
512
- test('aborts early when no functions are specified while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
513
- ;
514
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
515
- process.env = {};
516
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
517
- command['config']['layerVersion'] = '60';
518
- command['config']['extensionVersion'] = '10';
519
- command['config']['region'] = 'ap-southeast-1';
520
- command['config']['service'] = 'middletier';
521
- command['config']['environment'] = 'staging';
522
- command['config']['version'] = '0.2';
523
- yield command['execute']();
524
- const output = command.context.stdout.toString();
525
- expect(output).toMatchInlineSnapshot(`
526
- "
527
- 🐶 Instrumenting Lambda function
528
- [Error] No functions specified to instrument.
529
- "
530
- `);
531
- }));
532
- test("aborts early when function regions can't be found", () => __awaiter(void 0, void 0, void 0, function* () {
533
- ;
534
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
535
- const cli = (0, fixtures_2.makeCli)();
536
- const context = (0, fixtures_1.createMockContext)();
537
- const code = yield cli.run([
538
- 'lambda',
539
- 'instrument',
540
- '--function',
541
- 'my-func',
542
- '--layerVersion',
543
- '10',
544
- '--service',
545
- 'middletier',
546
- '--env',
547
- 'staging',
548
- '--version',
549
- '0.2',
550
- '--no-source-code-integration',
551
- ], context);
552
- const output = context.stdout.toString();
553
- expect(code).toBe(1);
554
- expect(output).toMatch(`Couldn't group functions. Error: No default region specified for ["my-func"]. Use -r, --region, or use a full functionARN\n`);
555
- }));
556
- test('aborts early when extensionVersion and forwarder are set', () => __awaiter(void 0, void 0, void 0, function* () {
557
- ;
558
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
559
- const cli = (0, fixtures_2.makeCli)();
560
- const context = (0, fixtures_1.createMockContext)();
561
- const code = yield cli.run([
562
- 'lambda',
563
- 'instrument',
564
- '--function',
565
- 'test-function-arn',
566
- '--forwarder',
567
- 'arn:aws:lambda:sa-east-1:000000000000:function:datadog-forwarder',
568
- '--extensionVersion',
569
- '6',
570
- '--region',
571
- 'us-east-1',
572
- '--service',
573
- 'middletier',
574
- '--env',
575
- 'staging',
576
- '--version',
577
- '0.2',
578
- ], context);
579
- const output = context.stdout.toString();
580
- expect(code).toBe(1);
581
- expect(output).toMatchInlineSnapshot(`
582
- "
583
- 🐶 Instrumenting Lambda function
584
- [Error] "extensionVersion" and "forwarder" should not be used at the same time.
585
- "
586
- `);
587
- }));
588
- test('check if functions are not empty while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
589
- ;
590
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
591
- process.env = {};
592
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
593
- command['config']['layerVersion'] = '60';
594
- command['config']['extensionVersion'] = '10';
595
- command['config']['region'] = 'ap-southeast-1';
596
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
597
- yield command['execute']();
598
- expect(command['config']['functions']).toHaveLength(1);
599
- }));
600
- test('aborts if functions and a pattern are set at the same time', () => __awaiter(void 0, void 0, void 0, function* () {
601
- ;
602
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
603
- process.env = {};
604
- let command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
605
- command['config']['environment'] = 'staging';
606
- command['config']['service'] = 'middletier';
607
- command['config']['version'] = '2';
608
- command['config']['region'] = 'ap-southeast-1';
609
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
610
- command['regExPattern'] = 'valid-pattern';
611
- command['sourceCodeIntegration'] = false;
612
- yield command['execute']();
613
- let output = command.context.stdout.toString();
614
- expect(output).toMatch('Functions in config file and "--functions-regex" should not be used at the same time.\n');
615
- command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
616
- command['environment'] = 'staging';
617
- command['service'] = 'middletier';
618
- command['version'] = '2';
619
- command['region'] = 'ap-southeast-1';
620
- command['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
621
- command['regExPattern'] = 'valid-pattern';
622
- command['sourceCodeIntegration'] = false;
623
- yield command['execute']();
624
- output = command.context.stdout.toString();
625
- expect(output).toMatch('"--functions" and "--functions-regex" should not be used at the same time.\n');
626
- }));
627
- test('aborts if pattern is set and no default region is specified', () => __awaiter(void 0, void 0, void 0, function* () {
628
- ;
629
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
630
- process.env = {};
631
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
632
- command['environment'] = 'staging';
633
- command['service'] = 'middletier';
634
- command['version'] = '2';
635
- command['regExPattern'] = 'valid-pattern';
636
- command['sourceCodeIntegration'] = false;
637
- yield command['execute']();
638
- const output = command.context.stdout.toString();
639
- expect(output).toMatch('[Error] No default region specified. [-r,--region]\n');
640
- }));
641
- test('aborts if the regEx pattern is an ARN', () => __awaiter(void 0, void 0, void 0, function* () {
642
- ;
643
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
644
- process.env = {};
645
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
646
- command['environment'] = 'staging';
647
- command['service'] = 'middletier';
648
- command['version'] = '2';
649
- command['region'] = 'ap-southeast-1';
650
- command['regExPattern'] = 'arn:aws:lambda:ap-southeast-1:123456789012:function:*';
651
- command['sourceCodeIntegration'] = false;
652
- yield command['execute']();
653
- const output = command.context.stdout.toString();
654
- expect(output).toMatch(`"--functions-regex" isn't meant to be used with ARNs.\n`);
655
- }));
656
- test('instrument multiple functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
657
- ;
658
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
659
- const node22LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node22-x`;
660
- const node20LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node20-x`;
661
- const node18LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node18-x`;
662
- const node16LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node16-x`;
663
- const extensionLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Extension`;
664
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
665
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
666
- config: {
667
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
668
- FunctionName: 'lambda-hello-world',
669
- Handler: 'index.handler',
670
- Runtime: 'nodejs16.x',
671
- },
672
- },
673
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
674
- config: {
675
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
676
- FunctionName: 'lambda-hello-world-2',
677
- Handler: 'index.handler',
678
- Runtime: 'nodejs18.x',
679
- },
680
- },
681
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-3': {
682
- config: {
683
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-3',
684
- FunctionName: 'lambda-hello-world-3',
685
- Handler: 'index.handler',
686
- Runtime: 'nodejs20.x',
687
- },
688
- },
689
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-4': {
690
- config: {
691
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-4',
692
- FunctionName: 'lambda-hello-world-4',
693
- Handler: 'index.handler',
694
- Runtime: 'nodejs22.x',
695
- },
696
- },
697
- });
698
- (0, fixtures_2.mockLambdaLayers)(lambdaClientMock, {
699
- [`${node16LibraryLayer}:1`]: {
700
- LayerName: `${node16LibraryLayer}`,
701
- VersionNumber: 1,
702
- },
703
- [`${node18LibraryLayer}:1`]: {
704
- LayerName: `${node18LibraryLayer}`,
705
- VersionNumber: 1,
706
- },
707
- [`${node20LibraryLayer}:1`]: {
708
- LayerName: `${node20LibraryLayer}`,
709
- VersionNumber: 1,
710
- },
711
- [`${node22LibraryLayer}:1`]: {
712
- LayerName: `${node22LibraryLayer}`,
713
- VersionNumber: 1,
714
- },
715
- [`${extensionLayer}:1`]: {
716
- LayerName: `${extensionLayer}`,
717
- VersionNumber: 1,
718
- },
719
- });
720
- prompt_2.requestAWSCredentials.mockImplementation(() => {
721
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
722
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
723
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
724
- });
725
- prompt_2.requestDatadogEnvVars.mockImplementation(() => {
726
- process.env[constants_1.CI_SITE_ENV_VAR] = 'datadoghq.com';
727
- process.env[constants_1.CI_API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
728
- });
729
- prompt_2.requestFunctionSelection.mockImplementation(() => [
730
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
731
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
732
- ]);
733
- prompt_1.requestConfirmation.mockImplementation(() => true);
734
- const cli = (0, fixtures_2.makeCli)();
735
- const context = (0, fixtures_1.createMockContext)();
736
- const code = yield cli.run(['lambda', 'instrument', '-i', '--no-source-code-integration'], context);
737
- const output = context.stdout.toString();
738
- expect(code).toBe(0);
739
- expect(output).toMatchSnapshot();
740
- }));
741
- test('instrument multiple specified functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
742
- ;
743
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
744
- const node16LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node16-x`;
745
- const node18LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node18-x`;
746
- const node20LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node20-x`;
747
- const node22LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node22-x`;
748
- const extensionLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Extension`;
749
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
750
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
751
- config: {
752
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
753
- FunctionName: 'lambda-hello-world',
754
- Handler: 'index.handler',
755
- Runtime: 'nodejs16.x',
756
- },
757
- },
758
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
759
- config: {
760
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
761
- FunctionName: 'lambda-hello-world-2',
762
- Handler: 'index.handler',
763
- Runtime: 'nodejs18.x',
764
- },
765
- },
766
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-3': {
767
- config: {
768
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-3',
769
- FunctionName: 'lambda-hello-world-3',
770
- Handler: 'index.handler',
771
- Runtime: 'nodejs20.x',
772
- },
773
- },
774
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-4': {
775
- config: {
776
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-4',
777
- FunctionName: 'lambda-hello-world-4',
778
- Handler: 'index.handler',
779
- Runtime: 'nodejs22.x',
780
- },
781
- },
782
- });
783
- (0, fixtures_2.mockLambdaLayers)(lambdaClientMock, {
784
- [`${node16LibraryLayer}:1`]: {
785
- LayerName: `${node16LibraryLayer}`,
786
- VersionNumber: 1,
787
- },
788
- [`${node18LibraryLayer}:1`]: {
789
- LayerName: `${node18LibraryLayer}`,
790
- VersionNumber: 1,
791
- },
792
- [`${node20LibraryLayer}:1`]: {
793
- LayerName: `${node20LibraryLayer}`,
794
- VersionNumber: 1,
795
- },
796
- [`${node22LibraryLayer}:1`]: {
797
- LayerName: `${node22LibraryLayer}`,
798
- VersionNumber: 1,
799
- },
800
- [`${extensionLayer}:1`]: {
801
- LayerName: `${extensionLayer}`,
802
- VersionNumber: 1,
803
- },
804
- });
805
- prompt_2.requestAWSCredentials.mockImplementation(() => {
806
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
807
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
808
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
809
- process.env[constants_2.AWS_SESSION_TOKEN_ENV_VAR] = 'some-session-token';
810
- });
811
- prompt_2.requestDatadogEnvVars.mockImplementation(() => {
812
- process.env[constants_1.CI_SITE_ENV_VAR] = 'datadoghq.com';
813
- process.env[constants_1.CI_API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
814
- });
815
- prompt_1.requestConfirmation.mockImplementation(() => true);
816
- const cli = (0, fixtures_2.makeCli)();
817
- const context = (0, fixtures_1.createMockContext)();
818
- const code = yield cli.run([
819
- 'lambda',
820
- 'instrument',
821
- '-i',
822
- '-f',
823
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
824
- '-f',
825
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
826
- '--no-source-code-integration',
827
- ], context);
828
- const output = context.stdout.toString();
829
- expect(code).toBe(0);
830
- expect(output).toMatchSnapshot();
831
- }));
832
- test('aborts if a problem occurs while setting the AWS credentials interactively', () => __awaiter(void 0, void 0, void 0, function* () {
833
- ;
834
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
835
- prompt_2.requestAWSCredentials.mockImplementation(() => Promise.reject('Unexpected error'));
836
- const cli = (0, fixtures_2.makeCli)();
837
- const context = (0, fixtures_1.createMockContext)();
838
- const code = yield cli.run(['lambda', 'instrument', '-i'], context);
839
- const output = context.stdout.toString();
840
- expect(code).toBe(1);
841
- expect(output).toMatchInlineSnapshot(`
842
- "
843
- 🐶 Instrumenting Lambda function
844
- [!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
845
- [Error] Unexpected error
846
- "
847
- `);
848
- }));
849
- test('aborts if a problem occurs while setting the Datadog Environment Variables interactively', () => __awaiter(void 0, void 0, void 0, function* () {
850
- ;
851
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
852
- process.env = {
853
- [constants_2.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_2.mockAwsAccessKeyId,
854
- [constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_2.mockAwsSecretAccessKey,
855
- [constants_2.AWS_DEFAULT_REGION_ENV_VAR]: 'sa,-east-1',
856
- };
857
- prompt_2.requestDatadogEnvVars.mockImplementation(() => Promise.reject('Unexpected error'));
858
- const cli = (0, fixtures_2.makeCli)();
859
- const context = (0, fixtures_1.createMockContext)();
860
- const code = yield cli.run(['lambda', 'instrument', '-i'], context);
861
- const output = context.stdout.toString();
862
- expect(code).toBe(1);
863
- expect(output).toMatchInlineSnapshot(`
864
- "
865
- 🐶 Instrumenting Lambda function
866
-
867
- [!] Configure AWS region.
868
-
869
- [!] Configure Datadog settings.
870
- [Error] Unexpected error
871
- "
872
- `);
873
- }));
874
- test('when provided it sets DD_ENV, DD_SERVICE, and DD_VERSION environment variables in interactive mode', () => __awaiter(void 0, void 0, void 0, function* () {
875
- ;
876
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
877
- const node22LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node22-x`;
878
- const extensionLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Extension`;
879
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
880
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
881
- config: {
882
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
883
- FunctionName: 'lambda-hello-world',
884
- Handler: 'index.handler',
885
- Runtime: 'nodejs22.x',
886
- },
887
- },
888
- });
889
- (0, fixtures_2.mockLambdaLayers)(lambdaClientMock, {
890
- [`${node22LibraryLayer}:1`]: {
891
- LayerName: `${node22LibraryLayer}`,
892
- VersionNumber: 1,
893
- },
894
- [`${extensionLayer}:1`]: {
895
- LayerName: `${extensionLayer}`,
896
- VersionNumber: 1,
897
- },
898
- });
899
- prompt_2.requestAWSCredentials.mockImplementation(() => {
900
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
901
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
902
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
903
- });
904
- prompt_2.requestDatadogEnvVars.mockImplementation(() => {
905
- process.env[constants_1.CI_SITE_ENV_VAR] = 'datadoghq.com';
906
- process.env[constants_1.CI_API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
907
- });
908
- prompt_2.requestFunctionSelection.mockImplementation(() => [
909
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
910
- ]);
911
- prompt_1.requestConfirmation.mockImplementation(() => true);
912
- prompt_2.requestEnvServiceVersion.mockImplementation(() => {
913
- process.env[constants_1.ENVIRONMENT_ENV_VAR] = fixtures_2.mockDatadogEnv;
914
- process.env[constants_1.SERVICE_ENV_VAR] = fixtures_2.mockDatadogService;
915
- process.env[constants_1.VERSION_ENV_VAR] = fixtures_2.mockDatadogVersion;
916
- });
917
- const cli = (0, fixtures_2.makeCli)();
918
- const context = (0, fixtures_1.createMockContext)();
919
- const code = yield cli.run(['lambda', 'instrument', '-i', '--no-source-code-integration'], context);
920
- const output = context.stdout.toString();
921
- expect(code).toBe(0);
922
- expect(output).toMatchSnapshot();
923
- }));
924
- test('when not provided it does not set DD_ENV, DD_SERVICE, and DD_VERSION tags in interactive mode', () => __awaiter(void 0, void 0, void 0, function* () {
925
- ;
926
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
927
- const node22LibraryLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Node22-x`;
928
- const extensionLayer = `arn:aws:lambda:sa-east-1:${constants_2.DEFAULT_LAYER_AWS_ACCOUNT}:layer:Datadog-Extension`;
929
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
930
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
931
- config: {
932
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
933
- FunctionName: 'lambda-hello-world',
934
- Handler: 'index.handler',
935
- Runtime: 'nodejs22.x',
936
- },
937
- },
938
- });
939
- (0, fixtures_2.mockLambdaLayers)(lambdaClientMock, {
940
- [`${node22LibraryLayer}:1`]: {
941
- LayerName: `${node22LibraryLayer}`,
942
- VersionNumber: 1,
943
- },
944
- [`${extensionLayer}:1`]: {
945
- LayerName: `${extensionLayer}`,
946
- VersionNumber: 1,
947
- },
948
- });
949
- prompt_2.requestAWSCredentials.mockImplementation(() => {
950
- process.env[constants_2.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_2.mockAwsAccessKeyId;
951
- process.env[constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_2.mockAwsSecretAccessKey;
952
- process.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
953
- });
954
- prompt_2.requestDatadogEnvVars.mockImplementation(() => {
955
- process.env[constants_1.CI_SITE_ENV_VAR] = 'datadoghq.com';
956
- process.env[constants_1.CI_API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
957
- });
958
- prompt_2.requestFunctionSelection.mockImplementation(() => [
959
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
960
- ]);
961
- prompt_1.requestConfirmation.mockImplementation(() => true);
962
- prompt_2.requestEnvServiceVersion.mockImplementation(() => {
963
- process.env[constants_1.ENVIRONMENT_ENV_VAR] = undefined;
964
- process.env[constants_1.SERVICE_ENV_VAR] = undefined;
965
- process.env[constants_1.VERSION_ENV_VAR] = undefined;
966
- });
967
- const cli = (0, fixtures_2.makeCli)();
968
- const context = (0, fixtures_1.createMockContext)();
969
- const code = yield cli.run(['lambda', 'instrument', '-i', '--no-source-code-integration'], context);
970
- const output = context.stdout.toString();
971
- expect(code).toBe(0);
972
- expect(output).toMatchSnapshot();
973
- }));
974
- test('aborts if there are no functions to instrument in the user AWS account', () => __awaiter(void 0, void 0, void 0, function* () {
975
- ;
976
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
977
- process.env = {
978
- [constants_2.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_2.mockAwsAccessKeyId,
979
- [constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_2.mockAwsSecretAccessKey,
980
- [constants_2.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
981
- [constants_1.CI_SITE_ENV_VAR]: 'datadoghq.com',
982
- [constants_1.CI_API_KEY_ENV_VAR]: fixtures_1.MOCK_DATADOG_API_KEY,
983
- };
984
- const cli = (0, fixtures_2.makeCli)();
985
- const context = (0, fixtures_1.createMockContext)();
986
- const code = yield cli.run(['lambda', 'instrument', '-i'], context);
987
- const output = context.stdout.toString();
988
- expect(code).toBe(1);
989
- expect(output).toMatchInlineSnapshot(`
990
- "
991
- 🐶 Instrumenting Lambda function
992
-
993
- [!] Configure AWS region.
994
- [Error] Couldn't find any Lambda functions in the specified region.
995
- "
996
- `);
997
- }));
998
- test('aborts early when the aws-sdk throws an error while instrumenting interactively', () => __awaiter(void 0, void 0, void 0, function* () {
999
- ;
1000
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1001
- process.env = {
1002
- [constants_2.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_2.mockAwsAccessKeyId,
1003
- [constants_2.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_2.mockAwsSecretAccessKey,
1004
- [constants_2.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
1005
- [constants_1.CI_SITE_ENV_VAR]: 'datadoghq.com',
1006
- [constants_1.CI_API_KEY_ENV_VAR]: fixtures_1.MOCK_DATADOG_API_KEY,
1007
- };
1008
- lambdaClientMock.on(client_lambda_1.ListFunctionsCommand).rejects('ListFunctionsError');
1009
- const cli = (0, fixtures_2.makeCli)();
1010
- const context = (0, fixtures_1.createMockContext)();
1011
- const code = yield cli.run(['lambda', 'instrument', '-i'], context);
1012
- const output = context.stdout.toString();
1013
- expect(code).toBe(1);
1014
- expect(output).toMatchInlineSnapshot(`
1015
- "
1016
- 🐶 Instrumenting Lambda function
1017
-
1018
- [!] Configure AWS region.
1019
- [Error] Couldn't fetch Lambda functions. Error: ListFunctionsError
1020
- "
1021
- `);
1022
- }));
1023
- test('instruments Ruby application properly', () => __awaiter(void 0, void 0, void 0, function* () {
1024
- ;
1025
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1026
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1027
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby32': {
1028
- config: {
1029
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ruby32',
1030
- Runtime: 'ruby3.2',
1031
- },
1032
- },
1033
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby32arm': {
1034
- config: {
1035
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ruby32arm',
1036
- Runtime: 'ruby3.2',
1037
- Architectures: ['arm64'],
1038
- },
1039
- },
1040
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby33': {
1041
- config: {
1042
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ruby33',
1043
- Runtime: 'ruby3.3',
1044
- },
1045
- },
1046
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby33arm': {
1047
- config: {
1048
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ruby33arm',
1049
- Runtime: 'ruby3.3',
1050
- Architectures: ['arm64'],
1051
- },
1052
- },
1053
- });
1054
- const cli = (0, fixtures_2.makeCli)();
1055
- const context = (0, fixtures_1.createMockContext)();
1056
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
1057
- const code = yield cli.run([
1058
- 'lambda',
1059
- 'instrument',
1060
- '-f',
1061
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby32',
1062
- '-f',
1063
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby33',
1064
- '-f',
1065
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby32arm',
1066
- '-f',
1067
- 'arn:aws:lambda:us-east-1:123456789012:function:ruby33arm',
1068
- '--dry-run',
1069
- '-e',
1070
- '40',
1071
- '-v',
1072
- '19',
1073
- '--extra-tags',
1074
- 'layer:api,team:intake',
1075
- '--service',
1076
- 'middletier',
1077
- '--env',
1078
- 'staging',
1079
- '--version',
1080
- '0.2',
1081
- '--no-source-code-integration',
1082
- ], context);
1083
- const output = context.stdout.toString();
1084
- expect(code).toBe(0);
1085
- expect(output).toMatchSnapshot();
1086
- }));
1087
- test('instruments image runtimes properly', () => __awaiter(void 0, void 0, void 0, function* () {
1088
- ;
1089
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1090
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1091
- 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2': {
1092
- config: {
1093
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2',
1094
- Runtime: 'provided.al2',
1095
- },
1096
- },
1097
- 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2023': {
1098
- config: {
1099
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2023',
1100
- Runtime: 'provided.al2023',
1101
- Architectures: ['arm64'],
1102
- },
1103
- },
1104
- });
1105
- const cli = (0, fixtures_2.makeCli)();
1106
- const context = (0, fixtures_1.createMockContext)();
1107
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
1108
- const code = yield cli.run([
1109
- 'lambda',
1110
- 'instrument',
1111
- '-f',
1112
- 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2',
1113
- '-f',
1114
- 'arn:aws:lambda:us-east-1:123456789012:function:provided-al2023',
1115
- '--dry-run',
1116
- '-e',
1117
- '40',
1118
- '--extra-tags',
1119
- 'layer:api,team:intake',
1120
- '--service',
1121
- 'middletier',
1122
- '--env',
1123
- 'staging',
1124
- '--version',
1125
- '0.2',
1126
- '--no-source-code-integration',
1127
- ], context);
1128
- const output = context.stdout.toString();
1129
- expect(code).toBe(0);
1130
- expect(output).toMatchSnapshot();
1131
- }));
1132
- test('aborts early when a layer version is set for a Custom runtime', () => __awaiter(void 0, void 0, void 0, function* () {
1133
- ;
1134
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1135
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1136
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1137
- config: {
1138
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1139
- Runtime: 'provided.al2',
1140
- },
1141
- },
1142
- });
1143
- const cli = (0, fixtures_2.makeCli)();
1144
- const context = (0, fixtures_1.createMockContext)();
1145
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1146
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
1147
- const code = yield cli.run([
1148
- 'lambda',
1149
- 'instrument',
1150
- '-f',
1151
- functionARN,
1152
- '--dry-run',
1153
- '-v',
1154
- '6',
1155
- '--extra-tags',
1156
- 'layer:api,team:intake',
1157
- '--service',
1158
- 'middletier',
1159
- '--env',
1160
- 'staging',
1161
- '--version',
1162
- '0.2',
1163
- '--no-source-code-integration',
1164
- ], context);
1165
- const output = context.stdout.toString();
1166
- expect(code).toBe(1);
1167
- expect(output).toMatchInlineSnapshot(`
1168
- "
1169
- [Dry Run] 🐶 Instrumenting Lambda function
1170
- [Error] Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the provided.al2 runtime. Please remove the --layer-version argument from the instrument command.
1171
- "
1172
- `);
1173
- }));
1174
- test('aborts early when .NET is using ARM64 architecture', () => __awaiter(void 0, void 0, void 0, function* () {
1175
- ;
1176
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1177
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1178
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1179
- config: {
1180
- Architectures: ['arm64'],
1181
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1182
- Runtime: 'dotnet6',
1183
- },
1184
- },
1185
- });
1186
- const cli = (0, fixtures_2.makeCli)();
1187
- const context = (0, fixtures_1.createMockContext)();
1188
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1189
- process.env.DATADOG_API_KEY = fixtures_1.MOCK_DATADOG_API_KEY;
1190
- const code = yield cli.run([
1191
- 'lambda',
1192
- 'instrument',
1193
- '-f',
1194
- functionARN,
1195
- '--dry-run',
1196
- '-v',
1197
- '6',
1198
- '--extra-tags',
1199
- 'layer:api,team:intake',
1200
- '--service',
1201
- 'middletier',
1202
- '--env',
1203
- 'staging',
1204
- '--version',
1205
- '0.2',
1206
- '--no-source-code-integration',
1207
- ], context);
1208
- const output = context.stdout.toString();
1209
- expect(code).toBe(1);
1210
- expect(output).toMatchInlineSnapshot(`
1211
- "
1212
- [Dry Run] 🐶 Instrumenting Lambda function
1213
- [Error] Couldn't fetch Lambda functions. Error: Instrumenting arm64 architecture is not supported for the given dd-extension version. Please choose the latest dd-extension version or use x86_64 architecture.
1214
- "
1215
- `);
1216
- }));
1217
- test('instruments correctly with profile when provided', () => __awaiter(void 0, void 0, void 0, function* () {
1218
- const credentials = fixtures_2.mockAwsCredentials;
1219
- credential_providers_1.fromIni.mockImplementation((_init) => () => __awaiter(void 0, void 0, void 0, function* () { return Promise.resolve(credentials); }));
1220
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1221
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1222
- config: {
1223
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1224
- Handler: 'index.handler',
1225
- Runtime: 'nodejs22.x',
1226
- },
1227
- },
1228
- });
1229
- const cli = (0, fixtures_2.makeCli)();
1230
- const context = (0, fixtures_1.createMockContext)();
1231
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1232
- const code = yield cli.run(['lambda', 'instrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE', '--no-source-code-integration'], context);
1233
- expect(code).toBe(0);
1234
- }));
1235
- test('prints error when updating aws profile credentials fails', () => __awaiter(void 0, void 0, void 0, function* () {
1236
- ;
1237
- credential_providers_1.fromIni.mockImplementation(() => {
1238
- throw Error('Update failed!');
1239
- });
1240
- const cli = (0, fixtures_2.makeCli)();
1241
- const context = (0, fixtures_1.createMockContext)();
1242
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1243
- const code = yield cli.run(['lambda', 'instrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE'], context);
1244
- const output = context.stdout.toString();
1245
- expect(code).toBe(1);
1246
- expect(output).toMatchInlineSnapshot(`
1247
- "
1248
- 🐶 Instrumenting Lambda function
1249
- [Error] Error: Couldn't set AWS profile credentials. Update failed!
1250
- "
1251
- `);
1252
- }));
1253
- test('prints which functions failed to instrument without aborting when at least one function was instrumented correctly', () => __awaiter(void 0, void 0, void 0, function* () {
1254
- const failingLambdas = [
1255
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
1256
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
1257
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
1258
- ];
1259
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1260
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1261
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
1262
- config: {
1263
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
1264
- FunctionName: 'lambda-1-us-east-1',
1265
- Handler: 'index.handler',
1266
- Runtime: 'nodejs22.x',
1267
- },
1268
- },
1269
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1': {
1270
- config: {
1271
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
1272
- FunctionName: 'lambda-2-us-east-1',
1273
- Handler: 'index.handler',
1274
- Runtime: 'nodejs22.x',
1275
- },
1276
- },
1277
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1': {
1278
- config: {
1279
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
1280
- FunctionName: 'lambda-3-us-east-1',
1281
- Handler: 'index.handler',
1282
- Runtime: 'nodejs22.x',
1283
- },
1284
- },
1285
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
1286
- config: {
1287
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
1288
- FunctionName: 'lambda-1-us-east-2',
1289
- Handler: 'index.handler',
1290
- Runtime: 'nodejs16.x',
1291
- },
1292
- },
1293
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2': {
1294
- config: {
1295
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
1296
- FunctionName: 'lambda-2-us-east-2',
1297
- Handler: 'index.handler',
1298
- Runtime: 'nodejs18.x',
1299
- },
1300
- },
1301
- });
1302
- for (const failingLambda of failingLambdas) {
1303
- lambdaClientMock
1304
- .on(client_lambda_1.UpdateFunctionConfigurationCommand, { FunctionName: failingLambda })
1305
- .rejects('Unexpected error updating request');
1306
- }
1307
- const cli = (0, fixtures_2.makeCli)();
1308
- const context = (0, fixtures_1.createMockContext)();
1309
- const code = yield cli.run([
1310
- 'lambda',
1311
- 'instrument',
1312
- '-f',
1313
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
1314
- '-f',
1315
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
1316
- '-f',
1317
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
1318
- '-f',
1319
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
1320
- '-f',
1321
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
1322
- ], context);
1323
- const output = context.stdout.toString();
1324
- expect(code).toBe(0);
1325
- expect(output).toMatchSnapshot();
1326
- }));
1327
- test('aborts when every lambda function fails to update on instrument', () => __awaiter(void 0, void 0, void 0, function* () {
1328
- ;
1329
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1330
- (0, fixtures_2.mockLambdaConfigurations)(lambdaClientMock, {
1331
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
1332
- config: {
1333
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
1334
- FunctionName: 'lambda-1-us-east-1',
1335
- Handler: 'index.handler',
1336
- Runtime: 'nodejs22.x',
1337
- },
1338
- },
1339
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
1340
- config: {
1341
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
1342
- FunctionName: 'lambda-1-us-east-2',
1343
- Handler: 'index.handler',
1344
- Runtime: 'nodejs18.x',
1345
- },
1346
- },
1347
- });
1348
- lambdaClientMock.on(client_lambda_1.UpdateFunctionConfigurationCommand).rejects('Unexpected error updating request');
1349
- const cli = (0, fixtures_2.makeCli)();
1350
- const context = (0, fixtures_1.createMockContext)();
1351
- const code = yield cli.run([
1352
- 'lambda',
1353
- 'instrument',
1354
- '-f',
1355
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
1356
- '-f',
1357
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
1358
- ], context);
1359
- const output = context.stdout.toString();
1360
- expect(code).toBe(1);
1361
- expect(output).toMatchSnapshot();
1362
- }));
1363
- });
1364
- describe('getSettings', () => {
1365
- beforeEach(() => {
1366
- lambdaClientMock.reset();
1367
- });
1368
- test('uses config file settings', () => {
1369
- process.env = {};
1370
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1371
- command['config']['flushMetricsToLogs'] = 'false';
1372
- command['config']['forwarder'] = 'my-forwarder';
1373
- command['config']['layerVersion'] = '2';
1374
- command['config']['extensionVersion'] = '6';
1375
- command['config']['layerAWSAccount'] = 'another-account';
1376
- command['config']['mergeXrayTraces'] = 'false';
1377
- command['config']['tracing'] = 'false';
1378
- command['config']['logLevel'] = 'debug';
1379
- expect(command['getSettings']()).toEqual({
1380
- appsecEnabled: false,
1381
- apmFlushDeadline: undefined,
1382
- captureLambdaPayload: false,
1383
- environment: undefined,
1384
- extensionVersion: 6,
1385
- extraTags: undefined,
1386
- flushMetricsToLogs: false,
1387
- forwarderARN: 'my-forwarder',
1388
- interactive: false,
1389
- layerAWSAccount: 'another-account',
1390
- layerVersion: 2,
1391
- logLevel: 'debug',
1392
- mergeXrayTraces: false,
1393
- service: undefined,
1394
- tracingEnabled: false,
1395
- version: undefined,
1396
- });
1397
- });
1398
- test('prefers command line arguments over config file', () => {
1399
- process.env = {};
1400
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1401
- command['forwarder'] = 'my-forwarder';
1402
- command['config']['forwarder'] = 'another-forwarder';
1403
- command['layerVersion'] = '1';
1404
- command['config']['layerVersion'] = '2';
1405
- command['layerAWSAccount'] = 'my-account';
1406
- command['config']['layerAWSAccount'] = 'another-account';
1407
- command['mergeXrayTraces'] = 'true';
1408
- command['config']['mergeXrayTraces'] = 'false';
1409
- command['flushMetricsToLogs'] = 'false';
1410
- command['config']['flushMetricsToLogs'] = 'true';
1411
- command['tracing'] = 'true';
1412
- command['config']['tracing'] = 'false';
1413
- command['logLevel'] = 'debug';
1414
- command['config']['logLevel'] = 'info';
1415
- command['apmFlushDeadline'] = '20';
1416
- command['config']['apmFlushDeadline'] = '50';
1417
- expect(command['getSettings']()).toEqual({
1418
- appsecEnabled: false,
1419
- apmFlushDeadline: '20',
1420
- captureLambdaPayload: false,
1421
- flushMetricsToLogs: false,
1422
- forwarderARN: 'my-forwarder',
1423
- interactive: false,
1424
- layerAWSAccount: 'my-account',
1425
- layerVersion: 1,
1426
- logLevel: 'debug',
1427
- mergeXrayTraces: true,
1428
- tracingEnabled: true,
1429
- });
1430
- });
1431
- test("returns undefined when layer version can't be parsed", () => {
1432
- process.env = {};
1433
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1434
- command.context = {
1435
- stdout: { write: jest.fn() },
1436
- };
1437
- command['layerVersion'] = 'abd';
1438
- expect(command['getSettings']()).toBeUndefined();
1439
- });
1440
- test("returns undefined when extension version can't be parsed", () => {
1441
- process.env = {};
1442
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1443
- command.context = {
1444
- stdout: { write: jest.fn() },
1445
- };
1446
- command['extensionVersion'] = 'abd';
1447
- expect(command['getSettings']()).toBeUndefined();
1448
- });
1449
- test('converts string boolean from command line and config file correctly', () => {
1450
- process.env = {};
1451
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1452
- const validSettings = {
1453
- appsecEnabled: false,
1454
- captureLambdaPayload: true,
1455
- extensionVersion: undefined,
1456
- flushMetricsToLogs: false,
1457
- forwarderARN: undefined,
1458
- interactive: false,
1459
- layerAWSAccount: undefined,
1460
- layerVersion: undefined,
1461
- logLevel: undefined,
1462
- mergeXrayTraces: false,
1463
- tracingEnabled: true,
1464
- };
1465
- command['config']['captureLambdaPayload'] = 'truE';
1466
- command['config']['flushMetricsToLogs'] = 'False';
1467
- command['config']['mergeXrayTraces'] = 'falSE';
1468
- command['config']['tracing'] = 'TRUE';
1469
- expect(command['getSettings']()).toEqual(validSettings);
1470
- command['config']['captureLambdaPayload'] = 'true';
1471
- command['config']['flushMetricsToLogs'] = 'false';
1472
- command['config']['mergeXrayTraces'] = 'false';
1473
- command['config']['tracing'] = 'true';
1474
- expect(command['getSettings']()).toEqual(validSettings);
1475
- validSettings.captureLambdaPayload = false;
1476
- validSettings.flushMetricsToLogs = true;
1477
- validSettings.mergeXrayTraces = true;
1478
- validSettings.tracingEnabled = false;
1479
- command['captureLambdaPayload'] = 'faLSE';
1480
- command['flushMetricsToLogs'] = 'truE';
1481
- command['mergeXrayTraces'] = 'TRUe';
1482
- command['tracing'] = 'FALSE';
1483
- expect(command['getSettings']()).toEqual(validSettings);
1484
- command['captureLambdaPayload'] = 'false';
1485
- command['flushMetricsToLogs'] = 'true';
1486
- command['mergeXrayTraces'] = 'true';
1487
- command['tracing'] = 'false';
1488
- expect(command['getSettings']()).toEqual(validSettings);
1489
- });
1490
- test('aborts early if converting string boolean has an invalid value', () => {
1491
- process.env = {};
1492
- const stringBooleans = [
1493
- 'flushMetricsToLogs',
1494
- 'mergeXrayTraces',
1495
- 'tracing',
1496
- ];
1497
- for (const option of stringBooleans) {
1498
- let command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1499
- command['config'][option] = 'NotBoolean';
1500
- command['getSettings']();
1501
- let output = command.context.stdout.toString();
1502
- expect(output).toMatch(`[Error] Invalid boolean specified for ${option}.\n`);
1503
- command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1504
- command[option] = 'NotBoolean';
1505
- command['getSettings']();
1506
- output = command.context.stdout.toString();
1507
- expect(output).toMatch(`Invalid boolean specified for ${option}.\n`);
1508
- }
1509
- });
1510
- test('warns if any of environment, service or version tags are not set', () => __awaiter(void 0, void 0, void 0, function* () {
1511
- ;
1512
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1513
- process.env = {};
1514
- let command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1515
- command['config']['region'] = 'ap-southeast-1';
1516
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
1517
- command['getSettings']();
1518
- let output = command.context.stdout.toString();
1519
- expect(output).toMatch('[Warning] The environment, service and version tags have not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.\n');
1520
- command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1521
- command['config']['region'] = 'ap-southeast-1';
1522
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
1523
- command['config']['environment'] = 'b';
1524
- command['config']['service'] = 'middletier';
1525
- command['getSettings']();
1526
- output = command.context.stdout.toString();
1527
- expect(output).toMatch('[Warning] The version tag has not been configured. Learn more about Datadog unified service tagging: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/#serverless-environment.\n');
1528
- }));
1529
- test('aborts early if extraTags do not comply with expected key:value list', () => __awaiter(void 0, void 0, void 0, function* () {
1530
- ;
1531
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1532
- process.env = {};
1533
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1534
- command['config']['region'] = 'ap-southeast-1';
1535
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
1536
- command['config']['service'] = 'middletier';
1537
- command['config']['environment'] = 'staging';
1538
- command['config']['version'] = '0.2';
1539
- command['config']['extraTags'] = 'not@complying:illegal-chars-in-key,complies:valid-pair';
1540
- command['getSettings']();
1541
- const output = command.context.stdout.toString();
1542
- expect(output).toMatch('[Error] Extra tags do not comply with the <key>:<value> array.\n');
1543
- }));
1544
- });
1545
- describe('printPlannedActions', () => {
1546
- test('prints no output when list is empty', () => {
1547
- process.env = {};
1548
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1549
- command['printPlannedActions']([]);
1550
- const output = command.context.stdout.toString();
1551
- expect(output).toMatchInlineSnapshot(`
1552
- "
1553
- No updates will be applied.
1554
- "
1555
- `);
1556
- });
1557
- test('prints log group actions', () => {
1558
- process.env = {};
1559
- const command = (0, fixtures_1.createCommand)(instrument_1.InstrumentCommand);
1560
- command['printPlannedActions']([
1561
- {
1562
- functionARN: 'my-func',
1563
- lambdaConfig: {},
1564
- logGroupConfiguration: {
1565
- createLogGroupCommandInput: { logGroupName: 'my-log-group' },
1566
- deleteSubscriptionFilterCommandInput: { filterName: 'my-filter' },
1567
- logGroupName: 'my-log-group',
1568
- putSubscriptionFilterCommandInput: { filterName: 'my-filter' },
1569
- },
1570
- },
1571
- ]);
1572
- const output = command.context.stdout.toString();
1573
- expect(output).toMatchInlineSnapshot(`
1574
- "
1575
- [Warning] Instrument your Lambda functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`uninstrument\` with the same arguments to revert the changes.
1576
-
1577
- [!] Functions to be updated:
1578
- - my-func
1579
-
1580
- Will apply the following updates:
1581
- CreateLogGroup -> my-log-group
1582
- {
1583
- "logGroupName": "my-log-group"
1584
- }
1585
- DeleteSubscriptionFilter -> my-log-group
1586
- {
1587
- "filterName": "my-filter"
1588
- }
1589
- PutSubscriptionFilter -> my-log-group
1590
- {
1591
- "filterName": "my-filter"
1592
- }
1593
- "
1594
- `);
1595
- });
1596
- });
1597
- });
1598
- });
1599
- //# sourceMappingURL=instrument.test.js.map