autotel 4.3.0 → 6.0.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 (384) hide show
  1. package/README.md +125 -103
  2. package/dist/analysis.cjs +87 -0
  3. package/dist/analysis.cjs.map +1 -0
  4. package/dist/analysis.d.cts +87 -0
  5. package/dist/analysis.d.cts.map +1 -0
  6. package/dist/analysis.d.ts +87 -0
  7. package/dist/analysis.d.ts.map +1 -0
  8. package/dist/analysis.js +85 -0
  9. package/dist/analysis.js.map +1 -0
  10. package/dist/{attribute-redacting-processor-DtTS9xxh.d.ts → attribute-redacting-processor-Pk7lAzWd.d.cts} +13 -8
  11. package/dist/attribute-redacting-processor-Pk7lAzWd.d.cts.map +1 -0
  12. package/dist/{attribute-redacting-processor-DtTS9xxh.d.cts → attribute-redacting-processor-Pk7lAzWd.d.ts} +13 -8
  13. package/dist/attribute-redacting-processor-Pk7lAzWd.d.ts.map +1 -0
  14. package/dist/attribute-redacting-processor.cjs +4 -4
  15. package/dist/attribute-redacting-processor.cjs.map +1 -1
  16. package/dist/attribute-redacting-processor.d.cts +1 -1
  17. package/dist/attribute-redacting-processor.d.ts +1 -1
  18. package/dist/attribute-redacting-processor.js +4 -4
  19. package/dist/attribute-redacting-processor.js.map +1 -1
  20. package/dist/attributes.d.cts +1 -1
  21. package/dist/attributes.d.ts +1 -1
  22. package/dist/auto.cjs +1 -1
  23. package/dist/auto.cjs.map +1 -1
  24. package/dist/auto.d.cts +1 -1
  25. package/dist/auto.d.ts +1 -1
  26. package/dist/auto.js +1 -1
  27. package/dist/auto.js.map +1 -1
  28. package/dist/business-baggage.d.cts +2 -3
  29. package/dist/business-baggage.d.cts.map +1 -1
  30. package/dist/business-baggage.d.ts +2 -3
  31. package/dist/business-baggage.d.ts.map +1 -1
  32. package/dist/{canonical-log-line-processor-xvjMgtpF.d.cts → canonical-log-line-processor-B4WgG-VS.d.cts} +2 -3
  33. package/dist/canonical-log-line-processor-B4WgG-VS.d.cts.map +1 -0
  34. package/dist/{canonical-log-line-processor-BcRuAdRk.d.ts → canonical-log-line-processor-CL_J7gb5.d.ts} +2 -3
  35. package/dist/canonical-log-line-processor-CL_J7gb5.d.ts.map +1 -0
  36. package/dist/{canonical-log-line-processor-CcrDi6TO.cjs → canonical-log-line-processor-DOjb6Kxy.cjs} +5 -5
  37. package/dist/canonical-log-line-processor-DOjb6Kxy.cjs.map +1 -0
  38. package/dist/{canonical-log-line-processor-FLezvFCB.js → canonical-log-line-processor-mKABvGP0.js} +5 -5
  39. package/dist/canonical-log-line-processor-mKABvGP0.js.map +1 -0
  40. package/dist/config.d.cts +12 -7
  41. package/dist/config.d.cts.map +1 -1
  42. package/dist/config.d.ts +12 -7
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/correlation-id.cjs +9 -9
  45. package/dist/correlation-id.d.cts +0 -1
  46. package/dist/correlation-id.d.cts.map +1 -1
  47. package/dist/correlation-id.d.ts +0 -1
  48. package/dist/correlation-id.d.ts.map +1 -1
  49. package/dist/correlation-id.js +1 -1
  50. package/dist/db.d.cts.map +1 -1
  51. package/dist/db.d.ts.map +1 -1
  52. package/dist/decorators.cjs +2 -2
  53. package/dist/decorators.cjs.map +1 -1
  54. package/dist/decorators.d.cts +1 -2
  55. package/dist/decorators.d.cts.map +1 -1
  56. package/dist/decorators.d.ts +1 -2
  57. package/dist/decorators.d.ts.map +1 -1
  58. package/dist/decorators.js +1 -1
  59. package/dist/decorators.js.map +1 -1
  60. package/dist/{define-event-CreknLm3.d.ts → define-event-B2z1SBe7.d.ts} +2 -3
  61. package/dist/define-event-B2z1SBe7.d.ts.map +1 -0
  62. package/dist/{define-event-HZRizPwz.d.cts → define-event-CGG048HE.d.cts} +2 -3
  63. package/dist/define-event-CGG048HE.d.cts.map +1 -0
  64. package/dist/diagnostics.cjs +10 -1
  65. package/dist/diagnostics.cjs.map +1 -1
  66. package/dist/diagnostics.d.cts +0 -1
  67. package/dist/diagnostics.d.cts.map +1 -1
  68. package/dist/diagnostics.d.ts +0 -1
  69. package/dist/diagnostics.d.ts.map +1 -1
  70. package/dist/diagnostics.js +10 -1
  71. package/dist/diagnostics.js.map +1 -1
  72. package/dist/drain-pipeline.d.cts +12 -5
  73. package/dist/drain-pipeline.d.cts.map +1 -1
  74. package/dist/drain-pipeline.d.ts +12 -5
  75. package/dist/drain-pipeline.d.ts.map +1 -1
  76. package/dist/enrichers.d.cts.map +1 -1
  77. package/dist/enrichers.d.ts.map +1 -1
  78. package/dist/{event-subscriber-D1XLkPzi.d.ts → event-subscriber-CWh8sTGh.d.cts} +2 -2
  79. package/dist/event-subscriber-CWh8sTGh.d.cts.map +1 -0
  80. package/dist/{event-subscriber-D1XLkPzi.d.cts → event-subscriber-CWh8sTGh.d.ts} +2 -2
  81. package/dist/event-subscriber-CWh8sTGh.d.ts.map +1 -0
  82. package/dist/event-subscriber.d.cts +1 -1
  83. package/dist/event-subscriber.d.ts +1 -1
  84. package/dist/{event-testing-CfFs3to2.d.ts → event-testing-CA2mIx1E.d.ts} +2 -3
  85. package/dist/event-testing-CA2mIx1E.d.ts.map +1 -0
  86. package/dist/{event-testing-BqRnI0z4.d.cts → event-testing-D0qWfqAy.d.cts} +2 -3
  87. package/dist/event-testing-D0qWfqAy.d.cts.map +1 -0
  88. package/dist/event-testing.d.cts +1 -1
  89. package/dist/event-testing.d.ts +1 -1
  90. package/dist/event.cjs +4 -4
  91. package/dist/event.d.cts +3 -4
  92. package/dist/event.d.cts.map +1 -1
  93. package/dist/event.d.ts +3 -4
  94. package/dist/event.d.ts.map +1 -1
  95. package/dist/event.js +1 -1
  96. package/dist/exporters.d.cts +0 -4
  97. package/dist/exporters.d.cts.map +1 -1
  98. package/dist/exporters.d.ts +0 -4
  99. package/dist/exporters.d.ts.map +1 -1
  100. package/dist/{filtering-span-processor-B8R8B7Uk.d.ts → filtering-span-processor-BpDagWNa.d.cts} +1 -2
  101. package/dist/filtering-span-processor-BpDagWNa.d.cts.map +1 -0
  102. package/dist/{filtering-span-processor-B8R8B7Uk.d.cts → filtering-span-processor-BpDagWNa.d.ts} +1 -2
  103. package/dist/filtering-span-processor-BpDagWNa.d.ts.map +1 -0
  104. package/dist/filtering-span-processor.d.cts +1 -1
  105. package/dist/filtering-span-processor.d.ts +1 -1
  106. package/dist/functional-BnDUxnSl.js +838 -0
  107. package/dist/functional-BnDUxnSl.js.map +1 -0
  108. package/dist/functional-DcLBuCPz.cjs +888 -0
  109. package/dist/functional-DcLBuCPz.cjs.map +1 -0
  110. package/dist/functional.cjs +2 -2
  111. package/dist/functional.d.cts +79 -130
  112. package/dist/functional.d.cts.map +1 -1
  113. package/dist/functional.d.ts +79 -130
  114. package/dist/functional.d.ts.map +1 -1
  115. package/dist/functional.js +2 -2
  116. package/dist/http.cjs +6 -6
  117. package/dist/http.cjs.map +1 -1
  118. package/dist/http.d.cts +4 -5
  119. package/dist/http.d.cts.map +1 -1
  120. package/dist/http.d.ts +4 -5
  121. package/dist/http.d.ts.map +1 -1
  122. package/dist/http.js +5 -5
  123. package/dist/http.js.map +1 -1
  124. package/dist/{index-eKuioqT1.d.cts → index-BPcxVucm.d.cts} +2 -3
  125. package/dist/index-BPcxVucm.d.cts.map +1 -0
  126. package/dist/{index-Ck06vlW2.d.ts → index-DolOVX6F.d.ts} +2 -3
  127. package/dist/index-DolOVX6F.d.ts.map +1 -0
  128. package/dist/index.cjs +25 -167
  129. package/dist/index.cjs.map +1 -1
  130. package/dist/index.d.cts +14 -14
  131. package/dist/index.d.cts.map +1 -1
  132. package/dist/index.d.ts +14 -14
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +6 -148
  135. package/dist/index.js.map +1 -1
  136. package/dist/init-C3RApHKJ.cjs +3371 -0
  137. package/dist/init-C3RApHKJ.cjs.map +1 -0
  138. package/dist/{init-DSrRmVnz.d.cts → init-D6n2diBy.d.ts} +46 -20
  139. package/dist/init-D6n2diBy.d.ts.map +1 -0
  140. package/dist/init-R-gSEXkJ.js +3190 -0
  141. package/dist/init-R-gSEXkJ.js.map +1 -0
  142. package/dist/{init-B7u-DjxM.d.ts → init-XzXzrarP.d.cts} +46 -20
  143. package/dist/init-XzXzrarP.d.cts.map +1 -0
  144. package/dist/instrumentation.cjs +7 -13
  145. package/dist/instrumentation.cjs.map +1 -1
  146. package/dist/instrumentation.d.cts +0 -1
  147. package/dist/instrumentation.d.cts.map +1 -1
  148. package/dist/instrumentation.d.ts +0 -1
  149. package/dist/instrumentation.d.ts.map +1 -1
  150. package/dist/instrumentation.js +8 -14
  151. package/dist/instrumentation.js.map +1 -1
  152. package/dist/{logger-BauSUhUv.d.ts → logger-CN4xpzMd.d.cts} +1 -2
  153. package/dist/logger-CN4xpzMd.d.cts.map +1 -0
  154. package/dist/{logger-BauSUhUv.d.cts → logger-CN4xpzMd.d.ts} +1 -2
  155. package/dist/logger-CN4xpzMd.d.ts.map +1 -0
  156. package/dist/logger-D3Ej3DII.js.map +1 -1
  157. package/dist/logger-thMPLpOG.cjs.map +1 -1
  158. package/dist/logger.d.cts +1 -1
  159. package/dist/logger.d.ts +1 -1
  160. package/dist/messaging-adapters.cjs.map +1 -1
  161. package/dist/messaging-adapters.d.cts +0 -1
  162. package/dist/messaging-adapters.d.cts.map +1 -1
  163. package/dist/messaging-adapters.d.ts +0 -1
  164. package/dist/messaging-adapters.d.ts.map +1 -1
  165. package/dist/messaging-adapters.js.map +1 -1
  166. package/dist/messaging-testing.d.cts +0 -1
  167. package/dist/messaging-testing.d.cts.map +1 -1
  168. package/dist/messaging-testing.d.ts +0 -1
  169. package/dist/messaging-testing.d.ts.map +1 -1
  170. package/dist/messaging.cjs +27 -10
  171. package/dist/messaging.cjs.map +1 -1
  172. package/dist/messaging.d.cts +6 -7
  173. package/dist/messaging.d.cts.map +1 -1
  174. package/dist/messaging.d.ts +6 -7
  175. package/dist/messaging.d.ts.map +1 -1
  176. package/dist/messaging.js +27 -10
  177. package/dist/messaging.js.map +1 -1
  178. package/dist/metric-helpers.d.cts +0 -1
  179. package/dist/metric-helpers.d.cts.map +1 -1
  180. package/dist/metric-helpers.d.ts +0 -1
  181. package/dist/metric-helpers.d.ts.map +1 -1
  182. package/dist/{metric-testing-DXdK3-Q3.d.ts → metric-testing-CWm6UhaR.d.ts} +2 -3
  183. package/dist/metric-testing-CWm6UhaR.d.ts.map +1 -0
  184. package/dist/{metric-testing-MxvzChDp.d.cts → metric-testing-CpvP3ZIa.d.cts} +2 -3
  185. package/dist/metric-testing-CpvP3ZIa.d.cts.map +1 -0
  186. package/dist/metric-testing.d.cts +1 -1
  187. package/dist/metric-testing.d.ts +1 -1
  188. package/dist/metric.d.cts +3 -4
  189. package/dist/metric.d.cts.map +1 -1
  190. package/dist/metric.d.ts +3 -4
  191. package/dist/metric.d.ts.map +1 -1
  192. package/dist/parse-error.d.cts.map +1 -1
  193. package/dist/parse-error.d.ts.map +1 -1
  194. package/dist/processors.cjs +1 -1
  195. package/dist/processors.d.cts +1 -1
  196. package/dist/processors.d.ts +1 -1
  197. package/dist/processors.js +1 -1
  198. package/dist/register.d.cts +1 -1
  199. package/dist/register.d.ts +1 -1
  200. package/dist/{sampling-DfYhDJij.d.cts → sampling-BR9fkSwx.d.cts} +127 -10
  201. package/dist/sampling-BR9fkSwx.d.cts.map +1 -0
  202. package/dist/{sampling-CR0Va1VB.d.ts → sampling-CP3e7-Yr.d.ts} +127 -10
  203. package/dist/sampling-CP3e7-Yr.d.ts.map +1 -0
  204. package/dist/sampling.cjs +160 -12
  205. package/dist/sampling.cjs.map +1 -1
  206. package/dist/sampling.d.cts +2 -2
  207. package/dist/sampling.d.ts +2 -2
  208. package/dist/sampling.js +157 -13
  209. package/dist/sampling.js.map +1 -1
  210. package/dist/security-schema.d.cts +9 -4
  211. package/dist/security-schema.d.cts.map +1 -1
  212. package/dist/security-schema.d.ts +9 -4
  213. package/dist/security-schema.d.ts.map +1 -1
  214. package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -1
  215. package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -1
  216. package/dist/semantic-conventions.cjs.map +1 -1
  217. package/dist/semantic-conventions.js.map +1 -1
  218. package/dist/semantic-helpers.cjs +85 -304
  219. package/dist/semantic-helpers.cjs.map +1 -1
  220. package/dist/semantic-helpers.d.cts +21 -12
  221. package/dist/semantic-helpers.d.cts.map +1 -1
  222. package/dist/semantic-helpers.d.ts +21 -12
  223. package/dist/semantic-helpers.d.ts.map +1 -1
  224. package/dist/semantic-helpers.js +85 -304
  225. package/dist/semantic-helpers.js.map +1 -1
  226. package/dist/slo.cjs +225 -0
  227. package/dist/slo.cjs.map +1 -0
  228. package/dist/slo.d.cts +97 -0
  229. package/dist/slo.d.cts.map +1 -0
  230. package/dist/slo.d.ts +97 -0
  231. package/dist/slo.d.ts.map +1 -0
  232. package/dist/slo.js +223 -0
  233. package/dist/slo.js.map +1 -0
  234. package/dist/{span-name-normalizer-8ZOGJuwv.d.ts → span-name-normalizer-CN1-8C76.d.cts} +1 -2
  235. package/dist/span-name-normalizer-CN1-8C76.d.cts.map +1 -0
  236. package/dist/{span-name-normalizer-8ZOGJuwv.d.cts → span-name-normalizer-CN1-8C76.d.ts} +1 -2
  237. package/dist/span-name-normalizer-CN1-8C76.d.ts.map +1 -0
  238. package/dist/span-name-normalizer.cjs.map +1 -1
  239. package/dist/span-name-normalizer.d.cts +1 -1
  240. package/dist/span-name-normalizer.d.ts +1 -1
  241. package/dist/span-name-normalizer.js.map +1 -1
  242. package/dist/tail-sampling-processor.d.cts +0 -1
  243. package/dist/tail-sampling-processor.d.cts.map +1 -1
  244. package/dist/tail-sampling-processor.d.ts +0 -1
  245. package/dist/tail-sampling-processor.d.ts.map +1 -1
  246. package/dist/test-span-collector.cjs.map +1 -1
  247. package/dist/test-span-collector.d.cts +0 -1
  248. package/dist/test-span-collector.d.cts.map +1 -1
  249. package/dist/test-span-collector.d.ts +0 -1
  250. package/dist/test-span-collector.d.ts.map +1 -1
  251. package/dist/test-span-collector.js.map +1 -1
  252. package/dist/testing.cjs +76 -11
  253. package/dist/testing.cjs.map +1 -1
  254. package/dist/testing.d.cts +30 -5
  255. package/dist/testing.d.cts.map +1 -1
  256. package/dist/testing.d.ts +30 -5
  257. package/dist/testing.d.ts.map +1 -1
  258. package/dist/testing.js +73 -12
  259. package/dist/testing.js.map +1 -1
  260. package/dist/{trace-context-Cijqoi6e.d.ts → trace-context-IuyoPyNq.d.cts} +9 -9
  261. package/dist/trace-context-IuyoPyNq.d.cts.map +1 -0
  262. package/dist/{trace-context-Cijqoi6e.d.cts → trace-context-IuyoPyNq.d.ts} +9 -9
  263. package/dist/trace-context-IuyoPyNq.d.ts.map +1 -0
  264. package/dist/trace-factory-validation-BjVAinz6.js +13 -0
  265. package/dist/trace-factory-validation-BjVAinz6.js.map +1 -0
  266. package/dist/trace-factory-validation-Dc8epn87.cjs +19 -0
  267. package/dist/trace-factory-validation-Dc8epn87.cjs.map +1 -0
  268. package/dist/trace-helpers.cjs +7 -7
  269. package/dist/trace-helpers.cjs.map +1 -1
  270. package/dist/trace-helpers.d.cts +6 -7
  271. package/dist/trace-helpers.d.cts.map +1 -1
  272. package/dist/trace-helpers.d.ts +6 -7
  273. package/dist/trace-helpers.d.ts.map +1 -1
  274. package/dist/trace-helpers.js +7 -7
  275. package/dist/trace-helpers.js.map +1 -1
  276. package/dist/tracer-provider.d.cts +0 -1
  277. package/dist/tracer-provider.d.cts.map +1 -1
  278. package/dist/tracer-provider.d.ts +0 -1
  279. package/dist/tracer-provider.d.ts.map +1 -1
  280. package/dist/validate.cjs.map +1 -1
  281. package/dist/validate.d.cts +1 -2
  282. package/dist/validate.d.cts.map +1 -1
  283. package/dist/validate.d.ts +1 -2
  284. package/dist/validate.d.ts.map +1 -1
  285. package/dist/validate.js.map +1 -1
  286. package/dist/validation-attributes.d.cts +17 -8
  287. package/dist/validation-attributes.d.cts.map +1 -1
  288. package/dist/validation-attributes.d.ts +17 -8
  289. package/dist/validation-attributes.d.ts.map +1 -1
  290. package/dist/webhook.cjs +5 -4
  291. package/dist/webhook.cjs.map +1 -1
  292. package/dist/webhook.d.cts +4 -4
  293. package/dist/webhook.d.cts.map +1 -1
  294. package/dist/webhook.d.ts +4 -4
  295. package/dist/webhook.d.ts.map +1 -1
  296. package/dist/webhook.js +5 -4
  297. package/dist/webhook.js.map +1 -1
  298. package/dist/workflow-distributed.cjs +5 -5
  299. package/dist/workflow-distributed.cjs.map +1 -1
  300. package/dist/workflow-distributed.d.cts +25 -15
  301. package/dist/workflow-distributed.d.cts.map +1 -1
  302. package/dist/workflow-distributed.d.ts +25 -15
  303. package/dist/workflow-distributed.d.ts.map +1 -1
  304. package/dist/workflow-distributed.js +5 -5
  305. package/dist/workflow-distributed.js.map +1 -1
  306. package/dist/workflow.cjs +24 -30
  307. package/dist/workflow.cjs.map +1 -1
  308. package/dist/workflow.d.cts +11 -6
  309. package/dist/workflow.d.cts.map +1 -1
  310. package/dist/workflow.d.ts +11 -6
  311. package/dist/workflow.d.ts.map +1 -1
  312. package/dist/workflow.js +24 -30
  313. package/dist/workflow.js.map +1 -1
  314. package/dist/yaml-config.d.cts +2 -3
  315. package/dist/yaml-config.d.cts.map +1 -1
  316. package/dist/yaml-config.d.ts +2 -3
  317. package/dist/yaml-config.d.ts.map +1 -1
  318. package/package.json +24 -16
  319. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +0 -1
  320. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +0 -1
  321. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +0 -1
  322. package/dist/canonical-log-line-processor-CcrDi6TO.cjs.map +0 -1
  323. package/dist/canonical-log-line-processor-FLezvFCB.js.map +0 -1
  324. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +0 -1
  325. package/dist/define-event-CreknLm3.d.ts.map +0 -1
  326. package/dist/define-event-HZRizPwz.d.cts.map +0 -1
  327. package/dist/event-BEm5IJ8U.js +0 -761
  328. package/dist/event-BEm5IJ8U.js.map +0 -1
  329. package/dist/event-rzA1X5h3.cjs +0 -778
  330. package/dist/event-rzA1X5h3.cjs.map +0 -1
  331. package/dist/event-subscriber-D1XLkPzi.d.cts.map +0 -1
  332. package/dist/event-subscriber-D1XLkPzi.d.ts.map +0 -1
  333. package/dist/event-testing-BqRnI0z4.d.cts.map +0 -1
  334. package/dist/event-testing-CfFs3to2.d.ts.map +0 -1
  335. package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +0 -1
  336. package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +0 -1
  337. package/dist/functional-CwsPyc4l.cjs +0 -1298
  338. package/dist/functional-CwsPyc4l.cjs.map +0 -1
  339. package/dist/functional-dAYhXQPA.js +0 -1248
  340. package/dist/functional-dAYhXQPA.js.map +0 -1
  341. package/dist/index-Ck06vlW2.d.ts.map +0 -1
  342. package/dist/index-eKuioqT1.d.cts.map +0 -1
  343. package/dist/init-B7u-DjxM.d.ts.map +0 -1
  344. package/dist/init-BvBB45-T.js +0 -1034
  345. package/dist/init-BvBB45-T.js.map +0 -1
  346. package/dist/init-BxJEJ9Tn.cjs +0 -1111
  347. package/dist/init-BxJEJ9Tn.cjs.map +0 -1
  348. package/dist/init-DSrRmVnz.d.cts.map +0 -1
  349. package/dist/logger-BauSUhUv.d.cts.map +0 -1
  350. package/dist/logger-BauSUhUv.d.ts.map +0 -1
  351. package/dist/metric-testing-DXdK3-Q3.d.ts.map +0 -1
  352. package/dist/metric-testing-MxvzChDp.d.cts.map +0 -1
  353. package/dist/operation-context-CKBoA4Qy.js +0 -59
  354. package/dist/operation-context-CKBoA4Qy.js.map +0 -1
  355. package/dist/operation-context-hzKbTKnt.cjs +0 -72
  356. package/dist/operation-context-hzKbTKnt.cjs.map +0 -1
  357. package/dist/sampling-CR0Va1VB.d.ts.map +0 -1
  358. package/dist/sampling-DfYhDJij.d.cts.map +0 -1
  359. package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +0 -1
  360. package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +0 -1
  361. package/dist/trace-context-Cijqoi6e.d.cts.map +0 -1
  362. package/dist/trace-context-Cijqoi6e.d.ts.map +0 -1
  363. package/dist/track-D7O7oIZa.js +0 -1115
  364. package/dist/track-D7O7oIZa.js.map +0 -1
  365. package/dist/track-eovhCJ-I.cjs +0 -1218
  366. package/dist/track-eovhCJ-I.cjs.map +0 -1
  367. package/skills/analyze-traces/SKILL.md +0 -180
  368. package/skills/autotel-core/SKILL.md +0 -159
  369. package/skills/autotel-events/SKILL.md +0 -84
  370. package/skills/autotel-frameworks/SKILL.md +0 -90
  371. package/skills/autotel-instrumentation/SKILL.md +0 -145
  372. package/skills/autotel-request-logging/SKILL.md +0 -94
  373. package/skills/autotel-structured-errors/SKILL.md +0 -125
  374. package/skills/build-audit-trails/SKILL.md +0 -460
  375. package/skills/build-audit-trails/references/audit-queries.md +0 -73
  376. package/skills/build-audit-trails/references/framework-wiring.md +0 -196
  377. package/skills/debug-missing-spans/SKILL.md +0 -250
  378. package/skills/migrate-to-autotel/SKILL.md +0 -269
  379. package/skills/review-otel-patterns/SKILL.md +0 -538
  380. package/skills/review-otel-patterns/references/code-review.md +0 -76
  381. package/skills/review-otel-patterns/references/processor-pipeline.md +0 -205
  382. package/skills/review-otel-patterns/references/structured-errors.md +0 -102
  383. package/skills/review-otel-patterns/references/wide-spans.md +0 -85
  384. package/skills/tune-sampling/SKILL.md +0 -215
@@ -1,1115 +0,0 @@
1
- import { getConfig } from "./config.js";
2
- import { c as isInitialized, d as warnIfNotInitialized, i as getLogger, n as getConfig$1, o as getValidationConfig, r as getEventsConfig } from "./init-BvBB45-T.js";
3
- import { r as recordStructuredError } from "./structured-error-9--cxBay.js";
4
- import { context, propagation, trace } from "@opentelemetry/api";
5
- import * as nodeAsyncHooks from "node:async_hooks";
6
-
7
- //#region src/rate-limiter.ts
8
- /**
9
- * Token bucket rate limiter
10
- *
11
- * Allows bursts up to burstCapacity, then smooths to maxEventsPerSecond.
12
- * Thread-safe for async operations.
13
- */
14
- var TokenBucketRateLimiter = class {
15
- tokens;
16
- maxTokens;
17
- refillRate;
18
- lastRefill;
19
- constructor(config) {
20
- this.maxTokens = config.burstCapacity || config.maxEventsPerSecond * 2;
21
- this.tokens = this.maxTokens;
22
- this.refillRate = config.maxEventsPerSecond / 1e3;
23
- this.lastRefill = Date.now();
24
- }
25
- /**
26
- * Try to consume a token (allow an event)
27
- * Returns true if allowed, false if rate limit exceeded
28
- */
29
- tryConsume(count = 1) {
30
- this.refill();
31
- if (this.tokens >= count) {
32
- this.tokens -= count;
33
- return true;
34
- }
35
- return false;
36
- }
37
- /**
38
- * Wait until a token is available (async rate limiting)
39
- * Returns a promise that resolves when the event can be processed
40
- */
41
- async waitForToken(count = 1) {
42
- this.refill();
43
- if (this.tokens >= count) {
44
- this.tokens -= count;
45
- return;
46
- }
47
- const tokensNeeded = count - this.tokens;
48
- const waitMs = Math.ceil(tokensNeeded / this.refillRate);
49
- await new Promise((resolve) => setTimeout(resolve, waitMs));
50
- return this.waitForToken(count);
51
- }
52
- /**
53
- * Refill tokens based on elapsed time
54
- */
55
- refill() {
56
- const now = Date.now();
57
- const tokensToAdd = (now - this.lastRefill) * this.refillRate;
58
- this.tokens = Math.min(this.maxTokens, this.tokens + tokensToAdd);
59
- this.lastRefill = now;
60
- }
61
- /**
62
- * Get current available tokens (for testing/debugging)
63
- */
64
- getAvailableTokens() {
65
- this.refill();
66
- return Math.floor(this.tokens);
67
- }
68
- /**
69
- * Reset the rate limiter (for testing)
70
- */
71
- reset() {
72
- this.tokens = this.maxTokens;
73
- this.lastRefill = Date.now();
74
- }
75
- };
76
-
77
- //#endregion
78
- //#region src/trace-context.ts
79
- /**
80
- * AsyncLocalStorage for storing the active context with baggage
81
- * This allows setters to update the context and have it persist
82
- */
83
- const contextStorage = new nodeAsyncHooks.AsyncLocalStorage();
84
- /**
85
- * Get the context storage instance (for initialization in functional.ts)
86
- */
87
- function getContextStorage() {
88
- return contextStorage;
89
- }
90
- /**
91
- * Get the active context, checking our stored context first
92
- * This ensures baggage setters work with OpenTelemetry's propagation
93
- */
94
- function getActiveContextWithBaggage() {
95
- return contextStorage.getStore()?.value ?? context.active();
96
- }
97
- /**
98
- * Set a value in AsyncLocalStorage, preferring enterWith() when available
99
- * (Node.js) and falling back to run() for environments that only support
100
- * run() (e.g. Cloudflare Workers).
101
- *
102
- * On runtimes without enterWith() we mutate the existing run() scope when one
103
- * exists. This is what allows baggage/correlation updates to remain visible
104
- * for the rest of the traced callback in Workers.
105
- */
106
- function enterOrRun(storage, value) {
107
- const existingStore = storage.getStore();
108
- if (existingStore) {
109
- existingStore.value = value;
110
- return;
111
- }
112
- const boxedValue = { value };
113
- try {
114
- storage.enterWith(boxedValue);
115
- } catch {
116
- storage.run(boxedValue, () => {});
117
- }
118
- }
119
- function updateActiveContext(newContext) {
120
- enterOrRun(contextStorage, newContext);
121
- const manager = context._getContextManager?.();
122
- if (!manager) return;
123
- const asyncLocal = manager._asyncLocalStorage ?? void 0;
124
- if (asyncLocal?.enterWith) {
125
- asyncLocal.enterWith(newContext);
126
- return;
127
- }
128
- if (typeof manager.with === "function") manager.with(newContext, () => {});
129
- }
130
- /**
131
- * Create a TraceContext from an OpenTelemetry Span
132
- *
133
- * This utility extracts trace context information from a span
134
- * and provides span manipulation methods and baggage operations in a consistent format.
135
- *
136
- * Note: Baggage methods always operate on the currently active context,
137
- * which may differ from the context when createTraceContext was called.
138
- */
139
- function createTraceContext(span) {
140
- const spanContext = span.spanContext();
141
- if (!contextStorage.getStore()?.value) {
142
- const activeContext = context.active();
143
- enterOrRun(contextStorage, activeContext);
144
- }
145
- const traceCtx = {
146
- traceId: spanContext.traceId,
147
- spanId: spanContext.spanId,
148
- correlationId: spanContext.traceId.slice(0, 16),
149
- setAttribute: span.setAttribute.bind(span),
150
- setAttributes: span.setAttributes.bind(span),
151
- setStatus: span.setStatus.bind(span),
152
- recordException: span.recordException.bind(span),
153
- addEvent: span.addEvent.bind(span),
154
- addLink: span.addLink.bind(span),
155
- addLinks: span.addLinks.bind(span),
156
- updateName: span.updateName.bind(span),
157
- isRecording: span.isRecording.bind(span),
158
- recordError: (error) => {
159
- const err = error instanceof Error ? error : new Error(String(error));
160
- recordStructuredError(traceCtx, err);
161
- },
162
- track: (event, data) => {
163
- track(event, data);
164
- },
165
- getBaggage(key) {
166
- const activeCtx = context.active();
167
- let baggage = propagation.getBaggage(activeCtx);
168
- if (!baggage) {
169
- const storedContext = contextStorage.getStore()?.value;
170
- if (storedContext) baggage = propagation.getBaggage(storedContext);
171
- }
172
- return baggage?.getEntry(key)?.value;
173
- },
174
- setBaggage(key, value) {
175
- const activeCtx = context.active();
176
- const currentContext = contextStorage.getStore()?.value ?? activeCtx;
177
- const updated = (propagation.getBaggage(currentContext) ?? propagation.createBaggage()).setEntry(key, { value });
178
- updateActiveContext(propagation.setBaggage(currentContext, updated));
179
- return value;
180
- },
181
- deleteBaggage(key) {
182
- const activeCtx = context.active();
183
- const currentContext = contextStorage.getStore()?.value ?? activeCtx;
184
- const baggage = propagation.getBaggage(currentContext);
185
- if (baggage) {
186
- const updated = baggage.removeEntry(key);
187
- updateActiveContext(propagation.setBaggage(currentContext, updated));
188
- }
189
- },
190
- getAllBaggage() {
191
- const activeCtx = context.active();
192
- let baggage = propagation.getBaggage(activeCtx);
193
- if (!baggage) {
194
- const storedContext = contextStorage.getStore()?.value;
195
- if (storedContext) baggage = propagation.getBaggage(storedContext);
196
- }
197
- if (!baggage) return /* @__PURE__ */ new Map();
198
- const entries = /* @__PURE__ */ new Map();
199
- for (const [key, entry] of baggage.getAllEntries()) entries.set(key, entry);
200
- return entries;
201
- },
202
- getTypedBaggage: ((namespace) => {
203
- const activeCtx = context.active();
204
- let baggage = propagation.getBaggage(activeCtx);
205
- if (!baggage) {
206
- const storedContext = contextStorage.getStore()?.value;
207
- if (storedContext) baggage = propagation.getBaggage(storedContext);
208
- }
209
- if (!baggage) return;
210
- const prefix = namespace ? `${namespace}.` : "";
211
- const result = {};
212
- for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix)) {
213
- const fieldName = key.slice(prefix.length);
214
- result[fieldName] = entry.value;
215
- } else if (!namespace) result[key] = entry.value;
216
- return Object.keys(result).length > 0 ? result : void 0;
217
- }),
218
- setTypedBaggage: ((namespace, value) => {
219
- const activeCtx = context.active();
220
- const currentContext = contextStorage.getStore()?.value ?? activeCtx;
221
- let baggage = propagation.getBaggage(currentContext) ?? propagation.createBaggage();
222
- const prefix = namespace ? `${namespace}.` : "";
223
- for (const [key, val] of Object.entries(value)) if (val !== void 0) {
224
- const baggageKey = `${prefix}${key}`;
225
- baggage = baggage.setEntry(baggageKey, { value: String(val) });
226
- }
227
- updateActiveContext(propagation.setBaggage(currentContext, baggage));
228
- })
229
- };
230
- return traceCtx;
231
- }
232
- /**
233
- * Define a typed baggage schema for type-safe baggage operations
234
- *
235
- * This helper provides a type-safe API for working with baggage entries.
236
- * The namespace parameter is optional and prefixes all keys to avoid collisions.
237
- *
238
- * @template T - The baggage schema type (all fields are treated as optional)
239
- * @param namespace - Optional namespace to prefix baggage keys
240
- *
241
- * @example Basic usage
242
- * ```typescript
243
- * type TenantBaggage = { tenantId: string; region?: string };
244
- * const tenantBaggage = defineBaggageSchema<TenantBaggage>('tenant');
245
- *
246
- * export const handler = trace<TenantBaggage>((ctx) => async () => {
247
- * // Get typed baggage
248
- * const tenant = tenantBaggage.get(ctx);
249
- * if (tenant?.tenantId) {
250
- * console.log('Tenant:', tenant.tenantId);
251
- * }
252
- *
253
- * // Set typed baggage
254
- * tenantBaggage.set(ctx, { tenantId: 't1', region: 'us-east-1' });
255
- * });
256
- * ```
257
- *
258
- * @example With withBaggage helper
259
- * ```typescript
260
- * const tenantBaggage = defineBaggageSchema<TenantBaggage>('tenant');
261
- *
262
- * export const handler = trace<TenantBaggage>((ctx) => async () => {
263
- * return await tenantBaggage.with(ctx, { tenantId: 't1' }, async () => {
264
- * // Baggage is available here and in child spans
265
- * const tenant = tenantBaggage.get(ctx);
266
- * });
267
- * });
268
- * ```
269
- */
270
- function defineBaggageSchema(namespace) {
271
- return {
272
- /**
273
- * Get typed baggage from context
274
- * @param ctx - Trace context
275
- * @returns Partial baggage object or undefined if no baggage is set
276
- */
277
- get: (ctx) => {
278
- if (!ctx.getTypedBaggage) return void 0;
279
- return ctx.getTypedBaggage(namespace);
280
- },
281
- /**
282
- * Set typed baggage in context
283
- *
284
- * Note: For proper scoping across async boundaries, use the `with` method instead
285
- *
286
- * @param ctx - Trace context
287
- * @param value - Partial baggage object to set
288
- */
289
- set: (ctx, value) => {
290
- if (!ctx.setTypedBaggage) return;
291
- ctx.setTypedBaggage(namespace, value);
292
- },
293
- /**
294
- * Run a function with typed baggage properly scoped
295
- *
296
- * This is the recommended way to set baggage as it ensures proper
297
- * scoping across async boundaries.
298
- *
299
- * @param ctx - Trace context (can be omitted, will use active context)
300
- * @param value - Partial baggage object to set
301
- * @param fn - Function to execute with the baggage
302
- */
303
- with: (ctxOrValue, valueOrFn, maybeFn) => {
304
- const value = maybeFn ? valueOrFn : ctxOrValue;
305
- const fn = maybeFn || valueOrFn;
306
- const prefix = namespace ? `${namespace}.` : "";
307
- const flatBaggage = {};
308
- for (const [key, val] of Object.entries(value)) if (val !== void 0) flatBaggage[`${prefix}${key}`] = String(val);
309
- const currentContext = context.active();
310
- let baggage = propagation.getBaggage(currentContext) ?? propagation.createBaggage();
311
- for (const [key, val] of Object.entries(flatBaggage)) baggage = baggage.setEntry(key, { value: val });
312
- const newContext = propagation.setBaggage(currentContext, baggage);
313
- return context.with(newContext, fn);
314
- }
315
- };
316
- }
317
-
318
- //#endregion
319
- //#region src/correlation-id.ts
320
- /**
321
- * Correlation ID utilities for event-driven observability
322
- *
323
- * Provides a stable join key across events, logs, and spans even when traces fragment.
324
- * Format: 16 hex chars (64 bits), crypto-random, URL-safe.
325
- *
326
- * Lifecycle:
327
- * 1. Generated at boundary root (HTTP server span, message process span, cron job span)
328
- * 2. Reused within context (nested work shares it via AsyncLocalStorage)
329
- * 3. Propagated via baggage (optional, default OFF to avoid header bloat)
330
- *
331
- * @example Basic usage
332
- * ```typescript
333
- * import { generateCorrelationId, getCorrelationId } from 'autotel/correlation-id';
334
- *
335
- * // Generate a new correlation ID
336
- * const id = generateCorrelationId();
337
- * // Returns: 'a1b2c3d4e5f67890'
338
- *
339
- * // Get current correlation ID from context
340
- * const currentId = getCorrelationId();
341
- * ```
342
- */
343
- /**
344
- * AsyncLocalStorage for storing correlation ID
345
- * This allows correlation IDs to persist across async boundaries
346
- */
347
- const correlationStorage = new nodeAsyncHooks.AsyncLocalStorage();
348
- /**
349
- * Baggage key for correlation ID propagation
350
- */
351
- const CORRELATION_ID_BAGGAGE_KEY = "autotel.correlation_id";
352
- /**
353
- * Generate a new correlation ID
354
- *
355
- * Format: 16 hex chars (64 bits), crypto-random, URL-safe
356
- *
357
- * @returns A new correlation ID
358
- *
359
- * @example
360
- * ```typescript
361
- * const id = generateCorrelationId();
362
- * // Returns: 'a1b2c3d4e5f67890'
363
- * ```
364
- */
365
- function generateCorrelationId() {
366
- const bytes = /* @__PURE__ */ new Uint8Array(8);
367
- crypto.getRandomValues(bytes);
368
- return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
369
- }
370
- /**
371
- * Get the current correlation ID from context
372
- *
373
- * Resolution order:
374
- * 1. AsyncLocalStorage (from explicit setCorrelationId or runWithCorrelationId)
375
- * 2. Baggage (if propagated from upstream)
376
- * 3. Active span's trace ID (first 16 chars as fallback)
377
- * 4. undefined (if not in any context)
378
- *
379
- * @returns Current correlation ID or undefined
380
- *
381
- * @example
382
- * ```typescript
383
- * const id = getCorrelationId();
384
- * if (id) {
385
- * console.log('Correlation ID:', id);
386
- * }
387
- * ```
388
- */
389
- function getCorrelationId() {
390
- const storedId = correlationStorage.getStore()?.value;
391
- if (storedId) return storedId;
392
- const activeContext = context.active();
393
- const baggageEntry = propagation.getBaggage(activeContext)?.getEntry(CORRELATION_ID_BAGGAGE_KEY);
394
- if (baggageEntry?.value) return baggageEntry.value;
395
- const span = trace.getActiveSpan();
396
- if (span) return span.spanContext().traceId.slice(0, 16);
397
- }
398
- /**
399
- * Get or create a correlation ID
400
- *
401
- * If a correlation ID exists in the current context, returns it.
402
- * Otherwise, generates a new one.
403
- *
404
- * @returns Existing or new correlation ID
405
- *
406
- * @example
407
- * ```typescript
408
- * const id = getOrCreateCorrelationId();
409
- * // Always returns a valid correlation ID
410
- * ```
411
- */
412
- function getOrCreateCorrelationId() {
413
- return getCorrelationId() ?? generateCorrelationId();
414
- }
415
- /**
416
- * Run a function with a specific correlation ID in context
417
- *
418
- * The correlation ID will be available via getCorrelationId() throughout
419
- * the execution of the function and any async operations it spawns.
420
- *
421
- * @param correlationId - Correlation ID to use
422
- * @param fn - Function to execute
423
- * @returns The return value of the function
424
- *
425
- * @example
426
- * ```typescript
427
- * await runWithCorrelationId('abc123', async () => {
428
- * // getCorrelationId() returns 'abc123' here
429
- * await processRequest();
430
- * });
431
- * ```
432
- */
433
- function runWithCorrelationId(correlationId, fn) {
434
- return correlationStorage.run({ value: correlationId }, fn);
435
- }
436
- /**
437
- * Set correlation ID in the current context (mutates context)
438
- *
439
- * Note: This updates the AsyncLocalStorage context. For proper scoping
440
- * across async boundaries, prefer runWithCorrelationId() instead.
441
- *
442
- * @param correlationId - Correlation ID to set
443
- *
444
- * @example
445
- * ```typescript
446
- * setCorrelationId('abc123');
447
- * // Now getCorrelationId() returns 'abc123'
448
- * ```
449
- */
450
- function setCorrelationId(correlationId) {
451
- enterOrRun(correlationStorage, correlationId);
452
- }
453
- /**
454
- * Set correlation ID in baggage for propagation
455
- *
456
- * This adds the correlation ID to the W3C baggage header, allowing it
457
- * to be propagated to downstream services.
458
- *
459
- * Note: Only use this when you explicitly want cross-service propagation.
460
- * Default is OFF to avoid header bloat.
461
- *
462
- * @param correlationId - Correlation ID to propagate
463
- * @returns New context with baggage set
464
- *
465
- * @example
466
- * ```typescript
467
- * const newContext = setCorrelationIdInBaggage('abc123');
468
- * context.with(newContext, () => {
469
- * // Baggage will be propagated in outgoing requests
470
- * });
471
- * ```
472
- */
473
- function setCorrelationIdInBaggage(correlationId) {
474
- const activeContext = context.active();
475
- let baggage = propagation.getBaggage(activeContext) ?? propagation.createBaggage();
476
- baggage = baggage.setEntry(CORRELATION_ID_BAGGAGE_KEY, { value: correlationId });
477
- return propagation.setBaggage(activeContext, baggage);
478
- }
479
- /**
480
- * Get the correlation storage instance (for internal use in init/shutdown)
481
- */
482
- function getCorrelationStorage() {
483
- return correlationStorage;
484
- }
485
-
486
- //#endregion
487
- //#region src/event-queue.ts
488
- const DEFAULT_CONFIG$1 = {
489
- maxSize: 5e4,
490
- batchSize: 100,
491
- flushInterval: 1e4,
492
- maxRetries: 3,
493
- rateLimit: {
494
- maxEventsPerSecond: 100,
495
- burstCapacity: 200
496
- }
497
- };
498
- /**
499
- * Get subscriber name for metrics (stable, low-cardinality)
500
- *
501
- * Priority:
502
- * 1. Explicit config: subscriber.name
503
- * 2. Class static property (if available)
504
- * 3. Fallback: lowercase class name without "Subscriber" suffix
505
- */
506
- function getSubscriberName(subscriber) {
507
- if (subscriber.name) return subscriber.name.toLowerCase();
508
- return (subscriber.constructor?.name || "unknown").replace(/Subscriber$/i, "").toLowerCase();
509
- }
510
- /**
511
- * Events queue with batching and backpressure
512
- *
513
- * Features:
514
- * - Batches events for efficient sending
515
- * - Bounded queue with drop-oldest policy (prod) or blocking (dev)
516
- * - Exponential backoff retry
517
- * - Rate limiting to prevent overwhelming subscribers
518
- * - Graceful flush on shutdown
519
- */
520
- var EventQueue = class {
521
- queue = [];
522
- flushTimer = null;
523
- config;
524
- subscribers;
525
- rateLimiter;
526
- flushPromise = null;
527
- isShuttingDown = false;
528
- metrics = null;
529
- observableCleanups = [];
530
- subscriberHealthy = /* @__PURE__ */ new Map();
531
- constructor(subscribers, config) {
532
- this.subscribers = subscribers;
533
- this.config = {
534
- ...DEFAULT_CONFIG$1,
535
- ...config
536
- };
537
- this.rateLimiter = this.config.rateLimit ? new TokenBucketRateLimiter(this.config.rateLimit) : null;
538
- for (const subscriber of subscribers) {
539
- const name = getSubscriberName(subscriber);
540
- this.subscriberHealthy.set(name, true);
541
- }
542
- this.initMetrics();
543
- }
544
- /**
545
- * Initialize OTel metrics for queue observability
546
- */
547
- initMetrics() {
548
- const meter = getConfig().meter;
549
- const queueSize = meter.createObservableGauge("autotel.event_delivery.queue.size", {
550
- description: "Current number of events in the delivery queue",
551
- unit: "count"
552
- });
553
- const queueSizeCallback = (observableResult) => {
554
- observableResult.observe(this.queue.length);
555
- };
556
- queueSize.addCallback(queueSizeCallback);
557
- this.observableCleanups.push(() => queueSize.removeCallback(queueSizeCallback));
558
- const oldestAge = meter.createObservableGauge("autotel.event_delivery.queue.oldest_age_ms", {
559
- description: "Age of the oldest event in the queue in milliseconds",
560
- unit: "ms"
561
- });
562
- const oldestAgeCallback = (observableResult) => {
563
- if (this.queue.length > 0) {
564
- const oldest = this.queue[0];
565
- const ageMs = Date.now() - oldest.timestamp;
566
- observableResult.observe(ageMs);
567
- } else observableResult.observe(0);
568
- };
569
- oldestAge.addCallback(oldestAgeCallback);
570
- this.observableCleanups.push(() => oldestAge.removeCallback(oldestAgeCallback));
571
- const delivered = meter.createCounter("autotel.event_delivery.queue.delivered", {
572
- description: "Number of events successfully delivered to subscribers",
573
- unit: "count"
574
- });
575
- const failed = meter.createCounter("autotel.event_delivery.queue.failed", {
576
- description: "Number of events that failed delivery after all retry attempts",
577
- unit: "count"
578
- });
579
- const dropped = meter.createCounter("autotel.event_delivery.queue.dropped", {
580
- description: "Number of events dropped from the queue",
581
- unit: "count"
582
- });
583
- const latency = meter.createHistogram("autotel.event_delivery.queue.latency_ms", {
584
- description: "Event delivery latency from enqueue to successful send",
585
- unit: "ms"
586
- });
587
- const subscriberHealth = meter.createObservableGauge("autotel.event_delivery.subscriber.health", {
588
- description: "Subscriber health status (1=healthy, 0=unhealthy)",
589
- unit: "1"
590
- });
591
- const subscriberHealthCallback = (observableResult) => {
592
- for (const [subscriberName, isHealthy] of this.subscriberHealthy) observableResult.observe(isHealthy ? 1 : 0, { subscriber: subscriberName });
593
- };
594
- subscriberHealth.addCallback(subscriberHealthCallback);
595
- this.observableCleanups.push(() => subscriberHealth.removeCallback(subscriberHealthCallback));
596
- this.metrics = {
597
- queueSize,
598
- oldestAge,
599
- delivered,
600
- failed,
601
- dropped,
602
- latency,
603
- subscriberHealth
604
- };
605
- }
606
- /**
607
- * Record a dropped event with reason and emit debug breadcrumb
608
- */
609
- recordDropped(reason, event, subscriberName) {
610
- const attrs = { reason };
611
- if (subscriberName) attrs.subscriber = subscriberName;
612
- this.metrics?.dropped.add(1, attrs);
613
- const logLevel = reason === "payload_invalid" ? "error" : "warn";
614
- const logger = getLogger();
615
- if (logLevel === "error") logger.error({
616
- eventName: event?.name,
617
- subscriber: subscriberName,
618
- reason,
619
- correlationId: event?._correlationId,
620
- traceId: event?._traceId
621
- }, `[autotel] Event dropped: ${reason}`);
622
- else logger.warn({
623
- eventName: event?.name,
624
- subscriber: subscriberName,
625
- reason,
626
- correlationId: event?._correlationId,
627
- traceId: event?._traceId
628
- }, `[autotel] Event dropped: ${reason}`);
629
- }
630
- /**
631
- * Record permanent delivery failure (after all retries exhausted)
632
- * Increments failed counter and logs error
633
- */
634
- recordFailed(event, subscriberName, error) {
635
- this.metrics?.failed.add(1, { subscriber: subscriberName });
636
- this.subscriberHealthy.set(subscriberName, false);
637
- getLogger().error({
638
- eventName: event.name,
639
- subscriber: subscriberName,
640
- correlationId: event._correlationId,
641
- traceId: event._traceId,
642
- err: error
643
- }, `[autotel] Event delivery failed after all retries`);
644
- }
645
- /**
646
- * Mark subscriber as unhealthy on transient failure (without incrementing failed counter)
647
- * Used during retry attempts - only recordFailed should increment the counter
648
- */
649
- markSubscriberUnhealthy(subscriberName) {
650
- this.subscriberHealthy.set(subscriberName, false);
651
- }
652
- /**
653
- * Record successful delivery
654
- */
655
- recordDelivered(event, subscriberName, startTime) {
656
- const latencyMs = Date.now() - startTime;
657
- this.metrics?.delivered.add(1, { subscriber: subscriberName });
658
- this.metrics?.latency.record(latencyMs, { subscriber: subscriberName });
659
- this.subscriberHealthy.set(subscriberName, true);
660
- }
661
- /**
662
- * Enqueue an event for sending
663
- *
664
- * Backpressure policy:
665
- * - Drops oldest event and logs warning if queue is full (same behavior in all environments)
666
- */
667
- enqueue(event) {
668
- if (this.isShuttingDown) {
669
- this.recordDropped("shutdown", event);
670
- return;
671
- }
672
- if (this.queue.length >= this.config.maxSize) {
673
- const droppedEvent = this.queue.shift();
674
- this.recordDropped("rate_limit", droppedEvent);
675
- getLogger().warn({ droppedEvent: droppedEvent?.name }, `[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.`);
676
- }
677
- const enrichedEvent = {
678
- ...event,
679
- _correlationId: event._correlationId || getOrCreateCorrelationId()
680
- };
681
- this.queue.push(enrichedEvent);
682
- this.scheduleBatchFlush();
683
- }
684
- /**
685
- * Schedule a batch flush if not already scheduled
686
- */
687
- scheduleBatchFlush() {
688
- if (this.flushTimer || this.flushPromise) return;
689
- this.flushTimer = setTimeout(() => {
690
- this.flushTimer = null;
691
- this.flushBatch();
692
- }, this.config.flushInterval);
693
- }
694
- /**
695
- * Flush a batch of events
696
- * Uses promise-based concurrency control to prevent race conditions
697
- */
698
- async flushBatch() {
699
- if (this.queue.length === 0) return;
700
- if (this.flushPromise) {
701
- await this.flushPromise;
702
- return;
703
- }
704
- this.flushPromise = this.doFlushBatch();
705
- try {
706
- await this.flushPromise;
707
- } finally {
708
- this.flushPromise = null;
709
- if (this.queue.length > 0) this.scheduleBatchFlush();
710
- }
711
- }
712
- /**
713
- * Internal flush implementation
714
- */
715
- async doFlushBatch() {
716
- const batch = this.queue.splice(0, this.config.batchSize);
717
- await this.sendWithRetry(batch, this.config.maxRetries);
718
- }
719
- /**
720
- * Send events with exponential backoff retry
721
- * Tracks per-event, per-subscriber failures so failed counter reflects actual failed deliveries.
722
- * On retry, only failed (event, subscriber) pairs are re-sent to avoid double-counting delivered.
723
- */
724
- async sendWithRetry(events, retriesLeft, subscribersByEventIndex) {
725
- const failedDeliveries = await this.sendToSubscribers(events, subscribersByEventIndex);
726
- if (failedDeliveries.length > 0) if (retriesLeft > 0) {
727
- const failedEventIndicesOrdered = [...new Set(failedDeliveries.map((f) => f.eventIndex))].sort((a, b) => a - b);
728
- const eventsToRetry = failedEventIndicesOrdered.map((i) => events[i]);
729
- const failedSubscribersByRetryIndex = /* @__PURE__ */ new Map();
730
- for (let j = 0; j < failedEventIndicesOrdered.length; j++) {
731
- const origIndex = failedEventIndicesOrdered[j];
732
- const set = /* @__PURE__ */ new Set();
733
- for (const { eventIndex, subscriberName } of failedDeliveries) if (eventIndex === origIndex) set.add(subscriberName);
734
- failedSubscribersByRetryIndex.set(j, set);
735
- }
736
- const delay = Math.pow(2, this.config.maxRetries - retriesLeft) * 1e3;
737
- await new Promise((resolve) => setTimeout(resolve, delay));
738
- return this.sendWithRetry(eventsToRetry, retriesLeft - 1, failedSubscribersByRetryIndex);
739
- } else {
740
- for (const { eventIndex, subscriberName, error } of failedDeliveries) {
741
- const event = events[eventIndex];
742
- if (event) this.recordFailed(event, subscriberName, error);
743
- }
744
- const failedSubscriberNames = [...new Set(failedDeliveries.map((f) => f.subscriberName))];
745
- getLogger().error({
746
- failedSubscribers: failedSubscriberNames,
747
- retriesAttempted: this.config.maxRetries
748
- }, "[autotel] Failed to send events after retries");
749
- }
750
- }
751
- /**
752
- * Send events to configured subscribers with rate limiting and metrics.
753
- * When subscribersByEventIndex is provided (retry path), only those subscribers are tried per event.
754
- * Returns per-event, per-subscriber failures (empty if all succeeded).
755
- */
756
- async sendToSubscribers(events, subscribersByEventIndex) {
757
- const failedDeliveries = [];
758
- const sendOne = async (event, eventIndex) => {
759
- const subscriberNames = subscribersByEventIndex?.get(eventIndex);
760
- const failures = await this.sendEventToSubscribers(event, subscriberNames ?? void 0);
761
- for (const failure of failures) failedDeliveries.push({
762
- eventIndex,
763
- subscriberName: failure.subscriberName,
764
- error: failure.error
765
- });
766
- };
767
- if (!this.rateLimiter) {
768
- for (let i = 0; i < events.length; i++) {
769
- const event = events[i];
770
- if (event) await sendOne(event, i);
771
- }
772
- return failedDeliveries;
773
- }
774
- for (let i = 0; i < events.length; i++) {
775
- await this.rateLimiter.waitForToken();
776
- const event = events[i];
777
- if (event) await sendOne(event, i);
778
- }
779
- return failedDeliveries;
780
- }
781
- /**
782
- * Send a single event to subscribers.
783
- * - When subscriberNames is undefined (initial attempt): send to all subscribers.
784
- * - When subscriberNames is provided (retry): send only to those subscribers (never re-send to healthy ones).
785
- * Returns list of subscribers that failed (empty if all succeeded).
786
- */
787
- async sendEventToSubscribers(event, subscriberNames) {
788
- const startTime = event.timestamp;
789
- const failures = [];
790
- const subscribersToTry = subscriberNames === void 0 ? this.subscribers : this.subscribers.filter((s) => subscriberNames.has(getSubscriberName(s)));
791
- const results = await Promise.allSettled(subscribersToTry.map(async (subscriber) => {
792
- const subscriberName = getSubscriberName(subscriber);
793
- try {
794
- await subscriber.trackEvent(event.name, event.attributes, {
795
- autotel: event.autotel,
796
- schema: event.schema
797
- });
798
- this.recordDelivered(event, subscriberName, startTime);
799
- return {
800
- subscriberName,
801
- success: true
802
- };
803
- } catch (error) {
804
- this.markSubscriberUnhealthy(subscriberName);
805
- return {
806
- subscriberName,
807
- success: false,
808
- error: error instanceof Error ? error : void 0
809
- };
810
- }
811
- }));
812
- for (const result of results) if (result.status === "fulfilled" && !result.value.success) failures.push({
813
- subscriberName: result.value.subscriberName,
814
- error: result.value.error
815
- });
816
- return failures;
817
- }
818
- /**
819
- * Flush all remaining events. Queue remains usable after flush (e.g. for
820
- * auto-flush at root span end). Use shutdown() when tearing down the queue.
821
- */
822
- async flush() {
823
- if (this.flushTimer) {
824
- clearTimeout(this.flushTimer);
825
- this.flushTimer = null;
826
- }
827
- if (this.flushPromise) await this.flushPromise;
828
- while (this.queue.length > 0) await this.doFlushBatch();
829
- }
830
- /**
831
- * Flush remaining events and permanently disable the queue (reject new events).
832
- * Use for process/SDK shutdown; use flush() for periodic or span-end drain.
833
- */
834
- async shutdown() {
835
- this.isShuttingDown = true;
836
- await this.flush();
837
- }
838
- /**
839
- * Cleanup observable metric callbacks to prevent memory leaks
840
- * Call this when destroying the EventQueue instance
841
- */
842
- cleanup() {
843
- for (const cleanupFn of this.observableCleanups) try {
844
- cleanupFn();
845
- } catch {}
846
- this.observableCleanups = [];
847
- }
848
- /**
849
- * Get queue size (for testing/debugging)
850
- */
851
- size() {
852
- return this.queue.length;
853
- }
854
- /**
855
- * Get subscriber health status (for testing/debugging)
856
- */
857
- getSubscriberHealth() {
858
- return new Map(this.subscriberHealthy);
859
- }
860
- /**
861
- * Check if a specific subscriber is healthy
862
- */
863
- isSubscriberHealthy(subscriberName) {
864
- return this.subscriberHealthy.get(subscriberName.toLowerCase()) ?? true;
865
- }
866
- /**
867
- * Manually mark a subscriber as healthy or unhealthy
868
- * (used for circuit breaker integration)
869
- */
870
- setSubscriberHealth(subscriberName, healthy) {
871
- this.subscriberHealthy.set(subscriberName.toLowerCase(), healthy);
872
- }
873
- };
874
-
875
- //#endregion
876
- //#region src/validation.ts
877
- const DEFAULT_CONFIG = {
878
- maxEventNameLength: 100,
879
- maxAttributeKeyLength: 100,
880
- maxAttributeValueLength: 1e3,
881
- maxAttributeCount: 50,
882
- maxNestingDepth: 3,
883
- sensitivePatterns: [
884
- /password/i,
885
- /secret/i,
886
- /token/i,
887
- /api[_-]?key/i,
888
- /access[_-]?key/i,
889
- /private[_-]?key/i,
890
- /auth/i,
891
- /credential/i,
892
- /ssn/i,
893
- /credit[_-]?card/i
894
- ]
895
- };
896
- var ValidationError = class extends Error {
897
- constructor(message) {
898
- super(message);
899
- this.name = "ValidationError";
900
- }
901
- };
902
- /**
903
- * Validate and sanitize event name
904
- * Throws ValidationError if invalid
905
- */
906
- function validateEventName(eventName, config = DEFAULT_CONFIG) {
907
- if (typeof eventName !== "string") throw new ValidationError(`Event name must be a string, got ${typeof eventName}`);
908
- const trimmed = eventName.trim();
909
- if (trimmed.length === 0) throw new ValidationError("Event name cannot be empty");
910
- if (trimmed.length > config.maxEventNameLength) throw new ValidationError(`Event name too long (${trimmed.length} chars). Max: ${config.maxEventNameLength}`);
911
- if (!/^[a-zA-Z0-9._-]+$/.test(trimmed)) throw new ValidationError(`Event name contains invalid characters: "${trimmed}". Use only letters, numbers, dots, underscores, and hyphens.`);
912
- return trimmed;
913
- }
914
- /**
915
- * Validate and sanitize attributes
916
- * Returns sanitized attributes (sensitive data redacted)
917
- */
918
- function validateAttributes(attributes, config = DEFAULT_CONFIG) {
919
- if (attributes === void 0 || attributes === null) return;
920
- if (typeof attributes !== "object" || Array.isArray(attributes)) throw new ValidationError("Attributes must be an object");
921
- const keys = Object.keys(attributes);
922
- if (keys.length > config.maxAttributeCount) throw new ValidationError(`Too many attributes (${keys.length}). Max: ${config.maxAttributeCount}`);
923
- const sanitized = {};
924
- for (const key of keys) {
925
- if (key.length > config.maxAttributeKeyLength) throw new ValidationError(`Attribute key too long: "${key.slice(0, 20)}..." (${key.length} chars). Max: ${config.maxAttributeKeyLength}`);
926
- const value = attributes[key];
927
- if (typeof value === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key))) {
928
- sanitized[key] = "[REDACTED]";
929
- continue;
930
- }
931
- sanitized[key] = sanitizeValue(value, config, 1);
932
- }
933
- return sanitized;
934
- }
935
- /**
936
- * Sanitize attribute value (recursive)
937
- */
938
- function sanitizeValue(value, config, depth) {
939
- if (depth > config.maxNestingDepth) return "[MAX_DEPTH_EXCEEDED]";
940
- if (value === null || value === void 0) return value;
941
- if (typeof value === "string") {
942
- if (value.length > config.maxAttributeValueLength) return value.slice(0, config.maxAttributeValueLength) + "...";
943
- return value;
944
- }
945
- if (typeof value === "number" || typeof value === "boolean") return value;
946
- if (Array.isArray(value)) return value.map((item) => sanitizeValue(item, config, depth + 1));
947
- if (typeof value === "object") try {
948
- JSON.stringify(value);
949
- const sanitized = {};
950
- for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) {
951
- const nested = value[key];
952
- sanitized[key] = typeof nested === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key)) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
953
- }
954
- return sanitized;
955
- } catch {
956
- return "[CIRCULAR]";
957
- }
958
- return `[${typeof value}]`;
959
- }
960
- /**
961
- * Validate and sanitize an events event
962
- * Returns { eventName, attributes } with sanitized values
963
- */
964
- function validateEvent(eventName, attributes, config) {
965
- const fullConfig = {
966
- ...DEFAULT_CONFIG,
967
- ...config
968
- };
969
- return {
970
- eventName: validateEventName(eventName, fullConfig),
971
- attributes: validateAttributes(attributes, fullConfig)
972
- };
973
- }
974
-
975
- //#endregion
976
- //#region src/track.ts
977
- /**
978
- * Global track() function for business events
979
- *
980
- * Simple, no instantiation needed, auto-attaches trace context
981
- */
982
- let eventsQueue = null;
983
- /**
984
- * Build autotel event context for trace correlation
985
- *
986
- * Works in multiple contexts:
987
- * 1. Inside a span → use current span's trace_id + span_id
988
- * 2. Outside span → use correlation_id only
989
- * 3. With trace URL config → include clickable trace URL
990
- */
991
- function buildAutotelContext(span) {
992
- const eventsConfig = getEventsConfig();
993
- const config = getConfig$1();
994
- const correlationId = getOrCreateCorrelationId();
995
- if (!eventsConfig?.includeTraceContext) return { correlation_id: correlationId };
996
- const autotelContext = { correlation_id: correlationId };
997
- const spanContext = span?.spanContext();
998
- if (spanContext) {
999
- autotelContext.trace_id = spanContext.traceId;
1000
- autotelContext.span_id = spanContext.spanId;
1001
- autotelContext.trace_flags = spanContext.traceFlags.toString(16).padStart(2, "0");
1002
- const traceState = spanContext.traceState;
1003
- if (traceState) try {
1004
- if (typeof traceState.serialize === "function") {
1005
- const traceStateStr = traceState.serialize();
1006
- if (traceStateStr) autotelContext.trace_state = traceStateStr;
1007
- }
1008
- } catch {}
1009
- if (eventsConfig.traceUrl && config) {
1010
- const traceUrl = eventsConfig.traceUrl({
1011
- traceId: spanContext.traceId,
1012
- spanId: spanContext.spanId,
1013
- correlationId,
1014
- serviceName: config.service,
1015
- environment: config.environment
1016
- });
1017
- if (traceUrl) autotelContext.trace_url = traceUrl;
1018
- }
1019
- } else if (eventsConfig.traceUrl && config) {
1020
- const traceUrl = eventsConfig.traceUrl({
1021
- correlationId,
1022
- serviceName: config.service,
1023
- environment: config.environment
1024
- });
1025
- if (traceUrl) autotelContext.trace_url = traceUrl;
1026
- }
1027
- return autotelContext;
1028
- }
1029
- /**
1030
- * Initialize events queue lazily
1031
- */
1032
- function getOrCreateQueue() {
1033
- if (!isInitialized()) {
1034
- warnIfNotInitialized("track()");
1035
- return null;
1036
- }
1037
- if (!eventsQueue) {
1038
- const config = getConfig$1();
1039
- if (!config?.subscribers || config.subscribers.length === 0) return null;
1040
- eventsQueue = new EventQueue(config.subscribers);
1041
- }
1042
- return eventsQueue;
1043
- }
1044
- /**
1045
- * Track a business events event
1046
- *
1047
- * Features:
1048
- * - Auto-attaches traceId and spanId if in active span
1049
- * - Batched sending with retry
1050
- * - Type-safe with optional generic
1051
- * - No-op if init() not called or no subscribers configured
1052
- *
1053
- * @example Basic usage
1054
- * ```typescript
1055
- * track('user.signup', { userId: '123', plan: 'pro' })
1056
- * ```
1057
- *
1058
- * @example With type safety
1059
- * ```typescript
1060
- * interface EventDatas {
1061
- * 'user.signup': { userId: string; plan: string }
1062
- * 'plan.upgraded': { userId: string; revenue: number }
1063
- * }
1064
- *
1065
- * track<EventDatas>('user.signup', { userId: '123', plan: 'pro' })
1066
- * ```
1067
- *
1068
- * @example Trace correlation (automatic)
1069
- * ```typescript
1070
- * @Instrumented()
1071
- * class UserService {
1072
- * async createUser(data: CreateUserData) {
1073
- * // This track call automatically includes traceId + spanId
1074
- * track('user.signup', { userId: data.id })
1075
- * }
1076
- * }
1077
- * ```
1078
- */
1079
- function track(event, data, options) {
1080
- const queue = getOrCreateQueue();
1081
- if (!queue) return;
1082
- const validated = validateEvent(event, data, getValidationConfig() || void 0);
1083
- const span = trace.getActiveSpan();
1084
- const enrichedData = span ? {
1085
- ...validated.attributes,
1086
- traceId: span.spanContext().traceId,
1087
- spanId: span.spanContext().spanId
1088
- } : validated.attributes;
1089
- const autotelContext = buildAutotelContext(span);
1090
- queue.enqueue({
1091
- name: validated.eventName,
1092
- attributes: enrichedData,
1093
- timestamp: Date.now(),
1094
- autotel: autotelContext,
1095
- schema: options?.schema
1096
- });
1097
- }
1098
- /**
1099
- * Get events queue (for flush/shutdown)
1100
- * @internal
1101
- */
1102
- function getEventQueue() {
1103
- return eventsQueue;
1104
- }
1105
- /**
1106
- * Reset events queue (for shutdown/cleanup)
1107
- * @internal
1108
- */
1109
- function resetEventQueue() {
1110
- eventsQueue = null;
1111
- }
1112
-
1113
- //#endregion
1114
- export { getContextStorage as _, CORRELATION_ID_BAGGAGE_KEY as a, getCorrelationStorage as c, setCorrelationId as d, setCorrelationIdInBaggage as f, getActiveContextWithBaggage as g, enterOrRun as h, validateEvent as i, getOrCreateCorrelationId as l, defineBaggageSchema as m, resetEventQueue as n, generateCorrelationId as o, createTraceContext as p, track as r, getCorrelationId as s, getEventQueue as t, runWithCorrelationId as u };
1115
- //# sourceMappingURL=track-D7O7oIZa.js.map