autotel 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (602) hide show
  1. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts +175 -0
  2. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +1 -0
  3. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts +175 -0
  4. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +1 -0
  5. package/dist/attribute-redacting-processor.cjs +374 -33
  6. package/dist/attribute-redacting-processor.cjs.map +1 -1
  7. package/dist/attribute-redacting-processor.d.cts +2 -207
  8. package/dist/attribute-redacting-processor.d.ts +2 -207
  9. package/dist/attribute-redacting-processor.js +368 -2
  10. package/dist/attribute-redacting-processor.js.map +1 -1
  11. package/dist/attributes-D3etyRVc.cjs +713 -0
  12. package/dist/attributes-D3etyRVc.cjs.map +1 -0
  13. package/dist/attributes-ksn4HVbd.js +600 -0
  14. package/dist/attributes-ksn4HVbd.js.map +1 -0
  15. package/dist/attributes.cjs +21 -85
  16. package/dist/attributes.d.cts +2 -20
  17. package/dist/attributes.d.ts +2 -20
  18. package/dist/attributes.js +3 -5
  19. package/dist/auto.cjs +50 -28
  20. package/dist/auto.cjs.map +1 -1
  21. package/dist/auto.d.cts +1 -2
  22. package/dist/auto.d.ts +1 -2
  23. package/dist/auto.js +49 -23
  24. package/dist/auto.js.map +1 -1
  25. package/dist/business-baggage.cjs +357 -13
  26. package/dist/business-baggage.cjs.map +1 -1
  27. package/dist/business-baggage.d.cts +106 -139
  28. package/dist/business-baggage.d.cts.map +1 -0
  29. package/dist/business-baggage.d.ts +106 -139
  30. package/dist/business-baggage.d.ts.map +1 -0
  31. package/dist/business-baggage.js +357 -2
  32. package/dist/business-baggage.js.map +1 -1
  33. package/dist/canonical-log-line-processor--RlFDHhm.cjs +377 -0
  34. package/dist/canonical-log-line-processor--RlFDHhm.cjs.map +1 -0
  35. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts +147 -0
  36. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +1 -0
  37. package/dist/canonical-log-line-processor-DbBQT5vY.js +366 -0
  38. package/dist/canonical-log-line-processor-DbBQT5vY.js.map +1 -0
  39. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts +147 -0
  40. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +1 -0
  41. package/dist/config.cjs +118 -22
  42. package/dist/config.cjs.map +1 -1
  43. package/dist/config.d.cts +33 -45
  44. package/dist/config.d.cts.map +1 -0
  45. package/dist/config.d.ts +33 -45
  46. package/dist/config.d.ts.map +1 -0
  47. package/dist/config.js +116 -3
  48. package/dist/config.js.map +1 -1
  49. package/dist/correlated-events-Bzh5y-UB.js +28 -0
  50. package/dist/correlated-events-Bzh5y-UB.js.map +1 -0
  51. package/dist/correlated-events-kSwLo3mi.cjs +34 -0
  52. package/dist/correlated-events-kSwLo3mi.cjs.map +1 -0
  53. package/dist/correlation-id.cjs +11 -54
  54. package/dist/correlation-id.d.cts +6 -5
  55. package/dist/correlation-id.d.cts.map +1 -0
  56. package/dist/correlation-id.d.ts +6 -5
  57. package/dist/correlation-id.d.ts.map +1 -0
  58. package/dist/correlation-id.js +3 -17
  59. package/dist/db.cjs +244 -209
  60. package/dist/db.cjs.map +1 -1
  61. package/dist/db.d.cts +28 -26
  62. package/dist/db.d.cts.map +1 -0
  63. package/dist/db.d.ts +28 -26
  64. package/dist/db.d.ts.map +1 -0
  65. package/dist/db.js +243 -207
  66. package/dist/db.js.map +1 -1
  67. package/dist/decorators.cjs +39 -66
  68. package/dist/decorators.cjs.map +1 -1
  69. package/dist/decorators.d.cts +10 -37
  70. package/dist/decorators.d.cts.map +1 -0
  71. package/dist/decorators.d.ts +10 -37
  72. package/dist/decorators.d.ts.map +1 -0
  73. package/dist/decorators.js +38 -64
  74. package/dist/decorators.js.map +1 -1
  75. package/dist/define-event-CreknLm3.d.ts +25 -0
  76. package/dist/define-event-CreknLm3.d.ts.map +1 -0
  77. package/dist/define-event-HZRizPwz.d.cts +25 -0
  78. package/dist/define-event-HZRizPwz.d.cts.map +1 -0
  79. package/dist/drain-pipeline.cjs +111 -9
  80. package/dist/drain-pipeline.cjs.map +1 -1
  81. package/dist/drain-pipeline.d.cts +27 -32
  82. package/dist/drain-pipeline.d.cts.map +1 -0
  83. package/dist/drain-pipeline.d.ts +27 -32
  84. package/dist/drain-pipeline.d.ts.map +1 -0
  85. package/dist/drain-pipeline.js +111 -2
  86. package/dist/drain-pipeline.js.map +1 -1
  87. package/dist/enrichers.cjs +59 -66
  88. package/dist/enrichers.cjs.map +1 -1
  89. package/dist/enrichers.d.cts +15 -13
  90. package/dist/enrichers.d.cts.map +1 -0
  91. package/dist/enrichers.d.ts +15 -13
  92. package/dist/enrichers.d.ts.map +1 -0
  93. package/dist/enrichers.js +58 -65
  94. package/dist/enrichers.js.map +1 -1
  95. package/dist/event-Dlqr4ZNL.cjs +778 -0
  96. package/dist/event-Dlqr4ZNL.cjs.map +1 -0
  97. package/dist/event-_58ryBjh.js +761 -0
  98. package/dist/event-_58ryBjh.js.map +1 -0
  99. package/dist/event-subscriber-D1XLkPzi.d.cts +223 -0
  100. package/dist/event-subscriber-D1XLkPzi.d.cts.map +1 -0
  101. package/dist/event-subscriber-D1XLkPzi.d.ts +223 -0
  102. package/dist/event-subscriber-D1XLkPzi.d.ts.map +1 -0
  103. package/dist/event-subscriber.cjs +0 -6
  104. package/dist/event-subscriber.d.cts +2 -221
  105. package/dist/event-subscriber.d.ts +2 -221
  106. package/dist/event-subscriber.js +1 -3
  107. package/dist/event-testing-BqRnI0z4.d.cts +106 -0
  108. package/dist/event-testing-BqRnI0z4.d.cts.map +1 -0
  109. package/dist/event-testing-CfFs3to2.d.ts +106 -0
  110. package/dist/event-testing-CfFs3to2.d.ts.map +1 -0
  111. package/dist/event-testing.cjs +93 -17
  112. package/dist/event-testing.cjs.map +1 -1
  113. package/dist/event-testing.d.cts +2 -110
  114. package/dist/event-testing.d.ts +2 -110
  115. package/dist/event-testing.js +91 -2
  116. package/dist/event-testing.js.map +1 -1
  117. package/dist/event.cjs +5 -37
  118. package/dist/event.d.cts +295 -340
  119. package/dist/event.d.cts.map +1 -0
  120. package/dist/event.d.ts +295 -340
  121. package/dist/event.d.ts.map +1 -0
  122. package/dist/event.js +3 -21
  123. package/dist/exporters.cjs +12 -16
  124. package/dist/exporters.d.cts +86 -111
  125. package/dist/exporters.d.cts.map +1 -0
  126. package/dist/exporters.d.ts +86 -111
  127. package/dist/exporters.d.ts.map +1 -0
  128. package/dist/exporters.js +4 -4
  129. package/dist/filtering-span-processor-B8R8B7Uk.d.cts +59 -0
  130. package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +1 -0
  131. package/dist/filtering-span-processor-B8R8B7Uk.d.ts +59 -0
  132. package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +1 -0
  133. package/dist/filtering-span-processor.cjs +49 -9
  134. package/dist/filtering-span-processor.cjs.map +1 -1
  135. package/dist/filtering-span-processor.d.cts +2 -80
  136. package/dist/filtering-span-processor.d.ts +2 -80
  137. package/dist/filtering-span-processor.js +49 -2
  138. package/dist/filtering-span-processor.js.map +1 -1
  139. package/dist/functional-BGkT8J-h.js +1265 -0
  140. package/dist/functional-BGkT8J-h.js.map +1 -0
  141. package/dist/functional-C4CzoVrX.cjs +1312 -0
  142. package/dist/functional-C4CzoVrX.cjs.map +1 -0
  143. package/dist/functional.cjs +11 -57
  144. package/dist/functional.d.cts +96 -97
  145. package/dist/functional.d.cts.map +1 -0
  146. package/dist/functional.d.ts +96 -97
  147. package/dist/functional.d.ts.map +1 -0
  148. package/dist/functional.js +3 -20
  149. package/dist/http.cjs +276 -176
  150. package/dist/http.cjs.map +1 -1
  151. package/dist/http.d.cts +17 -37
  152. package/dist/http.d.cts.map +1 -0
  153. package/dist/http.d.ts +17 -37
  154. package/dist/http.d.ts.map +1 -0
  155. package/dist/http.js +275 -174
  156. package/dist/http.js.map +1 -1
  157. package/dist/index-CX0aG1Uh.d.ts +708 -0
  158. package/dist/index-CX0aG1Uh.d.ts.map +1 -0
  159. package/dist/index-DIWZFKUS.d.cts +708 -0
  160. package/dist/index-DIWZFKUS.d.cts.map +1 -0
  161. package/dist/index.cjs +1049 -1172
  162. package/dist/index.cjs.map +1 -1
  163. package/dist/index.d.cts +401 -551
  164. package/dist/index.d.cts.map +1 -0
  165. package/dist/index.d.ts +401 -551
  166. package/dist/index.d.ts.map +1 -0
  167. package/dist/index.js +912 -714
  168. package/dist/index.js.map +1 -1
  169. package/dist/init-CNp-ee80.d.cts +1157 -0
  170. package/dist/init-CNp-ee80.d.cts.map +1 -0
  171. package/dist/init-Ch6t7MNI.js +1015 -0
  172. package/dist/init-Ch6t7MNI.js.map +1 -0
  173. package/dist/init-DJQOdVlN.d.ts +1157 -0
  174. package/dist/init-DJQOdVlN.d.ts.map +1 -0
  175. package/dist/init-DvapOXCc.cjs +1092 -0
  176. package/dist/init-DvapOXCc.cjs.map +1 -0
  177. package/dist/instrumentation.cjs +159 -185
  178. package/dist/instrumentation.cjs.map +1 -1
  179. package/dist/instrumentation.d.cts +42 -40
  180. package/dist/instrumentation.d.cts.map +1 -0
  181. package/dist/instrumentation.d.ts +42 -40
  182. package/dist/instrumentation.d.ts.map +1 -0
  183. package/dist/instrumentation.js +158 -183
  184. package/dist/instrumentation.js.map +1 -1
  185. package/dist/logger-BauSUhUv.d.cts +313 -0
  186. package/dist/logger-BauSUhUv.d.cts.map +1 -0
  187. package/dist/logger-BauSUhUv.d.ts +313 -0
  188. package/dist/logger-BauSUhUv.d.ts.map +1 -0
  189. package/dist/logger.cjs +225 -25
  190. package/dist/logger.cjs.map +1 -1
  191. package/dist/logger.d.cts +2 -348
  192. package/dist/logger.d.ts +2 -348
  193. package/dist/logger.js +204 -4
  194. package/dist/logger.js.map +1 -1
  195. package/dist/messaging-adapters.cjs +292 -187
  196. package/dist/messaging-adapters.cjs.map +1 -1
  197. package/dist/messaging-adapters.d.cts +28 -66
  198. package/dist/messaging-adapters.d.cts.map +1 -0
  199. package/dist/messaging-adapters.d.ts +28 -66
  200. package/dist/messaging-adapters.d.ts.map +1 -0
  201. package/dist/messaging-adapters.js +291 -185
  202. package/dist/messaging-adapters.js.map +1 -1
  203. package/dist/messaging-testing.cjs +306 -372
  204. package/dist/messaging-testing.cjs.map +1 -1
  205. package/dist/messaging-testing.d.cts +194 -223
  206. package/dist/messaging-testing.d.cts.map +1 -0
  207. package/dist/messaging-testing.d.ts +194 -223
  208. package/dist/messaging-testing.d.ts.map +1 -0
  209. package/dist/messaging-testing.js +305 -371
  210. package/dist/messaging-testing.js.map +1 -1
  211. package/dist/messaging.cjs +757 -36
  212. package/dist/messaging.cjs.map +1 -1
  213. package/dist/messaging.d.cts +603 -644
  214. package/dist/messaging.d.cts.map +1 -0
  215. package/dist/messaging.d.ts +603 -644
  216. package/dist/messaging.d.ts.map +1 -0
  217. package/dist/messaging.js +756 -21
  218. package/dist/messaging.js.map +1 -1
  219. package/dist/metric-helpers.cjs +27 -27
  220. package/dist/metric-helpers.cjs.map +1 -1
  221. package/dist/metric-helpers.d.cts +4 -2
  222. package/dist/metric-helpers.d.cts.map +1 -0
  223. package/dist/metric-helpers.d.ts +4 -2
  224. package/dist/metric-helpers.d.ts.map +1 -0
  225. package/dist/metric-helpers.js +24 -4
  226. package/dist/metric-helpers.js.map +1 -1
  227. package/dist/metric-testing-DXdK3-Q3.d.ts +106 -0
  228. package/dist/metric-testing-DXdK3-Q3.d.ts.map +1 -0
  229. package/dist/metric-testing-MxvzChDp.d.cts +106 -0
  230. package/dist/metric-testing-MxvzChDp.d.cts.map +1 -0
  231. package/dist/metric-testing.cjs +93 -17
  232. package/dist/metric-testing.cjs.map +1 -1
  233. package/dist/metric-testing.d.cts +2 -110
  234. package/dist/metric-testing.d.ts +2 -110
  235. package/dist/metric-testing.js +91 -2
  236. package/dist/metric-testing.js.map +1 -1
  237. package/dist/metric.cjs +306 -22
  238. package/dist/metric.cjs.map +1 -1
  239. package/dist/metric.d.cts +170 -198
  240. package/dist/metric.d.cts.map +1 -0
  241. package/dist/metric.d.ts +170 -198
  242. package/dist/metric.d.ts.map +1 -0
  243. package/dist/metric.js +277 -7
  244. package/dist/metric.js.map +1 -1
  245. package/dist/node-require-DF5QBX6z.cjs +99 -0
  246. package/dist/node-require-DF5QBX6z.cjs.map +1 -0
  247. package/dist/node-require-Db1oDpLj.js +88 -0
  248. package/dist/node-require-Db1oDpLj.js.map +1 -0
  249. package/dist/operation-context-C-2hmmtP.js +59 -0
  250. package/dist/operation-context-C-2hmmtP.js.map +1 -0
  251. package/dist/operation-context-n4_obUwq.cjs +70 -0
  252. package/dist/operation-context-n4_obUwq.cjs.map +1 -0
  253. package/dist/parse-error.cjs +55 -9
  254. package/dist/parse-error.cjs.map +1 -1
  255. package/dist/parse-error.d.cts +12 -10
  256. package/dist/parse-error.d.cts.map +1 -0
  257. package/dist/parse-error.d.ts +12 -10
  258. package/dist/parse-error.d.ts.map +1 -0
  259. package/dist/parse-error.js +55 -2
  260. package/dist/parse-error.js.map +1 -1
  261. package/dist/pretty-console-exporter-CMzlrRNg.cjs +232 -0
  262. package/dist/pretty-console-exporter-CMzlrRNg.cjs.map +1 -0
  263. package/dist/pretty-console-exporter-DqKl_q9z.js +227 -0
  264. package/dist/pretty-console-exporter-DqKl_q9z.js.map +1 -0
  265. package/dist/processors.cjs +13 -17
  266. package/dist/processors.d.cts +3 -171
  267. package/dist/processors.d.ts +3 -171
  268. package/dist/processors.js +4 -4
  269. package/dist/register.cjs +35 -6
  270. package/dist/register.cjs.map +1 -1
  271. package/dist/register.d.cts +1 -2
  272. package/dist/register.d.ts +1 -2
  273. package/dist/register.js +36 -3
  274. package/dist/register.js.map +1 -1
  275. package/dist/registry-DfXA3R1L.js +184 -0
  276. package/dist/registry-DfXA3R1L.js.map +1 -0
  277. package/dist/registry-JZg2J3RZ.cjs +334 -0
  278. package/dist/registry-JZg2J3RZ.cjs.map +1 -0
  279. package/dist/sampling-CR0Va1VB.d.ts +351 -0
  280. package/dist/sampling-CR0Va1VB.d.ts.map +1 -0
  281. package/dist/sampling-DfYhDJij.d.cts +351 -0
  282. package/dist/sampling-DfYhDJij.d.cts.map +1 -0
  283. package/dist/sampling.cjs +452 -60
  284. package/dist/sampling.cjs.map +1 -1
  285. package/dist/sampling.d.cts +2 -379
  286. package/dist/sampling.d.ts +2 -379
  287. package/dist/sampling.js +441 -5
  288. package/dist/sampling.js.map +1 -1
  289. package/dist/security-schema.cjs +65 -46
  290. package/dist/security-schema.cjs.map +1 -1
  291. package/dist/security-schema.d.cts +23 -26
  292. package/dist/security-schema.d.cts.map +1 -0
  293. package/dist/security-schema.d.ts +23 -26
  294. package/dist/security-schema.d.ts.map +1 -0
  295. package/dist/security-schema.js +64 -45
  296. package/dist/security-schema.js.map +1 -1
  297. package/dist/semantic-conventions-FhSxv-bK.d.cts +32 -0
  298. package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -0
  299. package/dist/semantic-conventions-FhSxv-bK.d.ts +32 -0
  300. package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -0
  301. package/dist/semantic-conventions.cjs +15 -26
  302. package/dist/semantic-conventions.cjs.map +1 -1
  303. package/dist/semantic-conventions.d.cts +2 -29
  304. package/dist/semantic-conventions.d.ts +2 -29
  305. package/dist/semantic-conventions.js +12 -3
  306. package/dist/semantic-conventions.js.map +1 -1
  307. package/dist/semantic-helpers.cjs +440 -39
  308. package/dist/semantic-helpers.cjs.map +1 -1
  309. package/dist/semantic-helpers.d.cts +38 -45
  310. package/dist/semantic-helpers.d.cts.map +1 -0
  311. package/dist/semantic-helpers.d.ts +38 -45
  312. package/dist/semantic-helpers.d.ts.map +1 -0
  313. package/dist/semantic-helpers.js +438 -20
  314. package/dist/semantic-helpers.js.map +1 -1
  315. package/dist/span-name-normalizer-8ZOGJuwv.d.cts +70 -0
  316. package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +1 -0
  317. package/dist/span-name-normalizer-8ZOGJuwv.d.ts +70 -0
  318. package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +1 -0
  319. package/dist/span-name-normalizer.cjs +95 -17
  320. package/dist/span-name-normalizer.cjs.map +1 -1
  321. package/dist/span-name-normalizer.d.cts +2 -94
  322. package/dist/span-name-normalizer.d.ts +2 -94
  323. package/dist/span-name-normalizer.js +93 -2
  324. package/dist/span-name-normalizer.js.map +1 -1
  325. package/dist/stable-hash-BNTMrmdB.cjs +28 -0
  326. package/dist/stable-hash-BNTMrmdB.cjs.map +1 -0
  327. package/dist/stable-hash-Cg5cT34Q.js +23 -0
  328. package/dist/stable-hash-Cg5cT34Q.js.map +1 -0
  329. package/dist/structured-error-9--cxBay.js +143 -0
  330. package/dist/structured-error-9--cxBay.js.map +1 -0
  331. package/dist/structured-error-CHg7DoIQ.cjs +178 -0
  332. package/dist/structured-error-CHg7DoIQ.cjs.map +1 -0
  333. package/dist/tail-sampling-processor.cjs +26 -13
  334. package/dist/tail-sampling-processor.cjs.map +1 -1
  335. package/dist/tail-sampling-processor.d.cts +11 -23
  336. package/dist/tail-sampling-processor.d.cts.map +1 -0
  337. package/dist/tail-sampling-processor.d.ts +11 -23
  338. package/dist/tail-sampling-processor.d.ts.map +1 -0
  339. package/dist/tail-sampling-processor.js +27 -6
  340. package/dist/tail-sampling-processor.js.map +1 -1
  341. package/dist/test-span-collector.cjs +70 -72
  342. package/dist/test-span-collector.cjs.map +1 -1
  343. package/dist/test-span-collector.d.cts +25 -43
  344. package/dist/test-span-collector.d.cts.map +1 -0
  345. package/dist/test-span-collector.d.ts +25 -43
  346. package/dist/test-span-collector.d.ts.map +1 -0
  347. package/dist/test-span-collector.js +69 -70
  348. package/dist/test-span-collector.js.map +1 -1
  349. package/dist/testing.cjs +389 -278
  350. package/dist/testing.cjs.map +1 -1
  351. package/dist/testing.d.cts +39 -62
  352. package/dist/testing.d.cts.map +1 -0
  353. package/dist/testing.d.ts +39 -62
  354. package/dist/testing.d.ts.map +1 -0
  355. package/dist/testing.js +386 -265
  356. package/dist/testing.js.map +1 -1
  357. package/dist/trace-context-Cijqoi6e.d.cts +212 -0
  358. package/dist/trace-context-Cijqoi6e.d.cts.map +1 -0
  359. package/dist/trace-context-Cijqoi6e.d.ts +212 -0
  360. package/dist/trace-context-Cijqoi6e.d.ts.map +1 -0
  361. package/dist/trace-helpers.cjs +634 -54
  362. package/dist/trace-helpers.cjs.map +1 -1
  363. package/dist/trace-helpers.d.cts +17 -49
  364. package/dist/trace-helpers.d.cts.map +1 -0
  365. package/dist/trace-helpers.d.ts +17 -49
  366. package/dist/trace-helpers.d.ts.map +1 -0
  367. package/dist/trace-helpers.js +624 -3
  368. package/dist/trace-helpers.js.map +1 -1
  369. package/dist/tracer-provider.cjs +227 -16
  370. package/dist/tracer-provider.cjs.map +1 -1
  371. package/dist/tracer-provider.d.cts +5 -4
  372. package/dist/tracer-provider.d.cts.map +1 -0
  373. package/dist/tracer-provider.d.ts +5 -4
  374. package/dist/tracer-provider.d.ts.map +1 -0
  375. package/dist/tracer-provider.js +227 -2
  376. package/dist/tracer-provider.js.map +1 -1
  377. package/dist/track-3HY4NGV-.cjs +1212 -0
  378. package/dist/track-3HY4NGV-.cjs.map +1 -0
  379. package/dist/track-nsKVy-pj.js +1111 -0
  380. package/dist/track-nsKVy-pj.js.map +1 -0
  381. package/dist/validate.cjs +178 -115
  382. package/dist/validate.cjs.map +1 -1
  383. package/dist/validate.d.cts +40 -64
  384. package/dist/validate.d.cts.map +1 -0
  385. package/dist/validate.d.ts +40 -64
  386. package/dist/validate.d.ts.map +1 -0
  387. package/dist/validate.js +177 -113
  388. package/dist/validate.js.map +1 -1
  389. package/dist/validation-attributes.cjs +42 -17
  390. package/dist/validation-attributes.cjs.map +1 -1
  391. package/dist/validation-attributes.d.cts +13 -20
  392. package/dist/validation-attributes.d.cts.map +1 -0
  393. package/dist/validation-attributes.d.ts +13 -20
  394. package/dist/validation-attributes.d.ts.map +1 -0
  395. package/dist/validation-attributes.js +40 -2
  396. package/dist/validation-attributes.js.map +1 -1
  397. package/dist/webhook.cjs +286 -256
  398. package/dist/webhook.cjs.map +1 -1
  399. package/dist/webhook.d.cts +157 -192
  400. package/dist/webhook.d.cts.map +1 -0
  401. package/dist/webhook.d.ts +157 -192
  402. package/dist/webhook.d.ts.map +1 -0
  403. package/dist/webhook.js +285 -254
  404. package/dist/webhook.js.map +1 -1
  405. package/dist/workflow-distributed.cjs +498 -412
  406. package/dist/workflow-distributed.cjs.map +1 -1
  407. package/dist/workflow-distributed.d.cts +163 -173
  408. package/dist/workflow-distributed.d.cts.map +1 -0
  409. package/dist/workflow-distributed.d.ts +163 -173
  410. package/dist/workflow-distributed.d.ts.map +1 -0
  411. package/dist/workflow-distributed.js +497 -410
  412. package/dist/workflow-distributed.js.map +1 -1
  413. package/dist/workflow.cjs +405 -40
  414. package/dist/workflow.cjs.map +1 -1
  415. package/dist/workflow.d.cts +78 -131
  416. package/dist/workflow.d.cts.map +1 -0
  417. package/dist/workflow.d.ts +78 -131
  418. package/dist/workflow.d.ts.map +1 -0
  419. package/dist/workflow.js +403 -21
  420. package/dist/workflow.js.map +1 -1
  421. package/dist/yaml-config-B3dQ82GR.cjs +272 -0
  422. package/dist/yaml-config-B3dQ82GR.cjs.map +1 -0
  423. package/dist/yaml-config.cjs +5 -24
  424. package/dist/yaml-config.d.cts +30 -64
  425. package/dist/yaml-config.d.cts.map +1 -0
  426. package/dist/yaml-config.d.ts +30 -64
  427. package/dist/yaml-config.d.ts.map +1 -0
  428. package/dist/yaml-config.js +226 -7
  429. package/dist/yaml-config.js.map +1 -1
  430. package/package.json +4 -4
  431. package/src/index.ts +3 -0
  432. package/src/request-logger.test.ts +53 -1
  433. package/src/request-logger.ts +58 -0
  434. package/src/validate.test.ts +3 -1
  435. package/src/validate.ts +9 -3
  436. package/dist/attributes.cjs.map +0 -1
  437. package/dist/attributes.js.map +0 -1
  438. package/dist/chunk-2ZKEORFN.cjs +0 -14
  439. package/dist/chunk-2ZKEORFN.cjs.map +0 -1
  440. package/dist/chunk-3QXBFGKP.js +0 -344
  441. package/dist/chunk-3QXBFGKP.js.map +0 -1
  442. package/dist/chunk-454CH4OV.js +0 -744
  443. package/dist/chunk-454CH4OV.js.map +0 -1
  444. package/dist/chunk-4A53YIAX.js +0 -180
  445. package/dist/chunk-4A53YIAX.js.map +0 -1
  446. package/dist/chunk-4IFSYQVX.js +0 -337
  447. package/dist/chunk-4IFSYQVX.js.map +0 -1
  448. package/dist/chunk-4P6ZOARG.cjs +0 -33
  449. package/dist/chunk-4P6ZOARG.cjs.map +0 -1
  450. package/dist/chunk-55ER2KD5.js +0 -228
  451. package/dist/chunk-55ER2KD5.js.map +0 -1
  452. package/dist/chunk-5ZN622AO.js +0 -73
  453. package/dist/chunk-5ZN622AO.js.map +0 -1
  454. package/dist/chunk-66YJ66GG.js +0 -1021
  455. package/dist/chunk-66YJ66GG.js.map +0 -1
  456. package/dist/chunk-6S5RUKU3.cjs +0 -347
  457. package/dist/chunk-6S5RUKU3.cjs.map +0 -1
  458. package/dist/chunk-6UQRVUN3.js +0 -222
  459. package/dist/chunk-6UQRVUN3.js.map +0 -1
  460. package/dist/chunk-7552UTQW.js +0 -11
  461. package/dist/chunk-7552UTQW.js.map +0 -1
  462. package/dist/chunk-7EQ4G4SI.cjs +0 -146
  463. package/dist/chunk-7EQ4G4SI.cjs.map +0 -1
  464. package/dist/chunk-7SAWIN74.js +0 -285
  465. package/dist/chunk-7SAWIN74.js.map +0 -1
  466. package/dist/chunk-A4E5AQFK.js +0 -30
  467. package/dist/chunk-A4E5AQFK.js.map +0 -1
  468. package/dist/chunk-ALPYR2GC.js +0 -1061
  469. package/dist/chunk-ALPYR2GC.js.map +0 -1
  470. package/dist/chunk-B7SWBE4P.cjs +0 -799
  471. package/dist/chunk-B7SWBE4P.cjs.map +0 -1
  472. package/dist/chunk-BZHG5IZ4.js +0 -73
  473. package/dist/chunk-BZHG5IZ4.js.map +0 -1
  474. package/dist/chunk-CEAQK2QY.cjs +0 -32
  475. package/dist/chunk-CEAQK2QY.cjs.map +0 -1
  476. package/dist/chunk-CMHVQR6P.js +0 -170
  477. package/dist/chunk-CMHVQR6P.js.map +0 -1
  478. package/dist/chunk-CU6IDACR.cjs +0 -224
  479. package/dist/chunk-CU6IDACR.cjs.map +0 -1
  480. package/dist/chunk-D4TM63S3.js +0 -795
  481. package/dist/chunk-D4TM63S3.js.map +0 -1
  482. package/dist/chunk-DCEDJQGG.js +0 -28
  483. package/dist/chunk-DCEDJQGG.js.map +0 -1
  484. package/dist/chunk-DPSA4QLA.js +0 -344
  485. package/dist/chunk-DPSA4QLA.js.map +0 -1
  486. package/dist/chunk-E6TERL5O.cjs +0 -23
  487. package/dist/chunk-E6TERL5O.cjs.map +0 -1
  488. package/dist/chunk-EE6CPXKH.cjs +0 -164
  489. package/dist/chunk-EE6CPXKH.cjs.map +0 -1
  490. package/dist/chunk-EOFB7XCL.cjs +0 -837
  491. package/dist/chunk-EOFB7XCL.cjs.map +0 -1
  492. package/dist/chunk-ESLWRGAG.cjs +0 -92
  493. package/dist/chunk-ESLWRGAG.cjs.map +0 -1
  494. package/dist/chunk-ESMHTKLJ.cjs +0 -206
  495. package/dist/chunk-ESMHTKLJ.cjs.map +0 -1
  496. package/dist/chunk-FMTHVSYY.cjs +0 -1039
  497. package/dist/chunk-FMTHVSYY.cjs.map +0 -1
  498. package/dist/chunk-FU6R566Y.cjs +0 -236
  499. package/dist/chunk-FU6R566Y.cjs.map +0 -1
  500. package/dist/chunk-GYR5K654.js +0 -91
  501. package/dist/chunk-GYR5K654.js.map +0 -1
  502. package/dist/chunk-HA2WBOGQ.js +0 -57
  503. package/dist/chunk-HA2WBOGQ.js.map +0 -1
  504. package/dist/chunk-HT5JQKN2.js +0 -118
  505. package/dist/chunk-HT5JQKN2.js.map +0 -1
  506. package/dist/chunk-INJD3G4K.cjs +0 -340
  507. package/dist/chunk-INJD3G4K.cjs.map +0 -1
  508. package/dist/chunk-IOYFAFHJ.cjs +0 -95
  509. package/dist/chunk-IOYFAFHJ.cjs.map +0 -1
  510. package/dist/chunk-J5QENANM.js +0 -87
  511. package/dist/chunk-J5QENANM.js.map +0 -1
  512. package/dist/chunk-J7VGRIAJ.js +0 -64
  513. package/dist/chunk-J7VGRIAJ.js.map +0 -1
  514. package/dist/chunk-KFOHQK7X.js +0 -144
  515. package/dist/chunk-KFOHQK7X.js.map +0 -1
  516. package/dist/chunk-KIL5CUN6.js +0 -31
  517. package/dist/chunk-KIL5CUN6.js.map +0 -1
  518. package/dist/chunk-KYXZS3EA.cjs +0 -100
  519. package/dist/chunk-KYXZS3EA.cjs.map +0 -1
  520. package/dist/chunk-LITNXTTT.js +0 -3
  521. package/dist/chunk-LITNXTTT.js.map +0 -1
  522. package/dist/chunk-LVIPBYFE.js +0 -157
  523. package/dist/chunk-LVIPBYFE.js.map +0 -1
  524. package/dist/chunk-M3LFHHTN.cjs +0 -764
  525. package/dist/chunk-M3LFHHTN.cjs.map +0 -1
  526. package/dist/chunk-N25JDZSC.js +0 -95
  527. package/dist/chunk-N25JDZSC.js.map +0 -1
  528. package/dist/chunk-NEIB3TLD.cjs +0 -360
  529. package/dist/chunk-NEIB3TLD.cjs.map +0 -1
  530. package/dist/chunk-NENU7E6V.cjs +0 -344
  531. package/dist/chunk-NENU7E6V.cjs.map +0 -1
  532. package/dist/chunk-NVAI5CCN.cjs +0 -39
  533. package/dist/chunk-NVAI5CCN.cjs.map +0 -1
  534. package/dist/chunk-NZ72VDNY.cjs +0 -4
  535. package/dist/chunk-NZ72VDNY.cjs.map +0 -1
  536. package/dist/chunk-OPPXYVEZ.cjs +0 -131
  537. package/dist/chunk-OPPXYVEZ.cjs.map +0 -1
  538. package/dist/chunk-Q4EULJQY.js +0 -35
  539. package/dist/chunk-Q4EULJQY.js.map +0 -1
  540. package/dist/chunk-QF7ARNUM.js +0 -339
  541. package/dist/chunk-QF7ARNUM.js.map +0 -1
  542. package/dist/chunk-QWW3E3JM.cjs +0 -178
  543. package/dist/chunk-QWW3E3JM.cjs.map +0 -1
  544. package/dist/chunk-R7QYGZUP.cjs +0 -1075
  545. package/dist/chunk-R7QYGZUP.cjs.map +0 -1
  546. package/dist/chunk-RUPKBKUF.js +0 -352
  547. package/dist/chunk-RUPKBKUF.js.map +0 -1
  548. package/dist/chunk-SEO6NAQT.js +0 -14
  549. package/dist/chunk-SEO6NAQT.js.map +0 -1
  550. package/dist/chunk-T4B5LB6E.cjs +0 -66
  551. package/dist/chunk-T4B5LB6E.cjs.map +0 -1
  552. package/dist/chunk-T5WRA76K.cjs +0 -32
  553. package/dist/chunk-T5WRA76K.cjs.map +0 -1
  554. package/dist/chunk-T7JO2TCP.js +0 -1233
  555. package/dist/chunk-T7JO2TCP.js.map +0 -1
  556. package/dist/chunk-TC5ZPWM4.cjs +0 -289
  557. package/dist/chunk-TC5ZPWM4.cjs.map +0 -1
  558. package/dist/chunk-TQ5UWA7S.js +0 -26
  559. package/dist/chunk-TQ5UWA7S.js.map +0 -1
  560. package/dist/chunk-UIKYE2QZ.js +0 -833
  561. package/dist/chunk-UIKYE2QZ.js.map +0 -1
  562. package/dist/chunk-UNPLAVE7.js +0 -21
  563. package/dist/chunk-UNPLAVE7.js.map +0 -1
  564. package/dist/chunk-UY3UYPBZ.cjs +0 -77
  565. package/dist/chunk-UY3UYPBZ.cjs.map +0 -1
  566. package/dist/chunk-V7UBMJAB.cjs +0 -1242
  567. package/dist/chunk-V7UBMJAB.cjs.map +0 -1
  568. package/dist/chunk-VH77IPJN.cjs +0 -358
  569. package/dist/chunk-VH77IPJN.cjs.map +0 -1
  570. package/dist/chunk-VQTCQKHQ.cjs +0 -17
  571. package/dist/chunk-VQTCQKHQ.cjs.map +0 -1
  572. package/dist/chunk-WGWSHJ2N.js +0 -38
  573. package/dist/chunk-WGWSHJ2N.js.map +0 -1
  574. package/dist/chunk-WJH6IYU2.cjs +0 -32
  575. package/dist/chunk-WJH6IYU2.cjs.map +0 -1
  576. package/dist/chunk-YREV3LGG.cjs +0 -61
  577. package/dist/chunk-YREV3LGG.cjs.map +0 -1
  578. package/dist/chunk-YTXEZ4SD.cjs +0 -77
  579. package/dist/chunk-YTXEZ4SD.cjs.map +0 -1
  580. package/dist/chunk-ZNMBW67B.cjs +0 -40
  581. package/dist/chunk-ZNMBW67B.cjs.map +0 -1
  582. package/dist/correlation-id.cjs.map +0 -1
  583. package/dist/correlation-id.js.map +0 -1
  584. package/dist/define-event-BL6Li7CM.d.ts +0 -23
  585. package/dist/define-event-ClP3T1Jx.d.cts +0 -23
  586. package/dist/event-subscriber.cjs.map +0 -1
  587. package/dist/event-subscriber.js.map +0 -1
  588. package/dist/event.cjs.map +0 -1
  589. package/dist/event.js.map +0 -1
  590. package/dist/exporters.cjs.map +0 -1
  591. package/dist/exporters.js.map +0 -1
  592. package/dist/functional.cjs.map +0 -1
  593. package/dist/functional.js.map +0 -1
  594. package/dist/init-DIowiiCh.d.ts +0 -1167
  595. package/dist/init-j-A1zI16.d.cts +0 -1167
  596. package/dist/processors.cjs.map +0 -1
  597. package/dist/processors.js.map +0 -1
  598. package/dist/trace-context-DbGKd1Rn.d.cts +0 -213
  599. package/dist/trace-context-DbGKd1Rn.d.ts +0 -213
  600. package/dist/utils-BahBCFtJ.d.cts +0 -712
  601. package/dist/utils-CLKwaUlG.d.ts +0 -712
  602. package/dist/yaml-config.cjs.map +0 -1
@@ -1,1039 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkEE6CPXKH_cjs = require('./chunk-EE6CPXKH.cjs');
4
- var chunkR7QYGZUP_cjs = require('./chunk-R7QYGZUP.cjs');
5
- var chunkESLWRGAG_cjs = require('./chunk-ESLWRGAG.cjs');
6
- var api = require('@opentelemetry/api');
7
- var async_hooks = require('async_hooks');
8
-
9
- // src/rate-limiter.ts
10
- var TokenBucketRateLimiter = class {
11
- tokens;
12
- maxTokens;
13
- refillRate;
14
- // tokens per millisecond
15
- lastRefill;
16
- constructor(config) {
17
- this.maxTokens = config.burstCapacity || config.maxEventsPerSecond * 2;
18
- this.tokens = this.maxTokens;
19
- this.refillRate = config.maxEventsPerSecond / 1e3;
20
- this.lastRefill = Date.now();
21
- }
22
- /**
23
- * Try to consume a token (allow an event)
24
- * Returns true if allowed, false if rate limit exceeded
25
- */
26
- tryConsume(count = 1) {
27
- this.refill();
28
- if (this.tokens >= count) {
29
- this.tokens -= count;
30
- return true;
31
- }
32
- return false;
33
- }
34
- /**
35
- * Wait until a token is available (async rate limiting)
36
- * Returns a promise that resolves when the event can be processed
37
- */
38
- async waitForToken(count = 1) {
39
- this.refill();
40
- if (this.tokens >= count) {
41
- this.tokens -= count;
42
- return;
43
- }
44
- const tokensNeeded = count - this.tokens;
45
- const waitMs = Math.ceil(tokensNeeded / this.refillRate);
46
- await new Promise((resolve) => setTimeout(resolve, waitMs));
47
- return this.waitForToken(count);
48
- }
49
- /**
50
- * Refill tokens based on elapsed time
51
- */
52
- refill() {
53
- const now = Date.now();
54
- const elapsed = now - this.lastRefill;
55
- const tokensToAdd = elapsed * this.refillRate;
56
- this.tokens = Math.min(this.maxTokens, this.tokens + tokensToAdd);
57
- this.lastRefill = now;
58
- }
59
- /**
60
- * Get current available tokens (for testing/debugging)
61
- */
62
- getAvailableTokens() {
63
- this.refill();
64
- return Math.floor(this.tokens);
65
- }
66
- /**
67
- * Reset the rate limiter (for testing)
68
- */
69
- reset() {
70
- this.tokens = this.maxTokens;
71
- this.lastRefill = Date.now();
72
- }
73
- };
74
-
75
- // src/event-queue.ts
76
- var DEFAULT_CONFIG = {
77
- maxSize: 5e4,
78
- batchSize: 100,
79
- flushInterval: 1e4,
80
- maxRetries: 3,
81
- rateLimit: {
82
- maxEventsPerSecond: 100,
83
- burstCapacity: 200
84
- }
85
- };
86
- function getSubscriberName(subscriber) {
87
- if (subscriber.name) {
88
- return subscriber.name.toLowerCase();
89
- }
90
- const className = subscriber.constructor?.name || "unknown";
91
- return className.replace(/Subscriber$/i, "").toLowerCase();
92
- }
93
- var EventQueue = class {
94
- queue = [];
95
- flushTimer = null;
96
- config;
97
- subscribers;
98
- rateLimiter;
99
- flushPromise = null;
100
- isShuttingDown = false;
101
- // Metrics
102
- metrics = null;
103
- // Observable callback cleanup functions
104
- observableCleanups = [];
105
- // Subscriber health tracking (for observable gauges)
106
- subscriberHealthy = /* @__PURE__ */ new Map();
107
- constructor(subscribers, config) {
108
- this.subscribers = subscribers;
109
- this.config = { ...DEFAULT_CONFIG, ...config };
110
- this.rateLimiter = this.config.rateLimit ? new TokenBucketRateLimiter(this.config.rateLimit) : null;
111
- for (const subscriber of subscribers) {
112
- const name = getSubscriberName(subscriber);
113
- this.subscriberHealthy.set(name, true);
114
- }
115
- this.initMetrics();
116
- }
117
- /**
118
- * Initialize OTel metrics for queue observability
119
- */
120
- initMetrics() {
121
- const runtimeConfig = chunkESLWRGAG_cjs.getConfig();
122
- const meter = runtimeConfig.meter;
123
- const queueSize = meter.createObservableGauge(
124
- "autotel.event_delivery.queue.size",
125
- {
126
- description: "Current number of events in the delivery queue",
127
- unit: "count"
128
- }
129
- );
130
- const queueSizeCallback = (observableResult) => {
131
- observableResult.observe(this.queue.length);
132
- };
133
- queueSize.addCallback(queueSizeCallback);
134
- this.observableCleanups.push(
135
- () => queueSize.removeCallback(queueSizeCallback)
136
- );
137
- const oldestAge = meter.createObservableGauge(
138
- "autotel.event_delivery.queue.oldest_age_ms",
139
- {
140
- description: "Age of the oldest event in the queue in milliseconds",
141
- unit: "ms"
142
- }
143
- );
144
- const oldestAgeCallback = (observableResult) => {
145
- if (this.queue.length > 0) {
146
- const oldest = this.queue[0];
147
- const ageMs = Date.now() - oldest.timestamp;
148
- observableResult.observe(ageMs);
149
- } else {
150
- observableResult.observe(0);
151
- }
152
- };
153
- oldestAge.addCallback(oldestAgeCallback);
154
- this.observableCleanups.push(
155
- () => oldestAge.removeCallback(oldestAgeCallback)
156
- );
157
- const delivered = meter.createCounter(
158
- "autotel.event_delivery.queue.delivered",
159
- {
160
- description: "Number of events successfully delivered to subscribers",
161
- unit: "count"
162
- }
163
- );
164
- const failed = meter.createCounter("autotel.event_delivery.queue.failed", {
165
- description: "Number of events that failed delivery after all retry attempts",
166
- unit: "count"
167
- });
168
- const dropped = meter.createCounter(
169
- "autotel.event_delivery.queue.dropped",
170
- {
171
- description: "Number of events dropped from the queue",
172
- unit: "count"
173
- }
174
- );
175
- const latency = meter.createHistogram(
176
- "autotel.event_delivery.queue.latency_ms",
177
- {
178
- description: "Event delivery latency from enqueue to successful send",
179
- unit: "ms"
180
- }
181
- );
182
- const subscriberHealth = meter.createObservableGauge(
183
- "autotel.event_delivery.subscriber.health",
184
- {
185
- description: "Subscriber health status (1=healthy, 0=unhealthy)",
186
- unit: "1"
187
- }
188
- );
189
- const subscriberHealthCallback = (observableResult) => {
190
- for (const [subscriberName, isHealthy] of this.subscriberHealthy) {
191
- observableResult.observe(isHealthy ? 1 : 0, {
192
- subscriber: subscriberName
193
- });
194
- }
195
- };
196
- subscriberHealth.addCallback(subscriberHealthCallback);
197
- this.observableCleanups.push(
198
- () => subscriberHealth.removeCallback(subscriberHealthCallback)
199
- );
200
- this.metrics = {
201
- queueSize,
202
- oldestAge,
203
- delivered,
204
- failed,
205
- dropped,
206
- latency,
207
- subscriberHealth
208
- };
209
- }
210
- /**
211
- * Record a dropped event with reason and emit debug breadcrumb
212
- */
213
- recordDropped(reason, event, subscriberName) {
214
- const attrs = { reason };
215
- if (subscriberName) {
216
- attrs.subscriber = subscriberName;
217
- }
218
- this.metrics?.dropped.add(1, attrs);
219
- const logLevel = reason === "payload_invalid" ? "error" : "warn";
220
- const logger = chunkR7QYGZUP_cjs.getLogger();
221
- if (logLevel === "error") {
222
- logger.error(
223
- {
224
- eventName: event?.name,
225
- subscriber: subscriberName,
226
- reason,
227
- correlationId: event?._correlationId,
228
- traceId: event?._traceId
229
- },
230
- `[autotel] Event dropped: ${reason}`
231
- );
232
- } else {
233
- logger.warn(
234
- {
235
- eventName: event?.name,
236
- subscriber: subscriberName,
237
- reason,
238
- correlationId: event?._correlationId,
239
- traceId: event?._traceId
240
- },
241
- `[autotel] Event dropped: ${reason}`
242
- );
243
- }
244
- }
245
- /**
246
- * Record permanent delivery failure (after all retries exhausted)
247
- * Increments failed counter and logs error
248
- */
249
- recordFailed(event, subscriberName, error) {
250
- this.metrics?.failed.add(1, { subscriber: subscriberName });
251
- this.subscriberHealthy.set(subscriberName, false);
252
- chunkR7QYGZUP_cjs.getLogger().error(
253
- {
254
- eventName: event.name,
255
- subscriber: subscriberName,
256
- correlationId: event._correlationId,
257
- traceId: event._traceId,
258
- err: error
259
- },
260
- `[autotel] Event delivery failed after all retries`
261
- );
262
- }
263
- /**
264
- * Mark subscriber as unhealthy on transient failure (without incrementing failed counter)
265
- * Used during retry attempts - only recordFailed should increment the counter
266
- */
267
- markSubscriberUnhealthy(subscriberName) {
268
- this.subscriberHealthy.set(subscriberName, false);
269
- }
270
- /**
271
- * Record successful delivery
272
- */
273
- recordDelivered(event, subscriberName, startTime) {
274
- const latencyMs = Date.now() - startTime;
275
- this.metrics?.delivered.add(1, { subscriber: subscriberName });
276
- this.metrics?.latency.record(latencyMs, { subscriber: subscriberName });
277
- this.subscriberHealthy.set(subscriberName, true);
278
- }
279
- /**
280
- * Enqueue an event for sending
281
- *
282
- * Backpressure policy:
283
- * - Drops oldest event and logs warning if queue is full (same behavior in all environments)
284
- */
285
- enqueue(event) {
286
- if (this.isShuttingDown) {
287
- this.recordDropped("shutdown", event);
288
- return;
289
- }
290
- if (this.queue.length >= this.config.maxSize) {
291
- const droppedEvent = this.queue.shift();
292
- this.recordDropped("rate_limit", droppedEvent);
293
- chunkR7QYGZUP_cjs.getLogger().warn(
294
- {
295
- droppedEvent: droppedEvent?.name
296
- },
297
- `[autotel] Events queue full (${this.config.maxSize} events). Dropping oldest event. Events are being produced faster than they can be sent. Check your subscribers or reduce tracking frequency.`
298
- );
299
- }
300
- const enrichedEvent = {
301
- ...event,
302
- _correlationId: event._correlationId || getOrCreateCorrelationId()
303
- };
304
- this.queue.push(enrichedEvent);
305
- this.scheduleBatchFlush();
306
- }
307
- /**
308
- * Schedule a batch flush if not already scheduled
309
- */
310
- scheduleBatchFlush() {
311
- if (this.flushTimer || this.flushPromise) return;
312
- this.flushTimer = setTimeout(() => {
313
- this.flushTimer = null;
314
- void this.flushBatch();
315
- }, this.config.flushInterval);
316
- }
317
- /**
318
- * Flush a batch of events
319
- * Uses promise-based concurrency control to prevent race conditions
320
- */
321
- async flushBatch() {
322
- if (this.queue.length === 0) return;
323
- if (this.flushPromise) {
324
- await this.flushPromise;
325
- return;
326
- }
327
- this.flushPromise = this.doFlushBatch();
328
- try {
329
- await this.flushPromise;
330
- } finally {
331
- this.flushPromise = null;
332
- if (this.queue.length > 0) {
333
- this.scheduleBatchFlush();
334
- }
335
- }
336
- }
337
- /**
338
- * Internal flush implementation
339
- */
340
- async doFlushBatch() {
341
- const batch = this.queue.splice(0, this.config.batchSize);
342
- await this.sendWithRetry(batch, this.config.maxRetries);
343
- }
344
- /**
345
- * Send events with exponential backoff retry
346
- * Tracks per-event, per-subscriber failures so failed counter reflects actual failed deliveries.
347
- * On retry, only failed (event, subscriber) pairs are re-sent to avoid double-counting delivered.
348
- */
349
- async sendWithRetry(events, retriesLeft, subscribersByEventIndex) {
350
- const failedDeliveries = await this.sendToSubscribers(
351
- events,
352
- subscribersByEventIndex
353
- );
354
- if (failedDeliveries.length > 0) {
355
- if (retriesLeft > 0) {
356
- const failedEventIndices = new Set(
357
- failedDeliveries.map((f) => f.eventIndex)
358
- );
359
- const failedEventIndicesOrdered = [...failedEventIndices].sort(
360
- (a, b) => a - b
361
- );
362
- const eventsToRetry = failedEventIndicesOrdered.map(
363
- (i) => events[i]
364
- );
365
- const failedSubscribersByRetryIndex = /* @__PURE__ */ new Map();
366
- for (let j = 0; j < failedEventIndicesOrdered.length; j++) {
367
- const origIndex = failedEventIndicesOrdered[j];
368
- const set = /* @__PURE__ */ new Set();
369
- for (const { eventIndex, subscriberName } of failedDeliveries) {
370
- if (eventIndex === origIndex) set.add(subscriberName);
371
- }
372
- failedSubscribersByRetryIndex.set(j, set);
373
- }
374
- const delay = Math.pow(2, this.config.maxRetries - retriesLeft) * 1e3;
375
- await new Promise((resolve) => setTimeout(resolve, delay));
376
- return this.sendWithRetry(
377
- eventsToRetry,
378
- retriesLeft - 1,
379
- failedSubscribersByRetryIndex
380
- );
381
- } else {
382
- for (const { eventIndex, subscriberName, error } of failedDeliveries) {
383
- const event = events[eventIndex];
384
- if (event) this.recordFailed(event, subscriberName, error);
385
- }
386
- const failedSubscriberNames = [
387
- ...new Set(failedDeliveries.map((f) => f.subscriberName))
388
- ];
389
- chunkR7QYGZUP_cjs.getLogger().error(
390
- {
391
- failedSubscribers: failedSubscriberNames,
392
- retriesAttempted: this.config.maxRetries
393
- },
394
- "[autotel] Failed to send events after retries"
395
- );
396
- }
397
- }
398
- }
399
- /**
400
- * Send events to configured subscribers with rate limiting and metrics.
401
- * When subscribersByEventIndex is provided (retry path), only those subscribers are tried per event.
402
- * Returns per-event, per-subscriber failures (empty if all succeeded).
403
- */
404
- async sendToSubscribers(events, subscribersByEventIndex) {
405
- const failedDeliveries = [];
406
- const sendOne = async (event, eventIndex) => {
407
- const subscriberNames = subscribersByEventIndex?.get(eventIndex);
408
- const failures = await this.sendEventToSubscribers(
409
- event,
410
- subscriberNames ?? void 0
411
- );
412
- for (const failure of failures) {
413
- failedDeliveries.push({
414
- eventIndex,
415
- subscriberName: failure.subscriberName,
416
- error: failure.error
417
- });
418
- }
419
- };
420
- if (!this.rateLimiter) {
421
- for (let i = 0; i < events.length; i++) {
422
- const event = events[i];
423
- if (event) await sendOne(event, i);
424
- }
425
- return failedDeliveries;
426
- }
427
- for (let i = 0; i < events.length; i++) {
428
- await this.rateLimiter.waitForToken();
429
- const event = events[i];
430
- if (event) await sendOne(event, i);
431
- }
432
- return failedDeliveries;
433
- }
434
- /**
435
- * Send a single event to subscribers.
436
- * - When subscriberNames is undefined (initial attempt): send to all subscribers.
437
- * - When subscriberNames is provided (retry): send only to those subscribers (never re-send to healthy ones).
438
- * Returns list of subscribers that failed (empty if all succeeded).
439
- */
440
- async sendEventToSubscribers(event, subscriberNames) {
441
- const startTime = event.timestamp;
442
- const failures = [];
443
- const subscribersToTry = subscriberNames === void 0 ? this.subscribers : this.subscribers.filter(
444
- (s) => subscriberNames.has(getSubscriberName(s))
445
- );
446
- const results = await Promise.allSettled(
447
- subscribersToTry.map(async (subscriber) => {
448
- const subscriberName = getSubscriberName(subscriber);
449
- try {
450
- await subscriber.trackEvent(event.name, event.attributes, {
451
- autotel: event.autotel,
452
- schema: event.schema
453
- });
454
- this.recordDelivered(event, subscriberName, startTime);
455
- return { subscriberName, success: true };
456
- } catch (error) {
457
- this.markSubscriberUnhealthy(subscriberName);
458
- return {
459
- subscriberName,
460
- success: false,
461
- error: error instanceof Error ? error : void 0
462
- };
463
- }
464
- })
465
- );
466
- for (const result of results) {
467
- if (result.status === "fulfilled" && !result.value.success) {
468
- failures.push({
469
- subscriberName: result.value.subscriberName,
470
- error: result.value.error
471
- });
472
- }
473
- }
474
- return failures;
475
- }
476
- /**
477
- * Flush all remaining events. Queue remains usable after flush (e.g. for
478
- * auto-flush at root span end). Use shutdown() when tearing down the queue.
479
- */
480
- async flush() {
481
- if (this.flushTimer) {
482
- clearTimeout(this.flushTimer);
483
- this.flushTimer = null;
484
- }
485
- if (this.flushPromise) {
486
- await this.flushPromise;
487
- }
488
- while (this.queue.length > 0) {
489
- await this.doFlushBatch();
490
- }
491
- }
492
- /**
493
- * Flush remaining events and permanently disable the queue (reject new events).
494
- * Use for process/SDK shutdown; use flush() for periodic or span-end drain.
495
- */
496
- async shutdown() {
497
- this.isShuttingDown = true;
498
- await this.flush();
499
- }
500
- /**
501
- * Cleanup observable metric callbacks to prevent memory leaks
502
- * Call this when destroying the EventQueue instance
503
- */
504
- cleanup() {
505
- for (const cleanupFn of this.observableCleanups) {
506
- try {
507
- cleanupFn();
508
- } catch {
509
- }
510
- }
511
- this.observableCleanups = [];
512
- }
513
- /**
514
- * Get queue size (for testing/debugging)
515
- */
516
- size() {
517
- return this.queue.length;
518
- }
519
- /**
520
- * Get subscriber health status (for testing/debugging)
521
- */
522
- getSubscriberHealth() {
523
- return new Map(this.subscriberHealthy);
524
- }
525
- /**
526
- * Check if a specific subscriber is healthy
527
- */
528
- isSubscriberHealthy(subscriberName) {
529
- return this.subscriberHealthy.get(subscriberName.toLowerCase()) ?? true;
530
- }
531
- /**
532
- * Manually mark a subscriber as healthy or unhealthy
533
- * (used for circuit breaker integration)
534
- */
535
- setSubscriberHealth(subscriberName, healthy) {
536
- this.subscriberHealthy.set(subscriberName.toLowerCase(), healthy);
537
- }
538
- };
539
-
540
- // src/validation.ts
541
- var DEFAULT_CONFIG2 = {
542
- maxEventNameLength: 100,
543
- maxAttributeKeyLength: 100,
544
- maxAttributeValueLength: 1e3,
545
- maxAttributeCount: 50,
546
- maxNestingDepth: 3,
547
- sensitivePatterns: [
548
- /password/i,
549
- /secret/i,
550
- /token/i,
551
- /api[_-]?key/i,
552
- /access[_-]?key/i,
553
- /private[_-]?key/i,
554
- /auth/i,
555
- /credential/i,
556
- /ssn/i,
557
- /credit[_-]?card/i
558
- ]
559
- };
560
- var ValidationError = class extends Error {
561
- constructor(message) {
562
- super(message);
563
- this.name = "ValidationError";
564
- }
565
- };
566
- function validateEventName(eventName, config = DEFAULT_CONFIG2) {
567
- if (typeof eventName !== "string") {
568
- throw new ValidationError(
569
- `Event name must be a string, got ${typeof eventName}`
570
- );
571
- }
572
- const trimmed = eventName.trim();
573
- if (trimmed.length === 0) {
574
- throw new ValidationError("Event name cannot be empty");
575
- }
576
- if (trimmed.length > config.maxEventNameLength) {
577
- throw new ValidationError(
578
- `Event name too long (${trimmed.length} chars). Max: ${config.maxEventNameLength}`
579
- );
580
- }
581
- if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) {
582
- throw new ValidationError(
583
- `Event name contains invalid characters: "${trimmed}". Use only letters, numbers, dots, underscores, and hyphens.`
584
- );
585
- }
586
- return trimmed;
587
- }
588
- function validateAttributes(attributes, config = DEFAULT_CONFIG2) {
589
- if (attributes === void 0 || attributes === null) {
590
- return void 0;
591
- }
592
- if (typeof attributes !== "object" || Array.isArray(attributes)) {
593
- throw new ValidationError("Attributes must be an object");
594
- }
595
- const keys = Object.keys(attributes);
596
- if (keys.length > config.maxAttributeCount) {
597
- throw new ValidationError(
598
- `Too many attributes (${keys.length}). Max: ${config.maxAttributeCount}`
599
- );
600
- }
601
- const sanitized = {};
602
- for (const key of keys) {
603
- if (key.length > config.maxAttributeKeyLength) {
604
- throw new ValidationError(
605
- `Attribute key too long: "${key.slice(0, 20)}..." (${key.length} chars). Max: ${config.maxAttributeKeyLength}`
606
- );
607
- }
608
- const value = attributes[key];
609
- const isSensitive = typeof value === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key));
610
- if (isSensitive) {
611
- sanitized[key] = "[REDACTED]";
612
- continue;
613
- }
614
- sanitized[key] = sanitizeValue(value, config, 1);
615
- }
616
- return sanitized;
617
- }
618
- function sanitizeValue(value, config, depth) {
619
- if (depth > config.maxNestingDepth) {
620
- return "[MAX_DEPTH_EXCEEDED]";
621
- }
622
- if (value === null || value === void 0) {
623
- return value;
624
- }
625
- if (typeof value === "string") {
626
- if (value.length > config.maxAttributeValueLength) {
627
- return value.slice(0, config.maxAttributeValueLength) + "...";
628
- }
629
- return value;
630
- }
631
- if (typeof value === "number" || typeof value === "boolean") {
632
- return value;
633
- }
634
- if (Array.isArray(value)) {
635
- return value.map((item) => sanitizeValue(item, config, depth + 1));
636
- }
637
- if (typeof value === "object") {
638
- try {
639
- JSON.stringify(value);
640
- const sanitized = {};
641
- for (const key in value) {
642
- if (Object.prototype.hasOwnProperty.call(value, key)) {
643
- const nested = value[key];
644
- const isSensitive = typeof nested === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key));
645
- sanitized[key] = isSensitive ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
646
- }
647
- }
648
- return sanitized;
649
- } catch {
650
- return "[CIRCULAR]";
651
- }
652
- }
653
- return `[${typeof value}]`;
654
- }
655
- function validateEvent(eventName, attributes, config) {
656
- const fullConfig = { ...DEFAULT_CONFIG2, ...config };
657
- return {
658
- eventName: validateEventName(eventName, fullConfig),
659
- attributes: validateAttributes(attributes, fullConfig)
660
- };
661
- }
662
-
663
- // src/track.ts
664
- var eventsQueue = null;
665
- function buildAutotelContext(span) {
666
- const eventsConfig = chunkR7QYGZUP_cjs.getEventsConfig();
667
- const config = chunkR7QYGZUP_cjs.getConfig();
668
- const correlationId = getOrCreateCorrelationId();
669
- if (!eventsConfig?.includeTraceContext) {
670
- return {
671
- correlation_id: correlationId
672
- };
673
- }
674
- const autotelContext = {
675
- correlation_id: correlationId
676
- };
677
- const spanContext = span?.spanContext();
678
- if (spanContext) {
679
- autotelContext.trace_id = spanContext.traceId;
680
- autotelContext.span_id = spanContext.spanId;
681
- autotelContext.trace_flags = spanContext.traceFlags.toString(16).padStart(2, "0");
682
- const traceState = spanContext.traceState;
683
- if (traceState) {
684
- try {
685
- if (typeof traceState.serialize === "function") {
686
- const traceStateStr = traceState.serialize();
687
- if (traceStateStr) {
688
- autotelContext.trace_state = traceStateStr;
689
- }
690
- }
691
- } catch {
692
- }
693
- }
694
- if (eventsConfig.traceUrl && config) {
695
- const traceUrl = eventsConfig.traceUrl({
696
- traceId: spanContext.traceId,
697
- spanId: spanContext.spanId,
698
- correlationId,
699
- serviceName: config.service,
700
- environment: config.environment
701
- });
702
- if (traceUrl) {
703
- autotelContext.trace_url = traceUrl;
704
- }
705
- }
706
- } else {
707
- if (eventsConfig.traceUrl && config) {
708
- const traceUrl = eventsConfig.traceUrl({
709
- correlationId,
710
- serviceName: config.service,
711
- environment: config.environment
712
- });
713
- if (traceUrl) {
714
- autotelContext.trace_url = traceUrl;
715
- }
716
- }
717
- }
718
- return autotelContext;
719
- }
720
- function getOrCreateQueue() {
721
- if (!chunkR7QYGZUP_cjs.isInitialized()) {
722
- chunkR7QYGZUP_cjs.warnIfNotInitialized("track()");
723
- return null;
724
- }
725
- if (!eventsQueue) {
726
- const config = chunkR7QYGZUP_cjs.getConfig();
727
- if (!config?.subscribers || config.subscribers.length === 0) {
728
- return null;
729
- }
730
- eventsQueue = new EventQueue(config.subscribers);
731
- }
732
- return eventsQueue;
733
- }
734
- function track(event, data, options) {
735
- const queue = getOrCreateQueue();
736
- if (!queue) return;
737
- const validationConfig = chunkR7QYGZUP_cjs.getValidationConfig();
738
- const validated = validateEvent(event, data, validationConfig || void 0);
739
- const span = api.trace.getActiveSpan();
740
- const enrichedData = span ? {
741
- ...validated.attributes,
742
- traceId: span.spanContext().traceId,
743
- spanId: span.spanContext().spanId
744
- } : validated.attributes;
745
- const autotelContext = buildAutotelContext(span);
746
- queue.enqueue({
747
- name: validated.eventName,
748
- attributes: enrichedData,
749
- timestamp: Date.now(),
750
- autotel: autotelContext,
751
- schema: options?.schema
752
- });
753
- }
754
- function getEventQueue() {
755
- return eventsQueue;
756
- }
757
- function resetEventQueue() {
758
- eventsQueue = null;
759
- }
760
-
761
- // src/trace-context.ts
762
- var contextStorage = new async_hooks.AsyncLocalStorage();
763
- function getContextStorage() {
764
- return contextStorage;
765
- }
766
- function getActiveContextWithBaggage() {
767
- const stored = contextStorage.getStore()?.value;
768
- return stored ?? api.context.active();
769
- }
770
- function enterOrRun(storage, value) {
771
- const existingStore = storage.getStore();
772
- if (existingStore) {
773
- existingStore.value = value;
774
- return;
775
- }
776
- const boxedValue = { value };
777
- try {
778
- storage.enterWith(boxedValue);
779
- } catch {
780
- storage.run(boxedValue, () => {
781
- });
782
- }
783
- }
784
- function updateActiveContext(newContext) {
785
- enterOrRun(contextStorage, newContext);
786
- const contextWithManager = api.context;
787
- const manager = contextWithManager._getContextManager?.();
788
- if (!manager) return;
789
- const asyncLocal = manager._asyncLocalStorage ?? void 0;
790
- if (asyncLocal?.enterWith) {
791
- asyncLocal.enterWith(newContext);
792
- return;
793
- }
794
- if (typeof manager.with === "function") {
795
- manager.with(newContext, () => {
796
- });
797
- }
798
- }
799
- function createTraceContext(span) {
800
- const spanContext = span.spanContext();
801
- const existingStored = contextStorage.getStore()?.value;
802
- if (!existingStored) {
803
- const activeContext = api.context.active();
804
- enterOrRun(contextStorage, activeContext);
805
- }
806
- const baggageHelpers = {
807
- getBaggage(key) {
808
- const activeCtx = api.context.active();
809
- let baggage = api.propagation.getBaggage(activeCtx);
810
- if (!baggage) {
811
- const storedContext = contextStorage.getStore()?.value;
812
- if (storedContext) {
813
- baggage = api.propagation.getBaggage(storedContext);
814
- }
815
- }
816
- return baggage?.getEntry(key)?.value;
817
- },
818
- setBaggage(key, value) {
819
- const activeCtx = api.context.active();
820
- const storedContext = contextStorage.getStore()?.value;
821
- const currentContext = storedContext ?? activeCtx;
822
- const baggage = api.propagation.getBaggage(currentContext) ?? api.propagation.createBaggage();
823
- const updated = baggage.setEntry(key, { value });
824
- const newContext = api.propagation.setBaggage(currentContext, updated);
825
- updateActiveContext(newContext);
826
- return value;
827
- },
828
- deleteBaggage(key) {
829
- const activeCtx = api.context.active();
830
- const storedContext = contextStorage.getStore()?.value;
831
- const currentContext = storedContext ?? activeCtx;
832
- const baggage = api.propagation.getBaggage(currentContext);
833
- if (baggage) {
834
- const updated = baggage.removeEntry(key);
835
- const newContext = api.propagation.setBaggage(currentContext, updated);
836
- updateActiveContext(newContext);
837
- }
838
- },
839
- getAllBaggage() {
840
- const activeCtx = api.context.active();
841
- let baggage = api.propagation.getBaggage(activeCtx);
842
- if (!baggage) {
843
- const storedContext = contextStorage.getStore()?.value;
844
- if (storedContext) {
845
- baggage = api.propagation.getBaggage(storedContext);
846
- }
847
- }
848
- if (!baggage) {
849
- return /* @__PURE__ */ new Map();
850
- }
851
- const entries = /* @__PURE__ */ new Map();
852
- for (const [key, entry] of baggage.getAllEntries()) {
853
- entries.set(key, entry);
854
- }
855
- return entries;
856
- },
857
- // Typed baggage helpers (used by defineBaggageSchema)
858
- getTypedBaggage: ((namespace) => {
859
- const activeCtx = api.context.active();
860
- let baggage = api.propagation.getBaggage(activeCtx);
861
- if (!baggage) {
862
- const storedContext = contextStorage.getStore()?.value;
863
- if (storedContext) {
864
- baggage = api.propagation.getBaggage(storedContext);
865
- }
866
- }
867
- if (!baggage) return;
868
- const prefix = namespace ? `${namespace}.` : "";
869
- const result = {};
870
- for (const [key, entry] of baggage.getAllEntries()) {
871
- if (namespace && key.startsWith(prefix)) {
872
- const fieldName = key.slice(prefix.length);
873
- result[fieldName] = entry.value;
874
- } else if (!namespace) {
875
- result[key] = entry.value;
876
- }
877
- }
878
- return Object.keys(result).length > 0 ? result : void 0;
879
- }),
880
- setTypedBaggage: ((namespace, value) => {
881
- const activeCtx = api.context.active();
882
- const storedContext = contextStorage.getStore()?.value;
883
- const currentContext = storedContext ?? activeCtx;
884
- let baggage = api.propagation.getBaggage(currentContext) ?? api.propagation.createBaggage();
885
- const prefix = namespace ? `${namespace}.` : "";
886
- for (const [key, val] of Object.entries(value)) {
887
- if (val !== void 0) {
888
- const baggageKey = `${prefix}${key}`;
889
- baggage = baggage.setEntry(baggageKey, { value: String(val) });
890
- }
891
- }
892
- const newContext = api.propagation.setBaggage(currentContext, baggage);
893
- updateActiveContext(newContext);
894
- })
895
- };
896
- const traceCtx = {
897
- traceId: spanContext.traceId,
898
- spanId: spanContext.spanId,
899
- correlationId: spanContext.traceId.slice(0, 16),
900
- setAttribute: span.setAttribute.bind(span),
901
- setAttributes: span.setAttributes.bind(span),
902
- setStatus: span.setStatus.bind(span),
903
- recordException: span.recordException.bind(span),
904
- addEvent: span.addEvent.bind(span),
905
- addLink: span.addLink.bind(span),
906
- addLinks: span.addLinks.bind(span),
907
- updateName: span.updateName.bind(span),
908
- isRecording: span.isRecording.bind(span),
909
- recordError: (error) => {
910
- const err = error instanceof Error ? error : new Error(String(error));
911
- chunkEE6CPXKH_cjs.recordStructuredError(traceCtx, err);
912
- },
913
- track: (event, data) => {
914
- track(event, data);
915
- },
916
- ...baggageHelpers
917
- };
918
- return traceCtx;
919
- }
920
- function defineBaggageSchema(namespace) {
921
- return {
922
- /**
923
- * Get typed baggage from context
924
- * @param ctx - Trace context
925
- * @returns Partial baggage object or undefined if no baggage is set
926
- */
927
- get: (ctx) => {
928
- if (!ctx.getTypedBaggage) return void 0;
929
- return ctx.getTypedBaggage(namespace);
930
- },
931
- /**
932
- * Set typed baggage in context
933
- *
934
- * Note: For proper scoping across async boundaries, use the `with` method instead
935
- *
936
- * @param ctx - Trace context
937
- * @param value - Partial baggage object to set
938
- */
939
- set: (ctx, value) => {
940
- if (!ctx.setTypedBaggage) return;
941
- ctx.setTypedBaggage(namespace, value);
942
- },
943
- /**
944
- * Run a function with typed baggage properly scoped
945
- *
946
- * This is the recommended way to set baggage as it ensures proper
947
- * scoping across async boundaries.
948
- *
949
- * @param ctx - Trace context (can be omitted, will use active context)
950
- * @param value - Partial baggage object to set
951
- * @param fn - Function to execute with the baggage
952
- */
953
- with: (ctxOrValue, valueOrFn, maybeFn) => {
954
- const value = maybeFn ? valueOrFn : ctxOrValue;
955
- const fn = maybeFn || valueOrFn;
956
- const prefix = namespace ? `${namespace}.` : "";
957
- const flatBaggage = {};
958
- for (const [key, val] of Object.entries(value)) {
959
- if (val !== void 0) {
960
- flatBaggage[`${prefix}${key}`] = String(val);
961
- }
962
- }
963
- const currentContext = api.context.active();
964
- let baggage = api.propagation.getBaggage(currentContext) ?? api.propagation.createBaggage();
965
- for (const [key, val] of Object.entries(flatBaggage)) {
966
- baggage = baggage.setEntry(key, { value: val });
967
- }
968
- const newContext = api.propagation.setBaggage(currentContext, baggage);
969
- return api.context.with(newContext, fn);
970
- }
971
- };
972
- }
973
-
974
- // src/correlation-id.ts
975
- var correlationStorage = new async_hooks.AsyncLocalStorage();
976
- var CORRELATION_ID_BAGGAGE_KEY = "autotel.correlation_id";
977
- function generateCorrelationId() {
978
- const bytes = new Uint8Array(8);
979
- crypto.getRandomValues(bytes);
980
- return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
981
- }
982
- function getCorrelationId() {
983
- const storedId = correlationStorage.getStore()?.value;
984
- if (storedId) {
985
- return storedId;
986
- }
987
- const activeContext = api.context.active();
988
- const baggage = api.propagation.getBaggage(activeContext);
989
- const baggageEntry = baggage?.getEntry(CORRELATION_ID_BAGGAGE_KEY);
990
- if (baggageEntry?.value) {
991
- return baggageEntry.value;
992
- }
993
- const span = api.trace.getActiveSpan();
994
- if (span) {
995
- const spanContext = span.spanContext();
996
- return spanContext.traceId.slice(0, 16);
997
- }
998
- return void 0;
999
- }
1000
- function getOrCreateCorrelationId() {
1001
- return getCorrelationId() ?? generateCorrelationId();
1002
- }
1003
- function runWithCorrelationId(correlationId, fn) {
1004
- return correlationStorage.run({ value: correlationId }, fn);
1005
- }
1006
- function setCorrelationId(correlationId) {
1007
- enterOrRun(correlationStorage, correlationId);
1008
- }
1009
- function setCorrelationIdInBaggage(correlationId) {
1010
- const activeContext = api.context.active();
1011
- let baggage = api.propagation.getBaggage(activeContext) ?? api.propagation.createBaggage();
1012
- baggage = baggage.setEntry(CORRELATION_ID_BAGGAGE_KEY, {
1013
- value: correlationId
1014
- });
1015
- return api.propagation.setBaggage(activeContext, baggage);
1016
- }
1017
- function getCorrelationStorage() {
1018
- return correlationStorage;
1019
- }
1020
-
1021
- exports.CORRELATION_ID_BAGGAGE_KEY = CORRELATION_ID_BAGGAGE_KEY;
1022
- exports.createTraceContext = createTraceContext;
1023
- exports.defineBaggageSchema = defineBaggageSchema;
1024
- exports.enterOrRun = enterOrRun;
1025
- exports.generateCorrelationId = generateCorrelationId;
1026
- exports.getActiveContextWithBaggage = getActiveContextWithBaggage;
1027
- exports.getContextStorage = getContextStorage;
1028
- exports.getCorrelationId = getCorrelationId;
1029
- exports.getCorrelationStorage = getCorrelationStorage;
1030
- exports.getEventQueue = getEventQueue;
1031
- exports.getOrCreateCorrelationId = getOrCreateCorrelationId;
1032
- exports.resetEventQueue = resetEventQueue;
1033
- exports.runWithCorrelationId = runWithCorrelationId;
1034
- exports.setCorrelationId = setCorrelationId;
1035
- exports.setCorrelationIdInBaggage = setCorrelationIdInBaggage;
1036
- exports.track = track;
1037
- exports.validateEvent = validateEvent;
1038
- //# sourceMappingURL=chunk-FMTHVSYY.cjs.map
1039
- //# sourceMappingURL=chunk-FMTHVSYY.cjs.map