autotel 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (591) hide show
  1. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts +175 -0
  2. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +1 -0
  3. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts +175 -0
  4. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +1 -0
  5. package/dist/attribute-redacting-processor.cjs +374 -33
  6. package/dist/attribute-redacting-processor.cjs.map +1 -1
  7. package/dist/attribute-redacting-processor.d.cts +2 -207
  8. package/dist/attribute-redacting-processor.d.ts +2 -207
  9. package/dist/attribute-redacting-processor.js +368 -2
  10. package/dist/attribute-redacting-processor.js.map +1 -1
  11. package/dist/attributes-D3etyRVc.cjs +713 -0
  12. package/dist/attributes-D3etyRVc.cjs.map +1 -0
  13. package/dist/attributes-ksn4HVbd.js +600 -0
  14. package/dist/attributes-ksn4HVbd.js.map +1 -0
  15. package/dist/attributes.cjs +21 -85
  16. package/dist/attributes.d.cts +2 -20
  17. package/dist/attributes.d.ts +2 -20
  18. package/dist/attributes.js +3 -5
  19. package/dist/auto.cjs +50 -28
  20. package/dist/auto.cjs.map +1 -1
  21. package/dist/auto.d.cts +1 -2
  22. package/dist/auto.d.ts +1 -2
  23. package/dist/auto.js +49 -23
  24. package/dist/auto.js.map +1 -1
  25. package/dist/business-baggage.cjs +357 -13
  26. package/dist/business-baggage.cjs.map +1 -1
  27. package/dist/business-baggage.d.cts +106 -139
  28. package/dist/business-baggage.d.cts.map +1 -0
  29. package/dist/business-baggage.d.ts +106 -139
  30. package/dist/business-baggage.d.ts.map +1 -0
  31. package/dist/business-baggage.js +357 -2
  32. package/dist/business-baggage.js.map +1 -1
  33. package/dist/canonical-log-line-processor--RlFDHhm.cjs +377 -0
  34. package/dist/canonical-log-line-processor--RlFDHhm.cjs.map +1 -0
  35. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts +147 -0
  36. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +1 -0
  37. package/dist/canonical-log-line-processor-DbBQT5vY.js +366 -0
  38. package/dist/canonical-log-line-processor-DbBQT5vY.js.map +1 -0
  39. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts +147 -0
  40. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +1 -0
  41. package/dist/config.cjs +118 -22
  42. package/dist/config.cjs.map +1 -1
  43. package/dist/config.d.cts +33 -45
  44. package/dist/config.d.cts.map +1 -0
  45. package/dist/config.d.ts +33 -45
  46. package/dist/config.d.ts.map +1 -0
  47. package/dist/config.js +116 -3
  48. package/dist/config.js.map +1 -1
  49. package/dist/correlated-events-Bzh5y-UB.js +28 -0
  50. package/dist/correlated-events-Bzh5y-UB.js.map +1 -0
  51. package/dist/correlated-events-kSwLo3mi.cjs +34 -0
  52. package/dist/correlated-events-kSwLo3mi.cjs.map +1 -0
  53. package/dist/correlation-id.cjs +11 -53
  54. package/dist/correlation-id.d.cts +6 -5
  55. package/dist/correlation-id.d.cts.map +1 -0
  56. package/dist/correlation-id.d.ts +6 -5
  57. package/dist/correlation-id.d.ts.map +1 -0
  58. package/dist/correlation-id.js +3 -16
  59. package/dist/db.cjs +244 -209
  60. package/dist/db.cjs.map +1 -1
  61. package/dist/db.d.cts +28 -26
  62. package/dist/db.d.cts.map +1 -0
  63. package/dist/db.d.ts +28 -26
  64. package/dist/db.d.ts.map +1 -0
  65. package/dist/db.js +243 -207
  66. package/dist/db.js.map +1 -1
  67. package/dist/decorators.cjs +39 -65
  68. package/dist/decorators.cjs.map +1 -1
  69. package/dist/decorators.d.cts +10 -37
  70. package/dist/decorators.d.cts.map +1 -0
  71. package/dist/decorators.d.ts +10 -37
  72. package/dist/decorators.d.ts.map +1 -0
  73. package/dist/decorators.js +38 -63
  74. package/dist/decorators.js.map +1 -1
  75. package/dist/define-event-CreknLm3.d.ts +25 -0
  76. package/dist/define-event-CreknLm3.d.ts.map +1 -0
  77. package/dist/define-event-HZRizPwz.d.cts +25 -0
  78. package/dist/define-event-HZRizPwz.d.cts.map +1 -0
  79. package/dist/drain-pipeline.cjs +111 -9
  80. package/dist/drain-pipeline.cjs.map +1 -1
  81. package/dist/drain-pipeline.d.cts +27 -32
  82. package/dist/drain-pipeline.d.cts.map +1 -0
  83. package/dist/drain-pipeline.d.ts +27 -32
  84. package/dist/drain-pipeline.d.ts.map +1 -0
  85. package/dist/drain-pipeline.js +111 -2
  86. package/dist/drain-pipeline.js.map +1 -1
  87. package/dist/enrichers.cjs +59 -66
  88. package/dist/enrichers.cjs.map +1 -1
  89. package/dist/enrichers.d.cts +15 -13
  90. package/dist/enrichers.d.cts.map +1 -0
  91. package/dist/enrichers.d.ts +15 -13
  92. package/dist/enrichers.d.ts.map +1 -0
  93. package/dist/enrichers.js +58 -65
  94. package/dist/enrichers.js.map +1 -1
  95. package/dist/event-Dlqr4ZNL.cjs +778 -0
  96. package/dist/event-Dlqr4ZNL.cjs.map +1 -0
  97. package/dist/event-_58ryBjh.js +761 -0
  98. package/dist/event-_58ryBjh.js.map +1 -0
  99. package/dist/event-subscriber-D1XLkPzi.d.cts +223 -0
  100. package/dist/event-subscriber-D1XLkPzi.d.cts.map +1 -0
  101. package/dist/event-subscriber-D1XLkPzi.d.ts +223 -0
  102. package/dist/event-subscriber-D1XLkPzi.d.ts.map +1 -0
  103. package/dist/event-subscriber.cjs +0 -6
  104. package/dist/event-subscriber.d.cts +2 -221
  105. package/dist/event-subscriber.d.ts +2 -221
  106. package/dist/event-subscriber.js +1 -3
  107. package/dist/event-testing-BqRnI0z4.d.cts +106 -0
  108. package/dist/event-testing-BqRnI0z4.d.cts.map +1 -0
  109. package/dist/event-testing-CfFs3to2.d.ts +106 -0
  110. package/dist/event-testing-CfFs3to2.d.ts.map +1 -0
  111. package/dist/event-testing.cjs +93 -17
  112. package/dist/event-testing.cjs.map +1 -1
  113. package/dist/event-testing.d.cts +2 -110
  114. package/dist/event-testing.d.ts +2 -110
  115. package/dist/event-testing.js +91 -2
  116. package/dist/event-testing.js.map +1 -1
  117. package/dist/event.cjs +5 -36
  118. package/dist/event.d.cts +295 -340
  119. package/dist/event.d.cts.map +1 -0
  120. package/dist/event.d.ts +295 -340
  121. package/dist/event.d.ts.map +1 -0
  122. package/dist/event.js +3 -20
  123. package/dist/exporters.cjs +12 -16
  124. package/dist/exporters.d.cts +86 -111
  125. package/dist/exporters.d.cts.map +1 -0
  126. package/dist/exporters.d.ts +86 -111
  127. package/dist/exporters.d.ts.map +1 -0
  128. package/dist/exporters.js +4 -4
  129. package/dist/filtering-span-processor-B8R8B7Uk.d.cts +59 -0
  130. package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +1 -0
  131. package/dist/filtering-span-processor-B8R8B7Uk.d.ts +59 -0
  132. package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +1 -0
  133. package/dist/filtering-span-processor.cjs +49 -9
  134. package/dist/filtering-span-processor.cjs.map +1 -1
  135. package/dist/filtering-span-processor.d.cts +2 -80
  136. package/dist/filtering-span-processor.d.ts +2 -80
  137. package/dist/filtering-span-processor.js +49 -2
  138. package/dist/filtering-span-processor.js.map +1 -1
  139. package/dist/functional-BGkT8J-h.js +1265 -0
  140. package/dist/functional-BGkT8J-h.js.map +1 -0
  141. package/dist/functional-C4CzoVrX.cjs +1312 -0
  142. package/dist/functional-C4CzoVrX.cjs.map +1 -0
  143. package/dist/functional.cjs +11 -56
  144. package/dist/functional.d.cts +96 -97
  145. package/dist/functional.d.cts.map +1 -0
  146. package/dist/functional.d.ts +96 -97
  147. package/dist/functional.d.ts.map +1 -0
  148. package/dist/functional.js +3 -19
  149. package/dist/http.cjs +276 -175
  150. package/dist/http.cjs.map +1 -1
  151. package/dist/http.d.cts +17 -37
  152. package/dist/http.d.cts.map +1 -0
  153. package/dist/http.d.ts +17 -37
  154. package/dist/http.d.ts.map +1 -0
  155. package/dist/http.js +275 -173
  156. package/dist/http.js.map +1 -1
  157. package/dist/index-CX0aG1Uh.d.ts +708 -0
  158. package/dist/index-CX0aG1Uh.d.ts.map +1 -0
  159. package/dist/index-DIWZFKUS.d.cts +708 -0
  160. package/dist/index-DIWZFKUS.d.cts.map +1 -0
  161. package/dist/index.cjs +1050 -1184
  162. package/dist/index.cjs.map +1 -1
  163. package/dist/index.d.cts +401 -570
  164. package/dist/index.d.cts.map +1 -0
  165. package/dist/index.d.ts +401 -570
  166. package/dist/index.d.ts.map +1 -0
  167. package/dist/index.js +913 -725
  168. package/dist/index.js.map +1 -1
  169. package/dist/init-CNp-ee80.d.cts +1157 -0
  170. package/dist/init-CNp-ee80.d.cts.map +1 -0
  171. package/dist/init-Ch6t7MNI.js +1015 -0
  172. package/dist/init-Ch6t7MNI.js.map +1 -0
  173. package/dist/init-DJQOdVlN.d.ts +1157 -0
  174. package/dist/init-DJQOdVlN.d.ts.map +1 -0
  175. package/dist/init-DvapOXCc.cjs +1092 -0
  176. package/dist/init-DvapOXCc.cjs.map +1 -0
  177. package/dist/instrumentation.cjs +159 -185
  178. package/dist/instrumentation.cjs.map +1 -1
  179. package/dist/instrumentation.d.cts +42 -40
  180. package/dist/instrumentation.d.cts.map +1 -0
  181. package/dist/instrumentation.d.ts +42 -40
  182. package/dist/instrumentation.d.ts.map +1 -0
  183. package/dist/instrumentation.js +158 -183
  184. package/dist/instrumentation.js.map +1 -1
  185. package/dist/logger-BauSUhUv.d.cts +313 -0
  186. package/dist/logger-BauSUhUv.d.cts.map +1 -0
  187. package/dist/logger-BauSUhUv.d.ts +313 -0
  188. package/dist/logger-BauSUhUv.d.ts.map +1 -0
  189. package/dist/logger.cjs +225 -25
  190. package/dist/logger.cjs.map +1 -1
  191. package/dist/logger.d.cts +2 -348
  192. package/dist/logger.d.ts +2 -348
  193. package/dist/logger.js +204 -4
  194. package/dist/logger.js.map +1 -1
  195. package/dist/messaging-adapters.cjs +292 -187
  196. package/dist/messaging-adapters.cjs.map +1 -1
  197. package/dist/messaging-adapters.d.cts +28 -66
  198. package/dist/messaging-adapters.d.cts.map +1 -0
  199. package/dist/messaging-adapters.d.ts +28 -66
  200. package/dist/messaging-adapters.d.ts.map +1 -0
  201. package/dist/messaging-adapters.js +291 -185
  202. package/dist/messaging-adapters.js.map +1 -1
  203. package/dist/messaging-testing.cjs +306 -372
  204. package/dist/messaging-testing.cjs.map +1 -1
  205. package/dist/messaging-testing.d.cts +194 -223
  206. package/dist/messaging-testing.d.cts.map +1 -0
  207. package/dist/messaging-testing.d.ts +194 -223
  208. package/dist/messaging-testing.d.ts.map +1 -0
  209. package/dist/messaging-testing.js +305 -371
  210. package/dist/messaging-testing.js.map +1 -1
  211. package/dist/messaging.cjs +757 -35
  212. package/dist/messaging.cjs.map +1 -1
  213. package/dist/messaging.d.cts +603 -644
  214. package/dist/messaging.d.cts.map +1 -0
  215. package/dist/messaging.d.ts +603 -644
  216. package/dist/messaging.d.ts.map +1 -0
  217. package/dist/messaging.js +756 -20
  218. package/dist/messaging.js.map +1 -1
  219. package/dist/metric-helpers.cjs +27 -27
  220. package/dist/metric-helpers.cjs.map +1 -1
  221. package/dist/metric-helpers.d.cts +4 -2
  222. package/dist/metric-helpers.d.cts.map +1 -0
  223. package/dist/metric-helpers.d.ts +4 -2
  224. package/dist/metric-helpers.d.ts.map +1 -0
  225. package/dist/metric-helpers.js +24 -4
  226. package/dist/metric-helpers.js.map +1 -1
  227. package/dist/metric-testing-DXdK3-Q3.d.ts +106 -0
  228. package/dist/metric-testing-DXdK3-Q3.d.ts.map +1 -0
  229. package/dist/metric-testing-MxvzChDp.d.cts +106 -0
  230. package/dist/metric-testing-MxvzChDp.d.cts.map +1 -0
  231. package/dist/metric-testing.cjs +93 -17
  232. package/dist/metric-testing.cjs.map +1 -1
  233. package/dist/metric-testing.d.cts +2 -110
  234. package/dist/metric-testing.d.ts +2 -110
  235. package/dist/metric-testing.js +91 -2
  236. package/dist/metric-testing.js.map +1 -1
  237. package/dist/metric.cjs +306 -22
  238. package/dist/metric.cjs.map +1 -1
  239. package/dist/metric.d.cts +170 -198
  240. package/dist/metric.d.cts.map +1 -0
  241. package/dist/metric.d.ts +170 -198
  242. package/dist/metric.d.ts.map +1 -0
  243. package/dist/metric.js +277 -7
  244. package/dist/metric.js.map +1 -1
  245. package/dist/node-require-DF5QBX6z.cjs +99 -0
  246. package/dist/node-require-DF5QBX6z.cjs.map +1 -0
  247. package/dist/node-require-Db1oDpLj.js +88 -0
  248. package/dist/node-require-Db1oDpLj.js.map +1 -0
  249. package/dist/operation-context-C-2hmmtP.js +59 -0
  250. package/dist/operation-context-C-2hmmtP.js.map +1 -0
  251. package/dist/operation-context-n4_obUwq.cjs +70 -0
  252. package/dist/operation-context-n4_obUwq.cjs.map +1 -0
  253. package/dist/parse-error.cjs +55 -9
  254. package/dist/parse-error.cjs.map +1 -1
  255. package/dist/parse-error.d.cts +12 -10
  256. package/dist/parse-error.d.cts.map +1 -0
  257. package/dist/parse-error.d.ts +12 -10
  258. package/dist/parse-error.d.ts.map +1 -0
  259. package/dist/parse-error.js +55 -2
  260. package/dist/parse-error.js.map +1 -1
  261. package/dist/pretty-console-exporter-CMzlrRNg.cjs +232 -0
  262. package/dist/pretty-console-exporter-CMzlrRNg.cjs.map +1 -0
  263. package/dist/pretty-console-exporter-DqKl_q9z.js +227 -0
  264. package/dist/pretty-console-exporter-DqKl_q9z.js.map +1 -0
  265. package/dist/processors.cjs +13 -17
  266. package/dist/processors.d.cts +3 -171
  267. package/dist/processors.d.ts +3 -171
  268. package/dist/processors.js +4 -4
  269. package/dist/register.cjs +35 -6
  270. package/dist/register.cjs.map +1 -1
  271. package/dist/register.d.cts +1 -2
  272. package/dist/register.d.ts +1 -2
  273. package/dist/register.js +36 -3
  274. package/dist/register.js.map +1 -1
  275. package/dist/registry-DfXA3R1L.js +184 -0
  276. package/dist/registry-DfXA3R1L.js.map +1 -0
  277. package/dist/registry-JZg2J3RZ.cjs +334 -0
  278. package/dist/registry-JZg2J3RZ.cjs.map +1 -0
  279. package/dist/sampling-CR0Va1VB.d.ts +351 -0
  280. package/dist/sampling-CR0Va1VB.d.ts.map +1 -0
  281. package/dist/sampling-DfYhDJij.d.cts +351 -0
  282. package/dist/sampling-DfYhDJij.d.cts.map +1 -0
  283. package/dist/sampling.cjs +452 -60
  284. package/dist/sampling.cjs.map +1 -1
  285. package/dist/sampling.d.cts +2 -379
  286. package/dist/sampling.d.ts +2 -379
  287. package/dist/sampling.js +441 -5
  288. package/dist/sampling.js.map +1 -1
  289. package/dist/security-schema.cjs +65 -46
  290. package/dist/security-schema.cjs.map +1 -1
  291. package/dist/security-schema.d.cts +23 -26
  292. package/dist/security-schema.d.cts.map +1 -0
  293. package/dist/security-schema.d.ts +23 -26
  294. package/dist/security-schema.d.ts.map +1 -0
  295. package/dist/security-schema.js +64 -45
  296. package/dist/security-schema.js.map +1 -1
  297. package/dist/semantic-conventions-FhSxv-bK.d.cts +32 -0
  298. package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -0
  299. package/dist/semantic-conventions-FhSxv-bK.d.ts +32 -0
  300. package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -0
  301. package/dist/semantic-conventions.cjs +15 -26
  302. package/dist/semantic-conventions.cjs.map +1 -1
  303. package/dist/semantic-conventions.d.cts +2 -29
  304. package/dist/semantic-conventions.d.ts +2 -29
  305. package/dist/semantic-conventions.js +12 -3
  306. package/dist/semantic-conventions.js.map +1 -1
  307. package/dist/semantic-helpers.cjs +440 -38
  308. package/dist/semantic-helpers.cjs.map +1 -1
  309. package/dist/semantic-helpers.d.cts +38 -45
  310. package/dist/semantic-helpers.d.cts.map +1 -0
  311. package/dist/semantic-helpers.d.ts +38 -45
  312. package/dist/semantic-helpers.d.ts.map +1 -0
  313. package/dist/semantic-helpers.js +438 -19
  314. package/dist/semantic-helpers.js.map +1 -1
  315. package/dist/span-name-normalizer-8ZOGJuwv.d.cts +70 -0
  316. package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +1 -0
  317. package/dist/span-name-normalizer-8ZOGJuwv.d.ts +70 -0
  318. package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +1 -0
  319. package/dist/span-name-normalizer.cjs +95 -17
  320. package/dist/span-name-normalizer.cjs.map +1 -1
  321. package/dist/span-name-normalizer.d.cts +2 -94
  322. package/dist/span-name-normalizer.d.ts +2 -94
  323. package/dist/span-name-normalizer.js +93 -2
  324. package/dist/span-name-normalizer.js.map +1 -1
  325. package/dist/stable-hash-BNTMrmdB.cjs +28 -0
  326. package/dist/stable-hash-BNTMrmdB.cjs.map +1 -0
  327. package/dist/stable-hash-Cg5cT34Q.js +23 -0
  328. package/dist/stable-hash-Cg5cT34Q.js.map +1 -0
  329. package/dist/structured-error-9--cxBay.js +143 -0
  330. package/dist/structured-error-9--cxBay.js.map +1 -0
  331. package/dist/structured-error-CHg7DoIQ.cjs +178 -0
  332. package/dist/structured-error-CHg7DoIQ.cjs.map +1 -0
  333. package/dist/tail-sampling-processor.cjs +26 -13
  334. package/dist/tail-sampling-processor.cjs.map +1 -1
  335. package/dist/tail-sampling-processor.d.cts +11 -23
  336. package/dist/tail-sampling-processor.d.cts.map +1 -0
  337. package/dist/tail-sampling-processor.d.ts +11 -23
  338. package/dist/tail-sampling-processor.d.ts.map +1 -0
  339. package/dist/tail-sampling-processor.js +27 -6
  340. package/dist/tail-sampling-processor.js.map +1 -1
  341. package/dist/test-span-collector.cjs +70 -72
  342. package/dist/test-span-collector.cjs.map +1 -1
  343. package/dist/test-span-collector.d.cts +25 -43
  344. package/dist/test-span-collector.d.cts.map +1 -0
  345. package/dist/test-span-collector.d.ts +25 -43
  346. package/dist/test-span-collector.d.ts.map +1 -0
  347. package/dist/test-span-collector.js +69 -70
  348. package/dist/test-span-collector.js.map +1 -1
  349. package/dist/testing.cjs +389 -278
  350. package/dist/testing.cjs.map +1 -1
  351. package/dist/testing.d.cts +39 -62
  352. package/dist/testing.d.cts.map +1 -0
  353. package/dist/testing.d.ts +39 -62
  354. package/dist/testing.d.ts.map +1 -0
  355. package/dist/testing.js +386 -265
  356. package/dist/testing.js.map +1 -1
  357. package/dist/trace-context-Cijqoi6e.d.cts +212 -0
  358. package/dist/trace-context-Cijqoi6e.d.cts.map +1 -0
  359. package/dist/trace-context-Cijqoi6e.d.ts +212 -0
  360. package/dist/trace-context-Cijqoi6e.d.ts.map +1 -0
  361. package/dist/trace-helpers.cjs +634 -54
  362. package/dist/trace-helpers.cjs.map +1 -1
  363. package/dist/trace-helpers.d.cts +17 -49
  364. package/dist/trace-helpers.d.cts.map +1 -0
  365. package/dist/trace-helpers.d.ts +17 -49
  366. package/dist/trace-helpers.d.ts.map +1 -0
  367. package/dist/trace-helpers.js +624 -3
  368. package/dist/trace-helpers.js.map +1 -1
  369. package/dist/tracer-provider.cjs +227 -16
  370. package/dist/tracer-provider.cjs.map +1 -1
  371. package/dist/tracer-provider.d.cts +5 -4
  372. package/dist/tracer-provider.d.cts.map +1 -0
  373. package/dist/tracer-provider.d.ts +5 -4
  374. package/dist/tracer-provider.d.ts.map +1 -0
  375. package/dist/tracer-provider.js +227 -2
  376. package/dist/tracer-provider.js.map +1 -1
  377. package/dist/track-3HY4NGV-.cjs +1212 -0
  378. package/dist/track-3HY4NGV-.cjs.map +1 -0
  379. package/dist/track-nsKVy-pj.js +1111 -0
  380. package/dist/track-nsKVy-pj.js.map +1 -0
  381. package/dist/validate.cjs +201 -0
  382. package/dist/validate.cjs.map +1 -0
  383. package/dist/validate.d.cts +105 -0
  384. package/dist/validate.d.cts.map +1 -0
  385. package/dist/validate.d.ts +105 -0
  386. package/dist/validate.d.ts.map +1 -0
  387. package/dist/validate.js +197 -0
  388. package/dist/validate.js.map +1 -0
  389. package/dist/validation-attributes.cjs +45 -0
  390. package/dist/validation-attributes.cjs.map +1 -0
  391. package/dist/validation-attributes.d.cts +33 -0
  392. package/dist/validation-attributes.d.cts.map +1 -0
  393. package/dist/validation-attributes.d.ts +33 -0
  394. package/dist/validation-attributes.d.ts.map +1 -0
  395. package/dist/validation-attributes.js +41 -0
  396. package/dist/validation-attributes.js.map +1 -0
  397. package/dist/webhook.cjs +286 -255
  398. package/dist/webhook.cjs.map +1 -1
  399. package/dist/webhook.d.cts +157 -192
  400. package/dist/webhook.d.cts.map +1 -0
  401. package/dist/webhook.d.ts +157 -192
  402. package/dist/webhook.d.ts.map +1 -0
  403. package/dist/webhook.js +285 -253
  404. package/dist/webhook.js.map +1 -1
  405. package/dist/workflow-distributed.cjs +498 -411
  406. package/dist/workflow-distributed.cjs.map +1 -1
  407. package/dist/workflow-distributed.d.cts +163 -173
  408. package/dist/workflow-distributed.d.cts.map +1 -0
  409. package/dist/workflow-distributed.d.ts +163 -173
  410. package/dist/workflow-distributed.d.ts.map +1 -0
  411. package/dist/workflow-distributed.js +497 -409
  412. package/dist/workflow-distributed.js.map +1 -1
  413. package/dist/workflow.cjs +405 -39
  414. package/dist/workflow.cjs.map +1 -1
  415. package/dist/workflow.d.cts +78 -131
  416. package/dist/workflow.d.cts.map +1 -0
  417. package/dist/workflow.d.ts +78 -131
  418. package/dist/workflow.d.ts.map +1 -0
  419. package/dist/workflow.js +403 -20
  420. package/dist/workflow.js.map +1 -1
  421. package/dist/yaml-config-B3dQ82GR.cjs +272 -0
  422. package/dist/yaml-config-B3dQ82GR.cjs.map +1 -0
  423. package/dist/yaml-config.cjs +5 -24
  424. package/dist/yaml-config.d.cts +30 -64
  425. package/dist/yaml-config.d.cts.map +1 -0
  426. package/dist/yaml-config.d.ts +30 -64
  427. package/dist/yaml-config.d.ts.map +1 -0
  428. package/dist/yaml-config.js +226 -7
  429. package/dist/yaml-config.js.map +1 -1
  430. package/package.json +14 -4
  431. package/src/define-event.ts +2 -21
  432. package/src/index.ts +3 -0
  433. package/src/request-logger.test.ts +53 -1
  434. package/src/request-logger.ts +58 -0
  435. package/src/stable-hash.ts +27 -0
  436. package/src/validate.test.ts +287 -0
  437. package/src/validate.ts +307 -0
  438. package/src/validation-attributes.ts +43 -0
  439. package/dist/attributes.cjs.map +0 -1
  440. package/dist/attributes.js.map +0 -1
  441. package/dist/chunk-2ZKEORFN.cjs +0 -14
  442. package/dist/chunk-2ZKEORFN.cjs.map +0 -1
  443. package/dist/chunk-3QXBFGKP.js +0 -344
  444. package/dist/chunk-3QXBFGKP.js.map +0 -1
  445. package/dist/chunk-454CH4OV.js +0 -744
  446. package/dist/chunk-454CH4OV.js.map +0 -1
  447. package/dist/chunk-4A53YIAX.js +0 -180
  448. package/dist/chunk-4A53YIAX.js.map +0 -1
  449. package/dist/chunk-4IFSYQVX.js +0 -337
  450. package/dist/chunk-4IFSYQVX.js.map +0 -1
  451. package/dist/chunk-4P6ZOARG.cjs +0 -33
  452. package/dist/chunk-4P6ZOARG.cjs.map +0 -1
  453. package/dist/chunk-55ER2KD5.js +0 -228
  454. package/dist/chunk-55ER2KD5.js.map +0 -1
  455. package/dist/chunk-5ZN622AO.js +0 -73
  456. package/dist/chunk-5ZN622AO.js.map +0 -1
  457. package/dist/chunk-6S5RUKU3.cjs +0 -347
  458. package/dist/chunk-6S5RUKU3.cjs.map +0 -1
  459. package/dist/chunk-6UQRVUN3.js +0 -222
  460. package/dist/chunk-6UQRVUN3.js.map +0 -1
  461. package/dist/chunk-7552UTQW.js +0 -11
  462. package/dist/chunk-7552UTQW.js.map +0 -1
  463. package/dist/chunk-7EQ4G4SI.cjs +0 -146
  464. package/dist/chunk-7EQ4G4SI.cjs.map +0 -1
  465. package/dist/chunk-7SAWIN74.js +0 -285
  466. package/dist/chunk-7SAWIN74.js.map +0 -1
  467. package/dist/chunk-A4E5AQFK.js +0 -30
  468. package/dist/chunk-A4E5AQFK.js.map +0 -1
  469. package/dist/chunk-AC5GNZKB.cjs +0 -344
  470. package/dist/chunk-AC5GNZKB.cjs.map +0 -1
  471. package/dist/chunk-ALPYR2GC.js +0 -1061
  472. package/dist/chunk-ALPYR2GC.js.map +0 -1
  473. package/dist/chunk-BZHG5IZ4.js +0 -73
  474. package/dist/chunk-BZHG5IZ4.js.map +0 -1
  475. package/dist/chunk-CEAQK2QY.cjs +0 -32
  476. package/dist/chunk-CEAQK2QY.cjs.map +0 -1
  477. package/dist/chunk-CMHVQR6P.js +0 -170
  478. package/dist/chunk-CMHVQR6P.js.map +0 -1
  479. package/dist/chunk-CU6IDACR.cjs +0 -224
  480. package/dist/chunk-CU6IDACR.cjs.map +0 -1
  481. package/dist/chunk-DPSA4QLA.js +0 -344
  482. package/dist/chunk-DPSA4QLA.js.map +0 -1
  483. package/dist/chunk-DQEHQNQE.js +0 -795
  484. package/dist/chunk-DQEHQNQE.js.map +0 -1
  485. package/dist/chunk-ESLWRGAG.cjs +0 -92
  486. package/dist/chunk-ESLWRGAG.cjs.map +0 -1
  487. package/dist/chunk-ESMHTKLJ.cjs +0 -206
  488. package/dist/chunk-ESMHTKLJ.cjs.map +0 -1
  489. package/dist/chunk-FGNDN2FD.cjs +0 -1242
  490. package/dist/chunk-FGNDN2FD.cjs.map +0 -1
  491. package/dist/chunk-FU6R566Y.cjs +0 -236
  492. package/dist/chunk-FU6R566Y.cjs.map +0 -1
  493. package/dist/chunk-GBFTC7Q7.cjs +0 -837
  494. package/dist/chunk-GBFTC7Q7.cjs.map +0 -1
  495. package/dist/chunk-GYR5K654.js +0 -91
  496. package/dist/chunk-GYR5K654.js.map +0 -1
  497. package/dist/chunk-HA2WBOGQ.js +0 -57
  498. package/dist/chunk-HA2WBOGQ.js.map +0 -1
  499. package/dist/chunk-HT5JQKN2.js +0 -118
  500. package/dist/chunk-HT5JQKN2.js.map +0 -1
  501. package/dist/chunk-INJD3G4K.cjs +0 -340
  502. package/dist/chunk-INJD3G4K.cjs.map +0 -1
  503. package/dist/chunk-IOYFAFHJ.cjs +0 -95
  504. package/dist/chunk-IOYFAFHJ.cjs.map +0 -1
  505. package/dist/chunk-J5QENANM.js +0 -87
  506. package/dist/chunk-J5QENANM.js.map +0 -1
  507. package/dist/chunk-J7VGRIAJ.js +0 -64
  508. package/dist/chunk-J7VGRIAJ.js.map +0 -1
  509. package/dist/chunk-KFOHQK7X.js +0 -144
  510. package/dist/chunk-KFOHQK7X.js.map +0 -1
  511. package/dist/chunk-KIL5CUN6.js +0 -31
  512. package/dist/chunk-KIL5CUN6.js.map +0 -1
  513. package/dist/chunk-LITNXTTT.js +0 -3
  514. package/dist/chunk-LITNXTTT.js.map +0 -1
  515. package/dist/chunk-M3LFHHTN.cjs +0 -764
  516. package/dist/chunk-M3LFHHTN.cjs.map +0 -1
  517. package/dist/chunk-NEIB3TLD.cjs +0 -360
  518. package/dist/chunk-NEIB3TLD.cjs.map +0 -1
  519. package/dist/chunk-NVAI5CCN.cjs +0 -39
  520. package/dist/chunk-NVAI5CCN.cjs.map +0 -1
  521. package/dist/chunk-NVGPMGI4.js +0 -95
  522. package/dist/chunk-NVGPMGI4.js.map +0 -1
  523. package/dist/chunk-NZ72VDNY.cjs +0 -4
  524. package/dist/chunk-NZ72VDNY.cjs.map +0 -1
  525. package/dist/chunk-O4JZUCUE.js +0 -1174
  526. package/dist/chunk-O4JZUCUE.js.map +0 -1
  527. package/dist/chunk-O7JOKRN2.js +0 -833
  528. package/dist/chunk-O7JOKRN2.js.map +0 -1
  529. package/dist/chunk-OPPXYVEZ.cjs +0 -131
  530. package/dist/chunk-OPPXYVEZ.cjs.map +0 -1
  531. package/dist/chunk-Q4EULJQY.js +0 -35
  532. package/dist/chunk-Q4EULJQY.js.map +0 -1
  533. package/dist/chunk-QWW3E3JM.cjs +0 -178
  534. package/dist/chunk-QWW3E3JM.cjs.map +0 -1
  535. package/dist/chunk-R7QYGZUP.cjs +0 -1075
  536. package/dist/chunk-R7QYGZUP.cjs.map +0 -1
  537. package/dist/chunk-RUPKBKUF.js +0 -352
  538. package/dist/chunk-RUPKBKUF.js.map +0 -1
  539. package/dist/chunk-SEO6NAQT.js +0 -14
  540. package/dist/chunk-SEO6NAQT.js.map +0 -1
  541. package/dist/chunk-T4B5LB6E.cjs +0 -66
  542. package/dist/chunk-T4B5LB6E.cjs.map +0 -1
  543. package/dist/chunk-TC5ZPWM4.cjs +0 -289
  544. package/dist/chunk-TC5ZPWM4.cjs.map +0 -1
  545. package/dist/chunk-TQ5UWA7S.js +0 -26
  546. package/dist/chunk-TQ5UWA7S.js.map +0 -1
  547. package/dist/chunk-URHPSJW2.js +0 -339
  548. package/dist/chunk-URHPSJW2.js.map +0 -1
  549. package/dist/chunk-UY3UYPBZ.cjs +0 -77
  550. package/dist/chunk-UY3UYPBZ.cjs.map +0 -1
  551. package/dist/chunk-VG2ABKJX.cjs +0 -100
  552. package/dist/chunk-VG2ABKJX.cjs.map +0 -1
  553. package/dist/chunk-VH77IPJN.cjs +0 -358
  554. package/dist/chunk-VH77IPJN.cjs.map +0 -1
  555. package/dist/chunk-VQTCQKHQ.cjs +0 -17
  556. package/dist/chunk-VQTCQKHQ.cjs.map +0 -1
  557. package/dist/chunk-WGWSHJ2N.js +0 -38
  558. package/dist/chunk-WGWSHJ2N.js.map +0 -1
  559. package/dist/chunk-WJH6IYU2.cjs +0 -32
  560. package/dist/chunk-WJH6IYU2.cjs.map +0 -1
  561. package/dist/chunk-YREV3LGG.cjs +0 -61
  562. package/dist/chunk-YREV3LGG.cjs.map +0 -1
  563. package/dist/chunk-YTXEZ4SD.cjs +0 -77
  564. package/dist/chunk-YTXEZ4SD.cjs.map +0 -1
  565. package/dist/chunk-YWCESU4Y.js +0 -1233
  566. package/dist/chunk-YWCESU4Y.js.map +0 -1
  567. package/dist/chunk-Z6HRSM2Y.cjs +0 -799
  568. package/dist/chunk-Z6HRSM2Y.cjs.map +0 -1
  569. package/dist/chunk-Z7PW3KHL.cjs +0 -1198
  570. package/dist/chunk-Z7PW3KHL.cjs.map +0 -1
  571. package/dist/chunk-ZNMBW67B.cjs +0 -40
  572. package/dist/chunk-ZNMBW67B.cjs.map +0 -1
  573. package/dist/correlation-id.cjs.map +0 -1
  574. package/dist/correlation-id.js.map +0 -1
  575. package/dist/event-subscriber.cjs.map +0 -1
  576. package/dist/event-subscriber.js.map +0 -1
  577. package/dist/event.cjs.map +0 -1
  578. package/dist/event.js.map +0 -1
  579. package/dist/exporters.cjs.map +0 -1
  580. package/dist/exporters.js.map +0 -1
  581. package/dist/functional.cjs.map +0 -1
  582. package/dist/functional.js.map +0 -1
  583. package/dist/init-DIowiiCh.d.ts +0 -1167
  584. package/dist/init-j-A1zI16.d.cts +0 -1167
  585. package/dist/processors.cjs.map +0 -1
  586. package/dist/processors.js.map +0 -1
  587. package/dist/trace-context-DbGKd1Rn.d.cts +0 -213
  588. package/dist/trace-context-DbGKd1Rn.d.ts +0 -213
  589. package/dist/utils-BahBCFtJ.d.cts +0 -712
  590. package/dist/utils-CLKwaUlG.d.ts +0 -712
  591. package/dist/yaml-config.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,1289 +1,1155 @@
1
- 'use strict';
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_sampling = require('./sampling.cjs');
3
+ const require_init = require('./init-DvapOXCc.cjs');
4
+ const require_filtering_span_processor = require('./filtering-span-processor.cjs');
5
+ const require_span_name_normalizer = require('./span-name-normalizer.cjs');
6
+ const require_attribute_redacting_processor = require('./attribute-redacting-processor.cjs');
7
+ const require_canonical_log_line_processor = require('./canonical-log-line-processor--RlFDHhm.cjs');
8
+ const require_tracer_provider = require('./tracer-provider.cjs');
9
+ const require_track = require('./track-3HY4NGV-.cjs');
10
+ const require_structured_error = require('./structured-error-CHg7DoIQ.cjs');
11
+ const require_trace_helpers = require('./trace-helpers.cjs');
12
+ const require_operation_context = require('./operation-context-n4_obUwq.cjs');
13
+ const require_functional = require('./functional-C4CzoVrX.cjs');
14
+ const require_stable_hash = require('./stable-hash-BNTMrmdB.cjs');
15
+ const require_event = require('./event-Dlqr4ZNL.cjs');
16
+ const require_metric = require('./metric.cjs');
17
+ const require_correlated_events = require('./correlated-events-kSwLo3mi.cjs');
18
+ const require_parse_error = require('./parse-error.cjs');
19
+ const require_drain_pipeline = require('./drain-pipeline.cjs');
20
+ const require_metric_helpers = require('./metric-helpers.cjs');
21
+ const require_semantic_helpers = require('./semantic-helpers.cjs');
22
+ const require_registry = require('./registry-JZg2J3RZ.cjs');
23
+ const require_semantic_conventions = require('./semantic-conventions.cjs');
24
+ const require_attributes = require('./attributes-D3etyRVc.cjs');
25
+ const require_messaging = require('./messaging.cjs');
26
+ const require_business_baggage = require('./business-baggage.cjs');
27
+ const require_workflow = require('./workflow.cjs');
28
+ let _opentelemetry_api = require("@opentelemetry/api");
29
+ let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
30
+ let node_async_hooks = require("node:async_hooks");
2
31
 
3
- var chunkT4B5LB6E_cjs = require('./chunk-T4B5LB6E.cjs');
4
- var chunk7EQ4G4SI_cjs = require('./chunk-7EQ4G4SI.cjs');
5
- var chunkAC5GNZKB_cjs = require('./chunk-AC5GNZKB.cjs');
6
- var chunkM3LFHHTN_cjs = require('./chunk-M3LFHHTN.cjs');
7
- var chunk2ZKEORFN_cjs = require('./chunk-2ZKEORFN.cjs');
8
- var chunkESMHTKLJ_cjs = require('./chunk-ESMHTKLJ.cjs');
9
- var chunkZ6HRSM2Y_cjs = require('./chunk-Z6HRSM2Y.cjs');
10
- var chunk4P6ZOARG_cjs = require('./chunk-4P6ZOARG.cjs');
11
- var chunkINJD3G4K_cjs = require('./chunk-INJD3G4K.cjs');
12
- var chunkTC5ZPWM4_cjs = require('./chunk-TC5ZPWM4.cjs');
13
- require('./chunk-YTXEZ4SD.cjs');
14
- var chunkWJH6IYU2_cjs = require('./chunk-WJH6IYU2.cjs');
15
- var chunkVG2ABKJX_cjs = require('./chunk-VG2ABKJX.cjs');
16
- var chunkFGNDN2FD_cjs = require('./chunk-FGNDN2FD.cjs');
17
- var chunkOPPXYVEZ_cjs = require('./chunk-OPPXYVEZ.cjs');
18
- var chunkGBFTC7Q7_cjs = require('./chunk-GBFTC7Q7.cjs');
19
- require('./chunk-NZ72VDNY.cjs');
20
- require('./chunk-UY3UYPBZ.cjs');
21
- var chunkVQTCQKHQ_cjs = require('./chunk-VQTCQKHQ.cjs');
22
- var chunkZ7PW3KHL_cjs = require('./chunk-Z7PW3KHL.cjs');
23
- var chunkR7QYGZUP_cjs = require('./chunk-R7QYGZUP.cjs');
24
- require('./chunk-QWW3E3JM.cjs');
25
- require('./chunk-CEAQK2QY.cjs');
26
- var chunkZNMBW67B_cjs = require('./chunk-ZNMBW67B.cjs');
27
- var chunkIOYFAFHJ_cjs = require('./chunk-IOYFAFHJ.cjs');
28
- var chunkNEIB3TLD_cjs = require('./chunk-NEIB3TLD.cjs');
29
- require('./chunk-CU6IDACR.cjs');
30
- var chunk6S5RUKU3_cjs = require('./chunk-6S5RUKU3.cjs');
31
- require('./chunk-NVAI5CCN.cjs');
32
- var chunkVH77IPJN_cjs = require('./chunk-VH77IPJN.cjs');
33
- require('./chunk-FU6R566Y.cjs');
34
- require('./chunk-ESLWRGAG.cjs');
35
- var chunkYREV3LGG_cjs = require('./chunk-YREV3LGG.cjs');
36
- var api = require('@opentelemetry/api');
37
- var crypto$1 = require('crypto');
38
- var async_hooks = require('async_hooks');
39
- var sdkMetrics = require('@opentelemetry/sdk-metrics');
40
-
41
- var otelMethods = {
42
- // Class methods on TraceAPI — bind to the singleton.
43
- setGlobalTracerProvider: api.trace.setGlobalTracerProvider.bind(api.trace),
44
- getTracerProvider: api.trace.getTracerProvider.bind(api.trace),
45
- getTracer: api.trace.getTracer.bind(api.trace),
46
- disable: api.trace.disable.bind(api.trace),
47
- // Instance fields on TraceAPI — already standalone, copy by reference.
48
- wrapSpanContext: api.trace.wrapSpanContext,
49
- isSpanContextValid: api.trace.isSpanContextValid,
50
- deleteSpan: api.trace.deleteSpan,
51
- getSpan: api.trace.getSpan,
52
- getActiveSpan: api.trace.getActiveSpan,
53
- getSpanContext: api.trace.getSpanContext,
54
- setSpan: api.trace.setSpan,
55
- setSpanContext: api.trace.setSpanContext
32
+ //#region src/trace-hybrid.ts
33
+ /**
34
+ * Hybrid `trace` export: callable like autotel's `trace(fn)`, AND exposes the
35
+ * full `@opentelemetry/api` `TraceAPI` surface (`trace.getActiveSpan()`,
36
+ * `trace.getTracer()`, …) so existing OTel code "just works" when imported
37
+ * from `autotel`.
38
+ *
39
+ * Implementation: `Object.assign` mutates the autotel `trace` function to
40
+ * attach the OTel TraceAPI methods. Because every reference to `trace` across
41
+ * autotel resolves to the same function instance, this is a one-time, global
42
+ * augmentation.
43
+ */
44
+ const otelMethods = {
45
+ setGlobalTracerProvider: _opentelemetry_api.trace.setGlobalTracerProvider.bind(_opentelemetry_api.trace),
46
+ getTracerProvider: _opentelemetry_api.trace.getTracerProvider.bind(_opentelemetry_api.trace),
47
+ getTracer: _opentelemetry_api.trace.getTracer.bind(_opentelemetry_api.trace),
48
+ disable: _opentelemetry_api.trace.disable.bind(_opentelemetry_api.trace),
49
+ wrapSpanContext: _opentelemetry_api.trace.wrapSpanContext,
50
+ isSpanContextValid: _opentelemetry_api.trace.isSpanContextValid,
51
+ deleteSpan: _opentelemetry_api.trace.deleteSpan,
52
+ getSpan: _opentelemetry_api.trace.getSpan,
53
+ getActiveSpan: _opentelemetry_api.trace.getActiveSpan,
54
+ getSpanContext: _opentelemetry_api.trace.getSpanContext,
55
+ setSpan: _opentelemetry_api.trace.setSpan,
56
+ setSpanContext: _opentelemetry_api.trace.setSpanContext
56
57
  };
57
- var trace2 = Object.assign(
58
- chunkFGNDN2FD_cjs.trace,
59
- otelMethods
60
- );
58
+ const trace = Object.assign(require_functional.trace, otelMethods);
59
+
60
+ //#endregion
61
+ //#region src/define-event.ts
61
62
  function defineEvent(name, schema, options = {}) {
62
- const jsonSchema = options.toJsonSchema?.(schema);
63
- const schemaMetadata = jsonSchema ? {
64
- source: "zod",
65
- jsonSchema,
66
- hash: hashSchema(jsonSchema)
67
- } : void 0;
68
- return {
69
- name,
70
- schemaMetadata,
71
- track(payload) {
72
- const parsed = schema.safeParse(payload);
73
- if (!parsed.success) {
74
- throw new Error(
75
- `Invalid payload for event "${name}". Schema validation failed.`
76
- );
77
- }
78
- chunkZ7PW3KHL_cjs.track(
79
- name,
80
- parsed.data,
81
- schemaMetadata ? { schema: schemaMetadata } : void 0
82
- );
83
- }
84
- };
85
- }
86
- function hashSchema(schema) {
87
- return crypto$1.createHash("sha256").update(stableStringify(schema)).digest("hex");
88
- }
89
- function stableStringify(value) {
90
- if (value === null || value === void 0 || typeof value !== "object") {
91
- return JSON.stringify(value);
92
- }
93
- if (Array.isArray(value)) {
94
- return "[" + value.map((v) => stableStringify(v)).join(",") + "]";
95
- }
96
- const obj = value;
97
- const body = Object.keys(obj).sort().map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",");
98
- return "{" + body + "}";
63
+ const jsonSchema = options.toJsonSchema?.(schema);
64
+ const schemaMetadata = jsonSchema ? {
65
+ source: "zod",
66
+ jsonSchema,
67
+ hash: require_stable_hash.hashJson(jsonSchema)
68
+ } : void 0;
69
+ return {
70
+ name,
71
+ schemaMetadata,
72
+ track(payload) {
73
+ const parsed = schema.safeParse(payload);
74
+ if (!parsed.success) throw new Error(`Invalid payload for event "${name}". Schema validation failed.`);
75
+ require_track.track(name, parsed.data, schemaMetadata ? { schema: schemaMetadata } : void 0);
76
+ }
77
+ };
99
78
  }
100
79
 
101
- // src/shutdown.ts
80
+ //#endregion
81
+ //#region src/shutdown.ts
82
+ /**
83
+ * Graceful shutdown with flush and cleanup
84
+ */
85
+ /**
86
+ * Flush all pending telemetry
87
+ *
88
+ * Flushes both events events and OpenTelemetry spans to their destinations.
89
+ * Includes timeout protection to prevent hanging in serverless environments.
90
+ *
91
+ * Safe to call multiple times.
92
+ *
93
+ * @param options - Optional configuration
94
+ * @param options.timeout - Timeout in milliseconds (default: 2000ms)
95
+ * @param options.forShutdown - If true, permanently disables the events queue after flush (used internally by shutdown())
96
+ *
97
+ * @example Manual flush in serverless
98
+ * ```typescript
99
+ * import { flush } from 'autotel';
100
+ *
101
+ * export const handler = async (event) => {
102
+ * // ... process event
103
+ * await flush(); // Flush before function returns
104
+ * return result;
105
+ * };
106
+ * ```
107
+ *
108
+ * @example With custom timeout
109
+ * ```typescript
110
+ * await flush({ timeout: 5000 }); // 5 second timeout
111
+ * ```
112
+ */
102
113
  async function flush(options) {
103
- const timeout = options?.timeout ?? 2e3;
104
- const forShutdown = options?.forShutdown ?? false;
105
- const doFlush = async () => {
106
- const eventsQueue = chunkZ7PW3KHL_cjs.getEventQueue();
107
- if (eventsQueue) {
108
- if (forShutdown) {
109
- await eventsQueue.shutdown();
110
- } else {
111
- await eventsQueue.flush();
112
- }
113
- }
114
- const sdk = chunkR7QYGZUP_cjs.getSdk();
115
- if (sdk) {
116
- try {
117
- const sdkAny = sdk;
118
- if (typeof sdkAny.getTracerProvider === "function") {
119
- const tracerProvider = sdkAny.getTracerProvider();
120
- if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
121
- await tracerProvider.forceFlush();
122
- }
123
- }
124
- } catch {
125
- }
126
- }
127
- };
128
- let timeoutHandle;
129
- try {
130
- await Promise.race([
131
- doFlush().finally(() => {
132
- if (timeoutHandle) {
133
- clearTimeout(timeoutHandle);
134
- }
135
- }),
136
- new Promise((_, reject) => {
137
- timeoutHandle = setTimeout(
138
- () => reject(new Error("Flush timeout")),
139
- timeout
140
- );
141
- timeoutHandle.unref();
142
- })
143
- ]);
144
- } catch (error) {
145
- if (timeoutHandle) {
146
- clearTimeout(timeoutHandle);
147
- }
148
- const logger = chunkR7QYGZUP_cjs.getLogger();
149
- logger.error(
150
- {
151
- err: error instanceof Error ? error : new Error(String(error))
152
- },
153
- "[autotel] Flush error"
154
- );
155
- throw error;
156
- }
114
+ const timeout = options?.timeout ?? 2e3;
115
+ const forShutdown = options?.forShutdown ?? false;
116
+ const doFlush = async () => {
117
+ const eventsQueue = require_track.getEventQueue();
118
+ if (eventsQueue) if (forShutdown) await eventsQueue.shutdown();
119
+ else await eventsQueue.flush();
120
+ const sdk = require_init.getSdk();
121
+ if (sdk) try {
122
+ const sdkAny = sdk;
123
+ if (typeof sdkAny.getTracerProvider === "function") {
124
+ const tracerProvider = sdkAny.getTracerProvider();
125
+ if (tracerProvider && typeof tracerProvider.forceFlush === "function") await tracerProvider.forceFlush();
126
+ }
127
+ } catch {}
128
+ };
129
+ let timeoutHandle;
130
+ try {
131
+ await Promise.race([doFlush().finally(() => {
132
+ if (timeoutHandle) clearTimeout(timeoutHandle);
133
+ }), new Promise((_, reject) => {
134
+ timeoutHandle = setTimeout(() => reject(/* @__PURE__ */ new Error("Flush timeout")), timeout);
135
+ timeoutHandle.unref();
136
+ })]);
137
+ } catch (error) {
138
+ if (timeoutHandle) clearTimeout(timeoutHandle);
139
+ require_init.getLogger().error({ err: error instanceof Error ? error : new Error(String(error)) }, "[autotel] Flush error");
140
+ throw error;
141
+ }
157
142
  }
143
+ /**
144
+ * Shutdown telemetry and cleanup resources
145
+ *
146
+ * - Flushes all pending data
147
+ * - Shuts down OpenTelemetry SDK
148
+ * - Cleans up resources
149
+ *
150
+ * Call this before process exit.
151
+ *
152
+ * Always performs cleanup even if flush fails, preventing resource leaks
153
+ * in serverless handlers or tests.
154
+ *
155
+ * @example Express server
156
+ * ```typescript
157
+ * const server = app.listen(3000)
158
+ *
159
+ * process.on('SIGTERM', async () => {
160
+ * await server.close()
161
+ * await shutdown()
162
+ * process.exit(0)
163
+ * })
164
+ * ```
165
+ */
158
166
  async function shutdown() {
159
- const logger = chunkR7QYGZUP_cjs.getLogger();
160
- let shutdownError = null;
161
- try {
162
- await flush({ forShutdown: true });
163
- } catch (error) {
164
- const err = error instanceof Error ? error : new Error(String(error));
165
- shutdownError = err;
166
- logger.error(
167
- {
168
- err
169
- },
170
- "[autotel] Flush failed during shutdown, continuing cleanup"
171
- );
172
- }
173
- try {
174
- const sdk = chunkR7QYGZUP_cjs.getSdk();
175
- if (sdk) {
176
- await sdk.shutdown();
177
- }
178
- } catch (error) {
179
- const err = error instanceof Error ? error : new Error(String(error));
180
- const isConnectionRefused = typeof error === "object" && error !== null && "code" in error && error.code === "ECONNREFUSED";
181
- if (!isConnectionRefused) {
182
- if (!shutdownError) {
183
- shutdownError = err;
184
- }
185
- logger.error({ err }, "[autotel] SDK shutdown failed");
186
- }
187
- } finally {
188
- await chunkR7QYGZUP_cjs._closeEmbeddedDevtools();
189
- const eventsQueue = chunkZ7PW3KHL_cjs.getEventQueue();
190
- if (eventsQueue && typeof eventsQueue.cleanup === "function") {
191
- eventsQueue.cleanup();
192
- }
193
- chunkGBFTC7Q7_cjs.resetEvents();
194
- chunkTC5ZPWM4_cjs.resetMetrics();
195
- chunkZ7PW3KHL_cjs.resetEventQueue();
196
- }
197
- if (shutdownError) {
198
- throw shutdownError;
199
- }
167
+ const logger = require_init.getLogger();
168
+ let shutdownError = null;
169
+ try {
170
+ await flush({ forShutdown: true });
171
+ } catch (error) {
172
+ const err = error instanceof Error ? error : new Error(String(error));
173
+ shutdownError = err;
174
+ logger.error({ err }, "[autotel] Flush failed during shutdown, continuing cleanup");
175
+ }
176
+ try {
177
+ const sdk = require_init.getSdk();
178
+ if (sdk) await sdk.shutdown();
179
+ } catch (error) {
180
+ const err = error instanceof Error ? error : new Error(String(error));
181
+ if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ECONNREFUSED")) {
182
+ if (!shutdownError) shutdownError = err;
183
+ logger.error({ err }, "[autotel] SDK shutdown failed");
184
+ }
185
+ } finally {
186
+ await require_init._closeEmbeddedDevtools();
187
+ const eventsQueue = require_track.getEventQueue();
188
+ if (eventsQueue && typeof eventsQueue.cleanup === "function") eventsQueue.cleanup();
189
+ require_event.resetEvents();
190
+ require_metric.resetMetrics();
191
+ require_track.resetEventQueue();
192
+ }
193
+ if (shutdownError) throw shutdownError;
200
194
  }
195
+ /**
196
+ * Register automatic shutdown hooks for common signals
197
+ *
198
+ * Handles:
199
+ * - SIGTERM (Docker/K8s graceful shutdown)
200
+ * - SIGINT (Ctrl+C)
201
+ *
202
+ * @internal Called automatically on module load
203
+ */
201
204
  function registerShutdownHooks() {
202
- if (typeof process === "undefined") return;
203
- const signals = ["SIGTERM", "SIGINT"];
204
- let shuttingDown = false;
205
- for (const signal of signals) {
206
- process.on(signal, async () => {
207
- if (shuttingDown) return;
208
- shuttingDown = true;
209
- if (process.env.NODE_ENV !== "test") {
210
- chunkR7QYGZUP_cjs.getLogger().info(
211
- {},
212
- `[autotel] Received ${signal}, flushing telemetry...`
213
- );
214
- }
215
- try {
216
- await shutdown();
217
- } catch (error) {
218
- chunkR7QYGZUP_cjs.getLogger().error(
219
- {
220
- err: error instanceof Error ? error : void 0
221
- },
222
- "[autotel] Error during shutdown"
223
- );
224
- } finally {
225
- process.exit(0);
226
- }
227
- });
228
- }
205
+ if (typeof process === "undefined") return;
206
+ const signals = ["SIGTERM", "SIGINT"];
207
+ let shuttingDown = false;
208
+ for (const signal of signals) process.on(signal, async () => {
209
+ if (shuttingDown) return;
210
+ shuttingDown = true;
211
+ if (process.env.NODE_ENV !== "test") require_init.getLogger().info({}, `[autotel] Received ${signal}, flushing telemetry...`);
212
+ try {
213
+ await shutdown();
214
+ } catch (error) {
215
+ require_init.getLogger().error({ err: error instanceof Error ? error : void 0 }, "[autotel] Error during shutdown");
216
+ } finally {
217
+ process.exit(0);
218
+ }
219
+ });
229
220
  }
230
221
  registerShutdownHooks();
231
- var POST_EMIT_FORK_HINT = "For intentional background work tied to this request, use log.fork('label', fn) when available.";
222
+
223
+ //#endregion
224
+ //#region src/request-logger.ts
225
+ const POST_EMIT_FORK_HINT = "For intentional background work tied to this request, use log.fork('label', fn) when available.";
232
226
  function warnPostEmit(method, detail) {
233
- console.warn(
234
- `[autotel] ${method} called after the wide event was emitted \u2014 ${detail} This data will not appear in observability. ${POST_EMIT_FORK_HINT}`
235
- );
227
+ console.warn(`[autotel] ${method} called after the wide event was emitted — ${detail} This data will not appear in observability. ${POST_EMIT_FORK_HINT}`);
236
228
  }
237
- function mergeInto(target, source) {
238
- for (const key in source) {
239
- const sourceVal = source[key];
240
- if (sourceVal === void 0) continue;
241
- const targetVal = target[key];
242
- if (sourceVal !== null && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal !== null && typeof targetVal === "object" && !Array.isArray(targetVal)) {
243
- mergeInto(
244
- targetVal,
245
- sourceVal
246
- );
247
- } else if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
248
- target[key] = [...targetVal, ...sourceVal];
249
- } else {
250
- target[key] = sourceVal;
251
- }
252
- }
229
+ function mergeInto$1(target, source) {
230
+ for (const key in source) {
231
+ const sourceVal = source[key];
232
+ if (sourceVal === void 0) continue;
233
+ const targetVal = target[key];
234
+ if (sourceVal !== null && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal !== null && typeof targetVal === "object" && !Array.isArray(targetVal)) mergeInto$1(targetVal, sourceVal);
235
+ else if (Array.isArray(targetVal) && Array.isArray(sourceVal)) target[key] = [...targetVal, ...sourceVal];
236
+ else target[key] = sourceVal;
237
+ }
253
238
  }
254
- var requestContextStore = new async_hooks.AsyncLocalStorage();
255
- function runWithRequestContext(ctx2, fn) {
256
- return requestContextStore.run(ctx2, fn);
239
+ const requestContextStore = new node_async_hooks.AsyncLocalStorage();
240
+ function runWithRequestContext(ctx, fn) {
241
+ return requestContextStore.run(ctx, fn);
257
242
  }
258
- function resolveContext(ctx2) {
259
- if (ctx2) return ctx2;
260
- const stored = requestContextStore.getStore();
261
- if (stored) return stored;
262
- const span2 = api.trace.getActiveSpan();
263
- if (!span2) {
264
- throw new Error(
265
- "[autotel] getRequestLogger() requires an active span or runWithRequestContext(). Wrap your handler with trace() or use runWithRequestContext()."
266
- );
267
- }
268
- return chunkZ7PW3KHL_cjs.createTraceContext(span2);
243
+ function resolveContext(ctx) {
244
+ if (ctx) return ctx;
245
+ const stored = requestContextStore.getStore();
246
+ if (stored) return stored;
247
+ const span = _opentelemetry_api.trace.getActiveSpan();
248
+ if (!span) throw new Error("[autotel] getRequestLogger() requires an active span or runWithRequestContext(). Wrap your handler with trace() or use runWithRequestContext().");
249
+ return require_track.createTraceContext(span);
250
+ }
251
+ function getRequestLogger(ctx, options) {
252
+ const activeContext = resolveContext(ctx);
253
+ let contextState = {};
254
+ let emitted = false;
255
+ let lastSnapshot = null;
256
+ const addLogEvent = (level, message, fields) => {
257
+ const attrs = fields ? require_structured_error.flattenToAttributes(fields) : void 0;
258
+ require_correlated_events.emitCorrelatedEvent(activeContext, `log.${level}`, {
259
+ message,
260
+ ...attrs ?? {}
261
+ });
262
+ };
263
+ const sealCheck = (method, keys) => {
264
+ if (emitted) warnPostEmit(method, `Keys dropped: ${keys.length ? keys.join(", ") : "(empty)"}.`);
265
+ };
266
+ return {
267
+ set(fields) {
268
+ sealCheck("log.set()", Object.keys(fields));
269
+ if (emitted) return;
270
+ mergeInto$1(contextState, fields);
271
+ activeContext.setAttributes(require_structured_error.flattenToAttributes(fields));
272
+ },
273
+ info(message, fields) {
274
+ sealCheck("log.info()", fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"]);
275
+ if (emitted) return;
276
+ addLogEvent("info", message, fields);
277
+ if (fields) {
278
+ mergeInto$1(contextState, fields);
279
+ activeContext.setAttributes(require_structured_error.flattenToAttributes(fields));
280
+ }
281
+ },
282
+ warn(message, fields) {
283
+ sealCheck("log.warn()", fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"]);
284
+ if (emitted) return;
285
+ addLogEvent("warn", message, fields);
286
+ activeContext.setAttribute("autotel.log.level", "warn");
287
+ if (fields) {
288
+ mergeInto$1(contextState, fields);
289
+ activeContext.setAttributes(require_structured_error.flattenToAttributes(fields));
290
+ }
291
+ },
292
+ error(error, fields) {
293
+ sealCheck("log.error()", fields ? [...Object.keys(fields), "error"] : ["error"]);
294
+ if (emitted) return;
295
+ const err = typeof error === "string" ? new Error(error) : error;
296
+ require_structured_error.recordStructuredError(activeContext, err);
297
+ addLogEvent("error", err.message, fields);
298
+ if (fields) {
299
+ mergeInto$1(contextState, fields);
300
+ activeContext.setAttributes(require_structured_error.flattenToAttributes(fields));
301
+ }
302
+ activeContext.setAttribute("autotel.log.level", "error");
303
+ },
304
+ getContext() {
305
+ return { ...contextState };
306
+ },
307
+ emitNow(overrides) {
308
+ if (emitted) {
309
+ warnPostEmit("log.emitNow()", "Ignoring duplicate emit.");
310
+ return lastSnapshot;
311
+ }
312
+ const mergedContext = {
313
+ ...contextState,
314
+ ...overrides ?? {}
315
+ };
316
+ const flattened = require_structured_error.flattenToAttributes(mergedContext);
317
+ activeContext.setAttributes(flattened);
318
+ const snapshot = {
319
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
320
+ traceId: activeContext.traceId,
321
+ spanId: activeContext.spanId,
322
+ correlationId: activeContext.correlationId,
323
+ context: mergedContext
324
+ };
325
+ require_correlated_events.emitCorrelatedEvent(activeContext, "log.emit.manual", { ...flattened });
326
+ if (options?.onEmit) Promise.resolve(options.onEmit(snapshot)).catch((error) => {
327
+ console.warn("[autotel] request logger onEmit failed:", error);
328
+ });
329
+ emitted = true;
330
+ lastSnapshot = snapshot;
331
+ return snapshot;
332
+ },
333
+ fork(label, fn, forkOptions) {
334
+ const parentRequestId = activeContext.correlationId;
335
+ if (typeof parentRequestId !== "string" || parentRequestId.length === 0) throw new Error("[autotel] log.fork() requires the parent logger to have a correlationId. Ensure the request was created by autotel middleware.");
336
+ const tracer = _opentelemetry_api.trace.getTracer("autotel.request-logger");
337
+ const lifecycle = forkOptions?.lifecycle;
338
+ tracer.startActiveSpan(`request.fork:${label}`, (childSpan) => {
339
+ const childContext = {
340
+ ...require_track.createTraceContext(childSpan),
341
+ correlationId: crypto.randomUUID()
342
+ };
343
+ requestContextStore.run(childContext, () => {
344
+ const childLog = getRequestLogger(childContext);
345
+ childLog.set({
346
+ operation: label,
347
+ _parentCorrelationId: parentRequestId
348
+ });
349
+ lifecycle?.onChildEnter?.(childLog);
350
+ Promise.resolve().then(() => fn()).then(() => {
351
+ childLog.emitNow();
352
+ }).catch((err) => {
353
+ const error = err instanceof Error ? err : new Error(String(err));
354
+ childLog.error(error);
355
+ childLog.emitNow();
356
+ }).finally(() => {
357
+ try {
358
+ lifecycle?.onChildExit?.(childLog);
359
+ } catch (hookError) {
360
+ console.warn("[autotel] fork onChildExit hook threw:", hookError);
361
+ }
362
+ childSpan.end();
363
+ });
364
+ });
365
+ });
366
+ }
367
+ };
368
+ }
369
+ /**
370
+ * Returns `true` when a request-logger context can be resolved without throwing —
371
+ * i.e. an explicit `ctx` was provided, a `runWithRequestContext()` scope is active,
372
+ * or there is an active OpenTelemetry span.
373
+ *
374
+ * Use this to branch on observability availability instead of wrapping
375
+ * {@link getRequestLogger} in try/catch.
376
+ */
377
+ function hasRequestContext(ctx) {
378
+ if (ctx) return true;
379
+ if (requestContextStore.getStore()) return true;
380
+ return _opentelemetry_api.trace.getActiveSpan() != null;
381
+ }
382
+ /**
383
+ * Like {@link getRequestLogger}, but returns `null` instead of throwing when no
384
+ * request context is available. Intended for best-effort instrumentation where a
385
+ * missing telemetry context must never crash business logic.
386
+ */
387
+ function getRequestLoggerSafe(ctx, options) {
388
+ if (!hasRequestContext(ctx)) return null;
389
+ return getRequestLogger(ctx, options);
269
390
  }
270
- function getRequestLogger(ctx2, options) {
271
- const activeContext = resolveContext(ctx2);
272
- let contextState = {};
273
- let emitted = false;
274
- let lastSnapshot = null;
275
- const addLogEvent = (level, message, fields) => {
276
- const attrs2 = fields ? chunkZ7PW3KHL_cjs.flattenToAttributes(fields) : void 0;
277
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(activeContext, `log.${level}`, {
278
- message,
279
- ...attrs2 ?? {}
280
- });
281
- };
282
- const sealCheck = (method, keys) => {
283
- if (emitted) {
284
- warnPostEmit(
285
- method,
286
- `Keys dropped: ${keys.length ? keys.join(", ") : "(empty)"}.`
287
- );
288
- }
289
- };
290
- return {
291
- set(fields) {
292
- sealCheck("log.set()", Object.keys(fields));
293
- if (emitted) return;
294
- mergeInto(contextState, fields);
295
- activeContext.setAttributes(chunkZ7PW3KHL_cjs.flattenToAttributes(fields));
296
- },
297
- info(message, fields) {
298
- const keys = fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"];
299
- sealCheck("log.info()", keys);
300
- if (emitted) return;
301
- addLogEvent("info", message, fields);
302
- if (fields) {
303
- mergeInto(contextState, fields);
304
- activeContext.setAttributes(chunkZ7PW3KHL_cjs.flattenToAttributes(fields));
305
- }
306
- },
307
- warn(message, fields) {
308
- const keys = fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"];
309
- sealCheck("log.warn()", keys);
310
- if (emitted) return;
311
- addLogEvent("warn", message, fields);
312
- activeContext.setAttribute("autotel.log.level", "warn");
313
- if (fields) {
314
- mergeInto(contextState, fields);
315
- activeContext.setAttributes(chunkZ7PW3KHL_cjs.flattenToAttributes(fields));
316
- }
317
- },
318
- error(error, fields) {
319
- const keys = fields ? [...Object.keys(fields), "error"] : ["error"];
320
- sealCheck("log.error()", keys);
321
- if (emitted) return;
322
- const err = typeof error === "string" ? new Error(error) : error;
323
- chunkZ7PW3KHL_cjs.recordStructuredError(activeContext, err);
324
- addLogEvent("error", err.message, fields);
325
- if (fields) {
326
- mergeInto(contextState, fields);
327
- activeContext.setAttributes(chunkZ7PW3KHL_cjs.flattenToAttributes(fields));
328
- }
329
- activeContext.setAttribute("autotel.log.level", "error");
330
- },
331
- getContext() {
332
- return { ...contextState };
333
- },
334
- emitNow(overrides) {
335
- if (emitted) {
336
- warnPostEmit("log.emitNow()", "Ignoring duplicate emit.");
337
- return lastSnapshot;
338
- }
339
- const mergedContext = {
340
- ...contextState,
341
- ...overrides ?? {}
342
- };
343
- const flattened = chunkZ7PW3KHL_cjs.flattenToAttributes(mergedContext);
344
- activeContext.setAttributes(flattened);
345
- const snapshot = {
346
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
347
- traceId: activeContext.traceId,
348
- spanId: activeContext.spanId,
349
- correlationId: activeContext.correlationId,
350
- context: mergedContext
351
- };
352
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(activeContext, "log.emit.manual", {
353
- ...flattened
354
- });
355
- if (options?.onEmit) {
356
- Promise.resolve(options.onEmit(snapshot)).catch((error) => {
357
- console.warn("[autotel] request logger onEmit failed:", error);
358
- });
359
- }
360
- emitted = true;
361
- lastSnapshot = snapshot;
362
- return snapshot;
363
- },
364
- fork(label, fn, forkOptions) {
365
- const parentRequestId = activeContext.correlationId;
366
- if (typeof parentRequestId !== "string" || parentRequestId.length === 0) {
367
- throw new Error(
368
- "[autotel] log.fork() requires the parent logger to have a correlationId. Ensure the request was created by autotel middleware."
369
- );
370
- }
371
- const tracer = api.trace.getTracer("autotel.request-logger");
372
- const lifecycle = forkOptions?.lifecycle;
373
- void tracer.startActiveSpan(`request.fork:${label}`, (childSpan) => {
374
- const childContext = {
375
- ...chunkZ7PW3KHL_cjs.createTraceContext(childSpan),
376
- correlationId: crypto.randomUUID()
377
- };
378
- requestContextStore.run(childContext, () => {
379
- const childLog = getRequestLogger(childContext);
380
- childLog.set({
381
- operation: label,
382
- _parentCorrelationId: parentRequestId
383
- });
384
- lifecycle?.onChildEnter?.(childLog);
385
- void Promise.resolve().then(() => fn()).then(() => {
386
- childLog.emitNow();
387
- }).catch((err) => {
388
- const error = err instanceof Error ? err : new Error(String(err));
389
- childLog.error(error);
390
- childLog.emitNow();
391
- }).finally(() => {
392
- try {
393
- lifecycle?.onChildExit?.(childLog);
394
- } catch (hookError) {
395
- console.warn(
396
- "[autotel] fork onChildExit hook threw:",
397
- hookError
398
- );
399
- }
400
- childSpan.end();
401
- });
402
- });
403
- });
404
- }
405
- };
391
+ /**
392
+ * A no-op {@link RequestLogger} whose methods do nothing. Used as a fallback by
393
+ * best-effort instrumentation so wrapped handlers can run un-instrumented without
394
+ * branching on logger presence.
395
+ */
396
+ function createNoopRequestLogger() {
397
+ const snapshot = () => ({
398
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
399
+ traceId: "",
400
+ spanId: "",
401
+ correlationId: "",
402
+ context: {}
403
+ });
404
+ return {
405
+ set() {},
406
+ info() {},
407
+ warn() {},
408
+ error() {},
409
+ getContext() {
410
+ return {};
411
+ },
412
+ emitNow() {
413
+ return snapshot();
414
+ },
415
+ fork(_label, fn) {
416
+ Promise.resolve().then(() => fn());
417
+ }
418
+ };
406
419
  }
407
420
 
408
- // src/error-catalog.ts
409
- var catalogCodeKey = /* @__PURE__ */ Symbol.for("autotel.catalog.code");
421
+ //#endregion
422
+ //#region src/error-catalog.ts
423
+ /**
424
+ * Typed error and audit catalogs.
425
+ *
426
+ * Group related errors into one catalog and get a refactor-safe builder per
427
+ * code, with autocomplete at every call site and typed message parameters.
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * import { defineErrorCatalog } from 'autotel';
432
+ *
433
+ * export const billing = defineErrorCatalog('billing', {
434
+ * PAYMENT_DECLINED: {
435
+ * status: 402,
436
+ * message: 'Card declined',
437
+ * why: 'The issuer rejected the charge',
438
+ * fix: 'Try a different payment method',
439
+ * },
440
+ * INSUFFICIENT_FUNDS: {
441
+ * status: 402,
442
+ * message: ({ available, required }: { available: number; required: number }) =>
443
+ * `Insufficient funds: $${available} of $${required}`,
444
+ * },
445
+ * });
446
+ *
447
+ * throw billing.PAYMENT_DECLINED({ cause: stripeError });
448
+ * throw billing.INSUFFICIENT_FUNDS({ available: 5, required: 100 });
449
+ *
450
+ * // In a catch block — refactor-safe, no magic strings:
451
+ * if (billing.PAYMENT_DECLINED.match(err)) { ... }
452
+ * ```
453
+ */
454
+ const catalogCodeKey = Symbol.for("autotel.catalog.code");
410
455
  function readCatalogCode(error) {
411
- if (error === null || typeof error !== "object") return void 0;
412
- return error[catalogCodeKey];
456
+ if (error === null || typeof error !== "object") return void 0;
457
+ return error[catalogCodeKey];
413
458
  }
459
+ /** True when `error` was produced by any autotel error catalog. */
414
460
  function isCatalogError(error) {
415
- return readCatalogCode(error) !== void 0;
461
+ return readCatalogCode(error) !== void 0;
416
462
  }
463
+ /** Returns the catalog code of `error`, or `undefined` if it has none. */
417
464
  function getCatalogCode(error) {
418
- return readCatalogCode(error);
465
+ return readCatalogCode(error);
419
466
  }
467
+ /**
468
+ * Define a typed error catalog. Returns an object whose keys are error
469
+ * builders. Each builder produces a {@link StructuredError} carrying the
470
+ * entry's message, status, code, why, fix, and link.
471
+ */
420
472
  function defineErrorCatalog(namespace, entries) {
421
- const catalog = {};
422
- for (const [key, entry] of Object.entries(entries)) {
423
- const code = entry.code ?? `${namespace}.${key}`;
424
- const usesParams = typeof entry.message === "function" || typeof entry.why === "function";
425
- const builder = ((paramsOrOptions, maybeOptions) => {
426
- const params = usesParams ? paramsOrOptions : void 0;
427
- const options = usesParams ? maybeOptions : paramsOrOptions;
428
- const message = typeof entry.message === "function" ? entry.message(params) : entry.message;
429
- const why = typeof entry.why === "function" ? entry.why(params) : entry.why;
430
- const error = chunkZ7PW3KHL_cjs.createStructuredError({
431
- message,
432
- name: entry.name ?? key,
433
- code,
434
- ...entry.status === void 0 ? {} : { status: entry.status },
435
- ...why === void 0 ? {} : { why },
436
- ...entry.fix === void 0 ? {} : { fix: entry.fix },
437
- ...entry.link === void 0 ? {} : { link: entry.link },
438
- ...options?.cause === void 0 ? {} : { cause: options.cause },
439
- ...options?.details === void 0 ? {} : { details: options.details },
440
- ...options?.internal === void 0 ? {} : { internal: options.internal }
441
- });
442
- Object.defineProperty(error, catalogCodeKey, {
443
- value: code,
444
- enumerable: false,
445
- writable: false,
446
- configurable: true
447
- });
448
- return error;
449
- });
450
- Object.defineProperty(builder, "code", {
451
- value: code,
452
- enumerable: true
453
- });
454
- Object.defineProperty(builder, "match", {
455
- value: (error) => readCatalogCode(error) === code,
456
- enumerable: false
457
- });
458
- catalog[key] = builder;
459
- }
460
- return Object.freeze(catalog);
473
+ const catalog = {};
474
+ for (const [key, entry] of Object.entries(entries)) {
475
+ const code = entry.code ?? `${namespace}.${key}`;
476
+ const usesParams = typeof entry.message === "function" || typeof entry.why === "function";
477
+ const builder = ((paramsOrOptions, maybeOptions) => {
478
+ const params = usesParams ? paramsOrOptions : void 0;
479
+ const options = usesParams ? maybeOptions : paramsOrOptions;
480
+ const message = typeof entry.message === "function" ? entry.message(params) : entry.message;
481
+ const why = typeof entry.why === "function" ? entry.why(params) : entry.why;
482
+ const error = require_structured_error.createStructuredError({
483
+ message,
484
+ name: entry.name ?? key,
485
+ code,
486
+ ...entry.status === void 0 ? {} : { status: entry.status },
487
+ ...why === void 0 ? {} : { why },
488
+ ...entry.fix === void 0 ? {} : { fix: entry.fix },
489
+ ...entry.link === void 0 ? {} : { link: entry.link },
490
+ ...options?.cause === void 0 ? {} : { cause: options.cause },
491
+ ...options?.details === void 0 ? {} : { details: options.details },
492
+ ...options?.internal === void 0 ? {} : { internal: options.internal }
493
+ });
494
+ Object.defineProperty(error, catalogCodeKey, {
495
+ value: code,
496
+ enumerable: false,
497
+ writable: false,
498
+ configurable: true
499
+ });
500
+ return error;
501
+ });
502
+ Object.defineProperty(builder, "code", {
503
+ value: code,
504
+ enumerable: true
505
+ });
506
+ Object.defineProperty(builder, "match", {
507
+ value: (error) => readCatalogCode(error) === code,
508
+ enumerable: false
509
+ });
510
+ catalog[key] = builder;
511
+ }
512
+ return Object.freeze(catalog);
461
513
  }
514
+ /**
515
+ * Define a typed audit catalog. Returns typed action descriptors you can pass
516
+ * to `track()` or audit helpers without scattering magic strings.
517
+ */
462
518
  function defineAuditCatalog(namespace, entries) {
463
- const catalog = {};
464
- for (const [key, entry] of Object.entries(entries)) {
465
- const action = entry.action ?? `${namespace}.${key}`;
466
- const severity = entry.severity ?? "info";
467
- const descriptor = ((params) => {
468
- const message = typeof entry.message === "function" ? entry.message(params) : entry.message;
469
- return Object.freeze({
470
- action,
471
- severity,
472
- ...message === void 0 ? {} : { message }
473
- });
474
- });
475
- Object.defineProperty(descriptor, "action", {
476
- value: action,
477
- enumerable: true
478
- });
479
- Object.defineProperty(descriptor, "severity", {
480
- value: severity,
481
- enumerable: true
482
- });
483
- catalog[key] = descriptor;
484
- }
485
- return Object.freeze(catalog);
519
+ const catalog = {};
520
+ for (const [key, entry] of Object.entries(entries)) {
521
+ const action = entry.action ?? `${namespace}.${key}`;
522
+ const severity = entry.severity ?? "info";
523
+ const descriptor = ((params) => {
524
+ const message = typeof entry.message === "function" ? entry.message(params) : entry.message;
525
+ return Object.freeze({
526
+ action,
527
+ severity,
528
+ ...message === void 0 ? {} : { message }
529
+ });
530
+ });
531
+ Object.defineProperty(descriptor, "action", {
532
+ value: action,
533
+ enumerable: true
534
+ });
535
+ Object.defineProperty(descriptor, "severity", {
536
+ value: severity,
537
+ enumerable: true
538
+ });
539
+ catalog[key] = descriptor;
540
+ }
541
+ return Object.freeze(catalog);
486
542
  }
487
543
 
488
- // src/drain-toolkit.ts
489
- var DEFAULT_TIMEOUT_MS = 5e3;
490
- var DEFAULT_RETRIES = 2;
544
+ //#endregion
545
+ //#region src/drain-toolkit.ts
546
+ const DEFAULT_TIMEOUT_MS = 5e3;
547
+ const DEFAULT_RETRIES = 2;
491
548
  function delay(ms) {
492
- return new Promise((resolve) => {
493
- const t = setTimeout(resolve, ms);
494
- t.unref?.();
495
- });
549
+ return new Promise((resolve) => {
550
+ setTimeout(resolve, ms).unref?.();
551
+ });
496
552
  }
497
553
  async function postWithRetry(options) {
498
- const { name, request: request2, timeoutMs, retries } = options;
499
- const attempts = Math.max(1, retries);
500
- let lastError;
501
- for (let attempt = 1; attempt <= attempts; attempt++) {
502
- const controller = new AbortController();
503
- const timeout = setTimeout(() => controller.abort(), timeoutMs);
504
- timeout.unref?.();
505
- try {
506
- const response = await fetch(request2.url, {
507
- method: "POST",
508
- headers: request2.headers,
509
- body: request2.body,
510
- signal: controller.signal
511
- });
512
- if (!response.ok) {
513
- throw new Error(
514
- `[autotel/${name}] HTTP ${response.status} draining ${request2.url}`
515
- );
516
- }
517
- return;
518
- } catch (error) {
519
- lastError = error;
520
- if (attempt < attempts) {
521
- await delay(100 * attempt);
522
- }
523
- } finally {
524
- clearTimeout(timeout);
525
- }
526
- }
527
- throw lastError;
554
+ const { name, request, timeoutMs, retries } = options;
555
+ const attempts = Math.max(1, retries);
556
+ let lastError;
557
+ for (let attempt = 1; attempt <= attempts; attempt++) {
558
+ const controller = new AbortController();
559
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
560
+ timeout.unref?.();
561
+ try {
562
+ const response = await fetch(request.url, {
563
+ method: "POST",
564
+ headers: request.headers,
565
+ body: request.body,
566
+ signal: controller.signal
567
+ });
568
+ if (!response.ok) throw new Error(`[autotel/${name}] HTTP ${response.status} draining ${request.url}`);
569
+ return;
570
+ } catch (error) {
571
+ lastError = error;
572
+ if (attempt < attempts) await delay(100 * attempt);
573
+ } finally {
574
+ clearTimeout(timeout);
575
+ }
576
+ }
577
+ throw lastError;
528
578
  }
529
579
  function defineDrain(options) {
530
- return async (ctx2) => {
531
- const contexts = Array.isArray(ctx2) ? ctx2 : [ctx2];
532
- if (contexts.length === 0) return;
533
- const config = await options.resolve();
534
- if (!config) return;
535
- const payloads = options.transform ? options.transform(contexts) : contexts;
536
- if (payloads.length === 0) return;
537
- try {
538
- await options.send(payloads, config);
539
- } catch (error) {
540
- console.error(`[autotel/${options.name}] drain failed:`, error);
541
- }
542
- };
580
+ return async (ctx) => {
581
+ const contexts = Array.isArray(ctx) ? ctx : [ctx];
582
+ if (contexts.length === 0) return;
583
+ const config = await options.resolve();
584
+ if (!config) return;
585
+ const payloads = options.transform ? options.transform(contexts) : contexts;
586
+ if (payloads.length === 0) return;
587
+ try {
588
+ await options.send(payloads, config);
589
+ } catch (error) {
590
+ console.error(`[autotel/${options.name}] drain failed:`, error);
591
+ }
592
+ };
543
593
  }
544
594
  function defineHttpDrain(options) {
545
- return defineDrain({
546
- name: options.name,
547
- resolve: options.resolve,
548
- transform: options.transform,
549
- send: async (payloads, config) => {
550
- const request2 = options.encode(payloads, config);
551
- if (!request2) return;
552
- const timeoutMs = options.resolveTimeoutMs?.(config) ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
553
- const retries = options.resolveRetries?.(config) ?? options.retries ?? DEFAULT_RETRIES;
554
- await postWithRetry({
555
- name: options.name,
556
- request: request2,
557
- timeoutMs,
558
- retries
559
- });
560
- }
561
- });
595
+ return defineDrain({
596
+ name: options.name,
597
+ resolve: options.resolve,
598
+ transform: options.transform,
599
+ send: async (payloads, config) => {
600
+ const request = options.encode(payloads, config);
601
+ if (!request) return;
602
+ const timeoutMs = options.resolveTimeoutMs?.(config) ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
603
+ const retries = options.resolveRetries?.(config) ?? options.retries ?? DEFAULT_RETRIES;
604
+ await postWithRetry({
605
+ name: options.name,
606
+ request,
607
+ timeoutMs,
608
+ retries
609
+ });
610
+ }
611
+ });
562
612
  }
563
613
 
564
- // src/enricher-toolkit.ts
614
+ //#endregion
615
+ //#region src/enricher-toolkit.ts
565
616
  function isPlainObject(value) {
566
- return value !== null && typeof value === "object" && !Array.isArray(value);
617
+ return value !== null && typeof value === "object" && !Array.isArray(value);
567
618
  }
568
- function mergeInto2(target, source) {
569
- for (const key in source) {
570
- const sourceVal = source[key];
571
- if (sourceVal === void 0) continue;
572
- const targetVal = target[key];
573
- if (isPlainObject(sourceVal) && isPlainObject(targetVal)) {
574
- mergeInto2(targetVal, sourceVal);
575
- } else {
576
- target[key] = sourceVal;
577
- }
578
- }
619
+ function mergeInto(target, source) {
620
+ for (const key in source) {
621
+ const sourceVal = source[key];
622
+ if (sourceVal === void 0) continue;
623
+ const targetVal = target[key];
624
+ if (isPlainObject(sourceVal) && isPlainObject(targetVal)) mergeInto(targetVal, sourceVal);
625
+ else target[key] = sourceVal;
626
+ }
579
627
  }
580
628
  function defineEnricher(def, options = {}) {
581
- return (ctx2) => {
582
- let computed;
583
- try {
584
- computed = def.compute(ctx2);
585
- } catch (error) {
586
- console.error(`[autotel/${def.name}] enrich failed:`, error);
587
- return;
588
- }
589
- if (!computed) return;
590
- if (options.overwrite || !isPlainObject(ctx2.event[def.field])) {
591
- ctx2.event[def.field] = computed;
592
- return;
593
- }
594
- mergeInto2(
595
- ctx2.event[def.field],
596
- computed
597
- );
598
- };
629
+ return (ctx) => {
630
+ let computed;
631
+ try {
632
+ computed = def.compute(ctx);
633
+ } catch (error) {
634
+ console.error(`[autotel/${def.name}] enrich failed:`, error);
635
+ return;
636
+ }
637
+ if (!computed) return;
638
+ if (options.overwrite || !isPlainObject(ctx.event[def.field])) {
639
+ ctx.event[def.field] = computed;
640
+ return;
641
+ }
642
+ mergeInto(ctx.event[def.field], computed);
643
+ };
599
644
  }
600
- var GEN_AI_DURATION_BUCKETS_SECONDS = Object.freeze(
601
- [0.01, 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 20, 30, 60, 120, 300]
602
- );
603
- var GEN_AI_TOKEN_USAGE_BUCKETS = Object.freeze([
604
- 1,
605
- 4,
606
- 16,
607
- 64,
608
- 256,
609
- 1024,
610
- 4096,
611
- 16384,
612
- 65536,
613
- 262144,
614
- 1048576,
615
- 4194304
645
+
646
+ //#endregion
647
+ //#region src/gen-ai-metrics.ts
648
+ /**
649
+ * LLM-tuned histogram buckets.
650
+ *
651
+ * Default OpenTelemetry histogram buckets target HTTP latency (0ms–10s)
652
+ * and small counter values. LLM workloads have very different shapes:
653
+ *
654
+ * - **Duration**: single-token prompts can be fast (50ms), long
655
+ * generations and reasoning models can run for minutes. Default buckets
656
+ * crush everything above 10s into one bucket.
657
+ * - **Token usage**: heavily right-skewed. A single request can range
658
+ * from tens of tokens to the million-token context windows.
659
+ * - **Cost (USD)**: per-request values are tiny (fractions of a cent),
660
+ * so linear buckets waste resolution at the low end.
661
+ *
662
+ * This module exposes empirically-chosen bucket arrays and a View helper
663
+ * so users can apply them to their `MeterProvider` without knowing the
664
+ * exact instrument names emitted by OpenAI/Anthropic/Traceloop plugins.
665
+ *
666
+ * @example
667
+ * ```typescript
668
+ * import { NodeSDK } from '@opentelemetry/sdk-node';
669
+ * import { genAiMetricViews } from 'autotel';
670
+ *
671
+ * const sdk = new NodeSDK({
672
+ * serviceName: 'my-agent',
673
+ * views: [...genAiMetricViews()],
674
+ * });
675
+ * sdk.start();
676
+ * ```
677
+ */
678
+ /**
679
+ * Duration buckets for LLM operations, in **seconds**. Covers fast
680
+ * completions (50ms) through long-running reasoning jobs (5 min).
681
+ *
682
+ * Aligns with the OTel GenAI semantic conventions' published advice for
683
+ * `gen_ai.client.operation.duration`.
684
+ */
685
+ const GEN_AI_DURATION_BUCKETS_SECONDS = Object.freeze([
686
+ .01,
687
+ .05,
688
+ .1,
689
+ .25,
690
+ .5,
691
+ 1,
692
+ 2,
693
+ 5,
694
+ 10,
695
+ 20,
696
+ 30,
697
+ 60,
698
+ 120,
699
+ 300
700
+ ]);
701
+ /**
702
+ * Token-count buckets for prompt, completion, and total token histograms.
703
+ * Ranges from tiny prompts to million-token context windows.
704
+ *
705
+ * Aligns with the OTel GenAI semantic conventions' published advice for
706
+ * `gen_ai.client.token.usage`.
707
+ */
708
+ const GEN_AI_TOKEN_USAGE_BUCKETS = Object.freeze([
709
+ 1,
710
+ 4,
711
+ 16,
712
+ 64,
713
+ 256,
714
+ 1024,
715
+ 4096,
716
+ 16384,
717
+ 65536,
718
+ 262144,
719
+ 1048576,
720
+ 4194304
616
721
  ]);
617
- var GEN_AI_COST_USD_BUCKETS = Object.freeze([
618
- 1e-5,
619
- 1e-4,
620
- 1e-3,
621
- 5e-3,
622
- 0.01,
623
- 0.05,
624
- 0.1,
625
- 0.5,
626
- 1,
627
- 5,
628
- 10,
629
- 50
722
+ /**
723
+ * USD cost buckets. Sub-cent resolution at the low end (fractions of a
724
+ * cent per small call) up to tens of dollars (batch jobs, Opus/o1 runs).
725
+ */
726
+ const GEN_AI_COST_USD_BUCKETS = Object.freeze([
727
+ 1e-5,
728
+ 1e-4,
729
+ .001,
730
+ .005,
731
+ .01,
732
+ .05,
733
+ .1,
734
+ .5,
735
+ 1,
736
+ 5,
737
+ 10,
738
+ 50
630
739
  ]);
740
+ /**
741
+ * Instrument-level advice object for `createHistogram(name, advice)`.
742
+ * Use when you control the instrument creation (e.g. custom business
743
+ * LLM metrics); `genAiMetricViews()` is better when the metric comes
744
+ * from a third-party plugin.
745
+ */
631
746
  function llmHistogramAdvice(kind) {
632
- const boundaries = kind === "duration" ? GEN_AI_DURATION_BUCKETS_SECONDS : kind === "tokens" ? GEN_AI_TOKEN_USAGE_BUCKETS : GEN_AI_COST_USD_BUCKETS;
633
- return { advice: { explicitBucketBoundaries: [...boundaries] } };
747
+ return { advice: { explicitBucketBoundaries: [...kind === "duration" ? GEN_AI_DURATION_BUCKETS_SECONDS : kind === "tokens" ? GEN_AI_TOKEN_USAGE_BUCKETS : GEN_AI_COST_USD_BUCKETS] } };
634
748
  }
749
+ /**
750
+ * Returns `View`s that re-bucket the standard OTel GenAI histograms. Pass
751
+ * the result to your `MeterProvider`'s `views` option.
752
+ *
753
+ * Matches instrument names emitted by:
754
+ * - OpenTelemetry GenAI autoinstrumentation
755
+ * - OpenInference / OpenLLMetry (traceloop)
756
+ * - Arize Phoenix, LangSmith, etc. that follow the OTel spec
757
+ *
758
+ * Add more instrument patterns via the `extra` argument if you emit
759
+ * custom LLM metrics.
760
+ */
635
761
  function genAiMetricViews(extra = []) {
636
- const defaults = [
637
- { instrumentName: "gen_ai.client.operation.duration", kind: "duration" },
638
- { instrumentName: "gen_ai.client.token.usage", kind: "tokens" },
639
- // Autotel-emitted cost metric. No-op if you don't emit it.
640
- { instrumentName: "gen_ai.client.cost.usd", kind: "cost" }
641
- ];
642
- return [...defaults, ...extra].map(
643
- ({ instrumentName, kind }) => ({
644
- instrumentName,
645
- aggregation: {
646
- type: sdkMetrics.AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
647
- options: {
648
- boundaries: kind === "duration" ? [...GEN_AI_DURATION_BUCKETS_SECONDS] : kind === "tokens" ? [...GEN_AI_TOKEN_USAGE_BUCKETS] : [...GEN_AI_COST_USD_BUCKETS]
649
- }
650
- }
651
- })
652
- );
762
+ return [...[
763
+ {
764
+ instrumentName: "gen_ai.client.operation.duration",
765
+ kind: "duration"
766
+ },
767
+ {
768
+ instrumentName: "gen_ai.client.token.usage",
769
+ kind: "tokens"
770
+ },
771
+ {
772
+ instrumentName: "gen_ai.client.cost.usd",
773
+ kind: "cost"
774
+ }
775
+ ], ...extra].map(({ instrumentName, kind }) => ({
776
+ instrumentName,
777
+ aggregation: {
778
+ type: _opentelemetry_sdk_metrics.AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
779
+ options: { boundaries: kind === "duration" ? [...GEN_AI_DURATION_BUCKETS_SECONDS] : kind === "tokens" ? [...GEN_AI_TOKEN_USAGE_BUCKETS] : [...GEN_AI_COST_USD_BUCKETS] }
780
+ }
781
+ }));
653
782
  }
654
783
 
655
- // src/gen-ai-events.ts
656
- function recordPromptSent(ctx2, event = {}) {
657
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(ctx2, "gen_ai.prompt.sent", buildPromptSentAttrs(event));
784
+ //#endregion
785
+ //#region src/gen-ai-events.ts
786
+ /**
787
+ * Record that a prompt was dispatched to the provider. Typically called
788
+ * before `await provider.chat.completions.create(...)`.
789
+ */
790
+ function recordPromptSent(ctx, event = {}) {
791
+ require_correlated_events.emitCorrelatedEvent(ctx, "gen_ai.prompt.sent", buildPromptSentAttrs(event));
658
792
  }
659
- function recordResponseReceived(ctx2, event = {}) {
660
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(
661
- ctx2,
662
- "gen_ai.response.received",
663
- buildResponseAttrs(event)
664
- );
793
+ /**
794
+ * Record a successful provider response. Call after the response arrives
795
+ * (for non-streaming) or after the stream completes.
796
+ */
797
+ function recordResponseReceived(ctx, event = {}) {
798
+ require_correlated_events.emitCorrelatedEvent(ctx, "gen_ai.response.received", buildResponseAttrs(event));
665
799
  }
666
- function recordRetry(ctx2, event) {
667
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(ctx2, "gen_ai.retry", buildRetryAttrs(event));
800
+ /**
801
+ * Record a retry attempt on an LLM call. Call *before* sleeping for
802
+ * `delayMs` so the event timestamp accurately marks when the retry
803
+ * decision was made.
804
+ */
805
+ function recordRetry(ctx, event) {
806
+ require_correlated_events.emitCorrelatedEvent(ctx, "gen_ai.retry", buildRetryAttrs(event));
668
807
  }
669
- function recordToolCall(ctx2, event) {
670
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(ctx2, "gen_ai.tool.call", buildToolCallAttrs(event));
808
+ /**
809
+ * Record a tool / function call made in the course of an agent step.
810
+ * Emits an event rather than a child span because many frameworks fire
811
+ * several tool calls within a single provider response.
812
+ */
813
+ function recordToolCall(ctx, event) {
814
+ require_correlated_events.emitCorrelatedEvent(ctx, "gen_ai.tool.call", buildToolCallAttrs(event));
671
815
  }
672
- function recordStreamFirstToken(ctx2, event = {}) {
673
- chunk4P6ZOARG_cjs.emitCorrelatedEvent(
674
- ctx2,
675
- "gen_ai.stream.first_token",
676
- buildStreamFirstTokenAttrs(event)
677
- );
816
+ /**
817
+ * Record the time-to-first-token for a streaming response. Pair with
818
+ * `recordResponseReceived` at the end so the span carries both the TTFT
819
+ * marker and the final usage numbers.
820
+ */
821
+ function recordStreamFirstToken(ctx, event = {}) {
822
+ require_correlated_events.emitCorrelatedEvent(ctx, "gen_ai.stream.first_token", buildStreamFirstTokenAttrs(event));
678
823
  }
679
824
  function buildPromptSentAttrs(event) {
680
- const attrs2 = {};
681
- if (event.model) attrs2["gen_ai.request.model"] = event.model;
682
- if (event.promptTokens !== void 0)
683
- attrs2["gen_ai.usage.input_tokens"] = event.promptTokens;
684
- if (event.messageCount !== void 0)
685
- attrs2["gen_ai.request.message_count"] = event.messageCount;
686
- if (event.operation) attrs2["gen_ai.operation.name"] = event.operation;
687
- return attrs2;
825
+ const attrs = {};
826
+ if (event.model) attrs["gen_ai.request.model"] = event.model;
827
+ if (event.promptTokens !== void 0) attrs["gen_ai.usage.input_tokens"] = event.promptTokens;
828
+ if (event.messageCount !== void 0) attrs["gen_ai.request.message_count"] = event.messageCount;
829
+ if (event.operation) attrs["gen_ai.operation.name"] = event.operation;
830
+ return attrs;
688
831
  }
689
832
  function buildResponseAttrs(event) {
690
- const attrs2 = {};
691
- if (event.model) attrs2["gen_ai.response.model"] = event.model;
692
- if (event.promptTokens !== void 0)
693
- attrs2["gen_ai.usage.input_tokens"] = event.promptTokens;
694
- if (event.completionTokens !== void 0)
695
- attrs2["gen_ai.usage.output_tokens"] = event.completionTokens;
696
- if (event.totalTokens !== void 0)
697
- attrs2["gen_ai.usage.total_tokens"] = event.totalTokens;
698
- if (event.finishReasons && event.finishReasons.length > 0) {
699
- attrs2["gen_ai.response.finish_reasons"] = event.finishReasons.join(",");
700
- }
701
- return attrs2;
833
+ const attrs = {};
834
+ if (event.model) attrs["gen_ai.response.model"] = event.model;
835
+ if (event.promptTokens !== void 0) attrs["gen_ai.usage.input_tokens"] = event.promptTokens;
836
+ if (event.completionTokens !== void 0) attrs["gen_ai.usage.output_tokens"] = event.completionTokens;
837
+ if (event.totalTokens !== void 0) attrs["gen_ai.usage.total_tokens"] = event.totalTokens;
838
+ if (event.finishReasons && event.finishReasons.length > 0) attrs["gen_ai.response.finish_reasons"] = event.finishReasons.join(",");
839
+ return attrs;
702
840
  }
703
841
  function buildRetryAttrs(event) {
704
- const attrs2 = { "retry.attempt": event.attempt };
705
- if (event.reason) attrs2["retry.reason"] = event.reason;
706
- if (event.delayMs !== void 0) attrs2["retry.delay_ms"] = event.delayMs;
707
- if (event.statusCode !== void 0)
708
- attrs2["http.response.status_code"] = event.statusCode;
709
- return attrs2;
842
+ const attrs = { "retry.attempt": event.attempt };
843
+ if (event.reason) attrs["retry.reason"] = event.reason;
844
+ if (event.delayMs !== void 0) attrs["retry.delay_ms"] = event.delayMs;
845
+ if (event.statusCode !== void 0) attrs["http.response.status_code"] = event.statusCode;
846
+ return attrs;
710
847
  }
711
848
  function buildToolCallAttrs(event) {
712
- const attrs2 = { "gen_ai.tool.name": event.toolName };
713
- if (event.toolCallId) attrs2["gen_ai.tool.call.id"] = event.toolCallId;
714
- if (event.arguments) attrs2["gen_ai.tool.arguments"] = event.arguments;
715
- return attrs2;
849
+ const attrs = { "gen_ai.tool.name": event.toolName };
850
+ if (event.toolCallId) attrs["gen_ai.tool.call.id"] = event.toolCallId;
851
+ if (event.arguments) attrs["gen_ai.tool.arguments"] = event.arguments;
852
+ return attrs;
716
853
  }
717
854
  function buildStreamFirstTokenAttrs(event) {
718
- const attrs2 = {};
719
- if (event.tokensSoFar !== void 0)
720
- attrs2["gen_ai.stream.tokens_so_far"] = event.tokensSoFar;
721
- return attrs2;
855
+ const attrs = {};
856
+ if (event.tokensSoFar !== void 0) attrs["gen_ai.stream.tokens_so_far"] = event.tokensSoFar;
857
+ return attrs;
722
858
  }
723
859
 
724
- // src/gen-ai-cost.ts
725
- var GEN_AI_COST_ATTRIBUTE = "gen_ai.usage.cost.usd";
726
- var MODEL_PRICING = {
727
- // OpenAI
728
- "gpt-4o": { inputPer1M: 2.5, outputPer1M: 10 },
729
- "gpt-4o-mini": { inputPer1M: 0.15, outputPer1M: 0.6 },
730
- "gpt-4.1": { inputPer1M: 2, outputPer1M: 8 },
731
- "gpt-4.1-mini": { inputPer1M: 0.4, outputPer1M: 1.6 },
732
- "gpt-4.1-nano": { inputPer1M: 0.1, outputPer1M: 0.4 },
733
- "o3-mini": { inputPer1M: 1.1, outputPer1M: 4.4 },
734
- // Anthropic Claude
735
- "claude-opus-4": { inputPer1M: 15, outputPer1M: 75 },
736
- "claude-sonnet-4": { inputPer1M: 3, outputPer1M: 15 },
737
- "claude-3-5-sonnet": { inputPer1M: 3, outputPer1M: 15 },
738
- "claude-3-5-haiku": { inputPer1M: 0.8, outputPer1M: 4 },
739
- "claude-3-opus": { inputPer1M: 15, outputPer1M: 75 },
740
- "claude-3-haiku": { inputPer1M: 0.25, outputPer1M: 1.25 },
741
- // Google Gemini
742
- "gemini-1.5-pro": { inputPer1M: 1.25, outputPer1M: 5 },
743
- "gemini-1.5-flash": { inputPer1M: 0.075, outputPer1M: 0.3 },
744
- "gemini-2.0-flash": { inputPer1M: 0.1, outputPer1M: 0.4 }
860
+ //#endregion
861
+ //#region src/gen-ai-cost.ts
862
+ /** Span attribute key autotel sets for an estimated call cost. */
863
+ const GEN_AI_COST_ATTRIBUTE = "gen_ai.usage.cost.usd";
864
+ /**
865
+ * Approximate public list prices (USD per 1M tokens) at the time of writing.
866
+ * Prices change; treat these as convenience defaults, not a billing source of
867
+ * truth. Override per call via `options.pricing` or mutate this table at init.
868
+ * Matching is exact first, then by longest key prefix, so versioned model ids
869
+ * (`claude-sonnet-4-6-20251101`) resolve to a base entry (`claude-sonnet-4-6`).
870
+ */
871
+ const MODEL_PRICING = {
872
+ "gpt-4o": {
873
+ inputPer1M: 2.5,
874
+ outputPer1M: 10
875
+ },
876
+ "gpt-4o-mini": {
877
+ inputPer1M: .15,
878
+ outputPer1M: .6
879
+ },
880
+ "gpt-4.1": {
881
+ inputPer1M: 2,
882
+ outputPer1M: 8
883
+ },
884
+ "gpt-4.1-mini": {
885
+ inputPer1M: .4,
886
+ outputPer1M: 1.6
887
+ },
888
+ "gpt-4.1-nano": {
889
+ inputPer1M: .1,
890
+ outputPer1M: .4
891
+ },
892
+ "o3-mini": {
893
+ inputPer1M: 1.1,
894
+ outputPer1M: 4.4
895
+ },
896
+ "claude-opus-4": {
897
+ inputPer1M: 15,
898
+ outputPer1M: 75
899
+ },
900
+ "claude-sonnet-4": {
901
+ inputPer1M: 3,
902
+ outputPer1M: 15
903
+ },
904
+ "claude-3-5-sonnet": {
905
+ inputPer1M: 3,
906
+ outputPer1M: 15
907
+ },
908
+ "claude-3-5-haiku": {
909
+ inputPer1M: .8,
910
+ outputPer1M: 4
911
+ },
912
+ "claude-3-opus": {
913
+ inputPer1M: 15,
914
+ outputPer1M: 75
915
+ },
916
+ "claude-3-haiku": {
917
+ inputPer1M: .25,
918
+ outputPer1M: 1.25
919
+ },
920
+ "gemini-1.5-pro": {
921
+ inputPer1M: 1.25,
922
+ outputPer1M: 5
923
+ },
924
+ "gemini-1.5-flash": {
925
+ inputPer1M: .075,
926
+ outputPer1M: .3
927
+ },
928
+ "gemini-2.0-flash": {
929
+ inputPer1M: .1,
930
+ outputPer1M: .4
931
+ }
745
932
  };
746
933
  function resolvePricing(table, model) {
747
- const exact = table[model];
748
- if (exact) return exact;
749
- let best;
750
- let bestLength = 0;
751
- for (const key of Object.keys(table)) {
752
- if (model.startsWith(key) && key.length > bestLength) {
753
- best = table[key];
754
- bestLength = key.length;
755
- }
756
- }
757
- return best;
934
+ const exact = table[model];
935
+ if (exact) return exact;
936
+ let best;
937
+ let bestLength = 0;
938
+ for (const key of Object.keys(table)) if (model.startsWith(key) && key.length > bestLength) {
939
+ best = table[key];
940
+ bestLength = key.length;
941
+ }
942
+ return best;
758
943
  }
759
944
  function round(value) {
760
- return Math.round(value * 1e6) / 1e6;
945
+ return Math.round(value * 1e6) / 1e6;
761
946
  }
947
+ /**
948
+ * Estimate the USD cost of an LLM call. Returns `undefined` when the model has
949
+ * no known pricing (supply one via `options.pricing`).
950
+ */
762
951
  function estimateLLMCost(model, usage, options) {
763
- const table = options?.pricing ? { ...MODEL_PRICING, ...options.pricing } : MODEL_PRICING;
764
- const price = resolvePricing(table, model);
765
- if (!price) return void 0;
766
- const cachedInput = usage.cachedInputTokens ?? 0;
767
- const billedInput = Math.max(0, (usage.inputTokens ?? 0) - cachedInput);
768
- const output = usage.outputTokens ?? 0;
769
- const cachedRate = price.cachedInputPer1M ?? price.inputPer1M;
770
- const cost = billedInput / 1e6 * price.inputPer1M + cachedInput / 1e6 * cachedRate + output / 1e6 * price.outputPer1M;
771
- return round(cost);
952
+ const price = resolvePricing(options?.pricing ? {
953
+ ...MODEL_PRICING,
954
+ ...options.pricing
955
+ } : MODEL_PRICING, model);
956
+ if (!price) return void 0;
957
+ const cachedInput = usage.cachedInputTokens ?? 0;
958
+ const billedInput = Math.max(0, (usage.inputTokens ?? 0) - cachedInput);
959
+ const output = usage.outputTokens ?? 0;
960
+ const cachedRate = price.cachedInputPer1M ?? price.inputPer1M;
961
+ return round(billedInput / 1e6 * price.inputPer1M + cachedInput / 1e6 * cachedRate + output / 1e6 * price.outputPer1M);
772
962
  }
773
- function recordLLMCost(ctx2, model, usage, options) {
774
- const cost = estimateLLMCost(model, usage, options);
775
- if (cost !== void 0) {
776
- ctx2.setAttribute(GEN_AI_COST_ATTRIBUTE, cost);
777
- }
778
- return cost;
963
+ /**
964
+ * Estimate cost and record it on `ctx` as the `gen_ai.usage.cost.usd` span
965
+ * attribute. Returns the estimated cost, or `undefined` when the model is
966
+ * unknown (in which case no attribute is set).
967
+ */
968
+ function recordLLMCost(ctx, model, usage, options) {
969
+ const cost = estimateLLMCost(model, usage, options);
970
+ if (cost !== void 0) ctx.setAttribute(GEN_AI_COST_ATTRIBUTE, cost);
971
+ return cost;
779
972
  }
780
973
 
781
- Object.defineProperty(exports, "parseError", {
782
- enumerable: true,
783
- get: function () { return chunkT4B5LB6E_cjs.parseError; }
784
- });
785
- Object.defineProperty(exports, "createDrainPipeline", {
786
- enumerable: true,
787
- get: function () { return chunk7EQ4G4SI_cjs.createDrainPipeline; }
788
- });
789
- Object.defineProperty(exports, "getCurrentWorkflowContext", {
790
- enumerable: true,
791
- get: function () { return chunkAC5GNZKB_cjs.getCurrentWorkflowContext; }
792
- });
793
- Object.defineProperty(exports, "isInWorkflow", {
794
- enumerable: true,
795
- get: function () { return chunkAC5GNZKB_cjs.isInWorkflow; }
796
- });
797
- Object.defineProperty(exports, "traceStep", {
798
- enumerable: true,
799
- get: function () { return chunkAC5GNZKB_cjs.traceStep; }
800
- });
801
- Object.defineProperty(exports, "traceWorkflow", {
802
- enumerable: true,
803
- get: function () { return chunkAC5GNZKB_cjs.traceWorkflow; }
804
- });
805
- Object.defineProperty(exports, "attrs", {
806
- enumerable: true,
807
- get: function () { return chunkM3LFHHTN_cjs.attrs; }
808
- });
809
- Object.defineProperty(exports, "autoRedactPII", {
810
- enumerable: true,
811
- get: function () { return chunkM3LFHHTN_cjs.autoRedactPII; }
812
- });
813
- Object.defineProperty(exports, "dbClient", {
814
- enumerable: true,
815
- get: function () { return chunkM3LFHHTN_cjs.dbClient; }
816
- });
817
- Object.defineProperty(exports, "httpClient", {
818
- enumerable: true,
819
- get: function () { return chunkM3LFHHTN_cjs.httpClient; }
820
- });
821
- Object.defineProperty(exports, "httpServer", {
822
- enumerable: true,
823
- get: function () { return chunkM3LFHHTN_cjs.httpServer; }
824
- });
825
- Object.defineProperty(exports, "identify", {
826
- enumerable: true,
827
- get: function () { return chunkM3LFHHTN_cjs.identify; }
828
- });
829
- Object.defineProperty(exports, "mergeAttrs", {
830
- enumerable: true,
831
- get: function () { return chunkM3LFHHTN_cjs.mergeAttrs; }
832
- });
833
- Object.defineProperty(exports, "mergeServiceResource", {
834
- enumerable: true,
835
- get: function () { return chunkM3LFHHTN_cjs.mergeServiceResource; }
836
- });
837
- Object.defineProperty(exports, "request", {
838
- enumerable: true,
839
- get: function () { return chunkM3LFHHTN_cjs.request; }
840
- });
841
- Object.defineProperty(exports, "safeSetAttributes", {
842
- enumerable: true,
843
- get: function () { return chunkM3LFHHTN_cjs.safeSetAttributes; }
844
- });
845
- Object.defineProperty(exports, "setDevice", {
846
- enumerable: true,
847
- get: function () { return chunkM3LFHHTN_cjs.setDevice; }
848
- });
849
- Object.defineProperty(exports, "setError", {
850
- enumerable: true,
851
- get: function () { return chunkM3LFHHTN_cjs.setError; }
852
- });
853
- Object.defineProperty(exports, "setException", {
854
- enumerable: true,
855
- get: function () { return chunkM3LFHHTN_cjs.setException; }
856
- });
857
- Object.defineProperty(exports, "setSession", {
858
- enumerable: true,
859
- get: function () { return chunkM3LFHHTN_cjs.setSession; }
860
- });
861
- Object.defineProperty(exports, "setUser", {
862
- enumerable: true,
863
- get: function () { return chunkM3LFHHTN_cjs.setUser; }
864
- });
865
- Object.defineProperty(exports, "validateAttribute", {
866
- enumerable: true,
867
- get: function () { return chunkM3LFHHTN_cjs.validateAttribute; }
868
- });
869
- Object.defineProperty(exports, "httpRequestHeaderAttribute", {
870
- enumerable: true,
871
- get: function () { return chunk2ZKEORFN_cjs.httpRequestHeaderAttribute; }
872
- });
873
- Object.defineProperty(exports, "httpResponseHeaderAttribute", {
874
- enumerable: true,
875
- get: function () { return chunk2ZKEORFN_cjs.httpResponseHeaderAttribute; }
876
- });
877
- Object.defineProperty(exports, "HTTPAttributes", {
878
- enumerable: true,
879
- get: function () { return chunkESMHTKLJ_cjs.HTTPAttributes; }
880
- });
881
- Object.defineProperty(exports, "ServiceAttributes", {
882
- enumerable: true,
883
- get: function () { return chunkESMHTKLJ_cjs.ServiceAttributes; }
884
- });
885
- Object.defineProperty(exports, "URLAttributes", {
886
- enumerable: true,
887
- get: function () { return chunkESMHTKLJ_cjs.URLAttributes; }
888
- });
889
- Object.defineProperty(exports, "traceConsumer", {
890
- enumerable: true,
891
- get: function () { return chunkZ6HRSM2Y_cjs.traceConsumer; }
892
- });
893
- Object.defineProperty(exports, "traceProducer", {
894
- enumerable: true,
895
- get: function () { return chunkZ6HRSM2Y_cjs.traceProducer; }
896
- });
897
- Object.defineProperty(exports, "BusinessBaggage", {
898
- enumerable: true,
899
- get: function () { return chunkINJD3G4K_cjs.BusinessBaggage; }
900
- });
901
- Object.defineProperty(exports, "createSafeBaggageSchema", {
902
- enumerable: true,
903
- get: function () { return chunkINJD3G4K_cjs.createSafeBaggageSchema; }
904
- });
905
- Object.defineProperty(exports, "Metric", {
906
- enumerable: true,
907
- get: function () { return chunkTC5ZPWM4_cjs.Metric; }
908
- });
909
- Object.defineProperty(exports, "getMetrics", {
910
- enumerable: true,
911
- get: function () { return chunkTC5ZPWM4_cjs.getMetrics; }
912
- });
913
- Object.defineProperty(exports, "resetMetrics", {
914
- enumerable: true,
915
- get: function () { return chunkTC5ZPWM4_cjs.resetMetrics; }
916
- });
917
- Object.defineProperty(exports, "createCounter", {
918
- enumerable: true,
919
- get: function () { return chunkWJH6IYU2_cjs.createCounter; }
920
- });
921
- Object.defineProperty(exports, "createHistogram", {
922
- enumerable: true,
923
- get: function () { return chunkWJH6IYU2_cjs.createHistogram; }
924
- });
925
- Object.defineProperty(exports, "createObservableGauge", {
926
- enumerable: true,
927
- get: function () { return chunkWJH6IYU2_cjs.createObservableGauge; }
928
- });
929
- Object.defineProperty(exports, "createUpDownCounter", {
930
- enumerable: true,
931
- get: function () { return chunkWJH6IYU2_cjs.createUpDownCounter; }
932
- });
933
- Object.defineProperty(exports, "getMeter", {
934
- enumerable: true,
935
- get: function () { return chunkWJH6IYU2_cjs.getMeter; }
936
- });
937
- Object.defineProperty(exports, "traceDB", {
938
- enumerable: true,
939
- get: function () { return chunkVG2ABKJX_cjs.traceDB; }
940
- });
941
- Object.defineProperty(exports, "traceHTTP", {
942
- enumerable: true,
943
- get: function () { return chunkVG2ABKJX_cjs.traceHTTP; }
944
- });
945
- Object.defineProperty(exports, "traceLLM", {
946
- enumerable: true,
947
- get: function () { return chunkVG2ABKJX_cjs.traceLLM; }
948
- });
949
- Object.defineProperty(exports, "traceMessaging", {
950
- enumerable: true,
951
- get: function () { return chunkVG2ABKJX_cjs.traceMessaging; }
952
- });
953
- Object.defineProperty(exports, "ctx", {
954
- enumerable: true,
955
- get: function () { return chunkFGNDN2FD_cjs.ctx; }
956
- });
957
- Object.defineProperty(exports, "instrument", {
958
- enumerable: true,
959
- get: function () { return chunkFGNDN2FD_cjs.instrument; }
960
- });
961
- Object.defineProperty(exports, "markAsImmediate", {
962
- enumerable: true,
963
- get: function () { return chunkFGNDN2FD_cjs.markAsImmediate; }
964
- });
965
- Object.defineProperty(exports, "span", {
966
- enumerable: true,
967
- get: function () { return chunkFGNDN2FD_cjs.span; }
968
- });
969
- Object.defineProperty(exports, "withBaggage", {
970
- enumerable: true,
971
- get: function () { return chunkFGNDN2FD_cjs.withBaggage; }
972
- });
973
- Object.defineProperty(exports, "withNewContext", {
974
- enumerable: true,
975
- get: function () { return chunkFGNDN2FD_cjs.withNewContext; }
976
- });
977
- Object.defineProperty(exports, "withTracing", {
978
- enumerable: true,
979
- get: function () { return chunkFGNDN2FD_cjs.withTracing; }
980
- });
981
- Object.defineProperty(exports, "createDeterministicTraceId", {
982
- enumerable: true,
983
- get: function () { return chunkOPPXYVEZ_cjs.createDeterministicTraceId; }
984
- });
985
- Object.defineProperty(exports, "enrichWithTraceContext", {
986
- enumerable: true,
987
- get: function () { return chunkOPPXYVEZ_cjs.enrichWithTraceContext; }
988
- });
989
- Object.defineProperty(exports, "finalizeSpan", {
990
- enumerable: true,
991
- get: function () { return chunkOPPXYVEZ_cjs.finalizeSpan; }
992
- });
993
- Object.defineProperty(exports, "flattenMetadata", {
994
- enumerable: true,
995
- get: function () { return chunkOPPXYVEZ_cjs.flattenMetadata; }
996
- });
997
- Object.defineProperty(exports, "getActiveContext", {
998
- enumerable: true,
999
- get: function () { return chunkOPPXYVEZ_cjs.getActiveContext; }
1000
- });
1001
- Object.defineProperty(exports, "getActiveSpan", {
1002
- enumerable: true,
1003
- get: function () { return chunkOPPXYVEZ_cjs.getActiveSpan; }
1004
- });
1005
- Object.defineProperty(exports, "getTraceContext", {
1006
- enumerable: true,
1007
- get: function () { return chunkOPPXYVEZ_cjs.getTraceContext; }
1008
- });
1009
- Object.defineProperty(exports, "getTracer", {
1010
- enumerable: true,
1011
- get: function () { return chunkOPPXYVEZ_cjs.getTracer; }
1012
- });
1013
- Object.defineProperty(exports, "isTracing", {
1014
- enumerable: true,
1015
- get: function () { return chunkOPPXYVEZ_cjs.isTracing; }
1016
- });
1017
- Object.defineProperty(exports, "resolveTraceUrl", {
1018
- enumerable: true,
1019
- get: function () { return chunkOPPXYVEZ_cjs.resolveTraceUrl; }
1020
- });
1021
- Object.defineProperty(exports, "runWithSpan", {
1022
- enumerable: true,
1023
- get: function () { return chunkOPPXYVEZ_cjs.runWithSpan; }
1024
- });
1025
- Object.defineProperty(exports, "Event", {
1026
- enumerable: true,
1027
- get: function () { return chunkGBFTC7Q7_cjs.Event; }
1028
- });
1029
- Object.defineProperty(exports, "getEvents", {
1030
- enumerable: true,
1031
- get: function () { return chunkGBFTC7Q7_cjs.getEvents; }
1032
- });
1033
- Object.defineProperty(exports, "resetEvents", {
1034
- enumerable: true,
1035
- get: function () { return chunkGBFTC7Q7_cjs.resetEvents; }
1036
- });
1037
- Object.defineProperty(exports, "getOperationContext", {
1038
- enumerable: true,
1039
- get: function () { return chunkVQTCQKHQ_cjs.getOperationContext; }
1040
- });
1041
- Object.defineProperty(exports, "runInOperationContext", {
1042
- enumerable: true,
1043
- get: function () { return chunkVQTCQKHQ_cjs.runInOperationContext; }
1044
- });
1045
- Object.defineProperty(exports, "CORRELATION_ID_BAGGAGE_KEY", {
1046
- enumerable: true,
1047
- get: function () { return chunkZ7PW3KHL_cjs.CORRELATION_ID_BAGGAGE_KEY; }
1048
- });
1049
- Object.defineProperty(exports, "createStructuredError", {
1050
- enumerable: true,
1051
- get: function () { return chunkZ7PW3KHL_cjs.createStructuredError; }
1052
- });
1053
- Object.defineProperty(exports, "defineBaggageSchema", {
1054
- enumerable: true,
1055
- get: function () { return chunkZ7PW3KHL_cjs.defineBaggageSchema; }
1056
- });
1057
- Object.defineProperty(exports, "flattenToAttributes", {
1058
- enumerable: true,
1059
- get: function () { return chunkZ7PW3KHL_cjs.flattenToAttributes; }
1060
- });
1061
- Object.defineProperty(exports, "generateCorrelationId", {
1062
- enumerable: true,
1063
- get: function () { return chunkZ7PW3KHL_cjs.generateCorrelationId; }
1064
- });
1065
- Object.defineProperty(exports, "getCorrelationId", {
1066
- enumerable: true,
1067
- get: function () { return chunkZ7PW3KHL_cjs.getCorrelationId; }
1068
- });
1069
- Object.defineProperty(exports, "getEventQueue", {
1070
- enumerable: true,
1071
- get: function () { return chunkZ7PW3KHL_cjs.getEventQueue; }
1072
- });
1073
- Object.defineProperty(exports, "getOrCreateCorrelationId", {
1074
- enumerable: true,
1075
- get: function () { return chunkZ7PW3KHL_cjs.getOrCreateCorrelationId; }
1076
- });
1077
- Object.defineProperty(exports, "getStructuredErrorAttributes", {
1078
- enumerable: true,
1079
- get: function () { return chunkZ7PW3KHL_cjs.getStructuredErrorAttributes; }
1080
- });
1081
- Object.defineProperty(exports, "recordStructuredError", {
1082
- enumerable: true,
1083
- get: function () { return chunkZ7PW3KHL_cjs.recordStructuredError; }
1084
- });
1085
- Object.defineProperty(exports, "runWithCorrelationId", {
1086
- enumerable: true,
1087
- get: function () { return chunkZ7PW3KHL_cjs.runWithCorrelationId; }
1088
- });
1089
- Object.defineProperty(exports, "setCorrelationId", {
1090
- enumerable: true,
1091
- get: function () { return chunkZ7PW3KHL_cjs.setCorrelationId; }
1092
- });
1093
- Object.defineProperty(exports, "setCorrelationIdInBaggage", {
1094
- enumerable: true,
1095
- get: function () { return chunkZ7PW3KHL_cjs.setCorrelationIdInBaggage; }
1096
- });
1097
- Object.defineProperty(exports, "structuredErrorToJSON", {
1098
- enumerable: true,
1099
- get: function () { return chunkZ7PW3KHL_cjs.structuredErrorToJSON; }
1100
- });
1101
- Object.defineProperty(exports, "toAttributeValue", {
1102
- enumerable: true,
1103
- get: function () { return chunkZ7PW3KHL_cjs.toAttributeValue; }
1104
- });
1105
- Object.defineProperty(exports, "track", {
1106
- enumerable: true,
1107
- get: function () { return chunkZ7PW3KHL_cjs.track; }
1108
- });
1109
- Object.defineProperty(exports, "BaggageSpanProcessor", {
1110
- enumerable: true,
1111
- get: function () { return chunkR7QYGZUP_cjs.BaggageSpanProcessor; }
1112
- });
1113
- Object.defineProperty(exports, "createStringRedactor", {
1114
- enumerable: true,
1115
- get: function () { return chunkR7QYGZUP_cjs.createStringRedactor; }
1116
- });
1117
- Object.defineProperty(exports, "init", {
1118
- enumerable: true,
1119
- get: function () { return chunkR7QYGZUP_cjs.init; }
1120
- });
1121
- Object.defineProperty(exports, "isInitialized", {
1122
- enumerable: true,
1123
- get: function () { return chunkR7QYGZUP_cjs.isInitialized; }
1124
- });
1125
- Object.defineProperty(exports, "isLoggerLocked", {
1126
- enumerable: true,
1127
- get: function () { return chunkR7QYGZUP_cjs.isLoggerLocked; }
1128
- });
1129
- Object.defineProperty(exports, "lockLogger", {
1130
- enumerable: true,
1131
- get: function () { return chunkR7QYGZUP_cjs.lockLogger; }
1132
- });
1133
- Object.defineProperty(exports, "FilteringSpanProcessor", {
1134
- enumerable: true,
1135
- get: function () { return chunkZNMBW67B_cjs.FilteringSpanProcessor; }
1136
- });
1137
- Object.defineProperty(exports, "NORMALIZER_PATTERNS", {
1138
- enumerable: true,
1139
- get: function () { return chunkIOYFAFHJ_cjs.NORMALIZER_PATTERNS; }
1140
- });
1141
- Object.defineProperty(exports, "NORMALIZER_PRESETS", {
1142
- enumerable: true,
1143
- get: function () { return chunkIOYFAFHJ_cjs.NORMALIZER_PRESETS; }
1144
- });
1145
- Object.defineProperty(exports, "SpanNameNormalizingProcessor", {
1146
- enumerable: true,
1147
- get: function () { return chunkIOYFAFHJ_cjs.SpanNameNormalizingProcessor; }
1148
- });
1149
- Object.defineProperty(exports, "AttributeRedactingProcessor", {
1150
- enumerable: true,
1151
- get: function () { return chunkNEIB3TLD_cjs.AttributeRedactingProcessor; }
1152
- });
1153
- Object.defineProperty(exports, "REDACTOR_PATTERNS", {
1154
- enumerable: true,
1155
- get: function () { return chunkNEIB3TLD_cjs.REDACTOR_PATTERNS; }
1156
- });
1157
- Object.defineProperty(exports, "REDACTOR_PRESETS", {
1158
- enumerable: true,
1159
- get: function () { return chunkNEIB3TLD_cjs.REDACTOR_PRESETS; }
1160
- });
1161
- Object.defineProperty(exports, "builtinPatterns", {
1162
- enumerable: true,
1163
- get: function () { return chunkNEIB3TLD_cjs.builtinPatterns; }
1164
- });
1165
- Object.defineProperty(exports, "createAttributeRedactor", {
1166
- enumerable: true,
1167
- get: function () { return chunkNEIB3TLD_cjs.createAttributeRedactor; }
1168
- });
1169
- Object.defineProperty(exports, "createRedactedSpan", {
1170
- enumerable: true,
1171
- get: function () { return chunkNEIB3TLD_cjs.createRedactedSpan; }
1172
- });
1173
- Object.defineProperty(exports, "normalizeAttributeRedactorConfig", {
1174
- enumerable: true,
1175
- get: function () { return chunkNEIB3TLD_cjs.normalizeAttributeRedactorConfig; }
1176
- });
1177
- Object.defineProperty(exports, "formatDuration", {
1178
- enumerable: true,
1179
- get: function () { return chunk6S5RUKU3_cjs.formatDuration; }
1180
- });
1181
- Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_EVALUATED", {
1182
- enumerable: true,
1183
- get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED; }
1184
- });
1185
- Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_KEEP", {
1186
- enumerable: true,
1187
- get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_KEEP; }
1188
- });
1189
- Object.defineProperty(exports, "AdaptiveSampler", {
1190
- enumerable: true,
1191
- get: function () { return chunkVH77IPJN_cjs.AdaptiveSampler; }
1192
- });
1193
- Object.defineProperty(exports, "AlwaysSampler", {
1194
- enumerable: true,
1195
- get: function () { return chunkVH77IPJN_cjs.AlwaysSampler; }
1196
- });
1197
- Object.defineProperty(exports, "NeverSampler", {
1198
- enumerable: true,
1199
- get: function () { return chunkVH77IPJN_cjs.NeverSampler; }
1200
- });
1201
- Object.defineProperty(exports, "RandomSampler", {
1202
- enumerable: true,
1203
- get: function () { return chunkVH77IPJN_cjs.RandomSampler; }
1204
- });
1205
- Object.defineProperty(exports, "UserIdSampler", {
1206
- enumerable: true,
1207
- get: function () { return chunkVH77IPJN_cjs.UserIdSampler; }
1208
- });
1209
- Object.defineProperty(exports, "createLinkFromHeaders", {
1210
- enumerable: true,
1211
- get: function () { return chunkVH77IPJN_cjs.createLinkFromHeaders; }
1212
- });
1213
- Object.defineProperty(exports, "extractLinksFromBatch", {
1214
- enumerable: true,
1215
- get: function () { return chunkVH77IPJN_cjs.extractLinksFromBatch; }
1216
- });
1217
- Object.defineProperty(exports, "resolveSamplingPreset", {
1218
- enumerable: true,
1219
- get: function () { return chunkVH77IPJN_cjs.resolveSamplingPreset; }
1220
- });
1221
- Object.defineProperty(exports, "samplingPresets", {
1222
- enumerable: true,
1223
- get: function () { return chunkVH77IPJN_cjs.samplingPresets; }
1224
- });
1225
- Object.defineProperty(exports, "getAutotelTracer", {
1226
- enumerable: true,
1227
- get: function () { return chunkYREV3LGG_cjs.getAutotelTracer; }
1228
- });
1229
- Object.defineProperty(exports, "getAutotelTracerProvider", {
1230
- enumerable: true,
1231
- get: function () { return chunkYREV3LGG_cjs.getAutotelTracerProvider; }
1232
- });
1233
- Object.defineProperty(exports, "setAutotelTracerProvider", {
1234
- enumerable: true,
1235
- get: function () { return chunkYREV3LGG_cjs.setAutotelTracerProvider; }
1236
- });
1237
- Object.defineProperty(exports, "ROOT_CONTEXT", {
1238
- enumerable: true,
1239
- get: function () { return api.ROOT_CONTEXT; }
1240
- });
1241
- Object.defineProperty(exports, "SpanKind", {
1242
- enumerable: true,
1243
- get: function () { return api.SpanKind; }
1244
- });
1245
- Object.defineProperty(exports, "SpanStatusCode", {
1246
- enumerable: true,
1247
- get: function () { return api.SpanStatusCode; }
974
+ //#endregion
975
+ exports.AUTOTEL_SAMPLING_TAIL_EVALUATED = require_sampling.AUTOTEL_SAMPLING_TAIL_EVALUATED;
976
+ exports.AUTOTEL_SAMPLING_TAIL_KEEP = require_sampling.AUTOTEL_SAMPLING_TAIL_KEEP;
977
+ exports.AdaptiveSampler = require_sampling.AdaptiveSampler;
978
+ exports.AlwaysSampler = require_sampling.AlwaysSampler;
979
+ exports.AttributeRedactingProcessor = require_attribute_redacting_processor.AttributeRedactingProcessor;
980
+ exports.BaggageSpanProcessor = require_init.BaggageSpanProcessor;
981
+ exports.BusinessBaggage = require_business_baggage.BusinessBaggage;
982
+ exports.CORRELATION_ID_BAGGAGE_KEY = require_track.CORRELATION_ID_BAGGAGE_KEY;
983
+ exports.Event = require_event.Event;
984
+ exports.FilteringSpanProcessor = require_filtering_span_processor.FilteringSpanProcessor;
985
+ exports.GEN_AI_COST_ATTRIBUTE = GEN_AI_COST_ATTRIBUTE;
986
+ exports.GEN_AI_COST_USD_BUCKETS = GEN_AI_COST_USD_BUCKETS;
987
+ exports.GEN_AI_DURATION_BUCKETS_SECONDS = GEN_AI_DURATION_BUCKETS_SECONDS;
988
+ exports.GEN_AI_TOKEN_USAGE_BUCKETS = GEN_AI_TOKEN_USAGE_BUCKETS;
989
+ exports.HTTPAttributes = require_registry.HTTPAttributes;
990
+ exports.MODEL_PRICING = MODEL_PRICING;
991
+ exports.Metric = require_metric.Metric;
992
+ exports.NORMALIZER_PATTERNS = require_span_name_normalizer.NORMALIZER_PATTERNS;
993
+ exports.NORMALIZER_PRESETS = require_span_name_normalizer.NORMALIZER_PRESETS;
994
+ exports.NeverSampler = require_sampling.NeverSampler;
995
+ exports.REDACTOR_PATTERNS = require_attribute_redacting_processor.REDACTOR_PATTERNS;
996
+ exports.REDACTOR_PRESETS = require_attribute_redacting_processor.REDACTOR_PRESETS;
997
+ Object.defineProperty(exports, 'ROOT_CONTEXT', {
998
+ enumerable: true,
999
+ get: function () {
1000
+ return _opentelemetry_api.ROOT_CONTEXT;
1001
+ }
1248
1002
  });
1249
- Object.defineProperty(exports, "context", {
1003
+ exports.RandomSampler = require_sampling.RandomSampler;
1004
+ exports.ServiceAttributes = require_registry.ServiceAttributes;
1005
+ Object.defineProperty(exports, 'SpanKind', {
1250
1006
  enumerable: true,
1251
- get: function () { return api.context; }
1007
+ get: function () {
1008
+ return _opentelemetry_api.SpanKind;
1009
+ }
1252
1010
  });
1253
- Object.defineProperty(exports, "otelTrace", {
1011
+ exports.SpanNameNormalizingProcessor = require_span_name_normalizer.SpanNameNormalizingProcessor;
1012
+ Object.defineProperty(exports, 'SpanStatusCode', {
1254
1013
  enumerable: true,
1255
- get: function () { return api.trace; }
1014
+ get: function () {
1015
+ return _opentelemetry_api.SpanStatusCode;
1016
+ }
1256
1017
  });
1257
- Object.defineProperty(exports, "propagation", {
1018
+ exports.URLAttributes = require_registry.URLAttributes;
1019
+ exports.UserIdSampler = require_sampling.UserIdSampler;
1020
+ exports.attrs = require_attributes.attrs;
1021
+ exports.autoRedactPII = require_attributes.autoRedactPII;
1022
+ exports.builtinPatterns = require_attribute_redacting_processor.builtinPatterns;
1023
+ Object.defineProperty(exports, 'context', {
1258
1024
  enumerable: true,
1259
- get: function () { return api.propagation; }
1025
+ get: function () {
1026
+ return _opentelemetry_api.context;
1027
+ }
1260
1028
  });
1261
- exports.GEN_AI_COST_ATTRIBUTE = GEN_AI_COST_ATTRIBUTE;
1262
- exports.GEN_AI_COST_USD_BUCKETS = GEN_AI_COST_USD_BUCKETS;
1263
- exports.GEN_AI_DURATION_BUCKETS_SECONDS = GEN_AI_DURATION_BUCKETS_SECONDS;
1264
- exports.GEN_AI_TOKEN_USAGE_BUCKETS = GEN_AI_TOKEN_USAGE_BUCKETS;
1265
- exports.MODEL_PRICING = MODEL_PRICING;
1029
+ exports.createAttributeRedactor = require_attribute_redacting_processor.createAttributeRedactor;
1030
+ exports.createCounter = require_metric_helpers.createCounter;
1031
+ exports.createDeterministicTraceId = require_trace_helpers.createDeterministicTraceId;
1032
+ exports.createDrainPipeline = require_drain_pipeline.createDrainPipeline;
1033
+ exports.createHistogram = require_metric_helpers.createHistogram;
1034
+ exports.createLinkFromHeaders = require_sampling.createLinkFromHeaders;
1035
+ exports.createNoopRequestLogger = createNoopRequestLogger;
1036
+ exports.createObservableGauge = require_metric_helpers.createObservableGauge;
1037
+ exports.createRedactedSpan = require_attribute_redacting_processor.createRedactedSpan;
1038
+ exports.createSafeBaggageSchema = require_business_baggage.createSafeBaggageSchema;
1039
+ exports.createStringRedactor = require_init.createStringRedactor;
1040
+ exports.createStructuredError = require_structured_error.createStructuredError;
1041
+ exports.createUpDownCounter = require_metric_helpers.createUpDownCounter;
1042
+ exports.ctx = require_functional.ctx;
1043
+ exports.dbClient = require_attributes.dbClient;
1266
1044
  exports.defineAuditCatalog = defineAuditCatalog;
1045
+ exports.defineBaggageSchema = require_track.defineBaggageSchema;
1267
1046
  exports.defineDrain = defineDrain;
1268
1047
  exports.defineEnricher = defineEnricher;
1269
1048
  exports.defineErrorCatalog = defineErrorCatalog;
1270
1049
  exports.defineEvent = defineEvent;
1271
1050
  exports.defineHttpDrain = defineHttpDrain;
1051
+ exports.enrichWithTraceContext = require_trace_helpers.enrichWithTraceContext;
1272
1052
  exports.estimateLLMCost = estimateLLMCost;
1053
+ exports.extractLinksFromBatch = require_sampling.extractLinksFromBatch;
1054
+ exports.finalizeSpan = require_trace_helpers.finalizeSpan;
1055
+ exports.flattenMetadata = require_trace_helpers.flattenMetadata;
1056
+ exports.flattenToAttributes = require_structured_error.flattenToAttributes;
1273
1057
  exports.flush = flush;
1058
+ exports.formatDuration = require_canonical_log_line_processor.formatDuration;
1274
1059
  exports.genAiMetricViews = genAiMetricViews;
1060
+ exports.generateCorrelationId = require_track.generateCorrelationId;
1061
+ exports.getActiveContext = require_trace_helpers.getActiveContext;
1062
+ exports.getActiveSpan = require_trace_helpers.getActiveSpan;
1063
+ exports.getAutotelTracer = require_tracer_provider.getAutotelTracer;
1064
+ exports.getAutotelTracerProvider = require_tracer_provider.getAutotelTracerProvider;
1275
1065
  exports.getCatalogCode = getCatalogCode;
1066
+ exports.getCorrelationId = require_track.getCorrelationId;
1067
+ exports.getCurrentWorkflowContext = require_workflow.getCurrentWorkflowContext;
1068
+ exports.getEventQueue = require_track.getEventQueue;
1069
+ exports.getEvents = require_event.getEvents;
1070
+ exports.getMeter = require_metric_helpers.getMeter;
1071
+ exports.getMetrics = require_metric.getMetrics;
1072
+ exports.getOperationContext = require_operation_context.getOperationContext;
1073
+ exports.getOrCreateCorrelationId = require_track.getOrCreateCorrelationId;
1276
1074
  exports.getRequestLogger = getRequestLogger;
1075
+ exports.getRequestLoggerSafe = getRequestLoggerSafe;
1076
+ exports.getStructuredErrorAttributes = require_structured_error.getStructuredErrorAttributes;
1077
+ exports.getTraceContext = require_trace_helpers.getTraceContext;
1078
+ exports.getTracer = require_trace_helpers.getTracer;
1079
+ exports.hasRequestContext = hasRequestContext;
1080
+ exports.httpClient = require_attributes.httpClient;
1081
+ exports.httpRequestHeaderAttribute = require_semantic_conventions.httpRequestHeaderAttribute;
1082
+ exports.httpResponseHeaderAttribute = require_semantic_conventions.httpResponseHeaderAttribute;
1083
+ exports.httpServer = require_attributes.httpServer;
1084
+ exports.identify = require_attributes.identify;
1085
+ exports.init = require_init.init;
1086
+ exports.instrument = require_functional.instrument;
1277
1087
  exports.isCatalogError = isCatalogError;
1088
+ exports.isInWorkflow = require_workflow.isInWorkflow;
1089
+ exports.isInitialized = require_init.isInitialized;
1090
+ exports.isLoggerLocked = require_init.isLoggerLocked;
1091
+ exports.isTracing = require_trace_helpers.isTracing;
1278
1092
  exports.llmHistogramAdvice = llmHistogramAdvice;
1093
+ exports.lockLogger = require_init.lockLogger;
1094
+ exports.markAsImmediate = require_functional.markAsImmediate;
1095
+ exports.mergeAttrs = require_attributes.mergeAttrs;
1096
+ exports.mergeServiceResource = require_attributes.mergeServiceResource;
1097
+ exports.normalizeAttributeRedactorConfig = require_attribute_redacting_processor.normalizeAttributeRedactorConfig;
1098
+ Object.defineProperty(exports, 'otelTrace', {
1099
+ enumerable: true,
1100
+ get: function () {
1101
+ return _opentelemetry_api.trace;
1102
+ }
1103
+ });
1104
+ exports.parseError = require_parse_error.parseError;
1105
+ Object.defineProperty(exports, 'propagation', {
1106
+ enumerable: true,
1107
+ get: function () {
1108
+ return _opentelemetry_api.propagation;
1109
+ }
1110
+ });
1279
1111
  exports.recordLLMCost = recordLLMCost;
1280
1112
  exports.recordPromptSent = recordPromptSent;
1281
1113
  exports.recordResponseReceived = recordResponseReceived;
1282
1114
  exports.recordRetry = recordRetry;
1283
1115
  exports.recordStreamFirstToken = recordStreamFirstToken;
1116
+ exports.recordStructuredError = require_structured_error.recordStructuredError;
1284
1117
  exports.recordToolCall = recordToolCall;
1118
+ exports.request = require_attributes.request;
1119
+ exports.resetEvents = require_event.resetEvents;
1120
+ exports.resetMetrics = require_metric.resetMetrics;
1121
+ exports.resolveSamplingPreset = require_sampling.resolveSamplingPreset;
1122
+ exports.resolveTraceUrl = require_trace_helpers.resolveTraceUrl;
1123
+ exports.runInOperationContext = require_operation_context.runInOperationContext;
1124
+ exports.runWithCorrelationId = require_track.runWithCorrelationId;
1285
1125
  exports.runWithRequestContext = runWithRequestContext;
1126
+ exports.runWithSpan = require_trace_helpers.runWithSpan;
1127
+ exports.safeSetAttributes = require_attributes.safeSetAttributes;
1128
+ exports.samplingPresets = require_sampling.samplingPresets;
1129
+ exports.setAutotelTracerProvider = require_tracer_provider.setAutotelTracerProvider;
1130
+ exports.setCorrelationId = require_track.setCorrelationId;
1131
+ exports.setCorrelationIdInBaggage = require_track.setCorrelationIdInBaggage;
1132
+ exports.setDevice = require_attributes.setDevice;
1133
+ exports.setError = require_attributes.setError;
1134
+ exports.setException = require_attributes.setException;
1135
+ exports.setSession = require_attributes.setSession;
1136
+ exports.setUser = require_attributes.setUser;
1286
1137
  exports.shutdown = shutdown;
1287
- exports.trace = trace2;
1288
- //# sourceMappingURL=index.cjs.map
1138
+ exports.span = require_functional.span;
1139
+ exports.structuredErrorToJSON = require_structured_error.structuredErrorToJSON;
1140
+ exports.toAttributeValue = require_structured_error.toAttributeValue;
1141
+ exports.trace = trace;
1142
+ exports.traceConsumer = require_messaging.traceConsumer;
1143
+ exports.traceDB = require_semantic_helpers.traceDB;
1144
+ exports.traceHTTP = require_semantic_helpers.traceHTTP;
1145
+ exports.traceLLM = require_semantic_helpers.traceLLM;
1146
+ exports.traceMessaging = require_semantic_helpers.traceMessaging;
1147
+ exports.traceProducer = require_messaging.traceProducer;
1148
+ exports.traceStep = require_workflow.traceStep;
1149
+ exports.traceWorkflow = require_workflow.traceWorkflow;
1150
+ exports.track = require_track.track;
1151
+ exports.validateAttribute = require_attributes.validateAttribute;
1152
+ exports.withBaggage = require_functional.withBaggage;
1153
+ exports.withNewContext = require_functional.withNewContext;
1154
+ exports.withTracing = require_functional.withTracing;
1289
1155
  //# sourceMappingURL=index.cjs.map