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
@@ -0,0 +1,888 @@
1
+ const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
2
+ const require_tracer_provider = require('./tracer-provider.cjs');
3
+ const require_config = require('./config.cjs');
4
+ const require_sampling = require('./sampling.cjs');
5
+ const require_init = require('./init-C3RApHKJ.cjs');
6
+ const require_trace_helpers = require('./trace-helpers.cjs');
7
+ let _opentelemetry_api = require("@opentelemetry/api");
8
+ let node_fs = require("node:fs");
9
+ node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
10
+ let node_url = require("node:url");
11
+ node_url = require_rolldown_runtime.__toESM(node_url, 1);
12
+
13
+ //#region src/variable-name-inference.ts
14
+ /**
15
+ * Variable Name Inference Utility
16
+ *
17
+ * Attempts to infer variable names from const/export const assignments
18
+ * by analyzing the call stack and parsing source code.
19
+ *
20
+ * This is a best-effort approach with graceful degradation - if inference
21
+ * fails for any reason, it returns undefined without breaking the application.
22
+ */
23
+ /**
24
+ * LRU Cache for inferred variable names
25
+ * Key: "file:line" (e.g., "/path/to/file.ts:42")
26
+ * Value: inferred variable name or undefined
27
+ */
28
+ const inferenceCache = /* @__PURE__ */ new Map();
29
+ const MAX_CACHE_SIZE = 50;
30
+ /**
31
+ * Captures the current call stack
32
+ */
33
+ function captureStackTrace() {
34
+ const originalStackTraceLimit = Error.stackTraceLimit;
35
+ Error.stackTraceLimit = 10;
36
+ const stack = (/* @__PURE__ */ new Error("Stack trace capture")).stack || "";
37
+ Error.stackTraceLimit = originalStackTraceLimit;
38
+ return stack;
39
+ }
40
+ /**
41
+ * Parses the stack trace to find where trace() was called
42
+ *
43
+ * Stack trace format (Node.js):
44
+ * at functionName (file:line:column)
45
+ * at file:line:column
46
+ *
47
+ * We skip frames until we find one that's NOT in functional.ts or this file.
48
+ * We also need to skip one additional frame (the trace/span/instrument function itself)
49
+ * to get to the actual user code.
50
+ */
51
+ function parseCallLocation(stack) {
52
+ const lines = stack.split("\n");
53
+ let skippedExternalFrame = false;
54
+ for (const line of lines) {
55
+ if (line.includes("variable-name-inference.ts") || line.includes("variable-name-inference.js") || line.includes("functional.ts") || line.includes("functional.js")) continue;
56
+ const match = line.match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/) || line.match(/^.*?([^:]+):(\d+):(\d+)/);
57
+ if (match) {
58
+ let filePath = match[1].trim();
59
+ if (filePath.startsWith("file://")) try {
60
+ filePath = node_url.fileURLToPath(filePath);
61
+ } catch {
62
+ continue;
63
+ }
64
+ if (!skippedExternalFrame) {
65
+ skippedExternalFrame = true;
66
+ continue;
67
+ }
68
+ return {
69
+ file: filePath,
70
+ line: Number.parseInt(match[2], 10),
71
+ column: Number.parseInt(match[3], 10)
72
+ };
73
+ }
74
+ }
75
+ }
76
+ /**
77
+ * Reads a specific line from a source file
78
+ */
79
+ function readSourceLine(filePath, lineNumber) {
80
+ try {
81
+ if (typeof node_fs.readFileSync !== "function") return;
82
+ return node_fs.readFileSync(filePath, "utf8").split("\n")[lineNumber - 1];
83
+ } catch {
84
+ return;
85
+ }
86
+ }
87
+ /**
88
+ * Extracts variable name from source code line using regex patterns
89
+ *
90
+ * Supported patterns:
91
+ * - const varName = anyFunction(
92
+ * - export const varName = anyFunction(
93
+ * - let varName = anyFunction(
94
+ * - var varName = anyFunction(
95
+ *
96
+ * Note: This won't work with destructuring assignments or complex patterns
97
+ */
98
+ function extractVariableName(sourceLine) {
99
+ const trimmed = sourceLine.trim();
100
+ for (const pattern of [
101
+ /export\s+const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
102
+ /const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
103
+ /export\s+let\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
104
+ /let\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
105
+ /export\s+var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
106
+ /var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/
107
+ ]) {
108
+ const match = trimmed.match(pattern);
109
+ if (match && match[1]) return match[1];
110
+ }
111
+ }
112
+ /**
113
+ * Adds an entry to the cache with LRU eviction
114
+ */
115
+ function cacheInference(key, value) {
116
+ if (inferenceCache.size >= MAX_CACHE_SIZE) {
117
+ const firstKey = inferenceCache.keys().next().value;
118
+ if (firstKey) inferenceCache.delete(firstKey);
119
+ }
120
+ inferenceCache.set(key, value);
121
+ }
122
+ /**
123
+ * Main entry point: Attempts to infer the variable name from the call stack
124
+ *
125
+ * This function:
126
+ * 1. Captures the call stack
127
+ * 2. Parses it to find where trace() was called (file + line)
128
+ * 3. Reads that line from the source file
129
+ * 4. Extracts the variable name using regex
130
+ *
131
+ * Returns undefined if inference fails at any step (graceful degradation).
132
+ * Results are cached to avoid repeated file I/O.
133
+ *
134
+ * @returns The inferred variable name, or undefined if inference failed
135
+ */
136
+ function inferVariableNameFromCallStack() {
137
+ try {
138
+ const callLocation = parseCallLocation(captureStackTrace());
139
+ if (!callLocation) return;
140
+ const cacheKey = `${callLocation.file}:${callLocation.line}`;
141
+ if (inferenceCache.has(cacheKey)) return inferenceCache.get(cacheKey);
142
+ const sourceLine = readSourceLine(callLocation.file, callLocation.line);
143
+ if (!sourceLine) return;
144
+ const variableName = extractVariableName(sourceLine);
145
+ cacheInference(cacheKey, variableName);
146
+ return variableName;
147
+ } catch {
148
+ return;
149
+ }
150
+ }
151
+
152
+ //#endregion
153
+ //#region src/functional.ts
154
+ /**
155
+ * Functional API for non-class code
156
+ *
157
+ * Three approaches for different use cases:
158
+ * 1. trace() - Zero-ceremony HOF for single functions
159
+ * 2. withTracing() - Middleware-style composable wrapper
160
+ * 3. instrument() - Batch auto-instrumentation for modules
161
+ *
162
+ * @example trace() - Single function
163
+ * ```typescript
164
+ * export const createUser = trace(async (data) => {
165
+ * getActiveTraceContext()?.setAttribute('user.id', data.id)
166
+ * return await db.users.create(data)
167
+ * })
168
+ * ```
169
+ *
170
+ * @example withTracing() - Composable middleware
171
+ * ```typescript
172
+ * export const createUser = withTracing({
173
+ * name: 'user.create'
174
+ * })(ctx => async (data) => {
175
+ * ctx.setAttribute('user.id', data.id)
176
+ * return await db.users.create(data)
177
+ * })
178
+ * ```
179
+ *
180
+ * @example instrument() - Batch instrumentation
181
+ * ```typescript
182
+ * export default instrument({
183
+ * createUser: async (data) => { },
184
+ * updateUser: async (id, data) => { }
185
+ * }, { serviceName: 'user' })
186
+ * ```
187
+ */
188
+ let unknownSpanNameWarningEmitted = false;
189
+ function resolveVariableName(named, variableName) {
190
+ const suppliedFunctionName = inferFunctionName(named);
191
+ const callStackVariableName = suppliedFunctionName ? void 0 : inferVariableNameFromCallStack();
192
+ return variableName || suppliedFunctionName || callStackVariableName;
193
+ }
194
+ /**
195
+ * Wrap an explicit context factory `(ctx) => (...args) => result`.
196
+ * Used by {@link withTracing}; the input is a factory by contract, so there is
197
+ * no plain-vs-factory detection. The factory is never invoked at construction
198
+ * time — only when the wrapper is called.
199
+ */
200
+ function wrapFactoryWithTracing(factory, options, variableName) {
201
+ return wrapWithTracingSync(factory, options, resolveVariableName(factory, variableName));
202
+ }
203
+ /**
204
+ * Wrap a plain function `(...args) => result`. Used by {@link trace} and
205
+ * {@link instrument}: the function receives its real arguments and no context
206
+ * is injected. Reach the active span via {@link getActiveTraceContext} inside
207
+ * the body (or any helper it calls).
208
+ */
209
+ function wrapPlainWithTracing(fn, options, variableName) {
210
+ const effectiveVariableName = resolveVariableName(fn, variableName);
211
+ const factory = (_ctx) => fn;
212
+ return wrapWithTracingSync(factory, options, effectiveVariableName);
213
+ }
214
+ const MAX_ERROR_MESSAGE_LENGTH = 500;
215
+ function createDummyCtx() {
216
+ return {
217
+ traceId: "",
218
+ spanId: "",
219
+ correlationId: "",
220
+ setAttribute: () => {},
221
+ setAttributes: () => {},
222
+ setStatus: () => {},
223
+ recordException: () => {},
224
+ addEvent: () => {},
225
+ addLink: () => {},
226
+ addLinks: () => {},
227
+ updateName: () => {},
228
+ isRecording: () => false,
229
+ getBaggage: () => {},
230
+ setBaggage: () => "",
231
+ deleteBaggage: () => {},
232
+ getAllBaggage: () => /* @__PURE__ */ new Map()
233
+ };
234
+ }
235
+ /** Attribute keys for opt-in function I/O capture (see TracingOptions). */
236
+ const AUTOTEL_INPUT_ATTR = "autotel.input";
237
+ const AUTOTEL_OUTPUT_ATTR = "autotel.output";
238
+ const CAPTURE_MAX_CHARS = 4096;
239
+ /** JSON-serialize a captured value, defensively (truncate, swallow cycles). */
240
+ function serializeCapture(value) {
241
+ if (value === void 0) return void 0;
242
+ try {
243
+ const json = typeof value === "string" ? value : JSON.stringify(value);
244
+ if (json === void 0) return void 0;
245
+ return json.length > CAPTURE_MAX_CHARS ? `${json.slice(0, CAPTURE_MAX_CHARS)}…[truncated]` : json;
246
+ } catch {
247
+ return;
248
+ }
249
+ }
250
+ /** `autotel.input` from args (single arg captured directly, else the array). */
251
+ function captureInputAttrs(args, enabled) {
252
+ if (!enabled) return {};
253
+ const s = serializeCapture(args.length === 1 ? args[0] : args);
254
+ return s === void 0 ? {} : { [AUTOTEL_INPUT_ATTR]: s };
255
+ }
256
+ /** `autotel.output` from the return value. */
257
+ function captureOutputAttrs(result, enabled) {
258
+ if (!enabled) return {};
259
+ const s = serializeCapture(result);
260
+ return s === void 0 ? {} : { [AUTOTEL_OUTPUT_ATTR]: s };
261
+ }
262
+ const INSTRUMENTED_SYMBOL = Symbol.for("autotel.functional.instrumented");
263
+ function hasInstrumentationFlag(value) {
264
+ return (typeof value === "function" || typeof value === "object") && value !== null && Boolean(value[INSTRUMENTED_SYMBOL]);
265
+ }
266
+ /**
267
+ * Truncate error message to prevent span bloat
268
+ */
269
+ function truncateErrorMessage(message) {
270
+ if (message.length <= MAX_ERROR_MESSAGE_LENGTH) return message;
271
+ return `${message.slice(0, MAX_ERROR_MESSAGE_LENGTH)}... (truncated)`;
272
+ }
273
+ /**
274
+ * Terminal handling for a value thrown by a traced function. Shared by all four
275
+ * `trace()` execution paths (immediate + wrapper, sync + async) so the outcome
276
+ * rules live in exactly one place. Ends the span; the caller flushes (await/void)
277
+ * and rethrows.
278
+ *
279
+ * If `isError` classifies the throw as expected control flow — e.g. a framework
280
+ * `redirect()` / `notFound()` signal — it is recorded as a success outcome with
281
+ * an OK status and no exception. Otherwise it is recorded as an error.
282
+ */
283
+ function finalizeThrownSpan(error, isError, ctx) {
284
+ const { span, spanName, duration, callCounter, durationHistogram, handleTailSampling, extraAttributes } = ctx;
285
+ const baseAttributes = {
286
+ ...extraAttributes,
287
+ "operation.name": spanName,
288
+ "code.function": spanName,
289
+ "operation.duration": duration
290
+ };
291
+ if (isError && !isError(error)) {
292
+ callCounter?.add(1, {
293
+ operation: spanName,
294
+ status: "success"
295
+ });
296
+ durationHistogram?.record(duration, {
297
+ operation: spanName,
298
+ status: "success"
299
+ });
300
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
301
+ span.setAttributes({
302
+ ...baseAttributes,
303
+ "operation.success": true
304
+ });
305
+ handleTailSampling(true, duration);
306
+ span.end();
307
+ return;
308
+ }
309
+ callCounter?.add(1, {
310
+ operation: spanName,
311
+ status: "error"
312
+ });
313
+ durationHistogram?.record(duration, {
314
+ operation: spanName,
315
+ status: "error"
316
+ });
317
+ const truncatedMessage = truncateErrorMessage(error instanceof Error ? error.message : "Unknown error");
318
+ span.setStatus({
319
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
320
+ message: truncatedMessage
321
+ });
322
+ span.setAttributes({
323
+ ...baseAttributes,
324
+ "operation.success": false,
325
+ error: true,
326
+ "exception.type": error instanceof Error ? error.constructor.name : "Error",
327
+ "exception.message": truncatedMessage
328
+ });
329
+ if (error instanceof Error && error.stack) span.setAttribute("exception.stack", error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH));
330
+ const thrown = error instanceof Error ? error : new Error(String(error));
331
+ span.recordException(thrown);
332
+ handleTailSampling(false, duration, thrown);
333
+ span.end();
334
+ }
335
+ /**
336
+ * Try to infer function name from function properties
337
+ * Checks for displayName, name, or other metadata that might be set
338
+ */
339
+ function inferFunctionName(fn) {
340
+ const displayName = fn.displayName;
341
+ if (displayName) return displayName;
342
+ if (fn.name && fn.name !== "anonymous" && fn.name !== "") return fn.name;
343
+ const match = Function.prototype.toString.call(fn).match(/function\s+([^(\s]+)/);
344
+ if (match && match[1] && match[1] !== "anonymous") return match[1];
345
+ }
346
+ /**
347
+ * Determine span name using priority:
348
+ * 1. Explicit name option
349
+ * 2. serviceName + functionName
350
+ * 3. Inferred from function/variable name (including stack trace fallback)
351
+ * 4. Fallback to 'unknown'
352
+ */
353
+ function getSpanName(options, fn, variableName) {
354
+ if (options.name) return options.name;
355
+ let fnName = variableName || inferFunctionName(fn);
356
+ fnName = fnName || "anonymous";
357
+ if (options.serviceName) return `${options.serviceName}.${fnName}`;
358
+ if (fnName && fnName !== "anonymous") return fnName;
359
+ const initConfig = require_init.getConfig();
360
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production" && !unknownSpanNameWarningEmitted && initConfig?.logger?.warn) {
361
+ unknownSpanNameWarningEmitted = true;
362
+ initConfig.logger.warn({}, "[autotel] Span name resolved to \"unknown\". Pass an explicit name, for example trace(\"operation.name\", fn).");
363
+ }
364
+ return "unknown";
365
+ }
366
+ /**
367
+ * Check if function should be skipped
368
+ */
369
+ function shouldSkip(key, fn, skip) {
370
+ if (key.startsWith("_")) return true;
371
+ if (!skip || skip.length === 0) return false;
372
+ for (const rule of skip) if (typeof rule === "string" && key === rule) return true;
373
+ else if (rule instanceof RegExp && rule.test(key)) return true;
374
+ else if (typeof rule === "function" && rule(key, fn)) return true;
375
+ return false;
376
+ }
377
+ /**
378
+ * Get current trace context value (internal helper)
379
+ *
380
+ * Returns base context (trace IDs) + span methods from the active span.
381
+ */
382
+ function getCtxValue() {
383
+ const activeSpan = _opentelemetry_api.trace.getActiveSpan();
384
+ if (!activeSpan) return null;
385
+ return require_init.createTraceContext(activeSpan);
386
+ }
387
+ /**
388
+ * Get the autotel {@link TraceContext} for the currently active span.
389
+ *
390
+ * This is the ambient accessor for the functional API: instead of threading a
391
+ * `ctx` parameter through a factory, call this inside any traced function (or a
392
+ * helper it calls) to reach `setAttribute`, `setUser`, `getBaggage`, and the
393
+ * rest of the context surface. Returns `undefined` when no span is active.
394
+ *
395
+ * @example
396
+ * ```typescript
397
+ * const getUser = trace('getUser', async (id: string) => {
398
+ * getActiveTraceContext()?.setAttribute('user.id', id);
399
+ * return db.users.find(id);
400
+ * });
401
+ * ```
402
+ *
403
+ * @see getActiveSpan for the raw OpenTelemetry span
404
+ * @see getRequestLogger which reads the active context when called with no args
405
+ */
406
+ function getActiveTraceContext() {
407
+ return getCtxValue() ?? void 0;
408
+ }
409
+ /**
410
+ * Context object that lazily evaluates the active span on property access
411
+ *
412
+ * Access trace context directly without function call syntax.
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * import { trace, ctx } from 'autotel'
417
+ *
418
+ * export const createUser = trace(async (data) => {
419
+ * // Direct property access - no function call!
420
+ * if (ctx.traceId) {
421
+ * ctx.setAttribute('user.id', data.id)
422
+ * console.log('Trace:', ctx.traceId)
423
+ * }
424
+ * })
425
+ * ```
426
+ */
427
+ const ctx = new Proxy({}, {
428
+ get(_target, prop) {
429
+ const ctxValue = getCtxValue();
430
+ if (!ctxValue) return;
431
+ return ctxValue[prop];
432
+ },
433
+ has(_target, prop) {
434
+ const ctxValue = getCtxValue();
435
+ if (!ctxValue) return false;
436
+ return prop in ctxValue;
437
+ },
438
+ ownKeys() {
439
+ const ctxValue = getCtxValue();
440
+ if (!ctxValue) return [];
441
+ return Object.keys(ctxValue);
442
+ },
443
+ getOwnPropertyDescriptor(_target, prop) {
444
+ const ctxValue = getCtxValue();
445
+ if (!ctxValue) return;
446
+ return Object.getOwnPropertyDescriptor(ctxValue, prop);
447
+ }
448
+ });
449
+ /**
450
+ * Build the root-operation flush policy once and reuse it for wrapped and
451
+ * immediate execution. Async operations await this function; sync operations
452
+ * trigger it without blocking.
453
+ */
454
+ function createRootTelemetryFlusher(options, isRootSpan) {
455
+ const initConfig = require_init.getConfig();
456
+ const shouldFlush = options.flushOnRootSpanEnd ?? initConfig?.flushOnRootSpanEnd ?? true;
457
+ const shouldFlushSpans = initConfig?.forceFlushOnShutdown ?? false;
458
+ return async () => {
459
+ if (!shouldFlush || !isRootSpan) return;
460
+ try {
461
+ const queue = require_init.getEventQueue();
462
+ if (queue && queue.size() > 0) await queue.flush();
463
+ if (shouldFlushSpans) await require_tracer_provider.getForceFlushableProvider(require_init.getSdk())?.forceFlush();
464
+ } catch (error) {
465
+ (require_init.getConfig()?.logger)?.error?.({ err: error instanceof Error ? error : void 0 }, `[autotel] Auto-flush failed${error instanceof Error ? "" : `: ${String(error)}`}`);
466
+ }
467
+ };
468
+ }
469
+ /**
470
+ * Give every root operation its own baggage context without replacing a
471
+ * caller's existing scope. AsyncLocalStorage keeps the scope alive until an
472
+ * async result settles and restores the previous store afterwards.
473
+ */
474
+ function runWithTraceContextStorage(fn) {
475
+ const storage = require_init.getContextStorage();
476
+ if (storage.getStore()) return fn();
477
+ return storage.run({ value: _opentelemetry_api.context.active() }, fn);
478
+ }
479
+ /**
480
+ * Core tracing wrapper for sync functions (internal implementation)
481
+ */
482
+ function wrapWithTracingSync(fnFactory, options, variableName) {
483
+ if (hasInstrumentationFlag(fnFactory)) {}
484
+ const config = require_config.getConfig();
485
+ const tracer = config.tracer;
486
+ const meter = config.meter;
487
+ const sampler = options.sampler || new require_sampling.AlwaysSampler();
488
+ const spanName = getSpanName(options, fnFactory, variableName);
489
+ const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
490
+ description: `Call count for ${spanName}`,
491
+ unit: "1"
492
+ }) : void 0;
493
+ const durationHistogram = options.withMetrics ? meter.createHistogram(`${spanName}.duration`, {
494
+ description: `Duration for ${spanName}`,
495
+ unit: "ms"
496
+ }) : void 0;
497
+ function wrappedFunction(...args) {
498
+ const samplingContext = {
499
+ operationName: spanName,
500
+ args,
501
+ metadata: {}
502
+ };
503
+ const shouldSample = sampler.shouldSample(samplingContext);
504
+ const sampleRate = sampler.sampleRate?.(samplingContext);
505
+ const needsTailSampling = sampler.needsTailSampling?.() ?? false;
506
+ if (!shouldSample && !needsTailSampling) return fnFactory(createDummyCtx()).call(this, ...args);
507
+ const startTime = performance.now();
508
+ const flushRootTelemetry = createRootTelemetryFlusher(options, options.startNewRoot || _opentelemetry_api.trace.getActiveSpan() === void 0);
509
+ const spanOptions = {};
510
+ if (options.startNewRoot) spanOptions.root = true;
511
+ if (options.spanKind !== void 0) spanOptions.kind = options.spanKind;
512
+ const parentContext = require_init.getActiveContextWithBaggage();
513
+ return tracer.startActiveSpan(spanName, spanOptions, parentContext, (span) => {
514
+ return require_init.runInOperationContext(spanName, () => runWithTraceContextStorage(() => {
515
+ let shouldKeepSpan = true;
516
+ require_trace_helpers.setSpanName(span, spanName);
517
+ if (sampleRate !== void 0 && sampleRate > 1) span.setAttribute(require_sampling.AUTOTEL_SAMPLING_RATE, sampleRate);
518
+ const fn = fnFactory(require_init.createTraceContext(span));
519
+ const argsAttributes = {
520
+ ...captureInputAttrs(args, options.captureInput),
521
+ ...options.attributesFromArgs ? options.attributesFromArgs(args) : {}
522
+ };
523
+ const handleTailSampling = (success, duration, error) => {
524
+ if (needsTailSampling && sampler.shouldKeepTrace) {
525
+ shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
526
+ success,
527
+ duration,
528
+ error
529
+ });
530
+ span.setAttribute(require_sampling.AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
531
+ span.setAttribute(require_sampling.AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
532
+ }
533
+ };
534
+ const onSuccess = (result) => {
535
+ const duration = performance.now() - startTime;
536
+ callCounter?.add(1, {
537
+ operation: spanName,
538
+ status: "success"
539
+ });
540
+ durationHistogram?.record(duration, {
541
+ operation: spanName,
542
+ status: "success"
543
+ });
544
+ const resultAttributes = {
545
+ ...captureOutputAttrs(result, options.captureOutput),
546
+ ...options.attributesFromResult ? options.attributesFromResult(result) : {}
547
+ };
548
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
549
+ span.setAttributes({
550
+ ...argsAttributes,
551
+ ...resultAttributes,
552
+ "operation.name": spanName,
553
+ "code.function": spanName,
554
+ "operation.duration": duration,
555
+ "operation.success": true
556
+ });
557
+ handleTailSampling(true, duration);
558
+ span.end();
559
+ return result;
560
+ };
561
+ const onError = (error) => {
562
+ finalizeThrownSpan(error, options.isError, {
563
+ span,
564
+ spanName,
565
+ duration: performance.now() - startTime,
566
+ callCounter,
567
+ durationHistogram,
568
+ handleTailSampling,
569
+ extraAttributes: argsAttributes
570
+ });
571
+ throw error;
572
+ };
573
+ try {
574
+ callCounter?.add(1, {
575
+ operation: spanName,
576
+ status: "started"
577
+ });
578
+ const result = _opentelemetry_api.context.with(require_init.getActiveContextWithBaggage(), () => fn.call(this, ...args));
579
+ if (result instanceof Promise) return result.then(async (value) => {
580
+ const completed = onSuccess(value);
581
+ await flushRootTelemetry();
582
+ return completed;
583
+ }, async (error) => {
584
+ try {
585
+ return onError(error);
586
+ } finally {
587
+ await flushRootTelemetry();
588
+ }
589
+ });
590
+ const completed = onSuccess(result);
591
+ flushRootTelemetry();
592
+ return completed;
593
+ } catch (error) {
594
+ try {
595
+ return onError(error);
596
+ } finally {
597
+ flushRootTelemetry();
598
+ }
599
+ }
600
+ }));
601
+ });
602
+ }
603
+ wrappedFunction[INSTRUMENTED_SYMBOL] = true;
604
+ Object.defineProperty(wrappedFunction, "name", {
605
+ value: variableName || "trace",
606
+ configurable: true
607
+ });
608
+ return wrappedFunction;
609
+ }
610
+ function trace(fnOrNameOrOptions, maybeFn) {
611
+ if (typeof fnOrNameOrOptions === "function") return wrapPlainWithTracing(fnOrNameOrOptions, {});
612
+ if (!maybeFn) throw new Error("trace(name|options, fn): fn is required");
613
+ return wrapPlainWithTracing(maybeFn, typeof fnOrNameOrOptions === "string" ? { name: fnOrNameOrOptions } : fnOrNameOrOptions);
614
+ }
615
+ /**
616
+ * Approach 2: withTracing() - Middleware-style composable wrapper
617
+ *
618
+ * Returns a HOF that wraps functions with tracing.
619
+ * Perfect for composition and reusable configuration.
620
+ *
621
+ * @example Standard usage
622
+ * ```typescript
623
+ * export const createUser = withTracing({
624
+ * name: 'user.create'
625
+ * })(ctx => async (data) => {
626
+ * ctx.setAttribute('user.id', data.id)
627
+ * return await db.users.create(data)
628
+ * })
629
+ * ```
630
+ *
631
+ * @example Composable
632
+ * ```typescript
633
+ * const tracer = withTracing({ serviceName: 'user' })
634
+ *
635
+ * export const createUser = tracer(ctx => async (data) => { })
636
+ * export const updateUser = tracer(ctx => async (id, data) => { })
637
+ * ```
638
+ *
639
+ * @example With other middleware
640
+ * ```typescript
641
+ * export const createUser = compose(
642
+ * withAuth({ role: 'admin' }),
643
+ * withTracing({ name: 'user.create' }),
644
+ * withRateLimit({ max: 100 })
645
+ * )(ctx => async (data) => { })
646
+ * ```
647
+ */
648
+ function withTracing(options = {}) {
649
+ return (fnFactory) => wrapFactoryWithTracing(fnFactory, options);
650
+ }
651
+ function instrument(options) {
652
+ if (!options || typeof options !== "object") throw new TypeError("instrument: expected { key, fn } or { functions: { name: fn } }");
653
+ if ("key" in options || "fn" in options) {
654
+ const { key, fn, ...tracingOptions } = options;
655
+ if (typeof key !== "string" || key.trim() === "") throw new TypeError("instrument: \"key\" must be a non-empty string in the { key, fn } form");
656
+ if (typeof fn !== "function") throw new TypeError("instrument: \"fn\" must be a function in the { key, fn } form");
657
+ return wrapPlainWithTracing(fn, tracingOptions, key);
658
+ }
659
+ const { functions, ...tracingOptions } = options;
660
+ if (!functions || typeof functions !== "object") throw new TypeError("instrument: expected { key, fn } or { functions: { name: fn } }");
661
+ const instrumented = {};
662
+ for (const key of Object.keys(functions)) {
663
+ const typedKey = key;
664
+ const fn = functions[typedKey];
665
+ if (!fn || typeof fn !== "function") {
666
+ instrumented[typedKey] = fn;
667
+ continue;
668
+ }
669
+ if (shouldSkip(key, fn, tracingOptions.skip)) {
670
+ instrumented[typedKey] = fn;
671
+ continue;
672
+ }
673
+ const fnOptions = {
674
+ ...tracingOptions,
675
+ ...tracingOptions.overrides?.[key],
676
+ name: tracingOptions.overrides?.[key]?.name
677
+ };
678
+ const boundFn = fn.bind(functions);
679
+ const fnFactory = (ctx) => {
680
+ return boundFn;
681
+ };
682
+ instrumented[typedKey] = wrapFactoryWithTracing(fnFactory, fnOptions, key);
683
+ }
684
+ return instrumented;
685
+ }
686
+ function span(nameOrOptions, fn) {
687
+ const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions;
688
+ const tracer = require_config.getConfig().tracer;
689
+ const { name, attributes, spanKind } = options;
690
+ const executeSpan = (span) => {
691
+ return require_init.runInOperationContext(name, () => {
692
+ try {
693
+ if (attributes) for (const [key, value] of Object.entries(attributes)) span.setAttribute(key, value);
694
+ const result = fn(span);
695
+ if (result instanceof Promise) return result.then((resolved) => {
696
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
697
+ span.end();
698
+ return resolved;
699
+ }).catch((error) => {
700
+ const errorMessage = error instanceof Error ? error.message.slice(0, MAX_ERROR_MESSAGE_LENGTH) : String(error).slice(0, MAX_ERROR_MESSAGE_LENGTH);
701
+ span.setAttribute("error.message", errorMessage);
702
+ span.setStatus({
703
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
704
+ message: errorMessage
705
+ });
706
+ span.recordException(error instanceof Error ? error : new Error(String(error)));
707
+ span.end();
708
+ throw error;
709
+ });
710
+ else {
711
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
712
+ span.end();
713
+ return result;
714
+ }
715
+ } catch (error) {
716
+ const errorMessage = error instanceof Error ? error.message.slice(0, MAX_ERROR_MESSAGE_LENGTH) : String(error).slice(0, MAX_ERROR_MESSAGE_LENGTH);
717
+ span.setAttribute("error.message", errorMessage);
718
+ span.setStatus({
719
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
720
+ message: errorMessage
721
+ });
722
+ span.recordException(error instanceof Error ? error : new Error(String(error)));
723
+ span.end();
724
+ throw error;
725
+ }
726
+ });
727
+ };
728
+ const parentContext = require_init.getActiveContextWithBaggage();
729
+ const result = tracer.startActiveSpan(name, spanKind === void 0 ? {} : { kind: spanKind }, parentContext, executeSpan);
730
+ if (result instanceof Promise) return result;
731
+ return result;
732
+ }
733
+ /**
734
+ * Execute a function in a new root context (prevents span propagation)
735
+ *
736
+ * Useful when you want to start a completely new trace without
737
+ * parent-child relationships.
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * async function handleWebhook(payload: WebhookPayload) {
742
+ * // This creates a new root trace, not connected to the HTTP request trace
743
+ * await withNewContext({
744
+ * fn: async () => {
745
+ * await span('webhook.process', async () => {
746
+ * await processWebhookPayload(payload)
747
+ * })
748
+ * }
749
+ * })
750
+ * }
751
+ * ```
752
+ */
753
+ async function withNewContext(options) {
754
+ const { fn } = options;
755
+ return require_config.getConfig().tracer.startActiveSpan("root", { root: true }, async (span) => {
756
+ try {
757
+ const result = await fn();
758
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
759
+ return result;
760
+ } catch (error) {
761
+ span.recordException(error instanceof Error ? error : new Error(String(error)));
762
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
763
+ throw error;
764
+ } finally {
765
+ span.end();
766
+ }
767
+ });
768
+ }
769
+ /**
770
+ * Execute a function with updated baggage entries
771
+ *
772
+ * Baggage is immutable in OpenTelemetry, so this helper creates a new context
773
+ * with the specified baggage entries and runs the function within that context.
774
+ * All child spans created within the function will inherit the baggage.
775
+ *
776
+ * @example Setting baggage for downstream services
777
+ * ```typescript
778
+ * import { withTracing, withBaggage } from 'autotel';
779
+ *
780
+ * export const createOrder = withTracing({ name: 'order.create' })((ctx) => async (order: Order) => {
781
+ * // Set baggage that will be propagated to downstream HTTP calls
782
+ * return await withBaggage({
783
+ * baggage: {
784
+ * 'tenant.id': order.tenantId,
785
+ * 'user.id': order.userId,
786
+ * },
787
+ * fn: async () => {
788
+ * // This HTTP call will include the baggage in headers
789
+ * await fetch('/api/charge', {
790
+ * method: 'POST',
791
+ * body: JSON.stringify(order),
792
+ * });
793
+ * },
794
+ * });
795
+ * });
796
+ * ```
797
+ *
798
+ * @example Using with existing baggage
799
+ * ```typescript
800
+ * export const processOrder = withTracing({ name: 'order.process' })((ctx) => async (order: Order) => {
801
+ * // Read existing baggage
802
+ * const tenantId = ctx.getBaggage('tenant.id');
803
+ *
804
+ * // Add additional baggage entries
805
+ * return await withBaggage({
806
+ * baggage: {
807
+ * 'order.id': order.id,
808
+ * 'order.amount': String(order.amount),
809
+ * },
810
+ * fn: async () => {
811
+ * await charge(order);
812
+ * },
813
+ * });
814
+ * });
815
+ * ```
816
+ */
817
+ function withBaggage(options) {
818
+ const { baggage: baggageEntries, fn } = options;
819
+ const currentContext = _opentelemetry_api.context.active();
820
+ let updatedBaggage = _opentelemetry_api.propagation.getBaggage(currentContext) ?? _opentelemetry_api.propagation.createBaggage();
821
+ for (const [key, value] of Object.entries(baggageEntries)) updatedBaggage = updatedBaggage.setEntry(key, { value });
822
+ const newContext = _opentelemetry_api.propagation.setBaggage(currentContext, updatedBaggage);
823
+ const ctxStorage = require_init.getContextStorage();
824
+ const previousStored = ctxStorage.getStore();
825
+ const baggageEnrichedStored = previousStored ? { value: _opentelemetry_api.propagation.setBaggage(previousStored.value, updatedBaggage) } : { value: newContext };
826
+ const result = previousStored ? ctxStorage.run(baggageEnrichedStored, () => _opentelemetry_api.context.with(newContext, fn)) : _opentelemetry_api.context.with(newContext, fn);
827
+ if (result instanceof Promise) return result.then((value) => {
828
+ if (previousStored) return ctxStorage.run(previousStored, () => value);
829
+ return value;
830
+ }, (error) => {
831
+ if (previousStored) return ctxStorage.run(previousStored, () => {
832
+ throw error;
833
+ });
834
+ throw error;
835
+ });
836
+ return result;
837
+ }
838
+
839
+ //#endregion
840
+ Object.defineProperty(exports, 'ctx', {
841
+ enumerable: true,
842
+ get: function () {
843
+ return ctx;
844
+ }
845
+ });
846
+ Object.defineProperty(exports, 'getActiveTraceContext', {
847
+ enumerable: true,
848
+ get: function () {
849
+ return getActiveTraceContext;
850
+ }
851
+ });
852
+ Object.defineProperty(exports, 'instrument', {
853
+ enumerable: true,
854
+ get: function () {
855
+ return instrument;
856
+ }
857
+ });
858
+ Object.defineProperty(exports, 'span', {
859
+ enumerable: true,
860
+ get: function () {
861
+ return span;
862
+ }
863
+ });
864
+ Object.defineProperty(exports, 'trace', {
865
+ enumerable: true,
866
+ get: function () {
867
+ return trace;
868
+ }
869
+ });
870
+ Object.defineProperty(exports, 'withBaggage', {
871
+ enumerable: true,
872
+ get: function () {
873
+ return withBaggage;
874
+ }
875
+ });
876
+ Object.defineProperty(exports, 'withNewContext', {
877
+ enumerable: true,
878
+ get: function () {
879
+ return withNewContext;
880
+ }
881
+ });
882
+ Object.defineProperty(exports, 'withTracing', {
883
+ enumerable: true,
884
+ get: function () {
885
+ return withTracing;
886
+ }
887
+ });
888
+ //# sourceMappingURL=functional-DcLBuCPz.cjs.map