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