@azure/monitor-opentelemetry-exporter 1.0.0-beta.26 → 1.0.0-beta.28

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 (368) hide show
  1. package/README.md +10 -13
  2. package/dist/commonjs/Declarations/Constants.d.ts +111 -0
  3. package/dist/commonjs/Declarations/Constants.d.ts.map +1 -0
  4. package/dist/commonjs/Declarations/Constants.js +127 -0
  5. package/dist/commonjs/Declarations/Constants.js.map +1 -0
  6. package/dist/commonjs/Declarations/Contracts/Constants.d.ts +14 -0
  7. package/dist/commonjs/Declarations/Contracts/Constants.d.ts.map +1 -0
  8. package/dist/commonjs/Declarations/Contracts/Constants.js +5 -0
  9. package/dist/commonjs/Declarations/Contracts/Constants.js.map +1 -0
  10. package/dist/commonjs/Declarations/Contracts/index.d.ts +2 -0
  11. package/dist/commonjs/Declarations/Contracts/index.d.ts.map +1 -0
  12. package/dist/commonjs/Declarations/Contracts/index.js +7 -0
  13. package/dist/commonjs/Declarations/Contracts/index.js.map +1 -0
  14. package/dist/commonjs/config.d.ts +30 -0
  15. package/dist/commonjs/config.d.ts.map +1 -0
  16. package/dist/commonjs/config.js +3 -0
  17. package/dist/commonjs/config.js.map +1 -0
  18. package/dist/commonjs/export/base.d.ts +36 -0
  19. package/dist/commonjs/export/base.d.ts.map +1 -0
  20. package/dist/commonjs/export/base.js +59 -0
  21. package/dist/commonjs/export/base.js.map +1 -0
  22. package/dist/commonjs/export/log.d.ts +30 -0
  23. package/dist/commonjs/export/log.d.ts.map +1 -0
  24. package/dist/commonjs/export/log.js +68 -0
  25. package/dist/commonjs/export/log.js.map +1 -0
  26. package/dist/commonjs/export/metric.d.ts +39 -0
  27. package/dist/commonjs/export/metric.d.ts.map +1 -0
  28. package/dist/commonjs/export/metric.js +79 -0
  29. package/dist/commonjs/export/metric.js.map +1 -0
  30. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.d.ts +39 -0
  31. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.d.ts.map +1 -0
  32. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js +126 -0
  33. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -0
  34. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.d.ts +51 -0
  35. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.d.ts.map +1 -0
  36. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js +288 -0
  37. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js.map +1 -0
  38. package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts +32 -0
  39. package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts.map +1 -0
  40. package/dist/commonjs/export/statsbeat/statsbeatExporter.js +62 -0
  41. package/dist/commonjs/export/statsbeat/statsbeatExporter.js.map +1 -0
  42. package/dist/commonjs/export/statsbeat/statsbeatMetrics.d.ts +11 -0
  43. package/dist/commonjs/export/statsbeat/statsbeatMetrics.d.ts.map +1 -0
  44. package/dist/commonjs/export/statsbeat/statsbeatMetrics.js +106 -0
  45. package/dist/commonjs/export/statsbeat/statsbeatMetrics.js.map +1 -0
  46. package/dist/commonjs/export/statsbeat/types.d.ts +97 -0
  47. package/dist/commonjs/export/statsbeat/types.d.ts.map +1 -0
  48. package/dist/commonjs/export/statsbeat/types.js +83 -0
  49. package/dist/commonjs/export/statsbeat/types.js.map +1 -0
  50. package/dist/commonjs/export/trace.d.ts +31 -0
  51. package/dist/commonjs/export/trace.d.ts.map +1 -0
  52. package/dist/commonjs/export/trace.js +76 -0
  53. package/dist/commonjs/export/trace.js.map +1 -0
  54. package/dist/commonjs/generated/applicationInsightsClient.d.ts +17 -0
  55. package/dist/commonjs/generated/applicationInsightsClient.d.ts.map +1 -0
  56. package/dist/commonjs/generated/applicationInsightsClient.js +89 -0
  57. package/dist/commonjs/generated/applicationInsightsClient.js.map +1 -0
  58. package/dist/commonjs/generated/index.d.ts +3 -0
  59. package/dist/commonjs/generated/index.d.ts.map +1 -0
  60. package/dist/commonjs/generated/index.js +15 -0
  61. package/dist/commonjs/generated/index.js.map +1 -0
  62. package/dist/commonjs/generated/models/index.d.ts +429 -0
  63. package/dist/commonjs/generated/models/index.d.ts.map +1 -0
  64. package/dist/commonjs/generated/models/index.js +93 -0
  65. package/dist/commonjs/generated/models/index.js.map +1 -0
  66. package/dist/commonjs/generated/models/mappers.d.ts +19 -0
  67. package/dist/commonjs/generated/models/mappers.d.ts.map +1 -0
  68. package/dist/commonjs/generated/models/mappers.js +848 -0
  69. package/dist/commonjs/generated/models/mappers.js.map +1 -0
  70. package/dist/commonjs/generated/models/parameters.d.ts +6 -0
  71. package/dist/commonjs/generated/models/parameters.d.ts.map +1 -0
  72. package/dist/commonjs/generated/models/parameters.js +60 -0
  73. package/dist/commonjs/generated/models/parameters.js.map +1 -0
  74. package/dist/commonjs/index.d.ts +10 -0
  75. package/dist/commonjs/index.d.ts.map +1 -0
  76. package/dist/commonjs/index.js +20 -0
  77. package/dist/commonjs/index.js.map +1 -0
  78. package/dist/commonjs/package.json +3 -0
  79. package/dist/commonjs/platform/index.d.ts +2 -0
  80. package/dist/commonjs/platform/index.d.ts.map +1 -0
  81. package/dist/commonjs/platform/index.js +10 -0
  82. package/dist/commonjs/platform/index.js.map +1 -0
  83. package/dist/commonjs/platform/nodejs/baseSender.d.ts +49 -0
  84. package/dist/commonjs/platform/nodejs/baseSender.d.ts.map +1 -0
  85. package/dist/commonjs/platform/nodejs/baseSender.js +239 -0
  86. package/dist/commonjs/platform/nodejs/baseSender.js.map +1 -0
  87. package/dist/commonjs/platform/nodejs/constants.d.ts +10 -0
  88. package/dist/commonjs/platform/nodejs/constants.d.ts.map +1 -0
  89. package/dist/commonjs/platform/nodejs/constants.js +15 -0
  90. package/dist/commonjs/platform/nodejs/constants.js.map +1 -0
  91. package/dist/commonjs/platform/nodejs/context/context.d.ts +20 -0
  92. package/dist/commonjs/platform/nodejs/context/context.d.ts.map +1 -0
  93. package/dist/commonjs/platform/nodejs/context/context.js +54 -0
  94. package/dist/commonjs/platform/nodejs/context/context.js.map +1 -0
  95. package/dist/commonjs/platform/nodejs/context/index.d.ts +2 -0
  96. package/dist/commonjs/platform/nodejs/context/index.d.ts.map +1 -0
  97. package/dist/commonjs/platform/nodejs/context/index.js +7 -0
  98. package/dist/commonjs/platform/nodejs/context/index.js.map +1 -0
  99. package/dist/commonjs/platform/nodejs/httpSender.d.ts +32 -0
  100. package/dist/commonjs/platform/nodejs/httpSender.d.ts.map +1 -0
  101. package/dist/commonjs/platform/nodejs/httpSender.js +70 -0
  102. package/dist/commonjs/platform/nodejs/httpSender.js.map +1 -0
  103. package/dist/commonjs/platform/nodejs/index.d.ts +8 -0
  104. package/dist/commonjs/platform/nodejs/index.d.ts.map +1 -0
  105. package/dist/commonjs/platform/nodejs/index.js +13 -0
  106. package/dist/commonjs/platform/nodejs/index.js.map +1 -0
  107. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.d.ts +18 -0
  108. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.d.ts.map +1 -0
  109. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.js +177 -0
  110. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.js.map +1 -0
  111. package/dist/commonjs/platform/nodejs/persist/fileSystemHelpers.d.ts +11 -0
  112. package/dist/commonjs/platform/nodejs/persist/fileSystemHelpers.d.ts.map +1 -0
  113. package/dist/commonjs/platform/nodejs/persist/fileSystemHelpers.js +60 -0
  114. package/dist/commonjs/platform/nodejs/persist/fileSystemHelpers.js.map +1 -0
  115. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts +29 -0
  116. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -0
  117. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js +184 -0
  118. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js.map +1 -0
  119. package/dist/commonjs/platform/nodejs/persist/index.d.ts +2 -0
  120. package/dist/commonjs/platform/nodejs/persist/index.d.ts.map +1 -0
  121. package/dist/commonjs/platform/nodejs/persist/index.js +7 -0
  122. package/dist/commonjs/platform/nodejs/persist/index.js.map +1 -0
  123. package/dist/commonjs/sampling.d.ts +38 -0
  124. package/dist/commonjs/sampling.d.ts.map +1 -0
  125. package/dist/commonjs/sampling.js +92 -0
  126. package/dist/commonjs/sampling.js.map +1 -0
  127. package/dist/commonjs/tsdoc-metadata.json +11 -0
  128. package/dist/commonjs/types.d.ts +86 -0
  129. package/dist/commonjs/types.d.ts.map +1 -0
  130. package/dist/commonjs/types.js +43 -0
  131. package/dist/commonjs/types.js.map +1 -0
  132. package/dist/commonjs/utils/breezeUtils.d.ts +25 -0
  133. package/dist/commonjs/utils/breezeUtils.d.ts.map +1 -0
  134. package/dist/commonjs/utils/breezeUtils.js +39 -0
  135. package/dist/commonjs/utils/breezeUtils.js.map +1 -0
  136. package/dist/commonjs/utils/common.d.ts +14 -0
  137. package/dist/commonjs/utils/common.d.ts.map +1 -0
  138. package/dist/commonjs/utils/common.js +250 -0
  139. package/dist/commonjs/utils/common.js.map +1 -0
  140. package/dist/commonjs/utils/connectionStringParser.d.ts +13 -0
  141. package/dist/commonjs/utils/connectionStringParser.d.ts.map +1 -0
  142. package/dist/commonjs/utils/connectionStringParser.js +83 -0
  143. package/dist/commonjs/utils/connectionStringParser.js.map +1 -0
  144. package/dist/commonjs/utils/constants/applicationinsights.d.ts +41 -0
  145. package/dist/commonjs/utils/constants/applicationinsights.d.ts.map +1 -0
  146. package/dist/commonjs/utils/constants/applicationinsights.js +47 -0
  147. package/dist/commonjs/utils/constants/applicationinsights.js.map +1 -0
  148. package/dist/commonjs/utils/constants/span/azAttributes.d.ts +16 -0
  149. package/dist/commonjs/utils/constants/span/azAttributes.d.ts.map +1 -0
  150. package/dist/commonjs/utils/constants/span/azAttributes.js +21 -0
  151. package/dist/commonjs/utils/constants/span/azAttributes.js.map +1 -0
  152. package/dist/commonjs/utils/eventhub.d.ts +10 -0
  153. package/dist/commonjs/utils/eventhub.d.ts.map +1 -0
  154. package/dist/commonjs/utils/eventhub.js +57 -0
  155. package/dist/commonjs/utils/eventhub.js.map +1 -0
  156. package/dist/commonjs/utils/logUtils.d.ts +8 -0
  157. package/dist/commonjs/utils/logUtils.d.ts.map +1 -0
  158. package/dist/commonjs/utils/logUtils.js +206 -0
  159. package/dist/commonjs/utils/logUtils.js.map +1 -0
  160. package/dist/commonjs/utils/metricUtils.d.ts +8 -0
  161. package/dist/commonjs/utils/metricUtils.d.ts.map +1 -0
  162. package/dist/commonjs/utils/metricUtils.js +90 -0
  163. package/dist/commonjs/utils/metricUtils.js.map +1 -0
  164. package/dist/commonjs/utils/spanUtils.d.ts +13 -0
  165. package/dist/commonjs/utils/spanUtils.d.ts.map +1 -0
  166. package/dist/commonjs/utils/spanUtils.js +461 -0
  167. package/dist/commonjs/utils/spanUtils.js.map +1 -0
  168. package/dist/esm/Declarations/Constants.d.ts +111 -0
  169. package/dist/esm/Declarations/Constants.d.ts.map +1 -0
  170. package/{dist-esm/src → dist/esm}/Declarations/Constants.js +19 -1
  171. package/dist/esm/Declarations/Constants.js.map +1 -0
  172. package/dist/esm/Declarations/Contracts/Constants.d.ts +14 -0
  173. package/dist/esm/Declarations/Contracts/Constants.d.ts.map +1 -0
  174. package/dist/esm/Declarations/Contracts/index.d.ts +2 -0
  175. package/dist/esm/Declarations/Contracts/index.d.ts.map +1 -0
  176. package/{dist-esm/src/platform/nodejs/context → dist/esm/Declarations/Contracts}/index.js +1 -1
  177. package/dist/esm/Declarations/Contracts/index.js.map +1 -0
  178. package/dist/esm/config.d.ts +30 -0
  179. package/dist/esm/config.d.ts.map +1 -0
  180. package/dist/esm/config.js.map +1 -0
  181. package/dist/esm/export/base.d.ts +36 -0
  182. package/dist/esm/export/base.d.ts.map +1 -0
  183. package/{dist-esm/src → dist/esm}/export/base.js +3 -3
  184. package/dist/esm/export/base.js.map +1 -0
  185. package/dist/esm/export/log.d.ts +30 -0
  186. package/dist/esm/export/log.d.ts.map +1 -0
  187. package/{dist-esm/src → dist/esm}/export/log.js +3 -4
  188. package/dist/esm/export/log.js.map +1 -0
  189. package/dist/esm/export/metric.d.ts +39 -0
  190. package/dist/esm/export/metric.d.ts.map +1 -0
  191. package/{dist-esm/src → dist/esm}/export/metric.js +4 -5
  192. package/dist/esm/export/metric.js.map +1 -0
  193. package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.d.ts +39 -0
  194. package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.d.ts.map +1 -0
  195. package/{dist-esm/src → dist/esm}/export/statsbeat/longIntervalStatsbeatMetrics.js +16 -14
  196. package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -0
  197. package/dist/esm/export/statsbeat/networkStatsbeatMetrics.d.ts +51 -0
  198. package/dist/esm/export/statsbeat/networkStatsbeatMetrics.d.ts.map +1 -0
  199. package/{dist-esm/src → dist/esm}/export/statsbeat/networkStatsbeatMetrics.js +45 -8
  200. package/dist/esm/export/statsbeat/networkStatsbeatMetrics.js.map +1 -0
  201. package/dist/esm/export/statsbeat/statsbeatExporter.d.ts +32 -0
  202. package/dist/esm/export/statsbeat/statsbeatExporter.d.ts.map +1 -0
  203. package/{dist-esm/src → dist/esm}/export/statsbeat/statsbeatExporter.js +3 -4
  204. package/dist/esm/export/statsbeat/statsbeatExporter.js.map +1 -0
  205. package/dist/esm/export/statsbeat/statsbeatMetrics.d.ts +11 -0
  206. package/dist/esm/export/statsbeat/statsbeatMetrics.d.ts.map +1 -0
  207. package/{dist-esm/src → dist/esm}/export/statsbeat/statsbeatMetrics.js +3 -4
  208. package/dist/esm/export/statsbeat/statsbeatMetrics.js.map +1 -0
  209. package/dist/esm/export/statsbeat/types.d.ts +97 -0
  210. package/dist/esm/export/statsbeat/types.d.ts.map +1 -0
  211. package/{dist-esm/src → dist/esm}/export/statsbeat/types.js +14 -0
  212. package/dist/esm/export/statsbeat/types.js.map +1 -0
  213. package/dist/esm/export/trace.d.ts +31 -0
  214. package/dist/esm/export/trace.d.ts.map +1 -0
  215. package/{dist-esm/src → dist/esm}/export/trace.js +4 -5
  216. package/dist/esm/export/trace.js.map +1 -0
  217. package/dist/esm/generated/applicationInsightsClient.d.ts +17 -0
  218. package/dist/esm/generated/applicationInsightsClient.d.ts.map +1 -0
  219. package/{dist-esm/src → dist/esm}/generated/applicationInsightsClient.js +3 -3
  220. package/dist/esm/generated/applicationInsightsClient.js.map +1 -0
  221. package/dist/esm/generated/index.d.ts +3 -0
  222. package/dist/esm/generated/index.d.ts.map +1 -0
  223. package/{dist-esm/src → dist/esm}/generated/index.js +2 -2
  224. package/dist/esm/generated/index.js.map +1 -0
  225. package/dist/esm/generated/models/index.d.ts +429 -0
  226. package/dist/esm/generated/models/index.d.ts.map +1 -0
  227. package/dist/esm/generated/models/mappers.d.ts +19 -0
  228. package/dist/esm/generated/models/mappers.d.ts.map +1 -0
  229. package/dist/esm/generated/models/parameters.d.ts +6 -0
  230. package/dist/esm/generated/models/parameters.d.ts.map +1 -0
  231. package/dist/esm/index.d.ts +10 -0
  232. package/dist/esm/index.d.ts.map +1 -0
  233. package/dist/esm/index.js +10 -0
  234. package/dist/esm/index.js.map +1 -0
  235. package/dist/esm/package.json +3 -0
  236. package/dist/esm/platform/index.d.ts +2 -0
  237. package/dist/esm/platform/index.d.ts.map +1 -0
  238. package/{dist-esm/src → dist/esm}/platform/index.js +1 -1
  239. package/dist/esm/platform/index.js.map +1 -0
  240. package/dist/esm/platform/nodejs/baseSender.d.ts +49 -0
  241. package/dist/esm/platform/nodejs/baseSender.d.ts.map +1 -0
  242. package/{dist-esm/src → dist/esm}/platform/nodejs/baseSender.js +27 -11
  243. package/dist/esm/platform/nodejs/baseSender.js.map +1 -0
  244. package/dist/esm/platform/nodejs/constants.d.ts +10 -0
  245. package/dist/esm/platform/nodejs/constants.d.ts.map +1 -0
  246. package/dist/esm/platform/nodejs/context/context.d.ts +20 -0
  247. package/dist/esm/platform/nodejs/context/context.d.ts.map +1 -0
  248. package/{dist-esm/src → dist/esm}/platform/nodejs/context/context.js +5 -5
  249. package/dist/esm/platform/nodejs/context/context.js.map +1 -0
  250. package/dist/esm/platform/nodejs/context/index.d.ts +2 -0
  251. package/dist/esm/platform/nodejs/context/index.d.ts.map +1 -0
  252. package/{dist-esm/src/Declarations/Contracts → dist/esm/platform/nodejs/context}/index.js +1 -1
  253. package/{dist-esm/src → dist/esm}/platform/nodejs/context/index.js.map +1 -1
  254. package/dist/esm/platform/nodejs/httpSender.d.ts +32 -0
  255. package/dist/esm/platform/nodejs/httpSender.d.ts.map +1 -0
  256. package/{dist-esm/src → dist/esm}/platform/nodejs/httpSender.js +3 -4
  257. package/dist/esm/platform/nodejs/httpSender.js.map +1 -0
  258. package/dist/esm/platform/nodejs/index.d.ts +8 -0
  259. package/dist/esm/platform/nodejs/index.d.ts.map +1 -0
  260. package/dist/esm/platform/nodejs/index.js +10 -0
  261. package/dist/esm/platform/nodejs/index.js.map +1 -0
  262. package/dist/esm/platform/nodejs/persist/fileAccessControl.d.ts +18 -0
  263. package/dist/esm/platform/nodejs/persist/fileAccessControl.d.ts.map +1 -0
  264. package/{dist-esm/src → dist/esm}/platform/nodejs/persist/fileAccessControl.js +14 -13
  265. package/dist/esm/platform/nodejs/persist/fileAccessControl.js.map +1 -0
  266. package/dist/esm/platform/nodejs/persist/fileSystemHelpers.d.ts +11 -0
  267. package/dist/esm/platform/nodejs/persist/fileSystemHelpers.d.ts.map +1 -0
  268. package/{dist-esm/src → dist/esm}/platform/nodejs/persist/fileSystemHelpers.js +6 -11
  269. package/dist/esm/platform/nodejs/persist/fileSystemHelpers.js.map +1 -0
  270. package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts +29 -0
  271. package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -0
  272. package/{dist-esm/src → dist/esm}/platform/nodejs/persist/fileSystemPersist.js +19 -26
  273. package/dist/esm/platform/nodejs/persist/fileSystemPersist.js.map +1 -0
  274. package/dist/esm/platform/nodejs/persist/index.d.ts +2 -0
  275. package/dist/esm/platform/nodejs/persist/index.d.ts.map +1 -0
  276. package/{dist-esm/src → dist/esm}/platform/nodejs/persist/index.js +1 -1
  277. package/{dist-esm/src → dist/esm}/platform/nodejs/persist/index.js.map +1 -1
  278. package/dist/esm/sampling.d.ts +38 -0
  279. package/dist/esm/sampling.d.ts.map +1 -0
  280. package/{dist-esm/src → dist/esm}/sampling.js +1 -1
  281. package/dist/esm/sampling.js.map +1 -0
  282. package/dist/esm/types.d.ts +86 -0
  283. package/dist/esm/types.d.ts.map +1 -0
  284. package/dist/esm/types.js.map +1 -0
  285. package/dist/esm/utils/breezeUtils.d.ts +25 -0
  286. package/dist/esm/utils/breezeUtils.d.ts.map +1 -0
  287. package/dist/esm/utils/common.d.ts +14 -0
  288. package/dist/esm/utils/common.d.ts.map +1 -0
  289. package/{dist-esm/src → dist/esm}/utils/common.js +20 -11
  290. package/dist/esm/utils/common.js.map +1 -0
  291. package/dist/esm/utils/connectionStringParser.d.ts +13 -0
  292. package/dist/esm/utils/connectionStringParser.d.ts.map +1 -0
  293. package/{dist-esm/src → dist/esm}/utils/connectionStringParser.js +1 -1
  294. package/dist/esm/utils/connectionStringParser.js.map +1 -0
  295. package/dist/esm/utils/constants/applicationinsights.d.ts +41 -0
  296. package/dist/esm/utils/constants/applicationinsights.d.ts.map +1 -0
  297. package/{dist-esm/src → dist/esm}/utils/constants/applicationinsights.js +1 -1
  298. package/{dist-esm/src → dist/esm}/utils/constants/applicationinsights.js.map +1 -1
  299. package/dist/esm/utils/constants/span/azAttributes.d.ts +16 -0
  300. package/dist/esm/utils/constants/span/azAttributes.d.ts.map +1 -0
  301. package/dist/esm/utils/eventhub.d.ts +10 -0
  302. package/dist/esm/utils/eventhub.d.ts.map +1 -0
  303. package/{dist-esm/src → dist/esm}/utils/eventhub.js +2 -2
  304. package/dist/esm/utils/eventhub.js.map +1 -0
  305. package/dist/esm/utils/logUtils.d.ts +8 -0
  306. package/dist/esm/utils/logUtils.d.ts.map +1 -0
  307. package/{dist-esm/src → dist/esm}/utils/logUtils.js +15 -11
  308. package/dist/esm/utils/logUtils.js.map +1 -0
  309. package/dist/esm/utils/metricUtils.d.ts +8 -0
  310. package/dist/esm/utils/metricUtils.d.ts.map +1 -0
  311. package/{dist-esm/src → dist/esm}/utils/metricUtils.js +2 -2
  312. package/dist/esm/utils/metricUtils.js.map +1 -0
  313. package/dist/esm/utils/spanUtils.d.ts +13 -0
  314. package/dist/esm/utils/spanUtils.d.ts.map +1 -0
  315. package/{dist-esm/src → dist/esm}/utils/spanUtils.js +33 -13
  316. package/dist/esm/utils/spanUtils.js.map +1 -0
  317. package/package.json +69 -50
  318. package/dist/index.js +0 -4045
  319. package/dist-esm/src/Declarations/Constants.js.map +0 -1
  320. package/dist-esm/src/Declarations/Contracts/index.js.map +0 -1
  321. package/dist-esm/src/config.js.map +0 -1
  322. package/dist-esm/src/export/base.js.map +0 -1
  323. package/dist-esm/src/export/log.js.map +0 -1
  324. package/dist-esm/src/export/metric.js.map +0 -1
  325. package/dist-esm/src/export/statsbeat/longIntervalStatsbeatMetrics.js.map +0 -1
  326. package/dist-esm/src/export/statsbeat/networkStatsbeatMetrics.js.map +0 -1
  327. package/dist-esm/src/export/statsbeat/statsbeatExporter.js.map +0 -1
  328. package/dist-esm/src/export/statsbeat/statsbeatMetrics.js.map +0 -1
  329. package/dist-esm/src/export/statsbeat/types.js.map +0 -1
  330. package/dist-esm/src/export/trace.js.map +0 -1
  331. package/dist-esm/src/generated/applicationInsightsClient.js.map +0 -1
  332. package/dist-esm/src/generated/index.js.map +0 -1
  333. package/dist-esm/src/index.js +0 -9
  334. package/dist-esm/src/index.js.map +0 -1
  335. package/dist-esm/src/platform/index.js.map +0 -1
  336. package/dist-esm/src/platform/nodejs/baseSender.js.map +0 -1
  337. package/dist-esm/src/platform/nodejs/context/context.js.map +0 -1
  338. package/dist-esm/src/platform/nodejs/httpSender.js.map +0 -1
  339. package/dist-esm/src/platform/nodejs/index.js +0 -10
  340. package/dist-esm/src/platform/nodejs/index.js.map +0 -1
  341. package/dist-esm/src/platform/nodejs/persist/fileAccessControl.js.map +0 -1
  342. package/dist-esm/src/platform/nodejs/persist/fileSystemHelpers.js.map +0 -1
  343. package/dist-esm/src/platform/nodejs/persist/fileSystemPersist.js.map +0 -1
  344. package/dist-esm/src/sampling.js.map +0 -1
  345. package/dist-esm/src/types.js.map +0 -1
  346. package/dist-esm/src/utils/common.js.map +0 -1
  347. package/dist-esm/src/utils/connectionStringParser.js.map +0 -1
  348. package/dist-esm/src/utils/eventhub.js.map +0 -1
  349. package/dist-esm/src/utils/logUtils.js.map +0 -1
  350. package/dist-esm/src/utils/metricUtils.js.map +0 -1
  351. package/dist-esm/src/utils/spanUtils.js.map +0 -1
  352. package/types/monitor-opentelemetry-exporter.d.ts +0 -222
  353. /package/{dist-esm/src → dist/esm}/Declarations/Contracts/Constants.js +0 -0
  354. /package/{dist-esm/src → dist/esm}/Declarations/Contracts/Constants.js.map +0 -0
  355. /package/{dist-esm/src → dist/esm}/config.js +0 -0
  356. /package/{dist-esm/src → dist/esm}/generated/models/index.js +0 -0
  357. /package/{dist-esm/src → dist/esm}/generated/models/index.js.map +0 -0
  358. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js +0 -0
  359. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js.map +0 -0
  360. /package/{dist-esm/src → dist/esm}/generated/models/parameters.js +0 -0
  361. /package/{dist-esm/src → dist/esm}/generated/models/parameters.js.map +0 -0
  362. /package/{dist-esm/src → dist/esm}/platform/nodejs/constants.js +0 -0
  363. /package/{dist-esm/src → dist/esm}/platform/nodejs/constants.js.map +0 -0
  364. /package/{dist-esm/src → dist/esm}/types.js +0 -0
  365. /package/{dist-esm/src → dist/esm}/utils/breezeUtils.js +0 -0
  366. /package/{dist-esm/src → dist/esm}/utils/breezeUtils.js.map +0 -0
  367. /package/{dist-esm/src → dist/esm}/utils/constants/span/azAttributes.js +0 -0
  368. /package/{dist-esm/src → dist/esm}/utils/constants/span/azAttributes.js.map +0 -0
package/dist/index.js DELETED
@@ -1,4045 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
6
- var api = require('@opentelemetry/api');
7
- var core = require('@opentelemetry/core');
8
- var semanticConventions = require('@opentelemetry/semantic-conventions');
9
- var os$1 = require('os');
10
- var url = require('url');
11
- var coreRestPipeline = require('@azure/core-rest-pipeline');
12
- var sdkMetrics = require('@opentelemetry/sdk-metrics');
13
- var fs = require('fs');
14
- var path = require('path');
15
- var child_process = require('child_process');
16
- var util = require('util');
17
- var coreClient = require('@azure/core-client');
18
-
19
- function _interopNamespaceDefault(e) {
20
- var n = Object.create(null);
21
- if (e) {
22
- Object.keys(e).forEach(function (k) {
23
- if (k !== 'default') {
24
- var d = Object.getOwnPropertyDescriptor(e, k);
25
- Object.defineProperty(n, k, d.get ? d : {
26
- enumerable: true,
27
- get: function () { return e[k]; }
28
- });
29
- }
30
- });
31
- }
32
- n.default = e;
33
- return Object.freeze(n);
34
- }
35
-
36
- var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os$1);
37
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
38
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
39
- var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
40
- var coreClient__namespace = /*#__PURE__*/_interopNamespaceDefault(coreClient);
41
-
42
- // Copyright (c) Microsoft Corporation.
43
- // Licensed under the MIT License.
44
- /**
45
- * AI MS Links.
46
- * @internal
47
- */
48
- const MS_LINKS = "_MS.links";
49
- /**
50
- * AI enqueued time attribute.
51
- * @internal
52
- */
53
- const ENQUEUED_TIME = "enqueuedTime";
54
- /**
55
- * AI time since enqueued attribute.
56
- * @internal
57
- */
58
- const TIME_SINCE_ENQUEUED = "timeSinceEnqueued";
59
- /**
60
- * AzureMonitorTraceExporter version.
61
- * @internal
62
- */
63
- const packageVersion = "1.0.0-beta.26";
64
- var DependencyTypes;
65
- (function (DependencyTypes) {
66
- DependencyTypes["InProc"] = "InProc";
67
- DependencyTypes["QueueMessage"] = "Queue Message";
68
- DependencyTypes["Sql"] = "SQL";
69
- DependencyTypes["Http"] = "Http";
70
- DependencyTypes["Grpc"] = "GRPC";
71
- DependencyTypes["Wcf"] = "WCF Service";
72
- })(DependencyTypes || (DependencyTypes = {}));
73
- const AzureMonitorSampleRate = "microsoft.sample_rate";
74
- const ApplicationInsightsBaseType = "_MS.baseType";
75
- const ApplicationInsightsMessageName = "Microsoft.ApplicationInsights.Message";
76
- const ApplicationInsightsExceptionName = "Microsoft.ApplicationInsights.Exception";
77
- const ApplicationInsightsPageViewName = "Microsoft.ApplicationInsights.PageView";
78
- const ApplicationInsightsAvailabilityName = "Microsoft.ApplicationInsights.Availability";
79
- const ApplicationInsightsEventName = "Microsoft.ApplicationInsights.Event";
80
- const ApplicationInsightsMessageBaseType = "MessageData";
81
- const ApplicationInsightsExceptionBaseType = "ExceptionData";
82
- const ApplicationInsightsPageViewBaseType = "PageViewData";
83
- const ApplicationInsightsAvailabilityBaseType = "AvailabilityData";
84
- const ApplicationInsightsEventBaseType = "EventData";
85
-
86
- /**
87
- * ApplicationInsightsSampler is responsible for the following:
88
- * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes
89
- * Adds item count to span attribute if span is sampled (needed for ingestion service)
90
- * @param samplingRatio - 0 to 1 value.
91
- */
92
- class ApplicationInsightsSampler {
93
- /**
94
- * Initializes a new instance of the ApplicationInsightsSampler class.
95
- * @param samplingRatio - Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.
96
- */
97
- constructor(samplingRatio = 1) {
98
- this.samplingRatio = samplingRatio;
99
- if (this.samplingRatio > 1 || this.samplingRatio < 0 || !Number.isFinite(this.samplingRatio)) {
100
- throw new Error("Wrong sampling rate, data will not be sampled out");
101
- }
102
- this._sampleRate = Math.round(this.samplingRatio * 100);
103
- }
104
- /**
105
- * Checks whether span needs to be created and tracked.
106
- *
107
- * @param context - Parent Context which may contain a span.
108
- * @param traceId - traceif of the span to be created. It can be different from the
109
- * traceId in the {@link SpanContext}. Typically in situations when the
110
- * span to be created starts a new trace.
111
- * @param spanName - Name of the span to be created.
112
- * @param spanKind - Kind of the span to be created.
113
- * @param attributes - Initial set of SpanAttributes for the Span being constructed.
114
- * @param links - Collection of links that will be associated with the Span to
115
- * be created. Typically useful for batch operations.
116
- * @returns a {@link SamplingResult}.
117
- */
118
- shouldSample(
119
- // @ts-expect-error unused argument
120
- context, traceId,
121
- // @ts-expect-error unused argument
122
- spanName,
123
- // @ts-expect-error unused argument
124
- spanKind, attributes,
125
- // @ts-expect-error unused argument
126
- links) {
127
- let isSampledIn = false;
128
- if (this._sampleRate === 100) {
129
- isSampledIn = true;
130
- }
131
- else if (this._sampleRate === 0) {
132
- isSampledIn = false;
133
- }
134
- else {
135
- isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;
136
- }
137
- // Add sample rate as span attribute
138
- attributes = attributes || {};
139
- // Only send the sample rate if it's not 100
140
- if (this._sampleRate !== 100) {
141
- attributes[AzureMonitorSampleRate] = this._sampleRate;
142
- }
143
- return isSampledIn
144
- ? { decision: sdkTraceBase.SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }
145
- : { decision: sdkTraceBase.SamplingDecision.NOT_RECORD, attributes: attributes };
146
- }
147
- /**
148
- * Return Sampler description
149
- */
150
- toString() {
151
- return `ApplicationInsightsSampler{${this.samplingRatio}}`;
152
- }
153
- _getSamplingHashCode(input) {
154
- const csharpMin = -2147483648;
155
- const csharpMax = 2147483647;
156
- let hash = 5381;
157
- if (!input) {
158
- return 0;
159
- }
160
- while (input.length < 8) {
161
- input = input + input;
162
- }
163
- for (let i = 0; i < input.length; i++) {
164
- // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)
165
- hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;
166
- }
167
- hash = hash <= csharpMin ? csharpMax : Math.abs(hash);
168
- return (hash / csharpMax) * 100;
169
- }
170
- }
171
-
172
- // Copyright (c) Microsoft Corporation.
173
- // Licensed under the MIT License.
174
- /**
175
- * Azure service API version.
176
- */
177
- exports.ServiceApiVersion = void 0;
178
- (function (ServiceApiVersion) {
179
- /**
180
- * V2 Version
181
- */
182
- ServiceApiVersion["V2"] = "2020-09-15_Preview";
183
- })(exports.ServiceApiVersion || (exports.ServiceApiVersion = {}));
184
- /**
185
- * Default Breeze endpoint.
186
- * @internal
187
- */
188
- const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com";
189
- /**
190
- * Default Breeze API version.
191
- * @internal
192
- */
193
- exports.ServiceApiVersion.V2;
194
- /**
195
- * Default Live Metrics endpoint.
196
- * @internal
197
- */
198
- const DEFAULT_LIVEMETRICS_ENDPOINT = "https://rt.services.visualstudio.com";
199
- /**
200
- * Connection string environment variable name.
201
- * @internal
202
- */
203
- const ENV_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING";
204
- /**
205
- * Disable Statsbeat environment variable name.
206
- * @internal
207
- */
208
- const ENV_DISABLE_STATSBEAT = "APPLICATION_INSIGHTS_NO_STATSBEAT";
209
- /**
210
- * QuickPulse metric counter names.
211
- * @internal
212
- */
213
- var QuickPulseCounter;
214
- (function (QuickPulseCounter) {
215
- // Memory
216
- QuickPulseCounter["COMMITTED_BYTES"] = "\\Memory\\Committed Bytes";
217
- // CPU
218
- QuickPulseCounter["PROCESSOR_TIME"] = "\\Processor(_Total)\\% Processor Time";
219
- // Request
220
- QuickPulseCounter["REQUEST_RATE"] = "\\ApplicationInsights\\Requests/Sec";
221
- QuickPulseCounter["REQUEST_FAILURE_RATE"] = "\\ApplicationInsights\\Requests Failed/Sec";
222
- QuickPulseCounter["REQUEST_DURATION"] = "\\ApplicationInsights\\Request Duration";
223
- // Dependency
224
- QuickPulseCounter["DEPENDENCY_RATE"] = "\\ApplicationInsights\\Dependency Calls/Sec";
225
- QuickPulseCounter["DEPENDENCY_FAILURE_RATE"] = "\\ApplicationInsights\\Dependency Calls Failed/Sec";
226
- QuickPulseCounter["DEPENDENCY_DURATION"] = "\\ApplicationInsights\\Dependency Call Duration";
227
- // Exception
228
- QuickPulseCounter["EXCEPTION_RATE"] = "\\ApplicationInsights\\Exceptions/Sec";
229
- })(QuickPulseCounter || (QuickPulseCounter = {}));
230
- /**
231
- * Performance metric counter names.
232
- * @internal
233
- */
234
- var PerformanceCounter;
235
- (function (PerformanceCounter) {
236
- // Memory
237
- PerformanceCounter["PRIVATE_BYTES"] = "\\Process(??APP_WIN32_PROC??)\\Private Bytes";
238
- PerformanceCounter["AVAILABLE_BYTES"] = "\\Memory\\Available Bytes";
239
- // CPU
240
- PerformanceCounter["PROCESSOR_TIME"] = "\\Processor(_Total)\\% Processor Time";
241
- PerformanceCounter["PROCESS_TIME"] = "\\Process(??APP_WIN32_PROC??)\\% Processor Time";
242
- // Requests
243
- PerformanceCounter["REQUEST_RATE"] = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Requests/Sec";
244
- PerformanceCounter["REQUEST_DURATION"] = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Request Execution Time";
245
- })(PerformanceCounter || (PerformanceCounter = {}));
246
- /**
247
- * Map a PerformanceCounter/QuickPulseCounter to a QuickPulseCounter. If no mapping exists, mapping is *undefined*
248
- * @internal
249
- */
250
- ({
251
- [PerformanceCounter.PROCESSOR_TIME]: QuickPulseCounter.PROCESSOR_TIME,
252
- [PerformanceCounter.REQUEST_RATE]: QuickPulseCounter.REQUEST_RATE,
253
- [PerformanceCounter.REQUEST_DURATION]: QuickPulseCounter.REQUEST_DURATION,
254
- // Remap quick pulse only counters
255
- [QuickPulseCounter.COMMITTED_BYTES]: QuickPulseCounter.COMMITTED_BYTES,
256
- [QuickPulseCounter.REQUEST_FAILURE_RATE]: QuickPulseCounter.REQUEST_FAILURE_RATE,
257
- [QuickPulseCounter.DEPENDENCY_RATE]: QuickPulseCounter.DEPENDENCY_RATE,
258
- [QuickPulseCounter.DEPENDENCY_FAILURE_RATE]: QuickPulseCounter.DEPENDENCY_FAILURE_RATE,
259
- [QuickPulseCounter.DEPENDENCY_DURATION]: QuickPulseCounter.DEPENDENCY_DURATION,
260
- [QuickPulseCounter.EXCEPTION_RATE]: QuickPulseCounter.EXCEPTION_RATE,
261
- });
262
-
263
- // Copyright (c) Microsoft Corporation.
264
- // Licensed under the MIT License.
265
- /**
266
- * ConnectionString parser.
267
- * @internal
268
- */
269
- class ConnectionStringParser {
270
- static parse(connectionString) {
271
- if (!connectionString) {
272
- return {};
273
- }
274
- const kvPairs = connectionString.split(ConnectionStringParser.FIELDS_SEPARATOR);
275
- let isValid = true;
276
- const result = kvPairs.reduce((fields, kv) => {
277
- const kvParts = kv.split(ConnectionStringParser.FIELD_KEY_VALUE_SEPARATOR);
278
- if (kvParts.length === 2) {
279
- // only save fields with valid formats
280
- const key = kvParts[0].toLowerCase();
281
- const value = kvParts[1];
282
- return Object.assign(Object.assign({}, fields), { [key]: value });
283
- }
284
- api.diag.error(`Connection string key-value pair is invalid: ${kv}`, `Entire connection string will be discarded`, connectionString);
285
- isValid = false;
286
- return fields;
287
- }, {});
288
- if (isValid && Object.keys(result).length > 0) {
289
- // this is a valid connection string, so parse the results
290
- if (result.endpointsuffix) {
291
- // use endpoint suffix where overrides are not provided
292
- const locationPrefix = result.location ? `${result.location}.` : "";
293
- result.ingestionendpoint =
294
- result.ingestionendpoint || `https://${locationPrefix}dc.${result.endpointsuffix}`;
295
- result.liveendpoint =
296
- result.liveendpoint || `https://${locationPrefix}live.${result.endpointsuffix}`;
297
- }
298
- result.ingestionendpoint = result.ingestionendpoint
299
- ? ConnectionStringParser.sanitizeUrl(result.ingestionendpoint)
300
- : DEFAULT_BREEZE_ENDPOINT;
301
- result.liveendpoint = result.liveendpoint
302
- ? ConnectionStringParser.sanitizeUrl(result.liveendpoint)
303
- : DEFAULT_LIVEMETRICS_ENDPOINT;
304
- if (result.authorization && result.authorization.toLowerCase() !== "ikey") {
305
- api.diag.warn(`Connection String contains an unsupported 'Authorization' value: ${result.authorization}. Defaulting to 'Authorization=ikey'. Instrumentation Key ${result.instrumentationkey}`);
306
- }
307
- }
308
- else {
309
- api.diag.error("An invalid connection string was passed in. There may be telemetry loss", connectionString);
310
- }
311
- return result;
312
- }
313
- static sanitizeUrl(url) {
314
- let newUrl = url.trim();
315
- if (newUrl.indexOf("https://") < 0) {
316
- // Try to update http to https
317
- newUrl = newUrl.replace("http://", "https://");
318
- }
319
- // Remove final slash if present
320
- if (newUrl[newUrl.length - 1] === "/") {
321
- newUrl = newUrl.slice(0, -1);
322
- }
323
- return newUrl;
324
- }
325
- static validateInstrumentationKey(iKey) {
326
- if (iKey.startsWith("InstrumentationKey=")) {
327
- const startIndex = iKey.indexOf("InstrumentationKey=") + "InstrumentationKey=".length;
328
- const endIndex = iKey.indexOf(";", startIndex);
329
- iKey = iKey.substring(startIndex, endIndex);
330
- }
331
- const UUID_Regex = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
332
- const regexp = new RegExp(UUID_Regex);
333
- return regexp.test(iKey);
334
- }
335
- }
336
- ConnectionStringParser.FIELDS_SEPARATOR = ";";
337
- ConnectionStringParser.FIELD_KEY_VALUE_SEPARATOR = "=";
338
-
339
- // Copyright (c) Microsoft Corporation.
340
- // Licensed under the MIT License.
341
- /**
342
- * Azure Monitor OpenTelemetry Trace Exporter.
343
- */
344
- class AzureMonitorBaseExporter {
345
- /**
346
- * Initializes a new instance of the AzureMonitorBaseExporter class.
347
- * @param AzureMonitorExporterOptions - Exporter configuration.
348
- */
349
- constructor(options = {}, isStatsbeatExporter) {
350
- var _a;
351
- /**
352
- * Instrumentation key to be used for exported envelopes
353
- */
354
- this.instrumentationKey = "";
355
- /**
356
- * Ingestion Endpoint URL
357
- */
358
- this.endpointUrl = "";
359
- /**
360
- *Flag to determine if exporter will generate Statsbeat data
361
- */
362
- this.trackStatsbeat = false;
363
- this.options = options;
364
- this.instrumentationKey = "";
365
- this.endpointUrl = DEFAULT_BREEZE_ENDPOINT;
366
- const connectionString = this.options.connectionString || process.env[ENV_CONNECTION_STRING];
367
- this.isStatsbeatExporter = isStatsbeatExporter ? isStatsbeatExporter : false;
368
- if (connectionString) {
369
- const parsedConnectionString = ConnectionStringParser.parse(connectionString);
370
- this.instrumentationKey =
371
- parsedConnectionString.instrumentationkey || this.instrumentationKey;
372
- this.endpointUrl = ((_a = parsedConnectionString.ingestionendpoint) === null || _a === void 0 ? void 0 : _a.trim()) || this.endpointUrl;
373
- this.aadAudience = parsedConnectionString.aadaudience;
374
- }
375
- // Instrumentation key is required
376
- if (!this.instrumentationKey) {
377
- const message = "No instrumentation key or connection string was provided to the Azure Monitor Exporter";
378
- api.diag.error(message);
379
- throw new Error(message);
380
- }
381
- if (!ConnectionStringParser.validateInstrumentationKey(this.instrumentationKey)) {
382
- const message = "Invalid instrumentation key was provided to the Azure Monitor Exporter";
383
- api.diag.error(message);
384
- throw new Error(message);
385
- }
386
- this.trackStatsbeat = !this.isStatsbeatExporter && !process.env[ENV_DISABLE_STATSBEAT];
387
- api.diag.debug("AzureMonitorExporter was successfully setup");
388
- }
389
- }
390
-
391
- // Copyright (c) Microsoft Corporation.
392
- // Licensed under the MIT License.
393
- class FileAccessControl {
394
- // Check if file access control could be enabled
395
- static checkFileProtection() {
396
- if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION &&
397
- !FileAccessControl.OS_FILE_PROTECTION_CHECKED) {
398
- FileAccessControl.OS_FILE_PROTECTION_CHECKED = true;
399
- // Node's chmod levels do not appropriately restrict file access on Windows
400
- // Use the built-in command line tool ICACLS on Windows to properly restrict
401
- // access to the temporary directory used for disk retry mode.
402
- if (FileAccessControl.USE_ICACLS) {
403
- // This should be async - but it's currently safer to have this synchronous
404
- // This guarantees we can immediately fail setDiskRetryMode if we need to
405
- try {
406
- FileAccessControl.OS_PROVIDES_FILE_PROTECTION = fs__namespace.existsSync(FileAccessControl.ICACLS_PATH);
407
- }
408
- catch (e) {
409
- // Ignore error
410
- }
411
- if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {
412
- api.diag.warn("Could not find ICACLS in expected location! This is necessary to use disk retry mode on Windows.");
413
- }
414
- }
415
- else {
416
- // chmod works everywhere else
417
- FileAccessControl.OS_PROVIDES_FILE_PROTECTION = true;
418
- }
419
- }
420
- }
421
- static async applyACLRules(directory) {
422
- if (FileAccessControl.USE_ICACLS) {
423
- if (FileAccessControl.ACLED_DIRECTORIES[directory] === undefined) {
424
- // Avoid multiple calls race condition by setting ACLED_DIRECTORIES to false for this directory immediately
425
- // If batches are being failed faster than the processes spawned below return, some data won't be stored to disk
426
- // This is better than the alternative of potentially infinitely spawned processes
427
- FileAccessControl.ACLED_DIRECTORIES[directory] = false;
428
- try {
429
- // Restrict this directory to only current user and administrator access
430
- const identity = await this._getACLIdentity();
431
- await this._runICACLS(this._getACLArguments(directory, identity));
432
- FileAccessControl.ACLED_DIRECTORIES[directory] = true;
433
- }
434
- catch (ex) {
435
- FileAccessControl.ACLED_DIRECTORIES[directory] = false; // false is used to cache failed (vs undefined which is "not yet tried")
436
- throw ex;
437
- }
438
- }
439
- else {
440
- if (!FileAccessControl.ACLED_DIRECTORIES[directory]) {
441
- throw new Error("Setting ACL restrictions did not succeed (cached result)");
442
- }
443
- }
444
- }
445
- }
446
- static applyACLRulesSync(directory) {
447
- if (FileAccessControl.USE_ICACLS) {
448
- // For performance, only run ACL rules if we haven't already during this session
449
- if (FileAccessControl.ACLED_DIRECTORIES[directory] === undefined) {
450
- this._runICACLSSync(this._getACLArguments(directory, this._getACLIdentitySync()));
451
- FileAccessControl.ACLED_DIRECTORIES[directory] = true; // If we get here, it succeeded. _runIACLSSync will throw on failures
452
- return;
453
- }
454
- else if (!FileAccessControl.ACLED_DIRECTORIES[directory]) {
455
- // falsy but not undefined
456
- throw new Error("Setting ACL restrictions did not succeed (cached result)");
457
- }
458
- }
459
- }
460
- static _runICACLS(args) {
461
- return new Promise((resolve, reject) => {
462
- const aclProc = child_process__namespace.spawn(FileAccessControl.ICACLS_PATH, args, {
463
- windowsHide: true,
464
- });
465
- aclProc.on("error", (e) => reject(e));
466
- aclProc.on("close", (code) => {
467
- if (code === 0) {
468
- resolve();
469
- }
470
- else {
471
- reject(new Error(`Setting ACL restrictions did not succeed (ICACLS returned code ${code})`));
472
- }
473
- });
474
- });
475
- }
476
- static _runICACLSSync(args) {
477
- // Some very old versions of Node (< 0.11) don't have this
478
- if (child_process__namespace.spawnSync) {
479
- const aclProc = child_process__namespace.spawnSync(FileAccessControl.ICACLS_PATH, args, {
480
- windowsHide: true,
481
- });
482
- if (aclProc.error) {
483
- throw aclProc.error;
484
- }
485
- else if (aclProc.status !== 0) {
486
- throw new Error(`Setting ACL restrictions did not succeed (ICACLS returned code ${aclProc.status})`);
487
- }
488
- }
489
- else {
490
- throw new Error("Could not synchronously call ICACLS under current version of Node.js");
491
- }
492
- }
493
- static _getACLIdentity() {
494
- return new Promise((resolve, reject) => {
495
- if (FileAccessControl.ACL_IDENTITY) {
496
- resolve(FileAccessControl.ACL_IDENTITY);
497
- }
498
- const psProc = child_process__namespace.spawn(FileAccessControl.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], {
499
- windowsHide: true,
500
- stdio: ["ignore", "pipe", "pipe"], // Needed to prevent hanging on Win 7
501
- });
502
- let data = "";
503
- psProc.stdout.on("data", (d) => (data += d));
504
- psProc.on("error", (e) => reject(e));
505
- psProc.on("close", (code) => {
506
- FileAccessControl.ACL_IDENTITY = data && data.trim();
507
- if (code === 0) {
508
- resolve(FileAccessControl.ACL_IDENTITY);
509
- }
510
- else {
511
- reject(new Error(`Getting ACL identity did not succeed (PS returned code ${code})`));
512
- }
513
- });
514
- });
515
- }
516
- static _getACLIdentitySync() {
517
- if (FileAccessControl.ACL_IDENTITY) {
518
- return FileAccessControl.ACL_IDENTITY;
519
- }
520
- // Some very old versions of Node (< 0.11) don't have this
521
- if (child_process__namespace.spawnSync) {
522
- const psProc = child_process__namespace.spawnSync(FileAccessControl.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], {
523
- windowsHide: true,
524
- stdio: ["ignore", "pipe", "pipe"], // Needed to prevent hanging on Win 7
525
- });
526
- if (psProc.error) {
527
- throw psProc.error;
528
- }
529
- else if (psProc.status !== 0) {
530
- throw new Error(`Getting ACL identity did not succeed (PS returned code ${psProc.status})`);
531
- }
532
- FileAccessControl.ACL_IDENTITY = psProc.stdout && psProc.stdout.toString().trim();
533
- return FileAccessControl.ACL_IDENTITY;
534
- }
535
- else {
536
- throw new Error("Could not synchronously get ACL identity under current version of Node.js");
537
- }
538
- }
539
- static _getACLArguments(directory, identity) {
540
- return [
541
- directory,
542
- "/grant",
543
- "*S-1-5-32-544:(OI)(CI)F", // Full permission for Administrators
544
- "/grant",
545
- `${identity}:(OI)(CI)F`, // Full permission for current user
546
- "/inheritance:r",
547
- ]; // Remove all inherited permissions
548
- }
549
- }
550
- FileAccessControl.ICACLS_PATH = `${process.env.systemdrive}/windows/system32/icacls.exe`;
551
- FileAccessControl.POWERSHELL_PATH = `${process.env.systemdrive}/windows/system32/windowspowershell/v1.0/powershell.exe`;
552
- FileAccessControl.ACLED_DIRECTORIES = {};
553
- FileAccessControl.ACL_IDENTITY = null;
554
- FileAccessControl.OS_FILE_PROTECTION_CHECKED = false;
555
- FileAccessControl.OS_PROVIDES_FILE_PROTECTION = false;
556
- FileAccessControl.USE_ICACLS = os__namespace.type() === "Windows_NT";
557
-
558
- // Copyright (c) Microsoft Corporation.
559
- // Licensed under the MIT License.
560
- const readdirAsync$1 = util.promisify(fs__namespace.readdir);
561
- const statAsync$1 = util.promisify(fs__namespace.stat);
562
- const lstatAsync = util.promisify(fs__namespace.lstat);
563
- const mkdirAsync = util.promisify(fs__namespace.mkdir);
564
- /**
565
- * Computes the size (in bytes) of all files in a directory at the root level. Asynchronously.
566
- * @internal
567
- */
568
- const getShallowDirectorySize = async (directory) => {
569
- let totalSize = 0;
570
- try {
571
- // Get the directory listing
572
- const files = await readdirAsync$1(directory);
573
- // Query all file sizes
574
- for (const file of files) {
575
- const fileStats = await statAsync$1(path__namespace.join(directory, file));
576
- if (fileStats.isFile()) {
577
- totalSize += fileStats.size;
578
- }
579
- }
580
- return totalSize;
581
- }
582
- catch (err) {
583
- api.diag.error(`Error getting directory size: ${err}`);
584
- return 0;
585
- }
586
- };
587
- /**
588
- * Validate directory exists.
589
- * @internal
590
- */
591
- const confirmDirExists = async (directory) => {
592
- try {
593
- const stats = await lstatAsync(directory);
594
- if (!stats.isDirectory()) {
595
- throw new Error("Path existed but was not a directory");
596
- }
597
- }
598
- catch (err) {
599
- if (err && err.code === "ENOENT") {
600
- try {
601
- const options = { recursive: true };
602
- await mkdirAsync(directory, options);
603
- }
604
- catch (mkdirErr) {
605
- if (mkdirErr && mkdirErr.code !== "EEXIST") {
606
- // Handle race condition by ignoring EEXIST
607
- throw mkdirErr;
608
- }
609
- }
610
- }
611
- }
612
- };
613
-
614
- // Copyright (c) Microsoft Corporation.
615
- // Licensed under the MIT License.
616
- const statAsync = util.promisify(fs__namespace.stat);
617
- const readdirAsync = util.promisify(fs__namespace.readdir);
618
- const readFileAsync = util.promisify(fs__namespace.readFile);
619
- const unlinkAsync = util.promisify(fs__namespace.unlink);
620
- const writeFileAsync = util.promisify(fs__namespace.writeFile);
621
- /**
622
- * File system persist class.
623
- * @internal
624
- */
625
- class FileSystemPersist {
626
- constructor(instrumentationKey, _options) {
627
- var _a, _b;
628
- this._options = _options;
629
- this.fileRetemptionPeriod = 2 * 24 * 60 * 60 * 1000; // 2 days
630
- this.cleanupTimeOut = 60 * 60 * 1000; // 1 hour
631
- this.maxBytesOnDisk = 50000000; // ~50MB
632
- this._tempDirectory = "";
633
- this._fileCleanupTimer = null;
634
- this._instrumentationKey = instrumentationKey;
635
- if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.disableOfflineStorage) {
636
- this._enabled = false;
637
- return;
638
- }
639
- this._enabled = true;
640
- FileAccessControl.checkFileProtection();
641
- if (!FileAccessControl.OS_PROVIDES_FILE_PROTECTION) {
642
- this._enabled = false;
643
- api.diag.error("Sufficient file protection capabilities were not detected. Files will not be persisted");
644
- }
645
- if (!this._instrumentationKey) {
646
- this._enabled = false;
647
- api.diag.error(`No instrumentation key was provided to FileSystemPersister. Files will not be persisted`);
648
- }
649
- if (this._enabled) {
650
- this._tempDirectory = path__namespace.join(((_b = this._options) === null || _b === void 0 ? void 0 : _b.storageDirectory) || os__namespace.tmpdir(), "Microsoft", "AzureMonitor", FileSystemPersist.TEMPDIR_PREFIX + this._instrumentationKey);
651
- // Starts file cleanup task
652
- if (!this._fileCleanupTimer) {
653
- this._fileCleanupTimer = setTimeout(() => {
654
- this._fileCleanupTask();
655
- }, this.cleanupTimeOut);
656
- this._fileCleanupTimer.unref();
657
- }
658
- }
659
- }
660
- push(value) {
661
- var _a;
662
- if (this._enabled) {
663
- api.diag.debug("Pushing value to persistent storage", value.toString());
664
- return this._storeToDisk(JSON.stringify(value));
665
- }
666
- // Only return a false promise if the SDK isn't set to disable offline storage
667
- if (!((_a = this._options) === null || _a === void 0 ? void 0 : _a.disableOfflineStorage)) {
668
- return new Promise((resolve) => {
669
- resolve(false);
670
- });
671
- }
672
- return new Promise((resolve) => {
673
- resolve(true);
674
- });
675
- }
676
- async shift() {
677
- if (this._enabled) {
678
- api.diag.debug("Searching for filesystem persisted files");
679
- try {
680
- const buffer = await this._getFirstFileOnDisk();
681
- if (buffer) {
682
- return JSON.parse(buffer.toString("utf8"));
683
- }
684
- }
685
- catch (e) {
686
- api.diag.debug("Failed to read persisted file", e);
687
- }
688
- return null;
689
- }
690
- return new Promise((resolve) => {
691
- resolve(null);
692
- });
693
- }
694
- /**
695
- * Check for temp telemetry files
696
- * reads the first file if exist, deletes it and tries to send its load
697
- */
698
- async _getFirstFileOnDisk() {
699
- try {
700
- const stats = await statAsync(this._tempDirectory);
701
- if (stats.isDirectory()) {
702
- const origFiles = await readdirAsync(this._tempDirectory);
703
- const files = origFiles.filter((f) => path__namespace.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
704
- if (files.length === 0) {
705
- return null;
706
- }
707
- else {
708
- const firstFile = files[0];
709
- const filePath = path__namespace.join(this._tempDirectory, firstFile);
710
- const payload = await readFileAsync(filePath);
711
- // delete the file first to prevent double sending
712
- await unlinkAsync(filePath);
713
- return payload;
714
- }
715
- }
716
- return null;
717
- }
718
- catch (e) {
719
- if (e.code === "ENOENT") {
720
- // File does not exist -- return null instead of throwing
721
- return null;
722
- }
723
- else {
724
- throw e;
725
- }
726
- }
727
- }
728
- async _storeToDisk(payload) {
729
- try {
730
- await confirmDirExists(this._tempDirectory);
731
- }
732
- catch (error) {
733
- api.diag.warn(`Error while checking/creating directory: `, error && error.message);
734
- return false;
735
- }
736
- try {
737
- const size = await getShallowDirectorySize(this._tempDirectory);
738
- if (size > this.maxBytesOnDisk) {
739
- api.diag.warn(`Not saving data due to max size limit being met. Directory size in bytes is: ${size}`);
740
- return false;
741
- }
742
- }
743
- catch (error) {
744
- api.diag.warn(`Error while checking size of persistence directory: `, error && error.message);
745
- return false;
746
- }
747
- const fileName = `${new Date().getTime()}${FileSystemPersist.FILENAME_SUFFIX}`;
748
- const fileFullPath = path__namespace.join(this._tempDirectory, fileName);
749
- // Mode 600 is w/r for creator and no read access for others
750
- api.diag.info(`saving data to disk at: ${fileFullPath}`);
751
- try {
752
- await writeFileAsync(fileFullPath, payload, { mode: 0o600 });
753
- }
754
- catch (writeError) {
755
- api.diag.warn(`Error writing file to persistent file storage`, writeError);
756
- return false;
757
- }
758
- return true;
759
- }
760
- async _fileCleanupTask() {
761
- try {
762
- const stats = await statAsync(this._tempDirectory);
763
- if (stats.isDirectory()) {
764
- const origFiles = await readdirAsync(this._tempDirectory);
765
- const files = origFiles.filter((f) => path__namespace.basename(f).includes(FileSystemPersist.FILENAME_SUFFIX));
766
- if (files.length === 0) {
767
- return false;
768
- }
769
- else {
770
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
771
- files.forEach(async (file) => {
772
- // Check expiration
773
- const fileCreationDate = new Date(parseInt(file.split(FileSystemPersist.FILENAME_SUFFIX)[0]));
774
- const expired = new Date(+new Date() - this.fileRetemptionPeriod) > fileCreationDate;
775
- if (expired) {
776
- const filePath = path__namespace.join(this._tempDirectory, file);
777
- await unlinkAsync(filePath);
778
- }
779
- });
780
- return true;
781
- }
782
- }
783
- return false;
784
- }
785
- catch (error) {
786
- api.diag.info(`Failed cleanup of persistent file storage expired files`, error);
787
- return false;
788
- }
789
- }
790
- }
791
- FileSystemPersist.TEMPDIR_PREFIX = "ot-azure-exporter-";
792
- FileSystemPersist.FILENAME_SUFFIX = ".ai.json";
793
-
794
- /*
795
- * Copyright (c) Microsoft Corporation.
796
- * Licensed under the MIT License.
797
- *
798
- * Code generated by Microsoft (R) AutoRest Code Generator.
799
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
800
- */
801
- /** Known values of {@link DataPointType} that the service accepts. */
802
- var KnownDataPointType;
803
- (function (KnownDataPointType) {
804
- /** Measurement */
805
- KnownDataPointType["Measurement"] = "Measurement";
806
- /** Aggregation */
807
- KnownDataPointType["Aggregation"] = "Aggregation";
808
- })(KnownDataPointType || (KnownDataPointType = {}));
809
- /** Known values of {@link SeverityLevel} that the service accepts. */
810
- var KnownSeverityLevel;
811
- (function (KnownSeverityLevel) {
812
- /** Verbose */
813
- KnownSeverityLevel["Verbose"] = "Verbose";
814
- /** Information */
815
- KnownSeverityLevel["Information"] = "Information";
816
- /** Warning */
817
- KnownSeverityLevel["Warning"] = "Warning";
818
- /** Error */
819
- KnownSeverityLevel["Error"] = "Error";
820
- /** Critical */
821
- KnownSeverityLevel["Critical"] = "Critical";
822
- })(KnownSeverityLevel || (KnownSeverityLevel = {}));
823
- /** Known values of {@link ContextTagKeys} that the service accepts. */
824
- var KnownContextTagKeys;
825
- (function (KnownContextTagKeys) {
826
- /** AiApplicationVer */
827
- KnownContextTagKeys["AiApplicationVer"] = "ai.application.ver";
828
- /** AiDeviceId */
829
- KnownContextTagKeys["AiDeviceId"] = "ai.device.id";
830
- /** AiDeviceLocale */
831
- KnownContextTagKeys["AiDeviceLocale"] = "ai.device.locale";
832
- /** AiDeviceModel */
833
- KnownContextTagKeys["AiDeviceModel"] = "ai.device.model";
834
- /** AiDeviceOemName */
835
- KnownContextTagKeys["AiDeviceOemName"] = "ai.device.oemName";
836
- /** AiDeviceOsVersion */
837
- KnownContextTagKeys["AiDeviceOsVersion"] = "ai.device.osVersion";
838
- /** AiDeviceType */
839
- KnownContextTagKeys["AiDeviceType"] = "ai.device.type";
840
- /** AiLocationIp */
841
- KnownContextTagKeys["AiLocationIp"] = "ai.location.ip";
842
- /** AiLocationCountry */
843
- KnownContextTagKeys["AiLocationCountry"] = "ai.location.country";
844
- /** AiLocationProvince */
845
- KnownContextTagKeys["AiLocationProvince"] = "ai.location.province";
846
- /** AiLocationCity */
847
- KnownContextTagKeys["AiLocationCity"] = "ai.location.city";
848
- /** AiOperationId */
849
- KnownContextTagKeys["AiOperationId"] = "ai.operation.id";
850
- /** AiOperationName */
851
- KnownContextTagKeys["AiOperationName"] = "ai.operation.name";
852
- /** AiOperationParentId */
853
- KnownContextTagKeys["AiOperationParentId"] = "ai.operation.parentId";
854
- /** AiOperationSyntheticSource */
855
- KnownContextTagKeys["AiOperationSyntheticSource"] = "ai.operation.syntheticSource";
856
- /** AiOperationCorrelationVector */
857
- KnownContextTagKeys["AiOperationCorrelationVector"] = "ai.operation.correlationVector";
858
- /** AiSessionId */
859
- KnownContextTagKeys["AiSessionId"] = "ai.session.id";
860
- /** AiSessionIsFirst */
861
- KnownContextTagKeys["AiSessionIsFirst"] = "ai.session.isFirst";
862
- /** AiUserAccountId */
863
- KnownContextTagKeys["AiUserAccountId"] = "ai.user.accountId";
864
- /** AiUserId */
865
- KnownContextTagKeys["AiUserId"] = "ai.user.id";
866
- /** AiUserAuthUserId */
867
- KnownContextTagKeys["AiUserAuthUserId"] = "ai.user.authUserId";
868
- /** AiCloudRole */
869
- KnownContextTagKeys["AiCloudRole"] = "ai.cloud.role";
870
- /** AiCloudRoleVer */
871
- KnownContextTagKeys["AiCloudRoleVer"] = "ai.cloud.roleVer";
872
- /** AiCloudRoleInstance */
873
- KnownContextTagKeys["AiCloudRoleInstance"] = "ai.cloud.roleInstance";
874
- /** AiCloudLocation */
875
- KnownContextTagKeys["AiCloudLocation"] = "ai.cloud.location";
876
- /** AiInternalSdkVersion */
877
- KnownContextTagKeys["AiInternalSdkVersion"] = "ai.internal.sdkVersion";
878
- /** AiInternalAgentVersion */
879
- KnownContextTagKeys["AiInternalAgentVersion"] = "ai.internal.agentVersion";
880
- /** AiInternalNodeName */
881
- KnownContextTagKeys["AiInternalNodeName"] = "ai.internal.nodeName";
882
- })(KnownContextTagKeys || (KnownContextTagKeys = {}));
883
-
884
- /*
885
- * Copyright (c) Microsoft Corporation.
886
- * Licensed under the MIT License.
887
- *
888
- * Code generated by Microsoft (R) AutoRest Code Generator.
889
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
890
- */
891
- const contentType = {
892
- parameterPath: ["options", "contentType"],
893
- mapper: {
894
- defaultValue: "application/json",
895
- isConstant: true,
896
- serializedName: "Content-Type",
897
- type: {
898
- name: "String",
899
- },
900
- },
901
- };
902
- const body = {
903
- parameterPath: "body",
904
- mapper: {
905
- serializedName: "body",
906
- required: true,
907
- type: {
908
- name: "Sequence",
909
- element: {
910
- type: {
911
- name: "Composite",
912
- className: "TelemetryItem",
913
- },
914
- },
915
- },
916
- },
917
- };
918
- const accept = {
919
- parameterPath: "accept",
920
- mapper: {
921
- defaultValue: "application/json",
922
- isConstant: true,
923
- serializedName: "Accept",
924
- type: {
925
- name: "String",
926
- },
927
- },
928
- };
929
- const host = {
930
- parameterPath: "host",
931
- mapper: {
932
- serializedName: "Host",
933
- required: true,
934
- type: {
935
- name: "String",
936
- },
937
- },
938
- skipEncoding: true,
939
- };
940
-
941
- /*
942
- * Copyright (c) Microsoft Corporation.
943
- * Licensed under the MIT License.
944
- *
945
- * Code generated by Microsoft (R) AutoRest Code Generator.
946
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
947
- */
948
- const TelemetryItem = {
949
- type: {
950
- name: "Composite",
951
- className: "TelemetryItem",
952
- modelProperties: {
953
- version: {
954
- defaultValue: 1,
955
- serializedName: "ver",
956
- type: {
957
- name: "Number",
958
- },
959
- },
960
- name: {
961
- serializedName: "name",
962
- required: true,
963
- type: {
964
- name: "String",
965
- },
966
- },
967
- time: {
968
- serializedName: "time",
969
- required: true,
970
- type: {
971
- name: "DateTime",
972
- },
973
- },
974
- sampleRate: {
975
- defaultValue: 100,
976
- serializedName: "sampleRate",
977
- type: {
978
- name: "Number",
979
- },
980
- },
981
- sequence: {
982
- constraints: {
983
- MaxLength: 64,
984
- },
985
- serializedName: "seq",
986
- type: {
987
- name: "String",
988
- },
989
- },
990
- instrumentationKey: {
991
- serializedName: "iKey",
992
- type: {
993
- name: "String",
994
- },
995
- },
996
- tags: {
997
- serializedName: "tags",
998
- type: {
999
- name: "Dictionary",
1000
- value: { type: { name: "String" } },
1001
- },
1002
- },
1003
- data: {
1004
- serializedName: "data",
1005
- type: {
1006
- name: "Composite",
1007
- className: "MonitorBase",
1008
- },
1009
- },
1010
- },
1011
- },
1012
- };
1013
- const MonitorBase = {
1014
- type: {
1015
- name: "Composite",
1016
- className: "MonitorBase",
1017
- modelProperties: {
1018
- baseType: {
1019
- serializedName: "baseType",
1020
- type: {
1021
- name: "String",
1022
- },
1023
- },
1024
- baseData: {
1025
- serializedName: "baseData",
1026
- type: {
1027
- name: "Composite",
1028
- className: "MonitorDomain",
1029
- },
1030
- },
1031
- },
1032
- },
1033
- };
1034
- const MonitorDomain = {
1035
- type: {
1036
- name: "Composite",
1037
- className: "MonitorDomain",
1038
- additionalProperties: { type: { name: "Object" } },
1039
- modelProperties: {
1040
- version: {
1041
- defaultValue: 2,
1042
- serializedName: "ver",
1043
- required: true,
1044
- type: {
1045
- name: "Number",
1046
- },
1047
- },
1048
- },
1049
- },
1050
- };
1051
- const TrackResponse = {
1052
- type: {
1053
- name: "Composite",
1054
- className: "TrackResponse",
1055
- modelProperties: {
1056
- itemsReceived: {
1057
- serializedName: "itemsReceived",
1058
- type: {
1059
- name: "Number",
1060
- },
1061
- },
1062
- itemsAccepted: {
1063
- serializedName: "itemsAccepted",
1064
- type: {
1065
- name: "Number",
1066
- },
1067
- },
1068
- errors: {
1069
- serializedName: "errors",
1070
- type: {
1071
- name: "Sequence",
1072
- element: {
1073
- type: {
1074
- name: "Composite",
1075
- className: "TelemetryErrorDetails",
1076
- },
1077
- },
1078
- },
1079
- },
1080
- },
1081
- },
1082
- };
1083
- const TelemetryErrorDetails = {
1084
- type: {
1085
- name: "Composite",
1086
- className: "TelemetryErrorDetails",
1087
- modelProperties: {
1088
- index: {
1089
- serializedName: "index",
1090
- type: {
1091
- name: "Number",
1092
- },
1093
- },
1094
- statusCode: {
1095
- serializedName: "statusCode",
1096
- type: {
1097
- name: "Number",
1098
- },
1099
- },
1100
- message: {
1101
- serializedName: "message",
1102
- type: {
1103
- name: "String",
1104
- },
1105
- },
1106
- },
1107
- },
1108
- };
1109
- const MetricDataPoint = {
1110
- type: {
1111
- name: "Composite",
1112
- className: "MetricDataPoint",
1113
- modelProperties: {
1114
- namespace: {
1115
- constraints: {
1116
- MaxLength: 256,
1117
- },
1118
- serializedName: "ns",
1119
- type: {
1120
- name: "String",
1121
- },
1122
- },
1123
- name: {
1124
- constraints: {
1125
- MaxLength: 1024,
1126
- },
1127
- serializedName: "name",
1128
- required: true,
1129
- type: {
1130
- name: "String",
1131
- },
1132
- },
1133
- dataPointType: {
1134
- serializedName: "kind",
1135
- type: {
1136
- name: "String",
1137
- },
1138
- },
1139
- value: {
1140
- serializedName: "value",
1141
- required: true,
1142
- type: {
1143
- name: "Number",
1144
- },
1145
- },
1146
- count: {
1147
- serializedName: "count",
1148
- nullable: true,
1149
- type: {
1150
- name: "Number",
1151
- },
1152
- },
1153
- min: {
1154
- serializedName: "min",
1155
- nullable: true,
1156
- type: {
1157
- name: "Number",
1158
- },
1159
- },
1160
- max: {
1161
- serializedName: "max",
1162
- nullable: true,
1163
- type: {
1164
- name: "Number",
1165
- },
1166
- },
1167
- stdDev: {
1168
- serializedName: "stdDev",
1169
- nullable: true,
1170
- type: {
1171
- name: "Number",
1172
- },
1173
- },
1174
- },
1175
- },
1176
- };
1177
- const TelemetryExceptionDetails = {
1178
- type: {
1179
- name: "Composite",
1180
- className: "TelemetryExceptionDetails",
1181
- modelProperties: {
1182
- id: {
1183
- serializedName: "id",
1184
- type: {
1185
- name: "Number",
1186
- },
1187
- },
1188
- outerId: {
1189
- serializedName: "outerId",
1190
- type: {
1191
- name: "Number",
1192
- },
1193
- },
1194
- typeName: {
1195
- constraints: {
1196
- MaxLength: 1024,
1197
- },
1198
- serializedName: "typeName",
1199
- type: {
1200
- name: "String",
1201
- },
1202
- },
1203
- message: {
1204
- constraints: {
1205
- MaxLength: 32768,
1206
- },
1207
- serializedName: "message",
1208
- required: true,
1209
- type: {
1210
- name: "String",
1211
- },
1212
- },
1213
- hasFullStack: {
1214
- defaultValue: true,
1215
- serializedName: "hasFullStack",
1216
- type: {
1217
- name: "Boolean",
1218
- },
1219
- },
1220
- stack: {
1221
- constraints: {
1222
- MaxLength: 32768,
1223
- },
1224
- serializedName: "stack",
1225
- type: {
1226
- name: "String",
1227
- },
1228
- },
1229
- parsedStack: {
1230
- serializedName: "parsedStack",
1231
- type: {
1232
- name: "Sequence",
1233
- element: {
1234
- type: {
1235
- name: "Composite",
1236
- className: "StackFrame",
1237
- },
1238
- },
1239
- },
1240
- },
1241
- },
1242
- },
1243
- };
1244
- const StackFrame = {
1245
- type: {
1246
- name: "Composite",
1247
- className: "StackFrame",
1248
- modelProperties: {
1249
- level: {
1250
- serializedName: "level",
1251
- required: true,
1252
- type: {
1253
- name: "Number",
1254
- },
1255
- },
1256
- method: {
1257
- constraints: {
1258
- MaxLength: 1024,
1259
- },
1260
- serializedName: "method",
1261
- required: true,
1262
- type: {
1263
- name: "String",
1264
- },
1265
- },
1266
- assembly: {
1267
- constraints: {
1268
- MaxLength: 1024,
1269
- },
1270
- serializedName: "assembly",
1271
- type: {
1272
- name: "String",
1273
- },
1274
- },
1275
- fileName: {
1276
- constraints: {
1277
- MaxLength: 1024,
1278
- },
1279
- serializedName: "fileName",
1280
- type: {
1281
- name: "String",
1282
- },
1283
- },
1284
- line: {
1285
- serializedName: "line",
1286
- type: {
1287
- name: "Number",
1288
- },
1289
- },
1290
- },
1291
- },
1292
- };
1293
- const AvailabilityData = {
1294
- type: {
1295
- name: "Composite",
1296
- className: "AvailabilityData",
1297
- additionalProperties: { type: { name: "Object" } },
1298
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1299
- constraints: {
1300
- MaxLength: 512,
1301
- },
1302
- serializedName: "id",
1303
- required: true,
1304
- type: {
1305
- name: "String",
1306
- },
1307
- }, name: {
1308
- constraints: {
1309
- MaxLength: 1024,
1310
- },
1311
- serializedName: "name",
1312
- required: true,
1313
- type: {
1314
- name: "String",
1315
- },
1316
- }, duration: {
1317
- serializedName: "duration",
1318
- required: true,
1319
- type: {
1320
- name: "String",
1321
- },
1322
- }, success: {
1323
- serializedName: "success",
1324
- required: true,
1325
- type: {
1326
- name: "Boolean",
1327
- },
1328
- }, runLocation: {
1329
- constraints: {
1330
- MaxLength: 1024,
1331
- },
1332
- serializedName: "runLocation",
1333
- type: {
1334
- name: "String",
1335
- },
1336
- }, message: {
1337
- constraints: {
1338
- MaxLength: 8192,
1339
- },
1340
- serializedName: "message",
1341
- type: {
1342
- name: "String",
1343
- },
1344
- }, properties: {
1345
- serializedName: "properties",
1346
- type: {
1347
- name: "Dictionary",
1348
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1349
- },
1350
- }, measurements: {
1351
- serializedName: "measurements",
1352
- type: {
1353
- name: "Dictionary",
1354
- value: { type: { name: "Number" } },
1355
- },
1356
- } }),
1357
- },
1358
- };
1359
- const TelemetryEventData = {
1360
- type: {
1361
- name: "Composite",
1362
- className: "TelemetryEventData",
1363
- additionalProperties: { type: { name: "Object" } },
1364
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { name: {
1365
- constraints: {
1366
- MaxLength: 512,
1367
- },
1368
- serializedName: "name",
1369
- required: true,
1370
- type: {
1371
- name: "String",
1372
- },
1373
- }, properties: {
1374
- serializedName: "properties",
1375
- type: {
1376
- name: "Dictionary",
1377
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1378
- },
1379
- }, measurements: {
1380
- serializedName: "measurements",
1381
- type: {
1382
- name: "Dictionary",
1383
- value: { type: { name: "Number" } },
1384
- },
1385
- } }),
1386
- },
1387
- };
1388
- const TelemetryExceptionData = {
1389
- type: {
1390
- name: "Composite",
1391
- className: "TelemetryExceptionData",
1392
- additionalProperties: { type: { name: "Object" } },
1393
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { exceptions: {
1394
- serializedName: "exceptions",
1395
- required: true,
1396
- type: {
1397
- name: "Sequence",
1398
- element: {
1399
- type: {
1400
- name: "Composite",
1401
- className: "TelemetryExceptionDetails",
1402
- },
1403
- },
1404
- },
1405
- }, severityLevel: {
1406
- serializedName: "severityLevel",
1407
- nullable: true,
1408
- type: {
1409
- name: "String",
1410
- },
1411
- }, problemId: {
1412
- constraints: {
1413
- MaxLength: 1024,
1414
- },
1415
- serializedName: "problemId",
1416
- type: {
1417
- name: "String",
1418
- },
1419
- }, properties: {
1420
- serializedName: "properties",
1421
- type: {
1422
- name: "Dictionary",
1423
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1424
- },
1425
- }, measurements: {
1426
- serializedName: "measurements",
1427
- type: {
1428
- name: "Dictionary",
1429
- value: { type: { name: "Number" } },
1430
- },
1431
- } }),
1432
- },
1433
- };
1434
- const MessageData = {
1435
- type: {
1436
- name: "Composite",
1437
- className: "MessageData",
1438
- additionalProperties: { type: { name: "Object" } },
1439
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { message: {
1440
- constraints: {
1441
- MaxLength: 32768,
1442
- },
1443
- serializedName: "message",
1444
- required: true,
1445
- type: {
1446
- name: "String",
1447
- },
1448
- }, severityLevel: {
1449
- serializedName: "severityLevel",
1450
- type: {
1451
- name: "String",
1452
- },
1453
- }, properties: {
1454
- serializedName: "properties",
1455
- type: {
1456
- name: "Dictionary",
1457
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1458
- },
1459
- }, measurements: {
1460
- serializedName: "measurements",
1461
- type: {
1462
- name: "Dictionary",
1463
- value: { type: { name: "Number" } },
1464
- },
1465
- } }),
1466
- },
1467
- };
1468
- const MetricsData = {
1469
- type: {
1470
- name: "Composite",
1471
- className: "MetricsData",
1472
- additionalProperties: { type: { name: "Object" } },
1473
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { metrics: {
1474
- serializedName: "metrics",
1475
- required: true,
1476
- type: {
1477
- name: "Sequence",
1478
- element: {
1479
- type: {
1480
- name: "Composite",
1481
- className: "MetricDataPoint",
1482
- },
1483
- },
1484
- },
1485
- }, properties: {
1486
- serializedName: "properties",
1487
- type: {
1488
- name: "Dictionary",
1489
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1490
- },
1491
- } }),
1492
- },
1493
- };
1494
- const PageViewData = {
1495
- type: {
1496
- name: "Composite",
1497
- className: "PageViewData",
1498
- additionalProperties: { type: { name: "Object" } },
1499
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1500
- constraints: {
1501
- MaxLength: 512,
1502
- },
1503
- serializedName: "id",
1504
- required: true,
1505
- type: {
1506
- name: "String",
1507
- },
1508
- }, name: {
1509
- constraints: {
1510
- MaxLength: 1024,
1511
- },
1512
- serializedName: "name",
1513
- required: true,
1514
- type: {
1515
- name: "String",
1516
- },
1517
- }, url: {
1518
- constraints: {
1519
- MaxLength: 2048,
1520
- },
1521
- serializedName: "url",
1522
- type: {
1523
- name: "String",
1524
- },
1525
- }, duration: {
1526
- serializedName: "duration",
1527
- type: {
1528
- name: "String",
1529
- },
1530
- }, referredUri: {
1531
- constraints: {
1532
- MaxLength: 2048,
1533
- },
1534
- serializedName: "referredUri",
1535
- type: {
1536
- name: "String",
1537
- },
1538
- }, properties: {
1539
- serializedName: "properties",
1540
- type: {
1541
- name: "Dictionary",
1542
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1543
- },
1544
- }, measurements: {
1545
- serializedName: "measurements",
1546
- type: {
1547
- name: "Dictionary",
1548
- value: { type: { name: "Number" } },
1549
- },
1550
- } }),
1551
- },
1552
- };
1553
- const PageViewPerfData = {
1554
- type: {
1555
- name: "Composite",
1556
- className: "PageViewPerfData",
1557
- additionalProperties: { type: { name: "Object" } },
1558
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1559
- constraints: {
1560
- MaxLength: 512,
1561
- },
1562
- serializedName: "id",
1563
- required: true,
1564
- type: {
1565
- name: "String",
1566
- },
1567
- }, name: {
1568
- constraints: {
1569
- MaxLength: 1024,
1570
- },
1571
- serializedName: "name",
1572
- required: true,
1573
- type: {
1574
- name: "String",
1575
- },
1576
- }, url: {
1577
- constraints: {
1578
- MaxLength: 2048,
1579
- },
1580
- serializedName: "url",
1581
- type: {
1582
- name: "String",
1583
- },
1584
- }, duration: {
1585
- serializedName: "duration",
1586
- type: {
1587
- name: "String",
1588
- },
1589
- }, perfTotal: {
1590
- serializedName: "perfTotal",
1591
- type: {
1592
- name: "String",
1593
- },
1594
- }, networkConnect: {
1595
- serializedName: "networkConnect",
1596
- type: {
1597
- name: "String",
1598
- },
1599
- }, sentRequest: {
1600
- serializedName: "sentRequest",
1601
- type: {
1602
- name: "String",
1603
- },
1604
- }, receivedResponse: {
1605
- serializedName: "receivedResponse",
1606
- type: {
1607
- name: "String",
1608
- },
1609
- }, domProcessing: {
1610
- serializedName: "domProcessing",
1611
- type: {
1612
- name: "String",
1613
- },
1614
- }, properties: {
1615
- serializedName: "properties",
1616
- type: {
1617
- name: "Dictionary",
1618
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1619
- },
1620
- }, measurements: {
1621
- serializedName: "measurements",
1622
- type: {
1623
- name: "Dictionary",
1624
- value: { type: { name: "Number" } },
1625
- },
1626
- } }),
1627
- },
1628
- };
1629
- const RemoteDependencyData = {
1630
- type: {
1631
- name: "Composite",
1632
- className: "RemoteDependencyData",
1633
- additionalProperties: { type: { name: "Object" } },
1634
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1635
- constraints: {
1636
- MaxLength: 512,
1637
- },
1638
- serializedName: "id",
1639
- type: {
1640
- name: "String",
1641
- },
1642
- }, name: {
1643
- constraints: {
1644
- MaxLength: 1024,
1645
- },
1646
- serializedName: "name",
1647
- required: true,
1648
- type: {
1649
- name: "String",
1650
- },
1651
- }, resultCode: {
1652
- constraints: {
1653
- MaxLength: 1024,
1654
- },
1655
- serializedName: "resultCode",
1656
- type: {
1657
- name: "String",
1658
- },
1659
- }, data: {
1660
- constraints: {
1661
- MaxLength: 8192,
1662
- },
1663
- serializedName: "data",
1664
- type: {
1665
- name: "String",
1666
- },
1667
- }, type: {
1668
- constraints: {
1669
- MaxLength: 1024,
1670
- },
1671
- serializedName: "type",
1672
- type: {
1673
- name: "String",
1674
- },
1675
- }, target: {
1676
- constraints: {
1677
- MaxLength: 1024,
1678
- },
1679
- serializedName: "target",
1680
- type: {
1681
- name: "String",
1682
- },
1683
- }, duration: {
1684
- serializedName: "duration",
1685
- required: true,
1686
- type: {
1687
- name: "String",
1688
- },
1689
- }, success: {
1690
- defaultValue: true,
1691
- serializedName: "success",
1692
- type: {
1693
- name: "Boolean",
1694
- },
1695
- }, properties: {
1696
- serializedName: "properties",
1697
- type: {
1698
- name: "Dictionary",
1699
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1700
- },
1701
- }, measurements: {
1702
- serializedName: "measurements",
1703
- type: {
1704
- name: "Dictionary",
1705
- value: { type: { name: "Number" } },
1706
- },
1707
- } }),
1708
- },
1709
- };
1710
- const RequestData = {
1711
- type: {
1712
- name: "Composite",
1713
- className: "RequestData",
1714
- additionalProperties: { type: { name: "Object" } },
1715
- modelProperties: Object.assign(Object.assign({}, MonitorDomain.type.modelProperties), { id: {
1716
- constraints: {
1717
- MaxLength: 512,
1718
- },
1719
- serializedName: "id",
1720
- required: true,
1721
- type: {
1722
- name: "String",
1723
- },
1724
- }, name: {
1725
- constraints: {
1726
- MaxLength: 1024,
1727
- },
1728
- serializedName: "name",
1729
- type: {
1730
- name: "String",
1731
- },
1732
- }, duration: {
1733
- serializedName: "duration",
1734
- required: true,
1735
- type: {
1736
- name: "String",
1737
- },
1738
- }, success: {
1739
- defaultValue: true,
1740
- serializedName: "success",
1741
- required: true,
1742
- type: {
1743
- name: "Boolean",
1744
- },
1745
- }, responseCode: {
1746
- constraints: {
1747
- MaxLength: 1024,
1748
- },
1749
- serializedName: "responseCode",
1750
- required: true,
1751
- type: {
1752
- name: "String",
1753
- },
1754
- }, source: {
1755
- constraints: {
1756
- MaxLength: 1024,
1757
- },
1758
- serializedName: "source",
1759
- type: {
1760
- name: "String",
1761
- },
1762
- }, url: {
1763
- constraints: {
1764
- MaxLength: 2048,
1765
- },
1766
- serializedName: "url",
1767
- type: {
1768
- name: "String",
1769
- },
1770
- }, properties: {
1771
- serializedName: "properties",
1772
- type: {
1773
- name: "Dictionary",
1774
- value: { type: { name: "String" }, constraints: { MaxLength: 8192 } },
1775
- },
1776
- }, measurements: {
1777
- serializedName: "measurements",
1778
- type: {
1779
- name: "Dictionary",
1780
- value: { type: { name: "Number" } },
1781
- },
1782
- } }),
1783
- },
1784
- };
1785
-
1786
- var Mappers = /*#__PURE__*/Object.freeze({
1787
- __proto__: null,
1788
- AvailabilityData: AvailabilityData,
1789
- MessageData: MessageData,
1790
- MetricDataPoint: MetricDataPoint,
1791
- MetricsData: MetricsData,
1792
- MonitorBase: MonitorBase,
1793
- MonitorDomain: MonitorDomain,
1794
- PageViewData: PageViewData,
1795
- PageViewPerfData: PageViewPerfData,
1796
- RemoteDependencyData: RemoteDependencyData,
1797
- RequestData: RequestData,
1798
- StackFrame: StackFrame,
1799
- TelemetryErrorDetails: TelemetryErrorDetails,
1800
- TelemetryEventData: TelemetryEventData,
1801
- TelemetryExceptionData: TelemetryExceptionData,
1802
- TelemetryExceptionDetails: TelemetryExceptionDetails,
1803
- TelemetryItem: TelemetryItem,
1804
- TrackResponse: TrackResponse
1805
- });
1806
-
1807
- /*
1808
- * Copyright (c) Microsoft Corporation.
1809
- * Licensed under the MIT License.
1810
- *
1811
- * Code generated by Microsoft (R) AutoRest Code Generator.
1812
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1813
- */
1814
- class ApplicationInsightsClient extends coreClient__namespace.ServiceClient {
1815
- /**
1816
- * Initializes a new instance of the ApplicationInsightsClient class.
1817
- * @param options The parameter options
1818
- */
1819
- constructor(options) {
1820
- var _a, _b;
1821
- // Initializing default values for options
1822
- if (!options) {
1823
- options = {};
1824
- }
1825
- const defaults = {
1826
- requestContentType: "application/json; charset=utf-8",
1827
- };
1828
- const packageDetails = `azsdk-js-monitor-opentelemetry-exporter/1.0.0-beta.26`;
1829
- const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1830
- ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1831
- : `${packageDetails}`;
1832
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1833
- userAgentPrefix,
1834
- }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{Host}/v2.1" });
1835
- super(optionsWithDefaults);
1836
- // Assigning values to Constant parameters
1837
- this.host = options.host || "https://dc.services.visualstudio.com";
1838
- }
1839
- /**
1840
- * This operation sends a sequence of telemetry events that will be monitored by Azure Monitor.
1841
- * @param body The list of telemetry events to track.
1842
- * @param options The options parameters.
1843
- */
1844
- track(body, options) {
1845
- return this.sendOperationRequest({ body, options }, trackOperationSpec);
1846
- }
1847
- }
1848
- // Operation Specifications
1849
- const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1850
- const trackOperationSpec = {
1851
- path: "/track",
1852
- httpMethod: "POST",
1853
- responses: {
1854
- 200: {
1855
- bodyMapper: TrackResponse,
1856
- },
1857
- 206: {
1858
- bodyMapper: TrackResponse,
1859
- },
1860
- 400: {
1861
- bodyMapper: TrackResponse,
1862
- isError: true,
1863
- },
1864
- 402: {
1865
- bodyMapper: TrackResponse,
1866
- isError: true,
1867
- },
1868
- 429: {
1869
- bodyMapper: TrackResponse,
1870
- isError: true,
1871
- },
1872
- 500: {
1873
- bodyMapper: TrackResponse,
1874
- isError: true,
1875
- },
1876
- 503: {
1877
- bodyMapper: TrackResponse,
1878
- isError: true,
1879
- },
1880
- },
1881
- requestBody: body,
1882
- urlParameters: [host],
1883
- headerParameters: [contentType, accept],
1884
- mediaType: "json",
1885
- serializer,
1886
- };
1887
-
1888
- // Copyright (c) Microsoft Corporation.
1889
- // Licensed under the MIT License.
1890
- class NetworkStatsbeat {
1891
- constructor(endpoint, host) {
1892
- this.endpoint = endpoint;
1893
- this.host = host;
1894
- this.totalRequestCount = 0;
1895
- this.totalSuccesfulRequestCount = 0;
1896
- this.totalFailedRequestCount = [];
1897
- this.retryCount = [];
1898
- this.exceptionCount = [];
1899
- this.throttleCount = [];
1900
- this.intervalRequestExecutionTime = 0;
1901
- this.lastIntervalRequestExecutionTime = 0;
1902
- this.lastTime = +new Date();
1903
- this.lastRequestCount = 0;
1904
- this.averageRequestExecutionTime = 0;
1905
- }
1906
- }
1907
- const STATSBEAT_LANGUAGE = "node";
1908
- const MAX_STATSBEAT_FAILURES = 3;
1909
- const StatsbeatResourceProvider = {
1910
- appsvc: "appsvc",
1911
- aks: "aks",
1912
- functions: "functions",
1913
- vm: "vm",
1914
- unknown: "unknown",
1915
- };
1916
- var StatsbeatCounter;
1917
- (function (StatsbeatCounter) {
1918
- StatsbeatCounter["SUCCESS_COUNT"] = "Request_Success_Count";
1919
- StatsbeatCounter["FAILURE_COUNT"] = "Request_Failure_Count";
1920
- StatsbeatCounter["RETRY_COUNT"] = "Retry_Count";
1921
- StatsbeatCounter["THROTTLE_COUNT"] = "Throttle_Count";
1922
- StatsbeatCounter["EXCEPTION_COUNT"] = "Exception_Count";
1923
- StatsbeatCounter["AVERAGE_DURATION"] = "Request_Duration";
1924
- StatsbeatCounter["ATTACH"] = "Attach";
1925
- StatsbeatCounter["FEATURE"] = "Feature";
1926
- })(StatsbeatCounter || (StatsbeatCounter = {}));
1927
- const AIMS_URI = "http://169.254.169.254/metadata/instance/compute";
1928
- const AIMS_API_VERSION = "api-version=2017-12-01";
1929
- const AIMS_FORMAT = "format=json";
1930
- const NON_EU_CONNECTION_STRING = "InstrumentationKey=c4a29126-a7cb-47e5-b348-11414998b11e;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com";
1931
- const EU_CONNECTION_STRING = "InstrumentationKey=7dc56bab-3c0c-4e9f-9ebb-d1acadee8d0f;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com";
1932
- const EU_ENDPOINTS = [
1933
- "westeurope",
1934
- "northeurope",
1935
- "francecentral",
1936
- "francesouth",
1937
- "germanywestcentral",
1938
- "norwayeast",
1939
- "norwaywest",
1940
- "swedencentral",
1941
- "switzerlandnorth",
1942
- "switzerlandwest",
1943
- "uksouth",
1944
- "ukwest",
1945
- ];
1946
- var StatsbeatFeatureType;
1947
- (function (StatsbeatFeatureType) {
1948
- StatsbeatFeatureType[StatsbeatFeatureType["FEATURE"] = 0] = "FEATURE";
1949
- StatsbeatFeatureType[StatsbeatFeatureType["INSTRUMENTATION"] = 1] = "INSTRUMENTATION";
1950
- })(StatsbeatFeatureType || (StatsbeatFeatureType = {}));
1951
-
1952
- // Copyright (c) Microsoft Corporation.
1953
- // Licensed under the MIT License.
1954
- // eslint-disable-next-line @typescript-eslint/no-require-imports
1955
- const os = require("os");
1956
- class StatsbeatMetrics {
1957
- constructor() {
1958
- this.resourceProvider = StatsbeatResourceProvider.unknown;
1959
- this.vmInfo = {};
1960
- this.os = os.type();
1961
- this.resourceIdentifier = "";
1962
- }
1963
- async getResourceProvider() {
1964
- // Check resource provider
1965
- this.resourceProvider = StatsbeatResourceProvider.unknown;
1966
- if (process.env.AKS_ARM_NAMESPACE_ID) {
1967
- // AKS
1968
- this.resourceProvider = StatsbeatResourceProvider.aks;
1969
- this.resourceIdentifier = process.env.AKS_ARM_NAMESPACE_ID;
1970
- }
1971
- else if (process.env.WEBSITE_SITE_NAME) {
1972
- // Web apps
1973
- this.resourceProvider = StatsbeatResourceProvider.appsvc;
1974
- this.resourceIdentifier = process.env.WEBSITE_SITE_NAME;
1975
- if (process.env.WEBSITE_HOME_STAMPNAME) {
1976
- this.resourceIdentifier += "/" + process.env.WEBSITE_HOME_STAMPNAME;
1977
- }
1978
- }
1979
- else if (process.env.FUNCTIONS_WORKER_RUNTIME) {
1980
- // Function apps
1981
- this.resourceProvider = StatsbeatResourceProvider.functions;
1982
- if (process.env.WEBSITE_HOSTNAME) {
1983
- this.resourceIdentifier = process.env.WEBSITE_HOSTNAME;
1984
- }
1985
- }
1986
- else if (await this.getAzureComputeMetadata()) {
1987
- this.resourceProvider = StatsbeatResourceProvider.vm;
1988
- this.resourceIdentifier = this.vmInfo.id + "/" + this.vmInfo.subscriptionId;
1989
- // Overrride OS as VM info have higher precedence
1990
- if (this.vmInfo.osType) {
1991
- this.os = this.vmInfo.osType;
1992
- }
1993
- }
1994
- else {
1995
- this.resourceProvider = StatsbeatResourceProvider.unknown;
1996
- }
1997
- }
1998
- async getAzureComputeMetadata() {
1999
- const httpClient = coreRestPipeline.createDefaultHttpClient();
2000
- const method = "GET";
2001
- const options = {
2002
- url: `${AIMS_URI}?${AIMS_API_VERSION}&${AIMS_FORMAT}`,
2003
- timeout: 5000, // 5 seconds
2004
- method: method,
2005
- allowInsecureConnection: true,
2006
- };
2007
- const request = coreRestPipeline.createPipelineRequest(options);
2008
- await httpClient
2009
- .sendRequest(request)
2010
- .then((res) => {
2011
- if (res.status === 200) {
2012
- // Success; VM
2013
- this.vmInfo.isVM = true;
2014
- let virtualMachineData = "";
2015
- res.on("data", (data) => {
2016
- virtualMachineData += data;
2017
- });
2018
- res.on("end", () => {
2019
- try {
2020
- const data = JSON.parse(virtualMachineData);
2021
- this.vmInfo.id = data["vmId"] || "";
2022
- this.vmInfo.subscriptionId = data["subscriptionId"] || "";
2023
- this.vmInfo.osType = data["osType"] || "";
2024
- }
2025
- catch (error) {
2026
- api.diag.debug("Failed to parse JSON: ", error);
2027
- }
2028
- });
2029
- return true;
2030
- }
2031
- else {
2032
- return false;
2033
- }
2034
- })
2035
- .catch(() => {
2036
- return false;
2037
- });
2038
- return false;
2039
- }
2040
- getConnectionString(endpointUrl) {
2041
- const currentEndpoint = endpointUrl;
2042
- for (let i = 0; i < EU_ENDPOINTS.length; i++) {
2043
- if (currentEndpoint.includes(EU_ENDPOINTS[i])) {
2044
- return EU_CONNECTION_STRING;
2045
- }
2046
- }
2047
- return NON_EU_CONNECTION_STRING;
2048
- }
2049
- }
2050
-
2051
- // Copyright (c) Microsoft Corporation.
2052
- // Licensed under the MIT License.
2053
- /**
2054
- * Performance Counter OpenTelemetry compliant names.
2055
- * @internal
2056
- */
2057
- var OTelPerformanceCounterNames;
2058
- (function (OTelPerformanceCounterNames) {
2059
- OTelPerformanceCounterNames["PRIVATE_BYTES"] = "Private_Bytes";
2060
- OTelPerformanceCounterNames["AVAILABLE_BYTES"] = "Available_Bytes";
2061
- OTelPerformanceCounterNames["PROCESSOR_TIME"] = "Processor_Time";
2062
- OTelPerformanceCounterNames["PROCESS_TIME"] = "Process_Time";
2063
- OTelPerformanceCounterNames["REQUEST_RATE"] = "Request_Rate";
2064
- OTelPerformanceCounterNames["REQUEST_DURATION"] = "Request_Execution_Time";
2065
- })(OTelPerformanceCounterNames || (OTelPerformanceCounterNames = {}));
2066
- /**
2067
- * Breeze Performance Counter names.
2068
- * @internal
2069
- */
2070
- var BreezePerformanceCounterNames;
2071
- (function (BreezePerformanceCounterNames) {
2072
- BreezePerformanceCounterNames["PRIVATE_BYTES"] = "\\Process(??APP_WIN32_PROC??)\\Private Bytes";
2073
- BreezePerformanceCounterNames["AVAILABLE_BYTES"] = "\\Memory\\Available Bytes";
2074
- BreezePerformanceCounterNames["PROCESSOR_TIME"] = "\\Processor(_Total)\\% Processor Time";
2075
- BreezePerformanceCounterNames["PROCESS_TIME"] = "\\Process(??APP_WIN32_PROC??)\\% Processor Time";
2076
- BreezePerformanceCounterNames["REQUEST_RATE"] = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Requests/Sec";
2077
- BreezePerformanceCounterNames["REQUEST_DURATION"] = "\\ASP.NET Applications(??APP_W3SVC_PROC??)\\Request Execution Time";
2078
- })(BreezePerformanceCounterNames || (BreezePerformanceCounterNames = {}));
2079
- /**
2080
- * Property Max Lengths
2081
- * @internal
2082
- */
2083
- var MaxPropertyLengths;
2084
- (function (MaxPropertyLengths) {
2085
- MaxPropertyLengths[MaxPropertyLengths["NINE_BIT"] = 512] = "NINE_BIT";
2086
- MaxPropertyLengths[MaxPropertyLengths["TEN_BIT"] = 1024] = "TEN_BIT";
2087
- MaxPropertyLengths[MaxPropertyLengths["THIRTEEN_BIT"] = 8192] = "THIRTEEN_BIT";
2088
- MaxPropertyLengths[MaxPropertyLengths["FIFTEEN_BIT"] = 32768] = "FIFTEEN_BIT";
2089
- })(MaxPropertyLengths || (MaxPropertyLengths = {}));
2090
-
2091
- // Copyright (c) Microsoft Corporation.
2092
- // Licensed under the MIT License.
2093
- const breezePerformanceCountersMap = new Map([
2094
- [OTelPerformanceCounterNames.PRIVATE_BYTES, BreezePerformanceCounterNames.PRIVATE_BYTES],
2095
- [OTelPerformanceCounterNames.AVAILABLE_BYTES, BreezePerformanceCounterNames.AVAILABLE_BYTES],
2096
- [OTelPerformanceCounterNames.PROCESSOR_TIME, BreezePerformanceCounterNames.PROCESSOR_TIME],
2097
- [OTelPerformanceCounterNames.PROCESS_TIME, BreezePerformanceCounterNames.PROCESS_TIME],
2098
- [OTelPerformanceCounterNames.REQUEST_RATE, BreezePerformanceCounterNames.REQUEST_RATE],
2099
- [OTelPerformanceCounterNames.REQUEST_DURATION, BreezePerformanceCounterNames.REQUEST_DURATION],
2100
- ]);
2101
- function createPropertiesFromMetricAttributes(attributes) {
2102
- const properties = {};
2103
- if (attributes) {
2104
- for (const key of Object.keys(attributes)) {
2105
- properties[key] = attributes[key];
2106
- }
2107
- }
2108
- return properties;
2109
- }
2110
- /**
2111
- * Metric to Azure envelope parsing.
2112
- * @internal
2113
- */
2114
- function resourceMetricsToEnvelope(metrics, ikey, isStatsbeat) {
2115
- const envelopes = [];
2116
- const time = new Date();
2117
- const instrumentationKey = ikey;
2118
- const tags = createTagsFromResource(metrics.resource);
2119
- let envelopeName;
2120
- if (isStatsbeat) {
2121
- envelopeName = "Microsoft.ApplicationInsights.Statsbeat";
2122
- }
2123
- else {
2124
- envelopeName = "Microsoft.ApplicationInsights.Metric";
2125
- }
2126
- metrics.scopeMetrics.forEach((scopeMetric) => {
2127
- scopeMetric.metrics.forEach((metric) => {
2128
- metric.dataPoints.forEach((dataPoint) => {
2129
- const baseData = {
2130
- metrics: [],
2131
- version: 2,
2132
- properties: {},
2133
- };
2134
- baseData.properties = createPropertiesFromMetricAttributes(dataPoint.attributes);
2135
- let perfCounterName;
2136
- if (breezePerformanceCountersMap.has(metric.descriptor.name)) {
2137
- perfCounterName = breezePerformanceCountersMap.get(metric.descriptor.name);
2138
- }
2139
- const metricDataPoint = {
2140
- name: perfCounterName ? perfCounterName : metric.descriptor.name,
2141
- value: 0,
2142
- dataPointType: "Aggregation",
2143
- };
2144
- if (metric.dataPointType === sdkMetrics.DataPointType.SUM ||
2145
- metric.dataPointType === sdkMetrics.DataPointType.GAUGE) {
2146
- metricDataPoint.value = dataPoint.value;
2147
- metricDataPoint.count = 1;
2148
- }
2149
- else {
2150
- metricDataPoint.value = dataPoint.value.sum || 0;
2151
- metricDataPoint.count = dataPoint.value.count;
2152
- metricDataPoint.max = dataPoint.value.max;
2153
- metricDataPoint.min = dataPoint.value.min;
2154
- }
2155
- baseData.metrics.push(metricDataPoint);
2156
- const envelope = {
2157
- name: envelopeName,
2158
- time: time,
2159
- sampleRate: 100, // Metrics are never sampled
2160
- instrumentationKey: instrumentationKey,
2161
- tags: tags,
2162
- version: 1,
2163
- data: {
2164
- baseType: "MetricData",
2165
- baseData: Object.assign({}, baseData),
2166
- },
2167
- };
2168
- envelopes.push(envelope);
2169
- });
2170
- });
2171
- });
2172
- return envelopes;
2173
- }
2174
-
2175
- // Copyright (c) Microsoft Corporation.
2176
- // Licensed under the MIT License.
2177
- /**
2178
- * Azure Monitor Statsbeat Exporter
2179
- */
2180
- class AzureMonitorStatsbeatExporter extends AzureMonitorBaseExporter {
2181
- /**
2182
- * Initializes a new instance of the AzureMonitorStatsbeatExporter class.
2183
- * @param options - Exporter configuration
2184
- */
2185
- constructor(options) {
2186
- super(options, true);
2187
- /**
2188
- * Flag to determine if the Exporter is shutdown.
2189
- */
2190
- this._isShutdown = false;
2191
- this._sender = new HttpSender({
2192
- endpointUrl: this.endpointUrl,
2193
- instrumentationKey: this.instrumentationKey,
2194
- trackStatsbeat: this.trackStatsbeat,
2195
- exporterOptions: options,
2196
- isStatsbeatSender: true,
2197
- });
2198
- }
2199
- /**
2200
- * Export Statsbeat metrics.
2201
- */
2202
- // eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
2203
- async export(metrics, resultCallback) {
2204
- if (this._isShutdown) {
2205
- setTimeout(() => resultCallback({ code: core.ExportResultCode.FAILED }), 0);
2206
- return;
2207
- }
2208
- const envelopes = resourceMetricsToEnvelope(metrics, this.instrumentationKey, true);
2209
- // Supress tracing until OpenTelemetry Metrics SDK support it
2210
- api.context.with(core.suppressTracing(api.context.active()), async () => {
2211
- resultCallback(await this._sender.exportEnvelopes(envelopes));
2212
- });
2213
- }
2214
- /**
2215
- * Shutdown AzureMonitorStatsbeatExporter.
2216
- */
2217
- async shutdown() {
2218
- this._isShutdown = true;
2219
- return this._sender.shutdown();
2220
- }
2221
- /**
2222
- * Force flush.
2223
- */
2224
- async forceFlush() {
2225
- return Promise.resolve();
2226
- }
2227
- }
2228
-
2229
- // Copyright (c) Microsoft Corporation.
2230
- // Licensed under the MIT License.
2231
- class NetworkStatsbeatMetrics extends StatsbeatMetrics {
2232
- constructor(options) {
2233
- super();
2234
- this.isInitialized = false;
2235
- this.statsCollectionShortInterval = 900000; // 15 minutes
2236
- this.networkStatsbeatCollection = [];
2237
- this.attach = "Manual";
2238
- this.connectionString = super.getConnectionString(options.endpointUrl);
2239
- this.networkStatsbeatMeterProvider = new sdkMetrics.MeterProvider();
2240
- const exporterConfig = {
2241
- connectionString: this.connectionString,
2242
- };
2243
- this.networkAzureExporter = new AzureMonitorStatsbeatExporter(exporterConfig);
2244
- // Exports Network Statsbeat every 15 minutes
2245
- const networkMetricReaderOptions = {
2246
- exporter: this.networkAzureExporter,
2247
- exportIntervalMillis: options.networkCollectionInterval || this.statsCollectionShortInterval, // 15 minutes
2248
- };
2249
- this.networkMetricReader = new sdkMetrics.PeriodicExportingMetricReader(networkMetricReaderOptions);
2250
- this.networkStatsbeatMeterProvider.addMetricReader(this.networkMetricReader);
2251
- this.networkStatsbeatMeter = this.networkStatsbeatMeterProvider.getMeter("Azure Monitor Network Statsbeat");
2252
- this.endpointUrl = options.endpointUrl;
2253
- this.runtimeVersion = process.version;
2254
- this.language = STATSBEAT_LANGUAGE;
2255
- this.version = packageVersion;
2256
- this.host = this.getShortHost(options.endpointUrl);
2257
- this.cikey = options.instrumentationKey;
2258
- this.successCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.SUCCESS_COUNT);
2259
- this.failureCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.FAILURE_COUNT);
2260
- this.retryCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.RETRY_COUNT);
2261
- this.throttleCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.THROTTLE_COUNT);
2262
- this.exceptionCountGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.EXCEPTION_COUNT);
2263
- this.averageDurationGauge = this.networkStatsbeatMeter.createObservableGauge(StatsbeatCounter.AVERAGE_DURATION);
2264
- this.commonProperties = {
2265
- os: this.os,
2266
- rp: this.resourceProvider,
2267
- cikey: this.cikey,
2268
- runtimeVersion: this.runtimeVersion,
2269
- language: this.language,
2270
- version: this.version,
2271
- attach: this.attach,
2272
- };
2273
- this.networkProperties = {
2274
- endpoint: this.endpointUrl,
2275
- host: this.host,
2276
- };
2277
- this.isInitialized = true;
2278
- this.initialize();
2279
- }
2280
- shutdown() {
2281
- return this.networkStatsbeatMeterProvider.shutdown();
2282
- }
2283
- async initialize() {
2284
- try {
2285
- await super.getResourceProvider();
2286
- // Add network observable callbacks
2287
- this.successCountGauge.addCallback(this.successCallback.bind(this));
2288
- this.networkStatsbeatMeter.addBatchObservableCallback(this.failureCallback.bind(this), [
2289
- this.failureCountGauge,
2290
- ]);
2291
- this.networkStatsbeatMeter.addBatchObservableCallback(this.retryCallback.bind(this), [
2292
- this.retryCountGauge,
2293
- ]);
2294
- this.networkStatsbeatMeter.addBatchObservableCallback(this.throttleCallback.bind(this), [
2295
- this.throttleCountGauge,
2296
- ]);
2297
- this.networkStatsbeatMeter.addBatchObservableCallback(this.exceptionCallback.bind(this), [
2298
- this.exceptionCountGauge,
2299
- ]);
2300
- this.averageDurationGauge.addCallback(this.durationCallback.bind(this));
2301
- }
2302
- catch (error) {
2303
- api.diag.debug("Call to get the resource provider failed.");
2304
- }
2305
- }
2306
- // Observable gauge callbacks
2307
- successCallback(observableResult) {
2308
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2309
- const attributes = Object.assign(Object.assign({}, this.commonProperties), this.networkProperties);
2310
- observableResult.observe(counter.totalSuccesfulRequestCount, attributes);
2311
- counter.totalSuccesfulRequestCount = 0;
2312
- }
2313
- failureCallback(observableResult) {
2314
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2315
- /*
2316
- Takes the failureCountGauge, value (of the counter), and attributes
2317
- create a unqiue counter based on statusCode as well
2318
- append statusCode to attributes so the newly created attributes are unique.
2319
- */
2320
- const attributes = Object.assign(Object.assign(Object.assign({}, this.networkProperties), this.commonProperties), { statusCode: 0 });
2321
- // For each { statusCode -> count } mapping, call observe, passing the count and attributes that include the statusCode
2322
- for (let i = 0; i < counter.totalFailedRequestCount.length; i++) {
2323
- attributes.statusCode = counter.totalFailedRequestCount[i].statusCode;
2324
- observableResult.observe(this.failureCountGauge, counter.totalFailedRequestCount[i].count, Object.assign({}, attributes));
2325
- counter.totalFailedRequestCount[i].count = 0;
2326
- }
2327
- }
2328
- retryCallback(observableResult) {
2329
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2330
- const attributes = Object.assign(Object.assign(Object.assign({}, this.networkProperties), this.commonProperties), { statusCode: 0 });
2331
- for (let i = 0; i < counter.retryCount.length; i++) {
2332
- attributes.statusCode = counter.retryCount[i].statusCode;
2333
- observableResult.observe(this.retryCountGauge, counter.retryCount[i].count, Object.assign({}, attributes));
2334
- counter.retryCount[i].count = 0;
2335
- }
2336
- }
2337
- throttleCallback(observableResult) {
2338
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2339
- const attributes = Object.assign(Object.assign(Object.assign({}, this.networkProperties), this.commonProperties), { statusCode: 0 });
2340
- for (let i = 0; i < counter.throttleCount.length; i++) {
2341
- attributes.statusCode = counter.throttleCount[i].statusCode;
2342
- observableResult.observe(this.throttleCountGauge, counter.throttleCount[i].count, Object.assign({}, attributes));
2343
- counter.throttleCount[i].count = 0;
2344
- }
2345
- }
2346
- exceptionCallback(observableResult) {
2347
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2348
- const attributes = Object.assign(Object.assign(Object.assign({}, this.networkProperties), this.commonProperties), { exceptionType: "" });
2349
- for (let i = 0; i < counter.exceptionCount.length; i++) {
2350
- attributes.exceptionType = counter.exceptionCount[i].exceptionType;
2351
- observableResult.observe(this.exceptionCountGauge, counter.exceptionCount[i].count, Object.assign({}, attributes));
2352
- counter.exceptionCount[i].count = 0;
2353
- }
2354
- }
2355
- durationCallback(observableResult) {
2356
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2357
- const attributes = Object.assign(Object.assign({}, this.networkProperties), this.commonProperties);
2358
- for (let i = 0; i < this.networkStatsbeatCollection.length; i++) {
2359
- const currentCounter = this.networkStatsbeatCollection[i];
2360
- currentCounter.time = Number(new Date());
2361
- const intervalRequests = currentCounter.totalRequestCount - currentCounter.lastRequestCount || 0;
2362
- currentCounter.averageRequestExecutionTime =
2363
- (currentCounter.intervalRequestExecutionTime -
2364
- currentCounter.lastIntervalRequestExecutionTime) /
2365
- intervalRequests || 0;
2366
- currentCounter.lastIntervalRequestExecutionTime = currentCounter.intervalRequestExecutionTime; // reset
2367
- currentCounter.lastRequestCount = currentCounter.totalRequestCount;
2368
- currentCounter.lastTime = currentCounter.time;
2369
- }
2370
- observableResult.observe(counter.averageRequestExecutionTime, attributes);
2371
- counter.averageRequestExecutionTime = 0;
2372
- }
2373
- // Public methods to increase counters
2374
- countSuccess(duration) {
2375
- if (!this.isInitialized) {
2376
- return;
2377
- }
2378
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2379
- counter.totalRequestCount++;
2380
- counter.totalSuccesfulRequestCount++;
2381
- counter.intervalRequestExecutionTime += duration;
2382
- }
2383
- countFailure(duration, statusCode) {
2384
- if (!this.isInitialized) {
2385
- return;
2386
- }
2387
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2388
- const currentStatusCounter = counter.totalFailedRequestCount.find((statusCounter) => statusCode === statusCounter.statusCode);
2389
- if (currentStatusCounter) {
2390
- currentStatusCounter.count++;
2391
- }
2392
- else {
2393
- counter.totalFailedRequestCount.push({ statusCode: statusCode, count: 1 });
2394
- }
2395
- counter.totalRequestCount++;
2396
- counter.intervalRequestExecutionTime += duration;
2397
- }
2398
- countRetry(statusCode) {
2399
- if (!this.isInitialized) {
2400
- return;
2401
- }
2402
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2403
- const currentStatusCounter = counter.retryCount.find((statusCounter) => statusCode === statusCounter.statusCode);
2404
- if (currentStatusCounter) {
2405
- currentStatusCounter.count++;
2406
- }
2407
- else {
2408
- counter.retryCount.push({ statusCode: statusCode, count: 1 });
2409
- }
2410
- }
2411
- countThrottle(statusCode) {
2412
- if (!this.isInitialized) {
2413
- return;
2414
- }
2415
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2416
- const currentStatusCounter = counter.throttleCount.find((statusCounter) => statusCode === statusCounter.statusCode);
2417
- if (currentStatusCounter) {
2418
- currentStatusCounter.count++;
2419
- }
2420
- else {
2421
- counter.throttleCount.push({ statusCode: statusCode, count: 1 });
2422
- }
2423
- }
2424
- countException(exceptionType) {
2425
- if (!this.isInitialized) {
2426
- return;
2427
- }
2428
- const counter = this.getNetworkStatsbeatCounter(this.endpointUrl, this.host);
2429
- const currentErrorCounter = counter.exceptionCount.find((exceptionCounter) => exceptionType.name === exceptionCounter.exceptionType);
2430
- if (currentErrorCounter) {
2431
- currentErrorCounter.count++;
2432
- }
2433
- else {
2434
- counter.exceptionCount.push({ exceptionType: exceptionType.name, count: 1 });
2435
- }
2436
- }
2437
- // Gets a networkStatsbeat counter if one exists for the given endpoint
2438
- getNetworkStatsbeatCounter(endpoint, host) {
2439
- // Check if the counter is available
2440
- for (let i = 0; i < this.networkStatsbeatCollection.length; i++) {
2441
- // Same object
2442
- if (endpoint === this.networkStatsbeatCollection[i].endpoint &&
2443
- host === this.networkStatsbeatCollection[i].host) {
2444
- return this.networkStatsbeatCollection[i];
2445
- }
2446
- }
2447
- // Create a new counter if not found
2448
- const newCounter = new NetworkStatsbeat(endpoint, host);
2449
- this.networkStatsbeatCollection.push(newCounter);
2450
- return newCounter;
2451
- }
2452
- getShortHost(originalHost) {
2453
- let shortHost = originalHost;
2454
- try {
2455
- const hostRegex = new RegExp(/^https?:\/\/(?:www\.)?([^/.-]+)/);
2456
- const res = hostRegex.exec(originalHost);
2457
- if (res !== null && res.length > 1) {
2458
- shortHost = res[1];
2459
- }
2460
- shortHost = shortHost.replace(".in.applicationinsights.azure.com", "");
2461
- }
2462
- catch (error) {
2463
- api.diag.debug("Failed to get the short host name.");
2464
- }
2465
- return shortHost;
2466
- }
2467
- }
2468
-
2469
- // Copyright (c) Microsoft Corporation.
2470
- // Licensed under the MIT License.
2471
- let instance$1 = null;
2472
- /**
2473
- * Long Interval Statsbeat Metrics
2474
- * @internal
2475
- */
2476
- class LongIntervalStatsbeatMetrics extends StatsbeatMetrics {
2477
- constructor(options) {
2478
- super();
2479
- this.statsCollectionLongInterval = 86400000; // 1 day
2480
- this.attach = "Manual";
2481
- this.feature = 0;
2482
- this.instrumentation = 0;
2483
- this.isInitialized = false;
2484
- this.connectionString = super.getConnectionString(options.endpointUrl);
2485
- const exporterConfig = {
2486
- connectionString: this.connectionString,
2487
- disableOfflineStorage: options.disableOfflineStorage,
2488
- };
2489
- this.setFeatures();
2490
- this.longIntervalStatsbeatMeterProvider = new sdkMetrics.MeterProvider();
2491
- this.longIntervalAzureExporter = new AzureMonitorStatsbeatExporter(exporterConfig);
2492
- // Export Long Interval Statsbeats every day
2493
- const longIntervalMetricReaderOptions = {
2494
- exporter: this.longIntervalAzureExporter,
2495
- exportIntervalMillis: Number(process.env.LONG_INTERVAL_EXPORT_MILLIS) || this.statsCollectionLongInterval, // 1 day
2496
- };
2497
- this.longIntervalMetricReader = new sdkMetrics.PeriodicExportingMetricReader(longIntervalMetricReaderOptions);
2498
- this.longIntervalStatsbeatMeterProvider.addMetricReader(this.longIntervalMetricReader);
2499
- this.longIntervalStatsbeatMeter = this.longIntervalStatsbeatMeterProvider.getMeter("Azure Monitor Long Interval Statsbeat");
2500
- // Assign Common Properties
2501
- this.runtimeVersion = process.version;
2502
- this.language = STATSBEAT_LANGUAGE;
2503
- this.version = packageVersion;
2504
- this.cikey = options.instrumentationKey;
2505
- this.featureStatsbeatGauge = this.longIntervalStatsbeatMeter.createObservableGauge(StatsbeatCounter.FEATURE);
2506
- this.attachStatsbeatGauge = this.longIntervalStatsbeatMeter.createObservableGauge(StatsbeatCounter.ATTACH);
2507
- this.commonProperties = {
2508
- os: this.os,
2509
- rp: this.resourceProvider,
2510
- cikey: this.cikey,
2511
- runtimeVersion: this.runtimeVersion,
2512
- language: this.language,
2513
- version: this.version,
2514
- attach: this.attach,
2515
- };
2516
- this.attachProperties = {
2517
- rpId: this.resourceIdentifier,
2518
- };
2519
- this.isInitialized = true;
2520
- this.initialize();
2521
- }
2522
- async initialize() {
2523
- try {
2524
- await this.getResourceProvider();
2525
- // Add long interval observable callbacks
2526
- this.attachStatsbeatGauge.addCallback(this.attachCallback.bind(this));
2527
- this.longIntervalStatsbeatMeter.addBatchObservableCallback(this.getEnvironmentStatus.bind(this), [this.featureStatsbeatGauge]);
2528
- // Export Feature/Attach Statsbeat once upon app initialization
2529
- this.longIntervalAzureExporter.export((await this.longIntervalMetricReader.collect()).resourceMetrics, (result) => {
2530
- if (result.code !== core.ExportResultCode.SUCCESS) {
2531
- api.diag.error(`LongIntervalStatsbeat: metrics export failed (error ${result.error})`);
2532
- }
2533
- });
2534
- }
2535
- catch (error) {
2536
- api.diag.debug("Call to get the resource provider failed.");
2537
- }
2538
- }
2539
- getEnvironmentStatus(observableResult) {
2540
- this.setFeatures();
2541
- let attributes;
2542
- if (this.instrumentation) {
2543
- attributes = Object.assign(Object.assign({}, this.commonProperties), { feature: this.instrumentation, type: StatsbeatFeatureType.INSTRUMENTATION });
2544
- observableResult.observe(this.featureStatsbeatGauge, 1, Object.assign({}, attributes));
2545
- }
2546
- if (this.feature) {
2547
- attributes = Object.assign(Object.assign({}, this.commonProperties), { feature: this.feature, type: StatsbeatFeatureType.FEATURE });
2548
- observableResult.observe(this.featureStatsbeatGauge, 1, Object.assign({}, attributes));
2549
- }
2550
- }
2551
- setFeatures() {
2552
- const statsbeatFeatures = process.env.AZURE_MONITOR_STATSBEAT_FEATURES;
2553
- if (statsbeatFeatures) {
2554
- try {
2555
- this.feature = JSON.parse(statsbeatFeatures).feature;
2556
- this.instrumentation = JSON.parse(statsbeatFeatures).instrumentation;
2557
- }
2558
- catch (error) {
2559
- api.diag.error(`LongIntervalStatsbeat: Failed to parse features/instrumentations (error ${error})`);
2560
- }
2561
- }
2562
- }
2563
- attachCallback(observableResult) {
2564
- const attributes = Object.assign(Object.assign({}, this.commonProperties), this.attachProperties);
2565
- observableResult.observe(1, attributes);
2566
- }
2567
- shutdown() {
2568
- return this.longIntervalStatsbeatMeterProvider.shutdown();
2569
- }
2570
- }
2571
- /**
2572
- * Singleton LongIntervalStatsbeatMetrics instance.
2573
- * @internal
2574
- */
2575
- function getInstance$1(options) {
2576
- if (!instance$1) {
2577
- instance$1 = new LongIntervalStatsbeatMetrics(options);
2578
- }
2579
- return instance$1;
2580
- }
2581
-
2582
- // Copyright (c) Microsoft Corporation.
2583
- // Licensed under the MIT License.
2584
- /**
2585
- * Breeze retriable status codes.
2586
- * @internal
2587
- */
2588
- function isRetriable(statusCode) {
2589
- return (statusCode === 206 || // Partial Accept
2590
- statusCode === 401 || // Unauthorized
2591
- statusCode === 403 || // Forbidden
2592
- statusCode === 408 || // Timeout
2593
- statusCode === 429 || // Too many requests
2594
- statusCode === 439 || // Daily quota exceeded (legacy)
2595
- statusCode === 500 || // Server Error
2596
- statusCode === 502 || // Bad Gateway
2597
- statusCode === 503 || // Server Unavailable
2598
- statusCode === 504 // Gateway Timeout
2599
- );
2600
- }
2601
- // Convert ms to c# time span format DD.HH:MM:SS.MMMMMM
2602
- function msToTimeSpan(totalms) {
2603
- if (isNaN(totalms) || totalms < 0) {
2604
- totalms = 0;
2605
- }
2606
- let sec = ((totalms / 1000) % 60).toFixed(7).replace(/0{0,4}$/, "");
2607
- let min = "" + (Math.floor(totalms / (1000 * 60)) % 60);
2608
- let hour = "" + (Math.floor(totalms / (1000 * 60 * 60)) % 24);
2609
- const days = Math.floor(totalms / (1000 * 60 * 60 * 24));
2610
- sec = sec.indexOf(".") < 2 ? "0" + sec : sec;
2611
- min = min.length < 2 ? "0" + min : min;
2612
- hour = hour.length < 2 ? "0" + hour : hour;
2613
- const daysText = days > 0 ? days + "." : "";
2614
- return daysText + hour + ":" + min + ":" + sec;
2615
- }
2616
-
2617
- // Copyright (c) Microsoft Corporation.
2618
- // Licensed under the MIT License.
2619
- const DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS = 60000;
2620
- /**
2621
- * Base sender class
2622
- * @internal
2623
- */
2624
- class BaseSender {
2625
- constructor(options) {
2626
- this.statsbeatFailureCount = 0;
2627
- this.batchSendRetryIntervalMs = DEFAULT_BATCH_SEND_RETRY_INTERVAL_MS;
2628
- this.numConsecutiveRedirects = 0;
2629
- this.disableOfflineStorage = options.exporterOptions.disableOfflineStorage || false;
2630
- this.persister = new FileSystemPersist(options.instrumentationKey, options.exporterOptions);
2631
- if (options.trackStatsbeat) {
2632
- // Initialize statsbeatMetrics
2633
- this.networkStatsbeatMetrics = new NetworkStatsbeatMetrics({
2634
- instrumentationKey: options.instrumentationKey,
2635
- endpointUrl: options.endpointUrl,
2636
- disableOfflineStorage: this.disableOfflineStorage,
2637
- });
2638
- this.longIntervalStatsbeatMetrics = getInstance$1({
2639
- instrumentationKey: options.instrumentationKey,
2640
- endpointUrl: options.endpointUrl,
2641
- disableOfflineStorage: this.disableOfflineStorage,
2642
- });
2643
- }
2644
- this.retryTimer = null;
2645
- this.isStatsbeatSender = options.isStatsbeatSender || false;
2646
- }
2647
- /**
2648
- * Export envelopes
2649
- */
2650
- async exportEnvelopes(envelopes) {
2651
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2652
- api.diag.info(`Exporting ${envelopes.length} envelope(s)`);
2653
- if (envelopes.length < 1) {
2654
- return { code: core.ExportResultCode.SUCCESS };
2655
- }
2656
- try {
2657
- const startTime = new Date().getTime();
2658
- const { result, statusCode } = await this.send(envelopes);
2659
- const endTime = new Date().getTime();
2660
- const duration = endTime - startTime;
2661
- this.numConsecutiveRedirects = 0;
2662
- if (statusCode === 200) {
2663
- // Success -- @todo: start retry timer
2664
- if (!this.retryTimer) {
2665
- this.retryTimer = setTimeout(() => {
2666
- this.retryTimer = null;
2667
- this.sendFirstPersistedFile();
2668
- }, this.batchSendRetryIntervalMs);
2669
- this.retryTimer.unref();
2670
- }
2671
- // If we are not exportings statsbeat and statsbeat is not disabled -- count success
2672
- (_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.countSuccess(duration);
2673
- return { code: core.ExportResultCode.SUCCESS };
2674
- }
2675
- else if (statusCode && isRetriable(statusCode)) {
2676
- // Failed -- persist failed data
2677
- if (statusCode === 429 || statusCode === 439) {
2678
- (_b = this.networkStatsbeatMetrics) === null || _b === void 0 ? void 0 : _b.countThrottle(statusCode);
2679
- }
2680
- if (result) {
2681
- api.diag.info(result);
2682
- const breezeResponse = JSON.parse(result);
2683
- const filteredEnvelopes = [];
2684
- if (breezeResponse.errors) {
2685
- breezeResponse.errors.forEach((error) => {
2686
- if (error.statusCode && isRetriable(error.statusCode)) {
2687
- filteredEnvelopes.push(envelopes[error.index]);
2688
- }
2689
- });
2690
- }
2691
- if (filteredEnvelopes.length > 0) {
2692
- (_c = this.networkStatsbeatMetrics) === null || _c === void 0 ? void 0 : _c.countRetry(statusCode);
2693
- // calls resultCallback(ExportResult) based on result of persister.push
2694
- return await this.persist(filteredEnvelopes);
2695
- }
2696
- // Failed -- not retriable
2697
- (_d = this.networkStatsbeatMetrics) === null || _d === void 0 ? void 0 : _d.countFailure(duration, statusCode);
2698
- return {
2699
- code: core.ExportResultCode.FAILED,
2700
- };
2701
- }
2702
- else {
2703
- // calls resultCallback(ExportResult) based on result of persister.push
2704
- (_e = this.networkStatsbeatMetrics) === null || _e === void 0 ? void 0 : _e.countRetry(statusCode);
2705
- return await this.persist(envelopes);
2706
- }
2707
- }
2708
- else {
2709
- // Failed -- not retriable
2710
- if (this.networkStatsbeatMetrics) {
2711
- if (statusCode) {
2712
- this.networkStatsbeatMetrics.countFailure(duration, statusCode);
2713
- }
2714
- }
2715
- else {
2716
- this.incrementStatsbeatFailure();
2717
- }
2718
- return {
2719
- code: core.ExportResultCode.FAILED,
2720
- };
2721
- }
2722
- }
2723
- catch (error) {
2724
- const restError = error;
2725
- if (restError.statusCode &&
2726
- (restError.statusCode === 307 || // Temporary redirect
2727
- restError.statusCode === 308)) {
2728
- // Permanent redirect
2729
- this.numConsecutiveRedirects++;
2730
- // To prevent circular redirects
2731
- if (this.numConsecutiveRedirects < 10) {
2732
- if (restError.response && restError.response.headers) {
2733
- const location = restError.response.headers.get("location");
2734
- if (location) {
2735
- // Update sender URL
2736
- this.handlePermanentRedirect(location);
2737
- // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically
2738
- return this.exportEnvelopes(envelopes);
2739
- }
2740
- }
2741
- }
2742
- else {
2743
- const redirectError = new Error("Circular redirect");
2744
- (_f = this.networkStatsbeatMetrics) === null || _f === void 0 ? void 0 : _f.countException(redirectError);
2745
- return { code: core.ExportResultCode.FAILED, error: redirectError };
2746
- }
2747
- }
2748
- else if (restError.statusCode && isRetriable(restError.statusCode)) {
2749
- (_g = this.networkStatsbeatMetrics) === null || _g === void 0 ? void 0 : _g.countRetry(restError.statusCode);
2750
- return this.persist(envelopes);
2751
- }
2752
- else if (restError.statusCode === 400 &&
2753
- restError.message.includes("Invalid instrumentation key")) {
2754
- const invalidInstrumentationKeyError = new Error("Invalid instrumentation key");
2755
- this.shutdownStatsbeat();
2756
- return { code: core.ExportResultCode.FAILED, error: invalidInstrumentationKeyError };
2757
- }
2758
- if (this.isNetworkError(restError)) {
2759
- if (restError.statusCode) {
2760
- (_h = this.networkStatsbeatMetrics) === null || _h === void 0 ? void 0 : _h.countRetry(restError.statusCode);
2761
- }
2762
- if (!this.isStatsbeatSender) {
2763
- api.diag.error("Retrying due to transient client side error. Error message:", restError.message);
2764
- }
2765
- return this.persist(envelopes);
2766
- }
2767
- (_j = this.networkStatsbeatMetrics) === null || _j === void 0 ? void 0 : _j.countException(restError);
2768
- if (!this.isStatsbeatSender) {
2769
- api.diag.error("Envelopes could not be exported and are not retriable. Error message:", restError.message);
2770
- }
2771
- return { code: core.ExportResultCode.FAILED, error: restError };
2772
- }
2773
- }
2774
- /**
2775
- * Persist envelopes to disk
2776
- */
2777
- async persist(envelopes) {
2778
- try {
2779
- const success = await this.persister.push(envelopes);
2780
- return success
2781
- ? { code: core.ExportResultCode.SUCCESS }
2782
- : {
2783
- code: core.ExportResultCode.FAILED,
2784
- error: new Error("Failed to persist envelope in disk."),
2785
- };
2786
- }
2787
- catch (ex) {
2788
- return { code: core.ExportResultCode.FAILED, error: ex };
2789
- }
2790
- }
2791
- /**
2792
- * Disable collection of statsbeat metrics after max failures
2793
- */
2794
- incrementStatsbeatFailure() {
2795
- this.statsbeatFailureCount++;
2796
- if (this.statsbeatFailureCount > MAX_STATSBEAT_FAILURES) {
2797
- this.shutdownStatsbeat();
2798
- }
2799
- }
2800
- /**
2801
- * Shutdown statsbeat metrics
2802
- */
2803
- shutdownStatsbeat() {
2804
- var _a, _b;
2805
- (_a = this.networkStatsbeatMetrics) === null || _a === void 0 ? void 0 : _a.shutdown();
2806
- (_b = this.longIntervalStatsbeatMetrics) === null || _b === void 0 ? void 0 : _b.shutdown();
2807
- this.networkStatsbeatMetrics = undefined;
2808
- this.statsbeatFailureCount = 0;
2809
- }
2810
- async sendFirstPersistedFile() {
2811
- try {
2812
- const envelopes = (await this.persister.shift());
2813
- if (envelopes) {
2814
- await this.send(envelopes);
2815
- }
2816
- }
2817
- catch (err) {
2818
- api.diag.warn(`Failed to fetch persisted file`, err);
2819
- }
2820
- }
2821
- isNetworkError(error) {
2822
- if (error && error.code && error.code === "REQUEST_SEND_ERROR") {
2823
- return true;
2824
- }
2825
- return false;
2826
- }
2827
- }
2828
-
2829
- // Copyright (c) Microsoft Corporation.
2830
- // Licensed under the MIT License.
2831
- const applicationInsightsResource = "https://monitor.azure.com//.default";
2832
- /**
2833
- * Exporter HTTP sender class
2834
- * @internal
2835
- */
2836
- class HttpSender extends BaseSender {
2837
- constructor(options) {
2838
- super(options);
2839
- // Build endpoint using provided configuration or default values
2840
- this.appInsightsClientOptions = Object.assign({ host: options.endpointUrl }, options.exporterOptions);
2841
- if (this.appInsightsClientOptions.credential) {
2842
- // Add credentialScopes
2843
- if (options.aadAudience) {
2844
- this.appInsightsClientOptions.credentialScopes = [options.aadAudience];
2845
- }
2846
- else {
2847
- // Default
2848
- this.appInsightsClientOptions.credentialScopes = [applicationInsightsResource];
2849
- }
2850
- }
2851
- this.appInsightsClient = new ApplicationInsightsClient(this.appInsightsClientOptions);
2852
- // Handle redirects in HTTP Sender
2853
- this.appInsightsClient.pipeline.removePolicy({ name: coreRestPipeline.redirectPolicyName });
2854
- }
2855
- /**
2856
- * Send Azure envelopes
2857
- * @internal
2858
- */
2859
- async send(envelopes) {
2860
- var _a;
2861
- const options = {};
2862
- let response;
2863
- function onResponse(rawResponse, flatResponse) {
2864
- response = rawResponse;
2865
- if (options.onResponse) {
2866
- options.onResponse(rawResponse, flatResponse);
2867
- }
2868
- }
2869
- await this.appInsightsClient.track(envelopes, Object.assign(Object.assign({}, options), { onResponse }));
2870
- return { statusCode: response === null || response === void 0 ? void 0 : response.status, result: (_a = response === null || response === void 0 ? void 0 : response.bodyAsText) !== null && _a !== void 0 ? _a : "" };
2871
- }
2872
- /**
2873
- * Shutdown sender
2874
- * @internal
2875
- */
2876
- // eslint-disable-next-line @typescript-eslint/require-await
2877
- async shutdown() {
2878
- api.diag.info("HttpSender shutting down");
2879
- }
2880
- handlePermanentRedirect(location) {
2881
- if (location) {
2882
- const locUrl = new url.URL(location);
2883
- if (locUrl && locUrl.host) {
2884
- this.appInsightsClient.host = "https://" + locUrl.host;
2885
- }
2886
- }
2887
- }
2888
- }
2889
-
2890
- // Copyright (c) Microsoft Corporation.
2891
- // Licensed under the MIT License.
2892
- let instance = null;
2893
- /**
2894
- * Azure Telemetry context.
2895
- * @internal
2896
- */
2897
- class Context {
2898
- constructor() {
2899
- this.tags = {};
2900
- this._loadDeviceContext();
2901
- this._loadInternalContext();
2902
- }
2903
- _loadDeviceContext() {
2904
- this.tags[KnownContextTagKeys.AiDeviceOsVersion] = os__namespace && `${os__namespace.type()} ${os__namespace.release()}`;
2905
- }
2906
- _loadInternalContext() {
2907
- const { node } = process.versions;
2908
- [Context.nodeVersion] = node.split(".");
2909
- Context.opentelemetryVersion = core.SDK_INFO[semanticConventions.SemanticResourceAttributes.TELEMETRY_SDK_VERSION];
2910
- Context.sdkVersion = packageVersion;
2911
- const prefix = process.env["AZURE_MONITOR_PREFIX"] ? process.env["AZURE_MONITOR_PREFIX"] : "";
2912
- const version = process.env["AZURE_MONITOR_DISTRO_VERSION"]
2913
- ? `ext${process.env["AZURE_MONITOR_DISTRO_VERSION"]}`
2914
- : `ext${Context.sdkVersion}`;
2915
- const internalSdkVersion = `${prefix}node${Context.nodeVersion}:otel${Context.opentelemetryVersion}:${version}`;
2916
- this.tags[KnownContextTagKeys.AiInternalSdkVersion] = internalSdkVersion;
2917
- }
2918
- }
2919
- Context.sdkVersion = null;
2920
- Context.opentelemetryVersion = null;
2921
- Context.nodeVersion = "";
2922
- /**
2923
- * Singleton Context instance
2924
- * @internal
2925
- */
2926
- function getInstance() {
2927
- if (!instance) {
2928
- instance = new Context();
2929
- }
2930
- return instance;
2931
- }
2932
-
2933
- // Copyright (c) Microsoft Corporation.
2934
- // Licensed under the MIT License.
2935
- function hrTimeToDate(hrTime) {
2936
- return new Date(core.hrTimeToNanoseconds(hrTime) / 1000000);
2937
- }
2938
- function createTagsFromResource(resource) {
2939
- const context = getInstance();
2940
- const tags = Object.assign({}, context.tags);
2941
- if (resource && resource.attributes) {
2942
- tags[KnownContextTagKeys.AiCloudRole] = getCloudRole(resource);
2943
- tags[KnownContextTagKeys.AiCloudRoleInstance] = getCloudRoleInstance(resource);
2944
- if (resource.attributes[semanticConventions.SEMRESATTRS_DEVICE_ID]) {
2945
- tags[KnownContextTagKeys.AiDeviceId] = String(resource.attributes[semanticConventions.SEMRESATTRS_DEVICE_ID]);
2946
- }
2947
- if (resource.attributes[semanticConventions.SEMRESATTRS_DEVICE_MODEL_NAME]) {
2948
- tags[KnownContextTagKeys.AiDeviceModel] = String(resource.attributes[semanticConventions.SEMRESATTRS_DEVICE_MODEL_NAME]);
2949
- }
2950
- if (resource.attributes[semanticConventions.SEMRESATTRS_SERVICE_VERSION]) {
2951
- tags[KnownContextTagKeys.AiApplicationVer] = String(resource.attributes[semanticConventions.SEMRESATTRS_SERVICE_VERSION]);
2952
- }
2953
- }
2954
- return tags;
2955
- }
2956
- function getCloudRole(resource) {
2957
- let cloudRole = "";
2958
- // Service attributes
2959
- const serviceName = resource.attributes[semanticConventions.SEMRESATTRS_SERVICE_NAME];
2960
- const serviceNamespace = resource.attributes[semanticConventions.SEMRESATTRS_SERVICE_NAMESPACE];
2961
- if (serviceName) {
2962
- // Custom Service name provided by customer is highest precedence
2963
- if (!String(serviceName).startsWith("unknown_service")) {
2964
- if (serviceNamespace) {
2965
- return `${serviceNamespace}.${serviceName}`;
2966
- }
2967
- else {
2968
- return String(serviceName);
2969
- }
2970
- }
2971
- else {
2972
- // Service attributes will be only used if K8S attributes are not present
2973
- if (serviceNamespace) {
2974
- cloudRole = `${serviceNamespace}.${serviceName}`;
2975
- }
2976
- else {
2977
- cloudRole = String(serviceName);
2978
- }
2979
- }
2980
- }
2981
- // Kubernetes attributes should take precedence
2982
- const kubernetesDeploymentName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_DEPLOYMENT_NAME];
2983
- if (kubernetesDeploymentName) {
2984
- return String(kubernetesDeploymentName);
2985
- }
2986
- const kuberneteReplicasetName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_REPLICASET_NAME];
2987
- if (kuberneteReplicasetName) {
2988
- return String(kuberneteReplicasetName);
2989
- }
2990
- const kubernetesStatefulSetName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_STATEFULSET_NAME];
2991
- if (kubernetesStatefulSetName) {
2992
- return String(kubernetesStatefulSetName);
2993
- }
2994
- const kubernetesJobName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_JOB_NAME];
2995
- if (kubernetesJobName) {
2996
- return String(kubernetesJobName);
2997
- }
2998
- const kubernetesCronjobName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_CRONJOB_NAME];
2999
- if (kubernetesCronjobName) {
3000
- return String(kubernetesCronjobName);
3001
- }
3002
- const kubernetesDaemonsetName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_DAEMONSET_NAME];
3003
- if (kubernetesDaemonsetName) {
3004
- return String(kubernetesDaemonsetName);
3005
- }
3006
- return cloudRole;
3007
- }
3008
- function getCloudRoleInstance(resource) {
3009
- // Kubernetes attributes should take precedence
3010
- const kubernetesPodName = resource.attributes[semanticConventions.SEMRESATTRS_K8S_POD_NAME];
3011
- if (kubernetesPodName) {
3012
- return String(kubernetesPodName);
3013
- }
3014
- // Service attributes
3015
- const serviceInstanceId = resource.attributes[semanticConventions.SEMRESATTRS_SERVICE_INSTANCE_ID];
3016
- if (serviceInstanceId) {
3017
- return String(serviceInstanceId);
3018
- }
3019
- // Default
3020
- return os$1 && os$1.hostname();
3021
- }
3022
- function isSqlDB(dbSystem) {
3023
- return (dbSystem === semanticConventions.DBSYSTEMVALUES_DB2 ||
3024
- dbSystem === semanticConventions.DBSYSTEMVALUES_DERBY ||
3025
- dbSystem === semanticConventions.DBSYSTEMVALUES_MARIADB ||
3026
- dbSystem === semanticConventions.DBSYSTEMVALUES_MSSQL ||
3027
- dbSystem === semanticConventions.DBSYSTEMVALUES_ORACLE ||
3028
- dbSystem === semanticConventions.DBSYSTEMVALUES_SQLITE ||
3029
- dbSystem === semanticConventions.DBSYSTEMVALUES_OTHER_SQL ||
3030
- dbSystem === semanticConventions.DBSYSTEMVALUES_HSQLDB ||
3031
- dbSystem === semanticConventions.DBSYSTEMVALUES_H2);
3032
- }
3033
- function getUrl(attributes) {
3034
- if (!attributes) {
3035
- return "";
3036
- }
3037
- const httpMethod = attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
3038
- if (httpMethod) {
3039
- const httpUrl = attributes[semanticConventions.SEMATTRS_HTTP_URL];
3040
- if (httpUrl) {
3041
- return String(httpUrl);
3042
- }
3043
- else {
3044
- const httpScheme = attributes[semanticConventions.SEMATTRS_HTTP_SCHEME];
3045
- const httpTarget = attributes[semanticConventions.SEMATTRS_HTTP_TARGET];
3046
- if (httpScheme && httpTarget) {
3047
- const httpHost = attributes[semanticConventions.SEMATTRS_HTTP_HOST];
3048
- if (httpHost) {
3049
- return `${httpScheme}://${httpHost}${httpTarget}`;
3050
- }
3051
- else {
3052
- const netPeerPort = attributes[semanticConventions.SEMATTRS_NET_PEER_PORT];
3053
- if (netPeerPort) {
3054
- const netPeerName = attributes[semanticConventions.SEMATTRS_NET_PEER_NAME];
3055
- if (netPeerName) {
3056
- return `${httpScheme}://${netPeerName}:${netPeerPort}${httpTarget}`;
3057
- }
3058
- else {
3059
- const netPeerIp = attributes[semanticConventions.SEMATTRS_NET_PEER_IP];
3060
- if (netPeerIp) {
3061
- return `${httpScheme}://${netPeerIp}:${netPeerPort}${httpTarget}`;
3062
- }
3063
- }
3064
- }
3065
- }
3066
- }
3067
- }
3068
- }
3069
- return "";
3070
- }
3071
- function getDependencyTarget(attributes) {
3072
- if (!attributes) {
3073
- return "";
3074
- }
3075
- const peerService = attributes[semanticConventions.SEMATTRS_PEER_SERVICE];
3076
- const httpHost = attributes[semanticConventions.SEMATTRS_HTTP_HOST];
3077
- const httpUrl = attributes[semanticConventions.SEMATTRS_HTTP_URL];
3078
- const netPeerName = attributes[semanticConventions.SEMATTRS_NET_PEER_NAME];
3079
- const netPeerIp = attributes[semanticConventions.SEMATTRS_NET_PEER_IP];
3080
- if (peerService) {
3081
- return String(peerService);
3082
- }
3083
- else if (httpHost) {
3084
- return String(httpHost);
3085
- }
3086
- else if (httpUrl) {
3087
- return String(httpUrl);
3088
- }
3089
- else if (netPeerName) {
3090
- return String(netPeerName);
3091
- }
3092
- else if (netPeerIp) {
3093
- return String(netPeerIp);
3094
- }
3095
- return "";
3096
- }
3097
- function createResourceMetricEnvelope(resource, instrumentationKey) {
3098
- if (resource && resource.attributes) {
3099
- const tags = createTagsFromResource(resource);
3100
- const resourceAttributes = {};
3101
- for (const key of Object.keys(resource.attributes)) {
3102
- // Avoid duplication ignoring fields already mapped.
3103
- if (!(key.startsWith("_MS.") ||
3104
- key === semanticConventions.SEMRESATTRS_TELEMETRY_SDK_VERSION ||
3105
- key === semanticConventions.SEMRESATTRS_TELEMETRY_SDK_LANGUAGE ||
3106
- key === semanticConventions.SEMRESATTRS_TELEMETRY_SDK_NAME)) {
3107
- resourceAttributes[key] = resource.attributes[key];
3108
- }
3109
- }
3110
- // Only send event when resource attributes are available
3111
- if (Object.keys(resourceAttributes).length > 0) {
3112
- const baseData = {
3113
- version: 2,
3114
- metrics: [{ name: "_OTELRESOURCE_", value: 1 }],
3115
- properties: resourceAttributes,
3116
- };
3117
- const envelope = {
3118
- name: "Microsoft.ApplicationInsights.Metric",
3119
- time: new Date(),
3120
- sampleRate: 100, // Metrics are never sampled
3121
- instrumentationKey: instrumentationKey,
3122
- version: 1,
3123
- data: {
3124
- baseType: "MetricData",
3125
- baseData: baseData,
3126
- },
3127
- tags: tags,
3128
- };
3129
- return envelope;
3130
- }
3131
- }
3132
- return;
3133
- }
3134
- function serializeAttribute(value) {
3135
- if (typeof value === "object") {
3136
- if (value instanceof Uint8Array) {
3137
- return String(value);
3138
- }
3139
- else {
3140
- try {
3141
- // Should handle Error objects as well
3142
- return JSON.stringify(value, Object.getOwnPropertyNames(value));
3143
- }
3144
- catch (err) {
3145
- // Failed to serialize, return string cast
3146
- return String(value);
3147
- }
3148
- }
3149
- }
3150
- // Return scalar and undefined values
3151
- return String(value);
3152
- }
3153
- function shouldCreateResourceMetric() {
3154
- var _a;
3155
- return !(((_a = process.env.ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true");
3156
- }
3157
-
3158
- // Copyright (c) Microsoft Corporation.
3159
- // Licensed under the MIT License.
3160
- /**
3161
- * Azure SDK namespace.
3162
- * @internal
3163
- */
3164
- const AzNamespace = "az.namespace";
3165
- /**
3166
- * Azure SDK Eventhub.
3167
- * @internal
3168
- */
3169
- const MicrosoftEventHub = "Microsoft.EventHub";
3170
- /**
3171
- * Azure SDK message bus destination.
3172
- * @internal
3173
- */
3174
- const MessageBusDestination = "message_bus.destination";
3175
-
3176
- // Copyright (c) Microsoft Corporation.
3177
- // Licensed under the MIT License.
3178
- /**
3179
- * Average span.links[].attributes.enqueuedTime
3180
- */
3181
- const getTimeSinceEnqueued = (span) => {
3182
- let countEnqueueDiffs = 0;
3183
- let sumEnqueueDiffs = 0;
3184
- const startTimeMs = core.hrTimeToMilliseconds(span.startTime);
3185
- span.links.forEach(({ attributes }) => {
3186
- const enqueuedTime = attributes === null || attributes === void 0 ? void 0 : attributes[ENQUEUED_TIME];
3187
- if (enqueuedTime) {
3188
- countEnqueueDiffs += 1;
3189
- sumEnqueueDiffs += startTimeMs - (parseFloat(enqueuedTime.toString()) || 0);
3190
- }
3191
- });
3192
- return Math.max(sumEnqueueDiffs / (countEnqueueDiffs || 1), 0);
3193
- };
3194
- /**
3195
- * Implementation of Mapping to Azure Monitor
3196
- *
3197
- * https://gist.github.com/lmolkova/e4215c0f44a49ef824983382762e6b92#mapping-to-azure-monitor-application-insights-telemetry
3198
- * @internal
3199
- */
3200
- const parseEventHubSpan = (span, baseData) => {
3201
- const namespace = span.attributes[AzNamespace];
3202
- const peerAddress = (span.attributes[semanticConventions.SEMATTRS_NET_PEER_NAME] ||
3203
- span.attributes["peer.address"] ||
3204
- "unknown").replace(/\/$/g, ""); // remove trailing "/"
3205
- const messageBusDestination = (span.attributes[MessageBusDestination] || "unknown");
3206
- switch (span.kind) {
3207
- case api.SpanKind.CLIENT:
3208
- baseData.type = namespace;
3209
- baseData.target = `${peerAddress}/${messageBusDestination}`;
3210
- break;
3211
- case api.SpanKind.PRODUCER:
3212
- baseData.type = `Queue Message | ${namespace}`;
3213
- baseData.target = `${peerAddress}/${messageBusDestination}`;
3214
- break;
3215
- case api.SpanKind.CONSUMER:
3216
- baseData.type = `Queue Message | ${namespace}`;
3217
- baseData.source = `${peerAddress}/${messageBusDestination}`;
3218
- baseData.measurements = Object.assign(Object.assign({}, baseData.measurements), { [TIME_SINCE_ENQUEUED]: getTimeSinceEnqueued(span) });
3219
- break;
3220
- }
3221
- };
3222
-
3223
- // Copyright (c) Microsoft Corporation.
3224
- // Licensed under the MIT License.
3225
- function createTagsFromSpan(span) {
3226
- const tags = createTagsFromResource(span.resource);
3227
- tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;
3228
- if (span.parentSpanId) {
3229
- tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanId;
3230
- }
3231
- const endUserId = span.attributes[semanticConventions.SEMATTRS_ENDUSER_ID];
3232
- if (endUserId) {
3233
- tags[KnownContextTagKeys.AiUserId] = String(endUserId);
3234
- }
3235
- const httpUserAgent = span.attributes[semanticConventions.SEMATTRS_HTTP_USER_AGENT];
3236
- if (httpUserAgent) {
3237
- // TODO: Not exposed in Swagger, need to update def
3238
- tags["ai.user.userAgent"] = String(httpUserAgent);
3239
- }
3240
- if (span.kind === api.SpanKind.SERVER) {
3241
- const httpMethod = span.attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
3242
- const httpClientIp = span.attributes[semanticConventions.SEMATTRS_HTTP_CLIENT_IP];
3243
- const netPeerIp = span.attributes[semanticConventions.SEMATTRS_NET_PEER_IP];
3244
- if (httpMethod) {
3245
- const httpRoute = span.attributes[semanticConventions.SEMATTRS_HTTP_ROUTE];
3246
- const httpUrl = span.attributes[semanticConventions.SEMATTRS_HTTP_URL];
3247
- tags[KnownContextTagKeys.AiOperationName] = span.name; // Default
3248
- if (httpRoute) {
3249
- tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${httpRoute}`;
3250
- }
3251
- else if (httpUrl) {
3252
- try {
3253
- const url = new URL(String(httpUrl));
3254
- tags[KnownContextTagKeys.AiOperationName] = `${httpMethod} ${url.pathname}`;
3255
- }
3256
- catch (_a) {
3257
- /* no-op */
3258
- }
3259
- }
3260
- if (httpClientIp) {
3261
- tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);
3262
- }
3263
- else if (netPeerIp) {
3264
- tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);
3265
- }
3266
- }
3267
- else {
3268
- tags[KnownContextTagKeys.AiOperationName] = span.name;
3269
- if (netPeerIp) {
3270
- tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);
3271
- }
3272
- }
3273
- }
3274
- // TODO: Operation Name and Location IP TBD for non server spans
3275
- return tags;
3276
- }
3277
- function createPropertiesFromSpanAttributes(attributes) {
3278
- const properties = {};
3279
- if (attributes) {
3280
- for (const key of Object.keys(attributes)) {
3281
- // Avoid duplication ignoring fields already mapped.
3282
- if (!(key.startsWith("_MS.") ||
3283
- key.startsWith("microsoft.") ||
3284
- key === semanticConventions.SEMATTRS_NET_PEER_IP ||
3285
- key === semanticConventions.SEMATTRS_NET_PEER_NAME ||
3286
- key === semanticConventions.SEMATTRS_PEER_SERVICE ||
3287
- key === semanticConventions.SEMATTRS_HTTP_METHOD ||
3288
- key === semanticConventions.SEMATTRS_HTTP_URL ||
3289
- key === semanticConventions.SEMATTRS_HTTP_STATUS_CODE ||
3290
- key === semanticConventions.SEMATTRS_HTTP_ROUTE ||
3291
- key === semanticConventions.SEMATTRS_HTTP_HOST ||
3292
- key === semanticConventions.SEMATTRS_HTTP_URL ||
3293
- key === semanticConventions.SEMATTRS_DB_SYSTEM ||
3294
- key === semanticConventions.SEMATTRS_DB_STATEMENT ||
3295
- key === semanticConventions.SEMATTRS_DB_OPERATION ||
3296
- key === semanticConventions.SEMATTRS_DB_NAME ||
3297
- key === semanticConventions.SEMATTRS_RPC_SYSTEM ||
3298
- key === semanticConventions.SEMATTRS_RPC_GRPC_STATUS_CODE ||
3299
- key === semanticConventions.SEMATTRS_EXCEPTION_TYPE ||
3300
- key === semanticConventions.SEMATTRS_EXCEPTION_MESSAGE ||
3301
- key === semanticConventions.SEMATTRS_EXCEPTION_STACKTRACE)) {
3302
- properties[key] = serializeAttribute(attributes[key]);
3303
- }
3304
- }
3305
- }
3306
- return properties;
3307
- }
3308
- function createPropertiesFromSpan(span) {
3309
- const properties = createPropertiesFromSpanAttributes(span.attributes);
3310
- const measurements = {};
3311
- const links = span.links.map((link) => ({
3312
- operation_Id: link.context.traceId,
3313
- id: link.context.spanId,
3314
- }));
3315
- if (links.length > 0) {
3316
- properties[MS_LINKS] = JSON.stringify(links);
3317
- }
3318
- return [properties, measurements];
3319
- }
3320
- function createDependencyData(span) {
3321
- var _a;
3322
- const remoteDependencyData = {
3323
- name: span.name, // Default
3324
- id: `${span.spanContext().spanId}`,
3325
- success: ((_a = span.status) === null || _a === void 0 ? void 0 : _a.code) !== api.SpanStatusCode.ERROR,
3326
- resultCode: "0",
3327
- type: "Dependency",
3328
- duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
3329
- version: 2,
3330
- };
3331
- if (span.kind === api.SpanKind.PRODUCER) {
3332
- remoteDependencyData.type = DependencyTypes.QueueMessage;
3333
- }
3334
- if (span.kind === api.SpanKind.INTERNAL && span.parentSpanId) {
3335
- remoteDependencyData.type = DependencyTypes.InProc;
3336
- }
3337
- const httpMethod = span.attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
3338
- const dbSystem = span.attributes[semanticConventions.SEMATTRS_DB_SYSTEM];
3339
- const rpcSystem = span.attributes[semanticConventions.SEMATTRS_RPC_SYSTEM];
3340
- // HTTP Dependency
3341
- if (httpMethod) {
3342
- const httpUrl = span.attributes[semanticConventions.SEMATTRS_HTTP_URL];
3343
- if (httpUrl) {
3344
- try {
3345
- const dependencyUrl = new URL(String(httpUrl));
3346
- remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;
3347
- }
3348
- catch (_b) {
3349
- /* no-op */
3350
- }
3351
- }
3352
- remoteDependencyData.type = DependencyTypes.Http;
3353
- remoteDependencyData.data = getUrl(span.attributes);
3354
- const httpStatusCode = span.attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
3355
- if (httpStatusCode) {
3356
- remoteDependencyData.resultCode = String(httpStatusCode);
3357
- }
3358
- let target = getDependencyTarget(span.attributes);
3359
- if (target) {
3360
- try {
3361
- // Remove default port
3362
- const portRegex = new RegExp(/(https?)(:\/\/.*)(:\d+)(\S*)/);
3363
- const res = portRegex.exec(target);
3364
- if (res !== null) {
3365
- const protocol = res[1];
3366
- const port = res[3];
3367
- if ((protocol === "https" && port === ":443") ||
3368
- (protocol === "http" && port === ":80")) {
3369
- // Drop port
3370
- target = res[1] + res[2] + res[4];
3371
- }
3372
- }
3373
- }
3374
- catch (_c) {
3375
- /* no-op */
3376
- }
3377
- remoteDependencyData.target = `${target}`;
3378
- }
3379
- }
3380
- // DB Dependency
3381
- else if (dbSystem) {
3382
- // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem
3383
- if (String(dbSystem) === semanticConventions.DBSYSTEMVALUES_MYSQL) {
3384
- remoteDependencyData.type = "mysql";
3385
- }
3386
- else if (String(dbSystem) === semanticConventions.DBSYSTEMVALUES_POSTGRESQL) {
3387
- remoteDependencyData.type = "postgresql";
3388
- }
3389
- else if (String(dbSystem) === semanticConventions.DBSYSTEMVALUES_MONGODB) {
3390
- remoteDependencyData.type = "mongodb";
3391
- }
3392
- else if (String(dbSystem) === semanticConventions.DBSYSTEMVALUES_REDIS) {
3393
- remoteDependencyData.type = "redis";
3394
- }
3395
- else if (isSqlDB(String(dbSystem))) {
3396
- remoteDependencyData.type = "SQL";
3397
- }
3398
- else {
3399
- remoteDependencyData.type = String(dbSystem);
3400
- }
3401
- const dbStatement = span.attributes[semanticConventions.SEMATTRS_DB_STATEMENT];
3402
- const dbOperation = span.attributes[semanticConventions.SEMATTRS_DB_OPERATION];
3403
- if (dbStatement) {
3404
- remoteDependencyData.data = String(dbStatement);
3405
- }
3406
- else if (dbOperation) {
3407
- remoteDependencyData.data = String(dbOperation);
3408
- }
3409
- const target = getDependencyTarget(span.attributes);
3410
- const dbName = span.attributes[semanticConventions.SEMATTRS_DB_NAME];
3411
- if (target) {
3412
- remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;
3413
- }
3414
- else {
3415
- remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;
3416
- }
3417
- }
3418
- // grpc Dependency
3419
- else if (rpcSystem) {
3420
- if (rpcSystem === DependencyTypes.Wcf) {
3421
- remoteDependencyData.type = DependencyTypes.Wcf;
3422
- }
3423
- else {
3424
- remoteDependencyData.type = DependencyTypes.Grpc;
3425
- }
3426
- const grpcStatusCode = span.attributes[semanticConventions.SEMATTRS_RPC_GRPC_STATUS_CODE];
3427
- if (grpcStatusCode) {
3428
- remoteDependencyData.resultCode = String(grpcStatusCode);
3429
- }
3430
- const target = getDependencyTarget(span.attributes);
3431
- if (target) {
3432
- remoteDependencyData.target = `${target}`;
3433
- }
3434
- else if (rpcSystem) {
3435
- remoteDependencyData.target = String(rpcSystem);
3436
- }
3437
- }
3438
- return remoteDependencyData;
3439
- }
3440
- function createRequestData(span) {
3441
- const requestData = {
3442
- id: `${span.spanContext().spanId}`,
3443
- success: span.status.code !== api.SpanStatusCode.ERROR &&
3444
- (Number(span.attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE]) || 0) < 400,
3445
- responseCode: "0",
3446
- duration: msToTimeSpan(core.hrTimeToMilliseconds(span.duration)),
3447
- version: 2,
3448
- source: undefined,
3449
- };
3450
- const httpMethod = span.attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
3451
- const grpcStatusCode = span.attributes[semanticConventions.SEMATTRS_RPC_GRPC_STATUS_CODE];
3452
- if (httpMethod) {
3453
- requestData.url = getUrl(span.attributes);
3454
- const httpStatusCode = span.attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
3455
- if (httpStatusCode) {
3456
- requestData.responseCode = String(httpStatusCode);
3457
- }
3458
- }
3459
- else if (grpcStatusCode) {
3460
- requestData.responseCode = String(grpcStatusCode);
3461
- }
3462
- return requestData;
3463
- }
3464
- /**
3465
- * Span to Azure envelope parsing.
3466
- * @internal
3467
- */
3468
- function readableSpanToEnvelope(span, ikey) {
3469
- let name;
3470
- let baseType;
3471
- let baseData;
3472
- const time = hrTimeToDate(span.startTime);
3473
- const instrumentationKey = ikey;
3474
- const tags = createTagsFromSpan(span);
3475
- const [properties, measurements] = createPropertiesFromSpan(span);
3476
- switch (span.kind) {
3477
- case api.SpanKind.CLIENT:
3478
- case api.SpanKind.PRODUCER:
3479
- case api.SpanKind.INTERNAL:
3480
- name = "Microsoft.ApplicationInsights.RemoteDependency";
3481
- baseType = "RemoteDependencyData";
3482
- baseData = createDependencyData(span);
3483
- break;
3484
- case api.SpanKind.SERVER:
3485
- case api.SpanKind.CONSUMER:
3486
- name = "Microsoft.ApplicationInsights.Request";
3487
- baseType = "RequestData";
3488
- baseData = createRequestData(span);
3489
- baseData.name = tags[KnownContextTagKeys.AiOperationName];
3490
- break;
3491
- default:
3492
- // never
3493
- api.diag.error(`Unsupported span kind ${span.kind}`);
3494
- throw new Error(`Unsupported span kind ${span.kind}`);
3495
- }
3496
- let sampleRate = 100;
3497
- if (span.attributes[AzureMonitorSampleRate]) {
3498
- sampleRate = Number(span.attributes[AzureMonitorSampleRate]);
3499
- }
3500
- // Azure SDK
3501
- if (span.attributes[AzNamespace]) {
3502
- if (span.kind === api.SpanKind.INTERNAL) {
3503
- baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;
3504
- }
3505
- if (span.attributes[AzNamespace] === MicrosoftEventHub) {
3506
- parseEventHubSpan(span, baseData);
3507
- }
3508
- }
3509
- // Truncate properties
3510
- if (baseData.id) {
3511
- baseData.id = baseData.id.substring(0, MaxPropertyLengths.NINE_BIT);
3512
- }
3513
- if (baseData.name) {
3514
- baseData.name = baseData.name.substring(0, MaxPropertyLengths.TEN_BIT);
3515
- }
3516
- if (baseData.resultCode) {
3517
- baseData.resultCode = String(baseData.resultCode).substring(0, MaxPropertyLengths.TEN_BIT);
3518
- }
3519
- if (baseData.data) {
3520
- baseData.data = String(baseData.data).substring(0, MaxPropertyLengths.THIRTEEN_BIT);
3521
- }
3522
- if (baseData.type) {
3523
- baseData.type = String(baseData.type).substring(0, MaxPropertyLengths.TEN_BIT);
3524
- }
3525
- if (baseData.target) {
3526
- baseData.target = String(baseData.target).substring(0, MaxPropertyLengths.TEN_BIT);
3527
- }
3528
- if (baseData.properties) {
3529
- for (const key of Object.keys(baseData.properties)) {
3530
- baseData.properties[key] = baseData.properties[key].substring(0, MaxPropertyLengths.THIRTEEN_BIT);
3531
- }
3532
- }
3533
- return {
3534
- name,
3535
- sampleRate,
3536
- time,
3537
- instrumentationKey,
3538
- tags,
3539
- version: 1,
3540
- data: {
3541
- baseType,
3542
- baseData: Object.assign(Object.assign({}, baseData), { properties,
3543
- measurements }),
3544
- },
3545
- };
3546
- }
3547
- /**
3548
- * Span Events to Azure envelopes parsing.
3549
- * @internal
3550
- */
3551
- function spanEventsToEnvelopes(span, ikey) {
3552
- const envelopes = [];
3553
- if (span.events) {
3554
- span.events.forEach((event) => {
3555
- var _a;
3556
- let baseType;
3557
- const time = hrTimeToDate(event.time);
3558
- let name = "";
3559
- let baseData;
3560
- const properties = createPropertiesFromSpanAttributes(event.attributes);
3561
- const tags = createTagsFromResource(span.resource);
3562
- tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;
3563
- const spanId = (_a = span.spanContext()) === null || _a === void 0 ? void 0 : _a.spanId;
3564
- if (spanId) {
3565
- tags[KnownContextTagKeys.AiOperationParentId] = spanId;
3566
- }
3567
- // Only generate exception telemetry for incoming requests
3568
- if (event.name === "exception") {
3569
- if (span.kind === api.SpanKind.SERVER) {
3570
- name = "Microsoft.ApplicationInsights.Exception";
3571
- baseType = "ExceptionData";
3572
- let typeName = "";
3573
- let message = "Exception";
3574
- let stack = "";
3575
- let hasFullStack = false;
3576
- if (event.attributes) {
3577
- typeName = String(event.attributes[semanticConventions.SEMATTRS_EXCEPTION_TYPE]);
3578
- stack = String(event.attributes[semanticConventions.SEMATTRS_EXCEPTION_STACKTRACE]);
3579
- if (stack) {
3580
- hasFullStack = true;
3581
- }
3582
- const exceptionMsg = event.attributes[semanticConventions.SEMATTRS_EXCEPTION_MESSAGE];
3583
- if (exceptionMsg) {
3584
- message = String(exceptionMsg);
3585
- }
3586
- const escaped = event.attributes[semanticConventions.SEMATTRS_EXCEPTION_ESCAPED];
3587
- if (escaped !== undefined) {
3588
- properties[semanticConventions.SEMATTRS_EXCEPTION_ESCAPED] = String(escaped);
3589
- }
3590
- }
3591
- const exceptionDetails = {
3592
- typeName: typeName,
3593
- message: message,
3594
- stack: stack,
3595
- hasFullStack: hasFullStack,
3596
- };
3597
- const exceptionData = {
3598
- exceptions: [exceptionDetails],
3599
- version: 2,
3600
- properties: properties,
3601
- };
3602
- baseData = exceptionData;
3603
- }
3604
- else {
3605
- // Drop non-server exception span events
3606
- return;
3607
- }
3608
- }
3609
- else {
3610
- name = "Microsoft.ApplicationInsights.Message";
3611
- baseType = "MessageData";
3612
- const messageData = {
3613
- message: event.name,
3614
- version: 2,
3615
- properties: properties,
3616
- };
3617
- baseData = messageData;
3618
- }
3619
- let sampleRate = 100;
3620
- if (span.attributes[AzureMonitorSampleRate]) {
3621
- sampleRate = Number(span.attributes[AzureMonitorSampleRate]);
3622
- }
3623
- // Truncate properties
3624
- if (baseData.message) {
3625
- baseData.message = String(baseData.message).substring(0, MaxPropertyLengths.FIFTEEN_BIT);
3626
- }
3627
- if (baseData.properties) {
3628
- for (const key of Object.keys(baseData.properties)) {
3629
- baseData.properties[key] = baseData.properties[key].substring(0, MaxPropertyLengths.THIRTEEN_BIT);
3630
- }
3631
- }
3632
- const env = {
3633
- name: name,
3634
- time: time,
3635
- instrumentationKey: ikey,
3636
- version: 1,
3637
- sampleRate: sampleRate,
3638
- data: {
3639
- baseType: baseType,
3640
- baseData: baseData,
3641
- },
3642
- tags: tags,
3643
- };
3644
- envelopes.push(env);
3645
- });
3646
- }
3647
- return envelopes;
3648
- }
3649
-
3650
- // Copyright (c) Microsoft Corporation.
3651
- // Licensed under the MIT License.
3652
- /**
3653
- * Azure Monitor OpenTelemetry Trace Exporter.
3654
- */
3655
- class AzureMonitorTraceExporter extends AzureMonitorBaseExporter {
3656
- /**
3657
- * Initializes a new instance of the AzureMonitorTraceExporter class.
3658
- * @param AzureExporterConfig - Exporter configuration.
3659
- */
3660
- constructor(options = {}) {
3661
- super(options);
3662
- /**
3663
- * Flag to determine if Exporter is shutdown.
3664
- */
3665
- this.isShutdown = false;
3666
- this.shouldCreateResourceMetric = shouldCreateResourceMetric();
3667
- this.sender = new HttpSender({
3668
- endpointUrl: this.endpointUrl,
3669
- instrumentationKey: this.instrumentationKey,
3670
- trackStatsbeat: this.trackStatsbeat,
3671
- exporterOptions: options,
3672
- aadAudience: this.aadAudience,
3673
- });
3674
- api.diag.debug("AzureMonitorTraceExporter was successfully setup");
3675
- }
3676
- /**
3677
- * Export OpenTelemetry spans.
3678
- * @param spans - Spans to export.
3679
- * @param resultCallback - Result callback.
3680
- */
3681
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
3682
- async export(spans, resultCallback) {
3683
- if (this.isShutdown) {
3684
- api.diag.info("Exporter shut down. Failed to export spans.");
3685
- setTimeout(() => resultCallback({ code: core.ExportResultCode.FAILED }), 0);
3686
- return;
3687
- }
3688
- api.diag.info(`Exporting ${spans.length} span(s). Converting to envelopes...`);
3689
- if (spans.length > 0) {
3690
- const envelopes = [];
3691
- const resourceMetricEnvelope = createResourceMetricEnvelope(spans[0].resource, this.instrumentationKey);
3692
- if (resourceMetricEnvelope && this.shouldCreateResourceMetric) {
3693
- envelopes.push(resourceMetricEnvelope);
3694
- }
3695
- spans.forEach((span) => {
3696
- envelopes.push(readableSpanToEnvelope(span, this.instrumentationKey));
3697
- const spanEventEnvelopes = spanEventsToEnvelopes(span, this.instrumentationKey);
3698
- if (spanEventEnvelopes.length > 0) {
3699
- envelopes.push(...spanEventEnvelopes);
3700
- }
3701
- });
3702
- resultCallback(await this.sender.exportEnvelopes(envelopes));
3703
- }
3704
- // No data to export
3705
- resultCallback({ code: core.ExportResultCode.SUCCESS });
3706
- }
3707
- /**
3708
- * Shutdown AzureMonitorTraceExporter.
3709
- */
3710
- async shutdown() {
3711
- this.isShutdown = true;
3712
- api.diag.info("AzureMonitorTraceExporter shutting down");
3713
- return this.sender.shutdown();
3714
- }
3715
- }
3716
-
3717
- // Copyright (c) Microsoft Corporation.
3718
- // Licensed under the MIT License.
3719
- /**
3720
- * Azure Monitor OpenTelemetry Metric Exporter.
3721
- */
3722
- class AzureMonitorMetricExporter extends AzureMonitorBaseExporter {
3723
- /**
3724
- * Initializes a new instance of the AzureMonitorMetricExporter class.
3725
- * @param AzureExporterConfig - Exporter configuration.
3726
- */
3727
- constructor(options = {}) {
3728
- super(options);
3729
- /**
3730
- * Flag to determine if Exporter is shutdown.
3731
- */
3732
- this._isShutdown = false;
3733
- this._sender = new HttpSender({
3734
- endpointUrl: this.endpointUrl,
3735
- instrumentationKey: this.instrumentationKey,
3736
- trackStatsbeat: this.trackStatsbeat,
3737
- exporterOptions: options,
3738
- aadAudience: this.aadAudience,
3739
- });
3740
- api.diag.debug("AzureMonitorMetricExporter was successfully setup");
3741
- }
3742
- /**
3743
- * Export OpenTelemetry resource metrics.
3744
- * @param metrics - Resource metrics to export.
3745
- * @param resultCallback - Result callback.
3746
- */
3747
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
3748
- async export(metrics, resultCallback) {
3749
- if (this._isShutdown) {
3750
- api.diag.info("Exporter shut down. Failed to export spans.");
3751
- setTimeout(() => resultCallback({ code: core.ExportResultCode.FAILED }), 0);
3752
- return;
3753
- }
3754
- api.diag.info(`Exporting ${metrics.scopeMetrics.length} metrics(s). Converting to envelopes...`);
3755
- const envelopes = resourceMetricsToEnvelope(metrics, this.instrumentationKey);
3756
- // Supress tracing until OpenTelemetry Metrics SDK support it
3757
- await api.context.with(core.suppressTracing(api.context.active()), async () => {
3758
- resultCallback(await this._sender.exportEnvelopes(envelopes));
3759
- });
3760
- }
3761
- /**
3762
- * Shutdown AzureMonitorMetricExporter.
3763
- */
3764
- async shutdown() {
3765
- this._isShutdown = true;
3766
- api.diag.info("AzureMonitorMetricExporter shutting down");
3767
- return this._sender.shutdown();
3768
- }
3769
- /**
3770
- * Select aggregation temporality
3771
- */
3772
- selectAggregationTemporality(instrumentType) {
3773
- if (instrumentType === sdkMetrics.InstrumentType.UP_DOWN_COUNTER ||
3774
- instrumentType === sdkMetrics.InstrumentType.OBSERVABLE_UP_DOWN_COUNTER) {
3775
- return sdkMetrics.AggregationTemporality.CUMULATIVE;
3776
- }
3777
- return sdkMetrics.AggregationTemporality.DELTA;
3778
- }
3779
- /**
3780
- * Force flush
3781
- */
3782
- async forceFlush() {
3783
- return Promise.resolve();
3784
- }
3785
- }
3786
-
3787
- // Copyright (c) Microsoft Corporation.
3788
- // Licensed under the MIT License.
3789
- /**
3790
- * Log to Azure envelope parsing.
3791
- * @internal
3792
- */
3793
- function logToEnvelope(log, ikey) {
3794
- const time = hrTimeToDate(log.hrTime);
3795
- const sampleRate = 100;
3796
- const instrumentationKey = ikey;
3797
- const tags = createTagsFromLog(log);
3798
- // eslint-disable-next-line prefer-const
3799
- let [properties, measurements] = createPropertiesFromLog(log);
3800
- let name;
3801
- let baseType;
3802
- let baseData;
3803
- if (!log.attributes[ApplicationInsightsBaseType]) {
3804
- // Get Exception attributes if available
3805
- const exceptionType = log.attributes[semanticConventions.SEMATTRS_EXCEPTION_TYPE];
3806
- if (exceptionType) {
3807
- const exceptionMessage = log.attributes[semanticConventions.SEMATTRS_EXCEPTION_MESSAGE];
3808
- const exceptionStacktrace = log.attributes[semanticConventions.SEMATTRS_EXCEPTION_STACKTRACE];
3809
- name = ApplicationInsightsExceptionName;
3810
- baseType = ApplicationInsightsExceptionBaseType;
3811
- const exceptionDetails = {
3812
- typeName: String(exceptionType),
3813
- message: String(exceptionMessage),
3814
- hasFullStack: exceptionStacktrace ? true : false,
3815
- stack: String(exceptionStacktrace),
3816
- };
3817
- const exceptionData = {
3818
- exceptions: [exceptionDetails],
3819
- severityLevel: String(getSeverity(log.severityNumber)),
3820
- version: 2,
3821
- };
3822
- baseData = exceptionData;
3823
- }
3824
- else {
3825
- name = ApplicationInsightsMessageName;
3826
- baseType = ApplicationInsightsMessageBaseType;
3827
- const messageData = {
3828
- message: String(log.body),
3829
- severityLevel: String(getSeverity(log.severityNumber)),
3830
- version: 2,
3831
- };
3832
- baseData = messageData;
3833
- }
3834
- }
3835
- else {
3836
- // If Legacy Application Insights Log
3837
- baseType = String(log.attributes[ApplicationInsightsBaseType]);
3838
- name = getLegacyApplicationInsightsName(log);
3839
- baseData = getLegacyApplicationInsightsBaseData(log);
3840
- measurements = getLegacyApplicationInsightsMeasurements(log);
3841
- if (!baseData) {
3842
- // Failed to parse log
3843
- return;
3844
- }
3845
- }
3846
- // Truncate properties
3847
- if (baseData.message) {
3848
- baseData.message = String(baseData.message).substring(0, MaxPropertyLengths.FIFTEEN_BIT);
3849
- }
3850
- if (properties) {
3851
- for (const key of Object.keys(properties)) {
3852
- properties[key] = String(properties[key]).substring(0, MaxPropertyLengths.THIRTEEN_BIT);
3853
- }
3854
- }
3855
- return {
3856
- name,
3857
- sampleRate,
3858
- time,
3859
- instrumentationKey,
3860
- tags,
3861
- version: 1,
3862
- data: {
3863
- baseType,
3864
- baseData: Object.assign(Object.assign({}, baseData), { properties,
3865
- measurements }),
3866
- },
3867
- };
3868
- }
3869
- function createTagsFromLog(log) {
3870
- var _a, _b;
3871
- const tags = createTagsFromResource(log.resource);
3872
- if ((_a = log.spanContext) === null || _a === void 0 ? void 0 : _a.traceId) {
3873
- tags[KnownContextTagKeys.AiOperationId] = log.spanContext.traceId;
3874
- }
3875
- if ((_b = log.spanContext) === null || _b === void 0 ? void 0 : _b.spanId) {
3876
- tags[KnownContextTagKeys.AiOperationParentId] = log.spanContext.spanId;
3877
- }
3878
- return tags;
3879
- }
3880
- function createPropertiesFromLog(log) {
3881
- const measurements = {};
3882
- const properties = {};
3883
- if (log.attributes) {
3884
- for (const key of Object.keys(log.attributes)) {
3885
- // Avoid duplication ignoring fields already mapped.
3886
- if (!(key.startsWith("_MS.") ||
3887
- key === semanticConventions.SEMATTRS_EXCEPTION_TYPE ||
3888
- key === semanticConventions.SEMATTRS_EXCEPTION_MESSAGE ||
3889
- key === semanticConventions.SEMATTRS_EXCEPTION_STACKTRACE)) {
3890
- properties[key] = serializeAttribute(log.attributes[key]);
3891
- }
3892
- }
3893
- }
3894
- return [properties, measurements];
3895
- }
3896
- // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber
3897
- function getSeverity(severityNumber) {
3898
- if (severityNumber) {
3899
- if (severityNumber > 0 && severityNumber < 9) {
3900
- return KnownSeverityLevel.Verbose;
3901
- }
3902
- else if (severityNumber >= 9 && severityNumber < 13) {
3903
- return KnownSeverityLevel.Information;
3904
- }
3905
- else if (severityNumber >= 13 && severityNumber < 17) {
3906
- return KnownSeverityLevel.Warning;
3907
- }
3908
- else if (severityNumber >= 17 && severityNumber < 21) {
3909
- return KnownSeverityLevel.Error;
3910
- }
3911
- else if (severityNumber >= 21 && severityNumber < 25) {
3912
- return KnownSeverityLevel.Critical;
3913
- }
3914
- }
3915
- return;
3916
- }
3917
- function getLegacyApplicationInsightsName(log) {
3918
- let name = "";
3919
- switch (log.attributes[ApplicationInsightsBaseType]) {
3920
- case ApplicationInsightsAvailabilityBaseType:
3921
- name = ApplicationInsightsAvailabilityName;
3922
- break;
3923
- case ApplicationInsightsExceptionBaseType:
3924
- name = ApplicationInsightsExceptionName;
3925
- break;
3926
- case ApplicationInsightsMessageBaseType:
3927
- name = ApplicationInsightsMessageName;
3928
- break;
3929
- case ApplicationInsightsPageViewBaseType:
3930
- name = ApplicationInsightsPageViewName;
3931
- break;
3932
- case ApplicationInsightsEventBaseType:
3933
- name = ApplicationInsightsEventName;
3934
- break;
3935
- }
3936
- return name;
3937
- }
3938
- function getLegacyApplicationInsightsMeasurements(log) {
3939
- var _a;
3940
- let measurements = {};
3941
- if ((_a = log.body) === null || _a === void 0 ? void 0 : _a.measurements) {
3942
- measurements = Object.assign({}, log.body.measurements);
3943
- }
3944
- return measurements;
3945
- }
3946
- function getLegacyApplicationInsightsBaseData(log) {
3947
- let baseData = {
3948
- version: 2,
3949
- };
3950
- if (log.body) {
3951
- try {
3952
- switch (log.attributes[ApplicationInsightsBaseType]) {
3953
- case ApplicationInsightsAvailabilityBaseType:
3954
- baseData = log.body;
3955
- break;
3956
- case ApplicationInsightsExceptionBaseType:
3957
- baseData = log.body;
3958
- break;
3959
- case ApplicationInsightsMessageBaseType:
3960
- baseData = log.body;
3961
- break;
3962
- case ApplicationInsightsPageViewBaseType:
3963
- baseData = log.body;
3964
- break;
3965
- case ApplicationInsightsEventBaseType:
3966
- baseData = log.body;
3967
- break;
3968
- }
3969
- if (typeof (baseData === null || baseData === void 0 ? void 0 : baseData.message) === "object") {
3970
- baseData.message = JSON.stringify(baseData.message);
3971
- }
3972
- }
3973
- catch (err) {
3974
- api.diag.error("AzureMonitorLogExporter failed to parse Application Insights Telemetry");
3975
- }
3976
- }
3977
- return baseData;
3978
- }
3979
-
3980
- // Copyright (c) Microsoft Corporation.
3981
- // Licensed under the MIT License.
3982
- /**
3983
- * Azure Monitor OpenTelemetry Log Exporter.
3984
- */
3985
- class AzureMonitorLogExporter extends AzureMonitorBaseExporter {
3986
- /**
3987
- * Initializes a new instance of the AzureMonitorLogExporter class.
3988
- * @param AzureExporterConfig - Exporter configuration.
3989
- */
3990
- constructor(options = {}) {
3991
- super(options);
3992
- /**
3993
- * Flag to determine if Exporter is shutdown.
3994
- */
3995
- this._isShutdown = false;
3996
- this._sender = new HttpSender({
3997
- endpointUrl: this.endpointUrl,
3998
- instrumentationKey: this.instrumentationKey,
3999
- trackStatsbeat: this.trackStatsbeat,
4000
- exporterOptions: options,
4001
- aadAudience: this.aadAudience,
4002
- });
4003
- api.diag.debug("AzureMonitorLogExporter was successfully setup");
4004
- }
4005
- /**
4006
- * Export OpenTelemetry logs.
4007
- * @param logs - Logs to export.
4008
- * @param resultCallback - Result callback.
4009
- */
4010
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
4011
- async export(logs, resultCallback) {
4012
- if (this._isShutdown) {
4013
- api.diag.info("Exporter shut down. Failed to export spans.");
4014
- setTimeout(() => resultCallback({ code: core.ExportResultCode.FAILED }), 0);
4015
- return;
4016
- }
4017
- api.diag.info(`Exporting ${logs.length} logs(s). Converting to envelopes...`);
4018
- const envelopes = [];
4019
- logs.forEach((log) => {
4020
- const envelope = logToEnvelope(log, this.instrumentationKey);
4021
- if (envelope) {
4022
- envelopes.push(envelope);
4023
- }
4024
- });
4025
- // Supress tracing until OpenTelemetry Logs SDK support it
4026
- await api.context.with(core.suppressTracing(api.context.active()), async () => {
4027
- resultCallback(await this._sender.exportEnvelopes(envelopes));
4028
- });
4029
- }
4030
- /**
4031
- * Shutdown AzureMonitorLogExporter.
4032
- */
4033
- async shutdown() {
4034
- this._isShutdown = true;
4035
- api.diag.info("AzureMonitorLogExporter shutting down");
4036
- return this._sender.shutdown();
4037
- }
4038
- }
4039
-
4040
- exports.ApplicationInsightsSampler = ApplicationInsightsSampler;
4041
- exports.AzureMonitorBaseExporter = AzureMonitorBaseExporter;
4042
- exports.AzureMonitorLogExporter = AzureMonitorLogExporter;
4043
- exports.AzureMonitorMetricExporter = AzureMonitorMetricExporter;
4044
- exports.AzureMonitorTraceExporter = AzureMonitorTraceExporter;
4045
- //# sourceMappingURL=index.js.map