autotel 4.3.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/README.md +125 -103
  2. package/dist/analysis.cjs +87 -0
  3. package/dist/analysis.cjs.map +1 -0
  4. package/dist/analysis.d.cts +87 -0
  5. package/dist/analysis.d.cts.map +1 -0
  6. package/dist/analysis.d.ts +87 -0
  7. package/dist/analysis.d.ts.map +1 -0
  8. package/dist/analysis.js +85 -0
  9. package/dist/analysis.js.map +1 -0
  10. package/dist/{attribute-redacting-processor-DtTS9xxh.d.ts → attribute-redacting-processor-Pk7lAzWd.d.cts} +13 -8
  11. package/dist/attribute-redacting-processor-Pk7lAzWd.d.cts.map +1 -0
  12. package/dist/{attribute-redacting-processor-DtTS9xxh.d.cts → attribute-redacting-processor-Pk7lAzWd.d.ts} +13 -8
  13. package/dist/attribute-redacting-processor-Pk7lAzWd.d.ts.map +1 -0
  14. package/dist/attribute-redacting-processor.cjs +4 -4
  15. package/dist/attribute-redacting-processor.cjs.map +1 -1
  16. package/dist/attribute-redacting-processor.d.cts +1 -1
  17. package/dist/attribute-redacting-processor.d.ts +1 -1
  18. package/dist/attribute-redacting-processor.js +4 -4
  19. package/dist/attribute-redacting-processor.js.map +1 -1
  20. package/dist/attributes.d.cts +1 -1
  21. package/dist/attributes.d.ts +1 -1
  22. package/dist/auto.cjs +1 -1
  23. package/dist/auto.cjs.map +1 -1
  24. package/dist/auto.d.cts +1 -1
  25. package/dist/auto.d.ts +1 -1
  26. package/dist/auto.js +1 -1
  27. package/dist/auto.js.map +1 -1
  28. package/dist/business-baggage.d.cts +2 -3
  29. package/dist/business-baggage.d.cts.map +1 -1
  30. package/dist/business-baggage.d.ts +2 -3
  31. package/dist/business-baggage.d.ts.map +1 -1
  32. package/dist/{canonical-log-line-processor-xvjMgtpF.d.cts → canonical-log-line-processor-B4WgG-VS.d.cts} +2 -3
  33. package/dist/canonical-log-line-processor-B4WgG-VS.d.cts.map +1 -0
  34. package/dist/{canonical-log-line-processor-BcRuAdRk.d.ts → canonical-log-line-processor-CL_J7gb5.d.ts} +2 -3
  35. package/dist/canonical-log-line-processor-CL_J7gb5.d.ts.map +1 -0
  36. package/dist/{canonical-log-line-processor-CcrDi6TO.cjs → canonical-log-line-processor-DOjb6Kxy.cjs} +5 -5
  37. package/dist/canonical-log-line-processor-DOjb6Kxy.cjs.map +1 -0
  38. package/dist/{canonical-log-line-processor-FLezvFCB.js → canonical-log-line-processor-mKABvGP0.js} +5 -5
  39. package/dist/canonical-log-line-processor-mKABvGP0.js.map +1 -0
  40. package/dist/config.d.cts +12 -7
  41. package/dist/config.d.cts.map +1 -1
  42. package/dist/config.d.ts +12 -7
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/correlation-id.cjs +9 -9
  45. package/dist/correlation-id.d.cts +0 -1
  46. package/dist/correlation-id.d.cts.map +1 -1
  47. package/dist/correlation-id.d.ts +0 -1
  48. package/dist/correlation-id.d.ts.map +1 -1
  49. package/dist/correlation-id.js +1 -1
  50. package/dist/db.d.cts.map +1 -1
  51. package/dist/db.d.ts.map +1 -1
  52. package/dist/decorators.cjs +2 -2
  53. package/dist/decorators.cjs.map +1 -1
  54. package/dist/decorators.d.cts +1 -2
  55. package/dist/decorators.d.cts.map +1 -1
  56. package/dist/decorators.d.ts +1 -2
  57. package/dist/decorators.d.ts.map +1 -1
  58. package/dist/decorators.js +1 -1
  59. package/dist/decorators.js.map +1 -1
  60. package/dist/{define-event-CreknLm3.d.ts → define-event-B2z1SBe7.d.ts} +2 -3
  61. package/dist/define-event-B2z1SBe7.d.ts.map +1 -0
  62. package/dist/{define-event-HZRizPwz.d.cts → define-event-CGG048HE.d.cts} +2 -3
  63. package/dist/define-event-CGG048HE.d.cts.map +1 -0
  64. package/dist/diagnostics.cjs +10 -1
  65. package/dist/diagnostics.cjs.map +1 -1
  66. package/dist/diagnostics.d.cts +0 -1
  67. package/dist/diagnostics.d.cts.map +1 -1
  68. package/dist/diagnostics.d.ts +0 -1
  69. package/dist/diagnostics.d.ts.map +1 -1
  70. package/dist/diagnostics.js +10 -1
  71. package/dist/diagnostics.js.map +1 -1
  72. package/dist/drain-pipeline.d.cts +12 -5
  73. package/dist/drain-pipeline.d.cts.map +1 -1
  74. package/dist/drain-pipeline.d.ts +12 -5
  75. package/dist/drain-pipeline.d.ts.map +1 -1
  76. package/dist/enrichers.d.cts.map +1 -1
  77. package/dist/enrichers.d.ts.map +1 -1
  78. package/dist/{event-subscriber-D1XLkPzi.d.ts → event-subscriber-CWh8sTGh.d.cts} +2 -2
  79. package/dist/event-subscriber-CWh8sTGh.d.cts.map +1 -0
  80. package/dist/{event-subscriber-D1XLkPzi.d.cts → event-subscriber-CWh8sTGh.d.ts} +2 -2
  81. package/dist/event-subscriber-CWh8sTGh.d.ts.map +1 -0
  82. package/dist/event-subscriber.d.cts +1 -1
  83. package/dist/event-subscriber.d.ts +1 -1
  84. package/dist/{event-testing-CfFs3to2.d.ts → event-testing-CA2mIx1E.d.ts} +2 -3
  85. package/dist/event-testing-CA2mIx1E.d.ts.map +1 -0
  86. package/dist/{event-testing-BqRnI0z4.d.cts → event-testing-D0qWfqAy.d.cts} +2 -3
  87. package/dist/event-testing-D0qWfqAy.d.cts.map +1 -0
  88. package/dist/event-testing.d.cts +1 -1
  89. package/dist/event-testing.d.ts +1 -1
  90. package/dist/event.cjs +4 -4
  91. package/dist/event.d.cts +3 -4
  92. package/dist/event.d.cts.map +1 -1
  93. package/dist/event.d.ts +3 -4
  94. package/dist/event.d.ts.map +1 -1
  95. package/dist/event.js +1 -1
  96. package/dist/exporters.d.cts +0 -4
  97. package/dist/exporters.d.cts.map +1 -1
  98. package/dist/exporters.d.ts +0 -4
  99. package/dist/exporters.d.ts.map +1 -1
  100. package/dist/{filtering-span-processor-B8R8B7Uk.d.ts → filtering-span-processor-BpDagWNa.d.cts} +1 -2
  101. package/dist/filtering-span-processor-BpDagWNa.d.cts.map +1 -0
  102. package/dist/{filtering-span-processor-B8R8B7Uk.d.cts → filtering-span-processor-BpDagWNa.d.ts} +1 -2
  103. package/dist/filtering-span-processor-BpDagWNa.d.ts.map +1 -0
  104. package/dist/filtering-span-processor.d.cts +1 -1
  105. package/dist/filtering-span-processor.d.ts +1 -1
  106. package/dist/functional-BnDUxnSl.js +838 -0
  107. package/dist/functional-BnDUxnSl.js.map +1 -0
  108. package/dist/functional-DcLBuCPz.cjs +888 -0
  109. package/dist/functional-DcLBuCPz.cjs.map +1 -0
  110. package/dist/functional.cjs +2 -2
  111. package/dist/functional.d.cts +79 -130
  112. package/dist/functional.d.cts.map +1 -1
  113. package/dist/functional.d.ts +79 -130
  114. package/dist/functional.d.ts.map +1 -1
  115. package/dist/functional.js +2 -2
  116. package/dist/http.cjs +6 -6
  117. package/dist/http.cjs.map +1 -1
  118. package/dist/http.d.cts +4 -5
  119. package/dist/http.d.cts.map +1 -1
  120. package/dist/http.d.ts +4 -5
  121. package/dist/http.d.ts.map +1 -1
  122. package/dist/http.js +5 -5
  123. package/dist/http.js.map +1 -1
  124. package/dist/{index-eKuioqT1.d.cts → index-BPcxVucm.d.cts} +2 -3
  125. package/dist/index-BPcxVucm.d.cts.map +1 -0
  126. package/dist/{index-Ck06vlW2.d.ts → index-DolOVX6F.d.ts} +2 -3
  127. package/dist/index-DolOVX6F.d.ts.map +1 -0
  128. package/dist/index.cjs +25 -167
  129. package/dist/index.cjs.map +1 -1
  130. package/dist/index.d.cts +14 -14
  131. package/dist/index.d.cts.map +1 -1
  132. package/dist/index.d.ts +14 -14
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +6 -148
  135. package/dist/index.js.map +1 -1
  136. package/dist/init-C3RApHKJ.cjs +3371 -0
  137. package/dist/init-C3RApHKJ.cjs.map +1 -0
  138. package/dist/{init-DSrRmVnz.d.cts → init-D6n2diBy.d.ts} +46 -20
  139. package/dist/init-D6n2diBy.d.ts.map +1 -0
  140. package/dist/init-R-gSEXkJ.js +3190 -0
  141. package/dist/init-R-gSEXkJ.js.map +1 -0
  142. package/dist/{init-B7u-DjxM.d.ts → init-XzXzrarP.d.cts} +46 -20
  143. package/dist/init-XzXzrarP.d.cts.map +1 -0
  144. package/dist/instrumentation.cjs +7 -13
  145. package/dist/instrumentation.cjs.map +1 -1
  146. package/dist/instrumentation.d.cts +0 -1
  147. package/dist/instrumentation.d.cts.map +1 -1
  148. package/dist/instrumentation.d.ts +0 -1
  149. package/dist/instrumentation.d.ts.map +1 -1
  150. package/dist/instrumentation.js +8 -14
  151. package/dist/instrumentation.js.map +1 -1
  152. package/dist/{logger-BauSUhUv.d.ts → logger-CN4xpzMd.d.cts} +1 -2
  153. package/dist/logger-CN4xpzMd.d.cts.map +1 -0
  154. package/dist/{logger-BauSUhUv.d.cts → logger-CN4xpzMd.d.ts} +1 -2
  155. package/dist/logger-CN4xpzMd.d.ts.map +1 -0
  156. package/dist/logger-D3Ej3DII.js.map +1 -1
  157. package/dist/logger-thMPLpOG.cjs.map +1 -1
  158. package/dist/logger.d.cts +1 -1
  159. package/dist/logger.d.ts +1 -1
  160. package/dist/messaging-adapters.cjs.map +1 -1
  161. package/dist/messaging-adapters.d.cts +0 -1
  162. package/dist/messaging-adapters.d.cts.map +1 -1
  163. package/dist/messaging-adapters.d.ts +0 -1
  164. package/dist/messaging-adapters.d.ts.map +1 -1
  165. package/dist/messaging-adapters.js.map +1 -1
  166. package/dist/messaging-testing.d.cts +0 -1
  167. package/dist/messaging-testing.d.cts.map +1 -1
  168. package/dist/messaging-testing.d.ts +0 -1
  169. package/dist/messaging-testing.d.ts.map +1 -1
  170. package/dist/messaging.cjs +27 -10
  171. package/dist/messaging.cjs.map +1 -1
  172. package/dist/messaging.d.cts +6 -7
  173. package/dist/messaging.d.cts.map +1 -1
  174. package/dist/messaging.d.ts +6 -7
  175. package/dist/messaging.d.ts.map +1 -1
  176. package/dist/messaging.js +27 -10
  177. package/dist/messaging.js.map +1 -1
  178. package/dist/metric-helpers.d.cts +0 -1
  179. package/dist/metric-helpers.d.cts.map +1 -1
  180. package/dist/metric-helpers.d.ts +0 -1
  181. package/dist/metric-helpers.d.ts.map +1 -1
  182. package/dist/{metric-testing-DXdK3-Q3.d.ts → metric-testing-CWm6UhaR.d.ts} +2 -3
  183. package/dist/metric-testing-CWm6UhaR.d.ts.map +1 -0
  184. package/dist/{metric-testing-MxvzChDp.d.cts → metric-testing-CpvP3ZIa.d.cts} +2 -3
  185. package/dist/metric-testing-CpvP3ZIa.d.cts.map +1 -0
  186. package/dist/metric-testing.d.cts +1 -1
  187. package/dist/metric-testing.d.ts +1 -1
  188. package/dist/metric.d.cts +3 -4
  189. package/dist/metric.d.cts.map +1 -1
  190. package/dist/metric.d.ts +3 -4
  191. package/dist/metric.d.ts.map +1 -1
  192. package/dist/parse-error.d.cts.map +1 -1
  193. package/dist/parse-error.d.ts.map +1 -1
  194. package/dist/processors.cjs +1 -1
  195. package/dist/processors.d.cts +1 -1
  196. package/dist/processors.d.ts +1 -1
  197. package/dist/processors.js +1 -1
  198. package/dist/register.d.cts +1 -1
  199. package/dist/register.d.ts +1 -1
  200. package/dist/{sampling-DfYhDJij.d.cts → sampling-BR9fkSwx.d.cts} +127 -10
  201. package/dist/sampling-BR9fkSwx.d.cts.map +1 -0
  202. package/dist/{sampling-CR0Va1VB.d.ts → sampling-CP3e7-Yr.d.ts} +127 -10
  203. package/dist/sampling-CP3e7-Yr.d.ts.map +1 -0
  204. package/dist/sampling.cjs +160 -12
  205. package/dist/sampling.cjs.map +1 -1
  206. package/dist/sampling.d.cts +2 -2
  207. package/dist/sampling.d.ts +2 -2
  208. package/dist/sampling.js +157 -13
  209. package/dist/sampling.js.map +1 -1
  210. package/dist/security-schema.d.cts +9 -4
  211. package/dist/security-schema.d.cts.map +1 -1
  212. package/dist/security-schema.d.ts +9 -4
  213. package/dist/security-schema.d.ts.map +1 -1
  214. package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -1
  215. package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -1
  216. package/dist/semantic-conventions.cjs.map +1 -1
  217. package/dist/semantic-conventions.js.map +1 -1
  218. package/dist/semantic-helpers.cjs +85 -304
  219. package/dist/semantic-helpers.cjs.map +1 -1
  220. package/dist/semantic-helpers.d.cts +21 -12
  221. package/dist/semantic-helpers.d.cts.map +1 -1
  222. package/dist/semantic-helpers.d.ts +21 -12
  223. package/dist/semantic-helpers.d.ts.map +1 -1
  224. package/dist/semantic-helpers.js +85 -304
  225. package/dist/semantic-helpers.js.map +1 -1
  226. package/dist/slo.cjs +225 -0
  227. package/dist/slo.cjs.map +1 -0
  228. package/dist/slo.d.cts +97 -0
  229. package/dist/slo.d.cts.map +1 -0
  230. package/dist/slo.d.ts +97 -0
  231. package/dist/slo.d.ts.map +1 -0
  232. package/dist/slo.js +223 -0
  233. package/dist/slo.js.map +1 -0
  234. package/dist/{span-name-normalizer-8ZOGJuwv.d.ts → span-name-normalizer-CN1-8C76.d.cts} +1 -2
  235. package/dist/span-name-normalizer-CN1-8C76.d.cts.map +1 -0
  236. package/dist/{span-name-normalizer-8ZOGJuwv.d.cts → span-name-normalizer-CN1-8C76.d.ts} +1 -2
  237. package/dist/span-name-normalizer-CN1-8C76.d.ts.map +1 -0
  238. package/dist/span-name-normalizer.cjs.map +1 -1
  239. package/dist/span-name-normalizer.d.cts +1 -1
  240. package/dist/span-name-normalizer.d.ts +1 -1
  241. package/dist/span-name-normalizer.js.map +1 -1
  242. package/dist/tail-sampling-processor.d.cts +0 -1
  243. package/dist/tail-sampling-processor.d.cts.map +1 -1
  244. package/dist/tail-sampling-processor.d.ts +0 -1
  245. package/dist/tail-sampling-processor.d.ts.map +1 -1
  246. package/dist/test-span-collector.cjs.map +1 -1
  247. package/dist/test-span-collector.d.cts +0 -1
  248. package/dist/test-span-collector.d.cts.map +1 -1
  249. package/dist/test-span-collector.d.ts +0 -1
  250. package/dist/test-span-collector.d.ts.map +1 -1
  251. package/dist/test-span-collector.js.map +1 -1
  252. package/dist/testing.cjs +76 -11
  253. package/dist/testing.cjs.map +1 -1
  254. package/dist/testing.d.cts +30 -5
  255. package/dist/testing.d.cts.map +1 -1
  256. package/dist/testing.d.ts +30 -5
  257. package/dist/testing.d.ts.map +1 -1
  258. package/dist/testing.js +73 -12
  259. package/dist/testing.js.map +1 -1
  260. package/dist/{trace-context-Cijqoi6e.d.ts → trace-context-IuyoPyNq.d.cts} +9 -9
  261. package/dist/trace-context-IuyoPyNq.d.cts.map +1 -0
  262. package/dist/{trace-context-Cijqoi6e.d.cts → trace-context-IuyoPyNq.d.ts} +9 -9
  263. package/dist/trace-context-IuyoPyNq.d.ts.map +1 -0
  264. package/dist/trace-factory-validation-BjVAinz6.js +13 -0
  265. package/dist/trace-factory-validation-BjVAinz6.js.map +1 -0
  266. package/dist/trace-factory-validation-Dc8epn87.cjs +19 -0
  267. package/dist/trace-factory-validation-Dc8epn87.cjs.map +1 -0
  268. package/dist/trace-helpers.cjs +7 -7
  269. package/dist/trace-helpers.cjs.map +1 -1
  270. package/dist/trace-helpers.d.cts +6 -7
  271. package/dist/trace-helpers.d.cts.map +1 -1
  272. package/dist/trace-helpers.d.ts +6 -7
  273. package/dist/trace-helpers.d.ts.map +1 -1
  274. package/dist/trace-helpers.js +7 -7
  275. package/dist/trace-helpers.js.map +1 -1
  276. package/dist/tracer-provider.d.cts +0 -1
  277. package/dist/tracer-provider.d.cts.map +1 -1
  278. package/dist/tracer-provider.d.ts +0 -1
  279. package/dist/tracer-provider.d.ts.map +1 -1
  280. package/dist/validate.cjs.map +1 -1
  281. package/dist/validate.d.cts +1 -2
  282. package/dist/validate.d.cts.map +1 -1
  283. package/dist/validate.d.ts +1 -2
  284. package/dist/validate.d.ts.map +1 -1
  285. package/dist/validate.js.map +1 -1
  286. package/dist/validation-attributes.d.cts +17 -8
  287. package/dist/validation-attributes.d.cts.map +1 -1
  288. package/dist/validation-attributes.d.ts +17 -8
  289. package/dist/validation-attributes.d.ts.map +1 -1
  290. package/dist/webhook.cjs +5 -4
  291. package/dist/webhook.cjs.map +1 -1
  292. package/dist/webhook.d.cts +4 -4
  293. package/dist/webhook.d.cts.map +1 -1
  294. package/dist/webhook.d.ts +4 -4
  295. package/dist/webhook.d.ts.map +1 -1
  296. package/dist/webhook.js +5 -4
  297. package/dist/webhook.js.map +1 -1
  298. package/dist/workflow-distributed.cjs +5 -5
  299. package/dist/workflow-distributed.cjs.map +1 -1
  300. package/dist/workflow-distributed.d.cts +25 -15
  301. package/dist/workflow-distributed.d.cts.map +1 -1
  302. package/dist/workflow-distributed.d.ts +25 -15
  303. package/dist/workflow-distributed.d.ts.map +1 -1
  304. package/dist/workflow-distributed.js +5 -5
  305. package/dist/workflow-distributed.js.map +1 -1
  306. package/dist/workflow.cjs +24 -30
  307. package/dist/workflow.cjs.map +1 -1
  308. package/dist/workflow.d.cts +11 -6
  309. package/dist/workflow.d.cts.map +1 -1
  310. package/dist/workflow.d.ts +11 -6
  311. package/dist/workflow.d.ts.map +1 -1
  312. package/dist/workflow.js +24 -30
  313. package/dist/workflow.js.map +1 -1
  314. package/dist/yaml-config.d.cts +2 -3
  315. package/dist/yaml-config.d.cts.map +1 -1
  316. package/dist/yaml-config.d.ts +2 -3
  317. package/dist/yaml-config.d.ts.map +1 -1
  318. package/package.json +24 -16
  319. package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +0 -1
  320. package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +0 -1
  321. package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +0 -1
  322. package/dist/canonical-log-line-processor-CcrDi6TO.cjs.map +0 -1
  323. package/dist/canonical-log-line-processor-FLezvFCB.js.map +0 -1
  324. package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +0 -1
  325. package/dist/define-event-CreknLm3.d.ts.map +0 -1
  326. package/dist/define-event-HZRizPwz.d.cts.map +0 -1
  327. package/dist/event-BEm5IJ8U.js +0 -761
  328. package/dist/event-BEm5IJ8U.js.map +0 -1
  329. package/dist/event-rzA1X5h3.cjs +0 -778
  330. package/dist/event-rzA1X5h3.cjs.map +0 -1
  331. package/dist/event-subscriber-D1XLkPzi.d.cts.map +0 -1
  332. package/dist/event-subscriber-D1XLkPzi.d.ts.map +0 -1
  333. package/dist/event-testing-BqRnI0z4.d.cts.map +0 -1
  334. package/dist/event-testing-CfFs3to2.d.ts.map +0 -1
  335. package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +0 -1
  336. package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +0 -1
  337. package/dist/functional-CwsPyc4l.cjs +0 -1298
  338. package/dist/functional-CwsPyc4l.cjs.map +0 -1
  339. package/dist/functional-dAYhXQPA.js +0 -1248
  340. package/dist/functional-dAYhXQPA.js.map +0 -1
  341. package/dist/index-Ck06vlW2.d.ts.map +0 -1
  342. package/dist/index-eKuioqT1.d.cts.map +0 -1
  343. package/dist/init-B7u-DjxM.d.ts.map +0 -1
  344. package/dist/init-BvBB45-T.js +0 -1034
  345. package/dist/init-BvBB45-T.js.map +0 -1
  346. package/dist/init-BxJEJ9Tn.cjs +0 -1111
  347. package/dist/init-BxJEJ9Tn.cjs.map +0 -1
  348. package/dist/init-DSrRmVnz.d.cts.map +0 -1
  349. package/dist/logger-BauSUhUv.d.cts.map +0 -1
  350. package/dist/logger-BauSUhUv.d.ts.map +0 -1
  351. package/dist/metric-testing-DXdK3-Q3.d.ts.map +0 -1
  352. package/dist/metric-testing-MxvzChDp.d.cts.map +0 -1
  353. package/dist/operation-context-CKBoA4Qy.js +0 -59
  354. package/dist/operation-context-CKBoA4Qy.js.map +0 -1
  355. package/dist/operation-context-hzKbTKnt.cjs +0 -72
  356. package/dist/operation-context-hzKbTKnt.cjs.map +0 -1
  357. package/dist/sampling-CR0Va1VB.d.ts.map +0 -1
  358. package/dist/sampling-DfYhDJij.d.cts.map +0 -1
  359. package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +0 -1
  360. package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +0 -1
  361. package/dist/trace-context-Cijqoi6e.d.cts.map +0 -1
  362. package/dist/trace-context-Cijqoi6e.d.ts.map +0 -1
  363. package/dist/track-D7O7oIZa.js +0 -1115
  364. package/dist/track-D7O7oIZa.js.map +0 -1
  365. package/dist/track-eovhCJ-I.cjs +0 -1218
  366. package/dist/track-eovhCJ-I.cjs.map +0 -1
  367. package/skills/analyze-traces/SKILL.md +0 -180
  368. package/skills/autotel-core/SKILL.md +0 -159
  369. package/skills/autotel-events/SKILL.md +0 -84
  370. package/skills/autotel-frameworks/SKILL.md +0 -90
  371. package/skills/autotel-instrumentation/SKILL.md +0 -145
  372. package/skills/autotel-request-logging/SKILL.md +0 -94
  373. package/skills/autotel-structured-errors/SKILL.md +0 -125
  374. package/skills/build-audit-trails/SKILL.md +0 -460
  375. package/skills/build-audit-trails/references/audit-queries.md +0 -73
  376. package/skills/build-audit-trails/references/framework-wiring.md +0 -196
  377. package/skills/debug-missing-spans/SKILL.md +0 -250
  378. package/skills/migrate-to-autotel/SKILL.md +0 -269
  379. package/skills/review-otel-patterns/SKILL.md +0 -538
  380. package/skills/review-otel-patterns/references/code-review.md +0 -76
  381. package/skills/review-otel-patterns/references/processor-pipeline.md +0 -205
  382. package/skills/review-otel-patterns/references/structured-errors.md +0 -102
  383. package/skills/review-otel-patterns/references/wide-spans.md +0 -85
  384. package/skills/tune-sampling/SKILL.md +0 -215
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_functional = require('./functional-CwsPyc4l.cjs');
2
+ const require_functional = require('./functional-DcLBuCPz.cjs');
3
+ const require_trace_factory_validation = require('./trace-factory-validation-Dc8epn87.cjs');
4
+ let _opentelemetry_api = require("@opentelemetry/api");
3
5
 
4
6
  //#region src/semantic-helpers.ts
5
7
  /**
@@ -10,317 +12,96 @@ const require_functional = require('./functional-CwsPyc4l.cjs');
10
12
  *
11
13
  * Based on: https://opentelemetry.io/docs/specs/semconv/
12
14
  */
15
+ function setConfiguredAttributes(ctx, attributes) {
16
+ if (!attributes) return;
17
+ for (const [key, value] of Object.entries(attributes)) {
18
+ if (value === void 0 || value === null) continue;
19
+ const attributeValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
20
+ ctx.setAttribute(key, attributeValue);
21
+ }
22
+ }
13
23
  /**
14
- * Trace database operations with DB semantic conventions
15
- *
16
- * Automatically adds standard attributes for database operations:
17
- * - db.system
18
- * - db.operation
19
- * - db.name
20
- * - db.collection.name (for NoSQL)
21
- *
22
- * **Use Cases:**
23
- * - SQL queries (PostgreSQL, MySQL, SQLite)
24
- * - NoSQL operations (MongoDB, DynamoDB, Redis)
25
- * - ORM queries (Prisma, TypeORM, Drizzle)
26
- *
27
- * @param config - Database operation configuration
28
- * @returns Traced function factory with DB attributes
29
- *
30
- * @example PostgreSQL query
31
- * ```typescript
32
- * import { traceDB } from 'autotel/semantic-helpers'
33
- * import { pool } from './db'
34
- *
35
- * export const getUser = traceDB({
36
- * system: 'postgresql',
37
- * operation: 'SELECT',
38
- * database: 'app_db',
39
- * collection: 'users'
40
- * })(ctx => async (userId: string) => {
41
- * const query = 'SELECT * FROM users WHERE id = $1'
42
- * ctx.setAttribute('db.statement', query)
43
- *
44
- * const result = await pool.query(query, [userId])
45
- * ctx.setAttribute('db.rows_affected', result.rowCount)
46
- *
47
- * return result.rows[0]
48
- * })
49
- * ```
50
- *
51
- * @example MongoDB with Mongoose
52
- * ```typescript
53
- * import { traceDB } from 'autotel/semantic-helpers'
54
- * import { User } from './models/User'
55
- *
56
- * export const findUsers = traceDB({
57
- * system: 'mongodb',
58
- * operation: 'find',
59
- * database: 'app_db',
60
- * collection: 'users'
61
- * })(ctx => async (filter: object) => {
62
- * ctx.setAttribute('db.mongodb.filter', JSON.stringify(filter))
63
- *
64
- * const users = await User.find(filter).limit(100)
65
- * ctx.setAttribute('db.response.count', users.length)
66
- *
67
- * return users
68
- * })
69
- * ```
70
- *
71
- * @example Redis operations
72
- * ```typescript
73
- * import { traceDB } from 'autotel/semantic-helpers'
74
- * import { redis } from './redis'
75
- *
76
- * export const cacheGet = traceDB({
77
- * system: 'redis',
78
- * operation: 'GET'
79
- * })(ctx => async (key: string) => {
80
- * ctx.setAttribute('db.redis.key', key)
81
- *
82
- * const value = await redis.get(key)
83
- * ctx.setAttribute('db.response.cache_hit', value !== null)
84
- *
85
- * return value
86
- * })
87
- * ```
88
- *
89
- * @example Prisma with detailed query info
90
- * ```typescript
91
- * import { traceDB } from 'autotel/semantic-helpers'
92
- * import { prisma } from './prisma'
93
- *
94
- * export const createPost = traceDB({
95
- * system: 'postgresql',
96
- * operation: 'INSERT',
97
- * database: 'app_db',
98
- * collection: 'posts'
99
- * })(ctx => async (data: { title: string; content: string; authorId: string }) => {
100
- * ctx.setAttribute('db.prisma.model', 'Post')
101
- * ctx.setAttribute('db.prisma.action', 'create')
102
- *
103
- * const post = await prisma.post.create({ data })
104
- *
105
- * ctx.setAttribute('db.response.id', post.id)
106
- * return post
107
- * })
108
- * ```
109
- *
110
- * @public
24
+ * Shared tail of `traceDB`/`traceHTTP`/`traceMessaging`: wrap `fn` directly
25
+ * when given, otherwise return the curried factory-acceptor form.
111
26
  */
112
- function traceDB(config) {
113
- return (fnFactory) => {
114
- return require_functional.trace((ctx) => {
115
- ctx.setAttribute("db.system", config.system);
116
- if (config.operation) ctx.setAttribute("db.operation", config.operation);
117
- if (config.database) ctx.setAttribute("db.name", config.database);
118
- if (config.collection) ctx.setAttribute("db.collection.name", config.collection);
119
- if (config.attributes) {
120
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0 && value !== null) {
121
- const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
122
- ctx.setAttribute(key, attrValue);
123
- }
124
- }
125
- return fnFactory(ctx);
27
+ function wrapSemantic(helperName, name, spanKind, configure, fn) {
28
+ if (fn) {
29
+ require_trace_factory_validation.assertTraceFactory(helperName, fn);
30
+ return require_functional.withTracing({
31
+ name,
32
+ spanKind
33
+ })((ctx) => {
34
+ configure(ctx);
35
+ return fn;
36
+ });
37
+ }
38
+ return (factory) => {
39
+ require_trace_factory_validation.assertTraceFactory(helperName, factory);
40
+ return require_functional.withTracing({
41
+ name,
42
+ spanKind
43
+ })((ctx) => {
44
+ configure(ctx);
45
+ const handler = factory(ctx);
46
+ require_trace_factory_validation.assertTraceFactory(helperName, handler, "result");
47
+ return handler;
126
48
  });
127
49
  };
128
50
  }
129
- /**
130
- * Trace HTTP client operations with HTTP semantic conventions
131
- *
132
- * Automatically adds standard attributes for HTTP requests:
133
- * - http.request.method
134
- * - url.full
135
- *
136
- * **Use Cases:**
137
- * - External API calls
138
- * - Microservice communication
139
- * - Third-party integrations
140
- *
141
- * @param config - HTTP operation configuration
142
- * @returns Traced function factory with HTTP attributes
143
- *
144
- * @example Fetch API
145
- * ```typescript
146
- * import { traceHTTP } from 'autotel/semantic-helpers'
147
- *
148
- * export const fetchUser = traceHTTP({
149
- * method: 'GET',
150
- * url: 'https://api.example.com/users/:id'
151
- * })(ctx => async (userId: string) => {
152
- * const url = `https://api.example.com/users/${userId}`
153
- * ctx.setAttribute('url.full', url)
154
- *
155
- * const response = await fetch(url)
156
- * ctx.setAttribute('http.response.status_code', response.status)
157
- *
158
- * if (!response.ok) {
159
- * ctx.setAttribute('error', true)
160
- * throw new Error(`HTTP ${response.status}: ${response.statusText}`)
161
- * }
162
- *
163
- * return response.json()
164
- * })
165
- * ```
166
- *
167
- * @example Axios with retry logic
168
- * ```typescript
169
- * import { traceHTTP } from 'autotel/semantic-helpers'
170
- * import axios from 'axios'
171
- *
172
- * export const sendWebhook = traceHTTP({
173
- * method: 'POST',
174
- * url: 'https://webhook.example.com/events'
175
- * })(ctx => async (payload: object) => {
176
- * let attempts = 0
177
- * const maxAttempts = 3
178
- *
179
- * while (attempts < maxAttempts) {
180
- * try {
181
- * attempts++
182
- * ctx.setAttribute('http.request.resend_count', attempts - 1)
183
- *
184
- * const response = await axios.post('https://webhook.example.com/events', payload)
185
- * ctx.setAttribute('http.response.status_code', response.status)
186
- * return response.data
187
- * } catch (error) {
188
- * if (attempts >= maxAttempts) throw error
189
- * await new Promise(resolve => setTimeout(resolve, 1000 * attempts))
190
- * }
191
- * }
192
- * })
193
- * ```
194
- *
195
- * @public
196
- */
197
- function traceHTTP(config) {
198
- return (fnFactory) => {
199
- return require_functional.trace((ctx) => {
200
- if (config.method) ctx.setAttribute("http.request.method", config.method);
201
- if (config.url) ctx.setAttribute("url.full", config.url);
202
- if (config.attributes) {
203
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0 && value !== null) {
204
- const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
205
- ctx.setAttribute(key, attrValue);
206
- }
207
- }
208
- return fnFactory(ctx);
209
- });
51
+ function traceDB(config, fn) {
52
+ if (!config || typeof config !== "object") throw new TypeError("traceDB: config must be an object");
53
+ if (typeof config.system !== "string" || config.system.trim() === "") throw new TypeError("traceDB: config.system must be a non-empty string");
54
+ const target = config.collection ?? config.database;
55
+ const spanName = (config.querySummary ?? [config.operation, target].filter(Boolean).join(" ")) || config.system;
56
+ const configure = (ctx) => {
57
+ ctx.setAttribute("db.system.name", config.system);
58
+ ctx.setAttribute("db.system", config.system);
59
+ if (config.operation) {
60
+ ctx.setAttribute("db.operation.name", config.operation);
61
+ ctx.setAttribute("db.operation", config.operation);
62
+ }
63
+ if (config.database) {
64
+ ctx.setAttribute("db.namespace", config.database);
65
+ ctx.setAttribute("db.name", config.database);
66
+ }
67
+ if (config.collection) ctx.setAttribute("db.collection.name", config.collection);
68
+ if (config.querySummary) ctx.setAttribute("db.query.summary", config.querySummary);
69
+ setConfiguredAttributes(ctx, config.attributes);
210
70
  };
71
+ return wrapSemantic("traceDB", spanName, _opentelemetry_api.SpanKind.CLIENT, configure, fn);
211
72
  }
212
- /**
213
- * Trace messaging operations with Messaging semantic conventions
214
- *
215
- * Automatically adds standard attributes for messaging:
216
- * - messaging.system
217
- * - messaging.operation
218
- * - messaging.destination.name
219
- *
220
- * **Use Cases:**
221
- * - Publishing messages to queues/topics
222
- * - Consuming messages from queues/topics
223
- * - Event-driven architectures
224
- *
225
- * @param config - Messaging operation configuration
226
- * @returns Traced function factory with Messaging attributes
227
- *
228
- * @example Publishing to Kafka
229
- * ```typescript
230
- * import { traceMessaging } from 'autotel/semantic-helpers'
231
- * import { kafka } from './kafka'
232
- *
233
- * const producer = kafka.producer()
234
- *
235
- * export const publishEvent = traceMessaging({
236
- * system: 'kafka',
237
- * operation: 'publish',
238
- * destination: 'user-events'
239
- * })(ctx => async (event: { type: string; userId: string; data: object }) => {
240
- * ctx.setAttribute('messaging.message.type', event.type)
241
- * ctx.setAttribute('messaging.kafka.partition', 0)
242
- *
243
- * await producer.send({
244
- * topic: 'user-events',
245
- * messages: [
246
- * {
247
- * key: event.userId,
248
- * value: JSON.stringify(event.data)
249
- * }
250
- * ]
251
- * })
252
- *
253
- * ctx.setAttribute('messaging.message.id', event.userId)
254
- * })
255
- * ```
256
- *
257
- * @example Consuming from RabbitMQ
258
- * ```typescript
259
- * import { traceMessaging } from 'autotel/semantic-helpers'
260
- * import { channel } from './rabbitmq'
261
- *
262
- * export const processOrder = traceMessaging({
263
- * system: 'rabbitmq',
264
- * operation: 'process',
265
- * destination: 'orders'
266
- * })(ctx => async (message: { orderId: string; items: object[] }) => {
267
- * ctx.setAttribute('messaging.message.id', message.orderId)
268
- * ctx.setAttribute('messaging.message.body.size', JSON.stringify(message).length)
269
- *
270
- * // Process order logic
271
- * const result = await processOrderInternal(message)
272
- *
273
- * ctx.setAttribute('messaging.operation.result', 'success')
274
- * return result
275
- * })
276
- * ```
277
- *
278
- * @example AWS SQS with batch processing
279
- * ```typescript
280
- * import { traceMessaging } from 'autotel/semantic-helpers'
281
- * import { SQS } from '@aws-sdk/client-sqs'
282
- *
283
- * const sqs = new SQS()
284
- *
285
- * export const sendBatch = traceMessaging({
286
- * system: 'aws_sqs',
287
- * operation: 'publish',
288
- * destination: 'notifications-queue'
289
- * })(ctx => async (messages: Array<{ id: string; body: object }>) => {
290
- * ctx.setAttribute('messaging.batch.message_count', messages.length)
291
- *
292
- * const result = await sqs.sendMessageBatch({
293
- * QueueUrl: process.env.QUEUE_URL,
294
- * Entries: messages.map(msg => ({
295
- * Id: msg.id,
296
- * MessageBody: JSON.stringify(msg.body)
297
- * }))
298
- * })
299
- *
300
- * ctx.setAttribute('messaging.operation.success_count', result.Successful?.length || 0)
301
- * ctx.setAttribute('messaging.operation.failed_count', result.Failed?.length || 0)
302
- *
303
- * return result
304
- * })
305
- * ```
306
- *
307
- * @public
308
- */
309
- function traceMessaging(config) {
310
- return (fnFactory) => {
311
- return require_functional.trace((ctx) => {
312
- ctx.setAttribute("messaging.system", config.system);
313
- if (config.operation) ctx.setAttribute("messaging.operation", config.operation);
314
- if (config.destination) ctx.setAttribute("messaging.destination.name", config.destination);
315
- if (config.attributes) {
316
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0 && value !== null) {
317
- const attrValue = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? value : JSON.stringify(value);
318
- ctx.setAttribute(key, attrValue);
319
- }
320
- }
321
- return fnFactory(ctx);
322
- });
73
+ function traceHTTP(config, fn) {
74
+ if (!config || typeof config !== "object") throw new TypeError("traceHTTP: config must be an object");
75
+ const method = config.method?.toUpperCase() || "HTTP";
76
+ const target = config.route ?? config.urlTemplate;
77
+ const spanName = target ? `${method} ${target}` : method;
78
+ const configure = (ctx) => {
79
+ if (config.method) ctx.setAttribute("http.request.method", method);
80
+ if (config.url) ctx.setAttribute("url.full", config.url);
81
+ if (config.route) ctx.setAttribute("http.route", config.route);
82
+ if (config.urlTemplate) ctx.setAttribute("url.template", config.urlTemplate);
83
+ setConfiguredAttributes(ctx, config.attributes);
84
+ };
85
+ return wrapSemantic("traceHTTP", spanName, _opentelemetry_api.SpanKind.CLIENT, configure, fn);
86
+ }
87
+ function traceMessaging(config, fn) {
88
+ if (!config || typeof config !== "object") throw new TypeError("traceMessaging: config must be an object");
89
+ if (typeof config.system !== "string" || config.system.trim() === "") throw new TypeError("traceMessaging: config.system must be a non-empty string");
90
+ const operation = config.operation ?? "messaging";
91
+ const spanName = [operation, config.destination].filter(Boolean).join(" ");
92
+ const operationType = operation === "publish" ? "send" : operation;
93
+ const spanKind = operation === "publish" ? _opentelemetry_api.SpanKind.PRODUCER : operation === "process" ? _opentelemetry_api.SpanKind.CONSUMER : operation === "receive" ? _opentelemetry_api.SpanKind.CLIENT : _opentelemetry_api.SpanKind.INTERNAL;
94
+ const configure = (ctx) => {
95
+ ctx.setAttribute("messaging.system", config.system);
96
+ if (config.operation) {
97
+ ctx.setAttribute("messaging.operation.name", config.operation);
98
+ ctx.setAttribute("messaging.operation.type", operationType);
99
+ ctx.setAttribute("messaging.operation", config.operation);
100
+ }
101
+ if (config.destination) ctx.setAttribute("messaging.destination.name", config.destination);
102
+ setConfiguredAttributes(ctx, config.attributes);
323
103
  };
104
+ return wrapSemantic("traceMessaging", spanName, spanKind, configure, fn);
324
105
  }
325
106
 
326
107
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-helpers.cjs","names":["trace"],"sources":["../src/semantic-helpers.ts"],"sourcesContent":["/**\n * Semantic convention helpers for OpenTelemetry\n *\n * Pre-configured trace helpers that follow OpenTelemetry semantic conventions\n * for common operation types. Reduces boilerplate and ensures consistency.\n *\n * Based on: https://opentelemetry.io/docs/specs/semconv/\n */\n\nimport { trace } from './functional';\nimport type { TraceContext } from './trace-context';\nimport type { Attributes } from '@opentelemetry/api';\n\n/**\n * Configuration for database operations\n *\n * Follows DB semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/database/\n */\nexport interface DBConfig {\n /** Database system (e.g., 'postgresql', 'mongodb', 'redis') */\n system: string;\n /** Operation type (e.g., 'SELECT', 'INSERT', 'find', 'get') */\n operation?: string;\n /** Database name */\n database?: string;\n /** Collection/table name */\n collection?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Configuration for HTTP client operations\n *\n * Follows HTTP semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/http/\n */\nexport interface HTTPConfig {\n /** HTTP method (e.g., 'GET', 'POST') */\n method?: string;\n /** Target URL or URL template */\n url?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Configuration for messaging operations\n *\n * Follows Messaging semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/messaging/\n */\nexport interface MessagingConfig {\n /** Messaging system (e.g., 'kafka', 'rabbitmq', 'sqs') */\n system: string;\n /** Operation type */\n operation?: 'publish' | 'receive' | 'process';\n /** Destination name (queue/topic) */\n destination?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Trace database operations with DB semantic conventions\n *\n * Automatically adds standard attributes for database operations:\n * - db.system\n * - db.operation\n * - db.name\n * - db.collection.name (for NoSQL)\n *\n * **Use Cases:**\n * - SQL queries (PostgreSQL, MySQL, SQLite)\n * - NoSQL operations (MongoDB, DynamoDB, Redis)\n * - ORM queries (Prisma, TypeORM, Drizzle)\n *\n * @param config - Database operation configuration\n * @returns Traced function factory with DB attributes\n *\n * @example PostgreSQL query\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { pool } from './db'\n *\n * export const getUser = traceDB({\n * system: 'postgresql',\n * operation: 'SELECT',\n * database: 'app_db',\n * collection: 'users'\n * })(ctx => async (userId: string) => {\n * const query = 'SELECT * FROM users WHERE id = $1'\n * ctx.setAttribute('db.statement', query)\n *\n * const result = await pool.query(query, [userId])\n * ctx.setAttribute('db.rows_affected', result.rowCount)\n *\n * return result.rows[0]\n * })\n * ```\n *\n * @example MongoDB with Mongoose\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { User } from './models/User'\n *\n * export const findUsers = traceDB({\n * system: 'mongodb',\n * operation: 'find',\n * database: 'app_db',\n * collection: 'users'\n * })(ctx => async (filter: object) => {\n * ctx.setAttribute('db.mongodb.filter', JSON.stringify(filter))\n *\n * const users = await User.find(filter).limit(100)\n * ctx.setAttribute('db.response.count', users.length)\n *\n * return users\n * })\n * ```\n *\n * @example Redis operations\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { redis } from './redis'\n *\n * export const cacheGet = traceDB({\n * system: 'redis',\n * operation: 'GET'\n * })(ctx => async (key: string) => {\n * ctx.setAttribute('db.redis.key', key)\n *\n * const value = await redis.get(key)\n * ctx.setAttribute('db.response.cache_hit', value !== null)\n *\n * return value\n * })\n * ```\n *\n * @example Prisma with detailed query info\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { prisma } from './prisma'\n *\n * export const createPost = traceDB({\n * system: 'postgresql',\n * operation: 'INSERT',\n * database: 'app_db',\n * collection: 'posts'\n * })(ctx => async (data: { title: string; content: string; authorId: string }) => {\n * ctx.setAttribute('db.prisma.model', 'Post')\n * ctx.setAttribute('db.prisma.action', 'create')\n *\n * const post = await prisma.post.create({ data })\n *\n * ctx.setAttribute('db.response.id', post.id)\n * return post\n * })\n * ```\n *\n * @public\n */\nexport function traceDB<TArgs extends unknown[], TReturn>(config: DBConfig) {\n return (\n fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>,\n ): ((...args: TArgs) => Promise<TReturn>) => {\n return trace<TArgs, TReturn>((ctx) => {\n // Set semantic convention attributes\n ctx.setAttribute('db.system', config.system);\n if (config.operation) {\n ctx.setAttribute('db.operation', config.operation);\n }\n if (config.database) {\n ctx.setAttribute('db.name', config.database);\n }\n if (config.collection) {\n ctx.setAttribute('db.collection.name', config.collection);\n }\n if (config.attributes) {\n for (const [key, value] of Object.entries(config.attributes)) {\n if (value !== undefined && value !== null) {\n // setAttribute only accepts primitives (string | number | boolean)\n // Arrays and objects should be serialized\n const attrValue =\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ? value\n : JSON.stringify(value);\n ctx.setAttribute(key, attrValue);\n }\n }\n }\n\n // Call the user's factory to get their function and return it\n return fnFactory(ctx);\n });\n };\n}\n\n/**\n * Trace HTTP client operations with HTTP semantic conventions\n *\n * Automatically adds standard attributes for HTTP requests:\n * - http.request.method\n * - url.full\n *\n * **Use Cases:**\n * - External API calls\n * - Microservice communication\n * - Third-party integrations\n *\n * @param config - HTTP operation configuration\n * @returns Traced function factory with HTTP attributes\n *\n * @example Fetch API\n * ```typescript\n * import { traceHTTP } from 'autotel/semantic-helpers'\n *\n * export const fetchUser = traceHTTP({\n * method: 'GET',\n * url: 'https://api.example.com/users/:id'\n * })(ctx => async (userId: string) => {\n * const url = `https://api.example.com/users/${userId}`\n * ctx.setAttribute('url.full', url)\n *\n * const response = await fetch(url)\n * ctx.setAttribute('http.response.status_code', response.status)\n *\n * if (!response.ok) {\n * ctx.setAttribute('error', true)\n * throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n * }\n *\n * return response.json()\n * })\n * ```\n *\n * @example Axios with retry logic\n * ```typescript\n * import { traceHTTP } from 'autotel/semantic-helpers'\n * import axios from 'axios'\n *\n * export const sendWebhook = traceHTTP({\n * method: 'POST',\n * url: 'https://webhook.example.com/events'\n * })(ctx => async (payload: object) => {\n * let attempts = 0\n * const maxAttempts = 3\n *\n * while (attempts < maxAttempts) {\n * try {\n * attempts++\n * ctx.setAttribute('http.request.resend_count', attempts - 1)\n *\n * const response = await axios.post('https://webhook.example.com/events', payload)\n * ctx.setAttribute('http.response.status_code', response.status)\n * return response.data\n * } catch (error) {\n * if (attempts >= maxAttempts) throw error\n * await new Promise(resolve => setTimeout(resolve, 1000 * attempts))\n * }\n * }\n * })\n * ```\n *\n * @public\n */\nexport function traceHTTP<TArgs extends unknown[], TReturn>(\n config: HTTPConfig,\n) {\n return (\n fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>,\n ): ((...args: TArgs) => Promise<TReturn>) => {\n return trace<TArgs, TReturn>((ctx) => {\n // Set semantic convention attributes\n if (config.method) {\n ctx.setAttribute('http.request.method', config.method);\n }\n if (config.url) {\n ctx.setAttribute('url.full', config.url);\n }\n if (config.attributes) {\n for (const [key, value] of Object.entries(config.attributes)) {\n if (value !== undefined && value !== null) {\n // setAttribute only accepts primitives (string | number | boolean)\n // Arrays and objects should be serialized\n const attrValue =\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ? value\n : JSON.stringify(value);\n ctx.setAttribute(key, attrValue);\n }\n }\n }\n\n // Call the user's factory to get their function and return it\n return fnFactory(ctx);\n });\n };\n}\n\n/**\n * Trace messaging operations with Messaging semantic conventions\n *\n * Automatically adds standard attributes for messaging:\n * - messaging.system\n * - messaging.operation\n * - messaging.destination.name\n *\n * **Use Cases:**\n * - Publishing messages to queues/topics\n * - Consuming messages from queues/topics\n * - Event-driven architectures\n *\n * @param config - Messaging operation configuration\n * @returns Traced function factory with Messaging attributes\n *\n * @example Publishing to Kafka\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { kafka } from './kafka'\n *\n * const producer = kafka.producer()\n *\n * export const publishEvent = traceMessaging({\n * system: 'kafka',\n * operation: 'publish',\n * destination: 'user-events'\n * })(ctx => async (event: { type: string; userId: string; data: object }) => {\n * ctx.setAttribute('messaging.message.type', event.type)\n * ctx.setAttribute('messaging.kafka.partition', 0)\n *\n * await producer.send({\n * topic: 'user-events',\n * messages: [\n * {\n * key: event.userId,\n * value: JSON.stringify(event.data)\n * }\n * ]\n * })\n *\n * ctx.setAttribute('messaging.message.id', event.userId)\n * })\n * ```\n *\n * @example Consuming from RabbitMQ\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { channel } from './rabbitmq'\n *\n * export const processOrder = traceMessaging({\n * system: 'rabbitmq',\n * operation: 'process',\n * destination: 'orders'\n * })(ctx => async (message: { orderId: string; items: object[] }) => {\n * ctx.setAttribute('messaging.message.id', message.orderId)\n * ctx.setAttribute('messaging.message.body.size', JSON.stringify(message).length)\n *\n * // Process order logic\n * const result = await processOrderInternal(message)\n *\n * ctx.setAttribute('messaging.operation.result', 'success')\n * return result\n * })\n * ```\n *\n * @example AWS SQS with batch processing\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { SQS } from '@aws-sdk/client-sqs'\n *\n * const sqs = new SQS()\n *\n * export const sendBatch = traceMessaging({\n * system: 'aws_sqs',\n * operation: 'publish',\n * destination: 'notifications-queue'\n * })(ctx => async (messages: Array<{ id: string; body: object }>) => {\n * ctx.setAttribute('messaging.batch.message_count', messages.length)\n *\n * const result = await sqs.sendMessageBatch({\n * QueueUrl: process.env.QUEUE_URL,\n * Entries: messages.map(msg => ({\n * Id: msg.id,\n * MessageBody: JSON.stringify(msg.body)\n * }))\n * })\n *\n * ctx.setAttribute('messaging.operation.success_count', result.Successful?.length || 0)\n * ctx.setAttribute('messaging.operation.failed_count', result.Failed?.length || 0)\n *\n * return result\n * })\n * ```\n *\n * @public\n */\nexport function traceMessaging<TArgs extends unknown[], TReturn>(\n config: MessagingConfig,\n) {\n return (\n fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>,\n ): ((...args: TArgs) => Promise<TReturn>) => {\n return trace<TArgs, TReturn>((ctx) => {\n // Set semantic convention attributes\n ctx.setAttribute('messaging.system', config.system);\n if (config.operation) {\n ctx.setAttribute('messaging.operation', config.operation);\n }\n if (config.destination) {\n ctx.setAttribute('messaging.destination.name', config.destination);\n }\n if (config.attributes) {\n for (const [key, value] of Object.entries(config.attributes)) {\n if (value !== undefined && value !== null) {\n // setAttribute only accepts primitives (string | number | boolean)\n // Arrays and objects should be serialized\n const attrValue =\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ? value\n : JSON.stringify(value);\n ctx.setAttribute(key, attrValue);\n }\n }\n }\n\n // Call the user's factory to get their function and return it\n return fnFactory(ctx);\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,SAAgB,eACd,QACA;CACA,QACE,cAC2C;EAC3C,OAAOA,0BAAuB,QAAQ;GAEpC,IAAI,aAAa,oBAAoB,OAAO,MAAM;GAClD,IAAI,OAAO,WACT,IAAI,aAAa,uBAAuB,OAAO,SAAS;GAE1D,IAAI,OAAO,aACT,IAAI,aAAa,8BAA8B,OAAO,WAAW;GAEnE,IAAI,OAAO,YACT;SAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,UAAU,GACzD,IAAI,UAAU,UAAa,UAAU,MAAM;KAGzC,MAAM,YACJ,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,YACb,QACA,KAAK,UAAU,KAAK;KAC1B,IAAI,aAAa,KAAK,SAAS;IACjC;GACF;GAIF,OAAO,UAAU,GAAG;EACtB,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"semantic-helpers.cjs","names":["withTracing","SpanKind"],"sources":["../src/semantic-helpers.ts"],"sourcesContent":["/**\n * Semantic convention helpers for OpenTelemetry\n *\n * Pre-configured trace helpers that follow OpenTelemetry semantic conventions\n * for common operation types. Reduces boilerplate and ensures consistency.\n *\n * Based on: https://opentelemetry.io/docs/specs/semconv/\n */\n\nimport { withTracing } from './functional';\nimport { assertTraceFactory } from './trace-factory-validation';\nimport type { TraceContext } from './trace-context';\nimport { SpanKind, type Attributes } from '@opentelemetry/api';\n\ntype SemanticHandler<TArgs extends unknown[], TReturn> = (\n ...args: TArgs\n) => TReturn | Promise<TReturn>;\n\ntype SemanticFactory<TArgs extends unknown[], TReturn> = (\n ctx: TraceContext,\n) => SemanticHandler<TArgs, TReturn>;\n\nfunction setConfiguredAttributes(\n ctx: TraceContext,\n attributes?: Attributes,\n): void {\n if (!attributes) return;\n for (const [key, value] of Object.entries(attributes)) {\n if (value === undefined || value === null) continue;\n const attributeValue =\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ? value\n : JSON.stringify(value);\n ctx.setAttribute(key, attributeValue);\n }\n}\n\n/**\n * Shared tail of `traceDB`/`traceHTTP`/`traceMessaging`: wrap `fn` directly\n * when given, otherwise return the curried factory-acceptor form.\n */\nfunction wrapSemantic<TArgs extends unknown[], TReturn>(\n helperName: string,\n name: string,\n spanKind: SpanKind,\n configure: (ctx: TraceContext) => void,\n fn?: SemanticHandler<TArgs, TReturn>,\n):\n | SemanticHandler<TArgs, TReturn>\n | (<TFactoryArgs extends unknown[], TFactoryReturn>(\n factory: SemanticFactory<TFactoryArgs, TFactoryReturn>,\n ) => SemanticHandler<TFactoryArgs, TFactoryReturn>) {\n if (fn) {\n assertTraceFactory(helperName, fn);\n return withTracing<TArgs, TReturn>({ name, spanKind })(\n (ctx: TraceContext) => {\n configure(ctx);\n return fn;\n },\n );\n }\n return <TFactoryArgs extends unknown[], TFactoryReturn>(\n factory: SemanticFactory<TFactoryArgs, TFactoryReturn>,\n ) => {\n assertTraceFactory(helperName, factory);\n return withTracing<TFactoryArgs, TFactoryReturn>({ name, spanKind })(\n (ctx: TraceContext) => {\n configure(ctx);\n const handler = factory(ctx);\n assertTraceFactory(helperName, handler, 'result');\n return handler;\n },\n );\n };\n}\n\n/**\n * Configuration for database operations\n *\n * Follows DB semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/database/\n */\nexport interface DBConfig {\n /** Database system (e.g., 'postgresql', 'mongodb', 'redis') */\n system: string;\n /** Operation type (e.g., 'SELECT', 'INSERT', 'find', 'get') */\n operation?: string;\n /** Database name */\n database?: string;\n /** Collection/table name */\n collection?: string;\n /** Low-cardinality query summary used as the preferred span name */\n querySummary?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Configuration for HTTP client operations\n *\n * Follows HTTP semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/http/\n */\nexport interface HTTPConfig {\n /** HTTP method (e.g., 'GET', 'POST') */\n method?: string;\n /** Target URL or URL template */\n url?: string;\n /** Low-cardinality server route used in the span name */\n route?: string;\n /** Low-cardinality client URL template used in the span name */\n urlTemplate?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Configuration for messaging operations\n *\n * Follows Messaging semantic conventions:\n * https://opentelemetry.io/docs/specs/semconv/messaging/\n */\nexport interface MessagingConfig {\n /** Messaging system (e.g., 'kafka', 'rabbitmq', 'sqs') */\n system: string;\n /** Operation type */\n operation?: 'publish' | 'receive' | 'process';\n /** Destination name (queue/topic) */\n destination?: string;\n /** Additional attributes to add to the span */\n attributes?: Attributes;\n}\n\n/**\n * Trace database operations with DB semantic conventions\n *\n * Automatically adds standard attributes for database operations:\n * - db.system.name\n * - db.operation.name\n * - db.namespace\n * - db.collection.name (for NoSQL)\n *\n * **Use Cases:**\n * - SQL queries (PostgreSQL, MySQL, SQLite)\n * - NoSQL operations (MongoDB, DynamoDB, Redis)\n * - ORM queries (Prisma, TypeORM, Drizzle)\n *\n * @param config - Database operation configuration\n * @returns Traced function factory with DB attributes\n *\n * @example PostgreSQL query\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { pool } from './db'\n *\n * export const getUser = traceDB({\n * system: 'postgresql',\n * operation: 'SELECT',\n * database: 'app_db',\n * collection: 'users',\n * querySummary: 'SELECT users'\n * })(ctx => async (userId: string) => {\n * const query = 'SELECT * FROM users WHERE id = $1'\n * const result = await pool.query(query, [userId])\n * ctx.setAttribute('db.rows_affected', result.rowCount)\n *\n * return result.rows[0]\n * })\n * ```\n *\n * @example MongoDB with Mongoose\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { User } from './models/User'\n *\n * export const findUsers = traceDB({\n * system: 'mongodb',\n * operation: 'find',\n * database: 'app_db',\n * collection: 'users'\n * })(ctx => async (filter: object) => {\n * ctx.setAttribute('db.mongodb.filter', JSON.stringify(filter))\n *\n * const users = await User.find(filter).limit(100)\n * ctx.setAttribute('db.response.count', users.length)\n *\n * return users\n * })\n * ```\n *\n * @example Redis operations\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { redis } from './redis'\n *\n * export const cacheGet = traceDB({\n * system: 'redis',\n * operation: 'GET'\n * })(ctx => async (key: string) => {\n * ctx.setAttribute('db.redis.key', key)\n *\n * const value = await redis.get(key)\n * ctx.setAttribute('db.response.cache_hit', value !== null)\n *\n * return value\n * })\n * ```\n *\n * @example Prisma with detailed query info\n * ```typescript\n * import { traceDB } from 'autotel/semantic-helpers'\n * import { prisma } from './prisma'\n *\n * export const createPost = traceDB({\n * system: 'postgresql',\n * operation: 'INSERT',\n * database: 'app_db',\n * collection: 'posts'\n * })(ctx => async (data: { title: string; content: string; authorId: string }) => {\n * ctx.setAttribute('db.prisma.model', 'Post')\n * ctx.setAttribute('db.prisma.action', 'create')\n *\n * const post = await prisma.post.create({ data })\n *\n * ctx.setAttribute('db.response.id', post.id)\n * return post\n * })\n * ```\n *\n * @public\n */\nexport function traceDB(\n config: DBConfig,\n): <TArgs extends unknown[], TReturn>(\n factory: SemanticFactory<TArgs, TReturn>,\n) => SemanticHandler<TArgs, TReturn>;\nexport function traceDB<TArgs extends unknown[], TReturn>(\n config: DBConfig,\n fn: SemanticHandler<TArgs, TReturn>,\n): SemanticHandler<TArgs, TReturn>;\nexport function traceDB<TArgs extends unknown[], TReturn>(\n config: DBConfig,\n fn?: SemanticHandler<TArgs, TReturn>,\n):\n | SemanticHandler<TArgs, TReturn>\n | (<TFactoryArgs extends unknown[], TFactoryReturn>(\n factory: SemanticFactory<TFactoryArgs, TFactoryReturn>,\n ) => SemanticHandler<TFactoryArgs, TFactoryReturn>) {\n if (!config || typeof config !== 'object') {\n throw new TypeError('traceDB: config must be an object');\n }\n if (typeof config.system !== 'string' || config.system.trim() === '') {\n throw new TypeError('traceDB: config.system must be a non-empty string');\n }\n const target = config.collection ?? config.database;\n const name =\n config.querySummary ?? [config.operation, target].filter(Boolean).join(' ');\n const spanName = name || config.system;\n const configure = (ctx: TraceContext) => {\n // Emit current stable names plus legacy aliases for dashboard compatibility.\n ctx.setAttribute('db.system.name', config.system);\n ctx.setAttribute('db.system', config.system);\n if (config.operation) {\n ctx.setAttribute('db.operation.name', config.operation);\n ctx.setAttribute('db.operation', config.operation);\n }\n if (config.database) {\n ctx.setAttribute('db.namespace', config.database);\n ctx.setAttribute('db.name', config.database);\n }\n if (config.collection) {\n ctx.setAttribute('db.collection.name', config.collection);\n }\n if (config.querySummary) {\n ctx.setAttribute('db.query.summary', config.querySummary);\n }\n setConfiguredAttributes(ctx, config.attributes);\n };\n return wrapSemantic('traceDB', spanName, SpanKind.CLIENT, configure, fn);\n}\n\n/**\n * Trace HTTP client operations with HTTP semantic conventions\n *\n * Automatically adds standard attributes for HTTP requests:\n * - http.request.method\n * - url.full\n *\n * **Use Cases:**\n * - External API calls\n * - Microservice communication\n * - Third-party integrations\n *\n * @param config - HTTP operation configuration\n * @returns Traced function factory with HTTP attributes\n *\n * @example Fetch API\n * ```typescript\n * import { traceHTTP } from 'autotel/semantic-helpers'\n *\n * export const fetchUser = traceHTTP({\n * method: 'GET',\n * urlTemplate: '/users/{id}'\n * })(ctx => async (userId: string) => {\n * const url = `https://api.example.com/users/${userId}`\n * ctx.setAttribute('url.full', url)\n *\n * const response = await fetch(url)\n * ctx.setAttribute('http.response.status_code', response.status)\n *\n * if (!response.ok) {\n * ctx.setAttribute('error', true)\n * throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n * }\n *\n * return response.json()\n * })\n * ```\n *\n * @example Axios with retry logic\n * ```typescript\n * import { traceHTTP } from 'autotel/semantic-helpers'\n * import axios from 'axios'\n *\n * export const sendWebhook = traceHTTP({\n * method: 'POST',\n * url: 'https://webhook.example.com/events'\n * })(ctx => async (payload: object) => {\n * let attempts = 0\n * const maxAttempts = 3\n *\n * while (attempts < maxAttempts) {\n * try {\n * attempts++\n * ctx.setAttribute('http.request.resend_count', attempts - 1)\n *\n * const response = await axios.post('https://webhook.example.com/events', payload)\n * ctx.setAttribute('http.response.status_code', response.status)\n * return response.data\n * } catch (error) {\n * if (attempts >= maxAttempts) throw error\n * await new Promise(resolve => setTimeout(resolve, 1000 * attempts))\n * }\n * }\n * })\n * ```\n *\n * @public\n */\nexport function traceHTTP(\n config: HTTPConfig,\n): <TArgs extends unknown[], TReturn>(\n factory: SemanticFactory<TArgs, TReturn>,\n) => SemanticHandler<TArgs, TReturn>;\nexport function traceHTTP<TArgs extends unknown[], TReturn>(\n config: HTTPConfig,\n fn: SemanticHandler<TArgs, TReturn>,\n): SemanticHandler<TArgs, TReturn>;\nexport function traceHTTP<TArgs extends unknown[], TReturn>(\n config: HTTPConfig,\n fn?: SemanticHandler<TArgs, TReturn>,\n):\n | SemanticHandler<TArgs, TReturn>\n | (<TFactoryArgs extends unknown[], TFactoryReturn>(\n factory: SemanticFactory<TFactoryArgs, TFactoryReturn>,\n ) => SemanticHandler<TFactoryArgs, TFactoryReturn>) {\n if (!config || typeof config !== 'object') {\n throw new TypeError('traceHTTP: config must be an object');\n }\n const method = config.method?.toUpperCase() || 'HTTP';\n const target = config.route ?? config.urlTemplate;\n const spanName = target ? `${method} ${target}` : method;\n const configure = (ctx: TraceContext) => {\n if (config.method) ctx.setAttribute('http.request.method', method);\n if (config.url) ctx.setAttribute('url.full', config.url);\n if (config.route) ctx.setAttribute('http.route', config.route);\n if (config.urlTemplate) {\n ctx.setAttribute('url.template', config.urlTemplate);\n }\n setConfiguredAttributes(ctx, config.attributes);\n };\n return wrapSemantic('traceHTTP', spanName, SpanKind.CLIENT, configure, fn);\n}\n\n/**\n * Trace messaging operations with Messaging semantic conventions\n *\n * Automatically adds standard attributes for messaging:\n * - messaging.system\n * - messaging.operation\n * - messaging.destination.name\n *\n * **Use Cases:**\n * - Publishing messages to queues/topics\n * - Consuming messages from queues/topics\n * - Event-driven architectures\n *\n * @param config - Messaging operation configuration\n * @returns Traced function factory with Messaging attributes\n *\n * @example Publishing to Kafka\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { kafka } from './kafka'\n *\n * const producer = kafka.producer()\n *\n * export const publishEvent = traceMessaging({\n * system: 'kafka',\n * operation: 'publish',\n * destination: 'user-events'\n * })(ctx => async (event: { type: string; userId: string; data: object }) => {\n * ctx.setAttribute('messaging.message.type', event.type)\n * ctx.setAttribute('messaging.kafka.partition', 0)\n *\n * await producer.send({\n * topic: 'user-events',\n * messages: [\n * {\n * key: event.userId,\n * value: JSON.stringify(event.data)\n * }\n * ]\n * })\n *\n * ctx.setAttribute('messaging.message.id', event.userId)\n * })\n * ```\n *\n * @example Consuming from RabbitMQ\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { channel } from './rabbitmq'\n *\n * export const processOrder = traceMessaging({\n * system: 'rabbitmq',\n * operation: 'process',\n * destination: 'orders'\n * })(ctx => async (message: { orderId: string; items: object[] }) => {\n * ctx.setAttribute('messaging.message.id', message.orderId)\n * ctx.setAttribute('messaging.message.body.size', JSON.stringify(message).length)\n *\n * // Process order logic\n * const result = await processOrderInternal(message)\n *\n * ctx.setAttribute('messaging.operation.result', 'success')\n * return result\n * })\n * ```\n *\n * @example AWS SQS with batch processing\n * ```typescript\n * import { traceMessaging } from 'autotel/semantic-helpers'\n * import { SQS } from '@aws-sdk/client-sqs'\n *\n * const sqs = new SQS()\n *\n * export const sendBatch = traceMessaging({\n * system: 'aws_sqs',\n * operation: 'publish',\n * destination: 'notifications-queue'\n * })(ctx => async (messages: Array<{ id: string; body: object }>) => {\n * ctx.setAttribute('messaging.batch.message_count', messages.length)\n *\n * const result = await sqs.sendMessageBatch({\n * QueueUrl: process.env.QUEUE_URL,\n * Entries: messages.map(msg => ({\n * Id: msg.id,\n * MessageBody: JSON.stringify(msg.body)\n * }))\n * })\n *\n * ctx.setAttribute('messaging.operation.success_count', result.Successful?.length || 0)\n * ctx.setAttribute('messaging.operation.failed_count', result.Failed?.length || 0)\n *\n * return result\n * })\n * ```\n *\n * @public\n */\nexport function traceMessaging(\n config: MessagingConfig,\n): <TArgs extends unknown[], TReturn>(\n factory: SemanticFactory<TArgs, TReturn>,\n) => SemanticHandler<TArgs, TReturn>;\nexport function traceMessaging<TArgs extends unknown[], TReturn>(\n config: MessagingConfig,\n fn: SemanticHandler<TArgs, TReturn>,\n): SemanticHandler<TArgs, TReturn>;\nexport function traceMessaging<TArgs extends unknown[], TReturn>(\n config: MessagingConfig,\n fn?: SemanticHandler<TArgs, TReturn>,\n):\n | SemanticHandler<TArgs, TReturn>\n | (<TFactoryArgs extends unknown[], TFactoryReturn>(\n factory: SemanticFactory<TFactoryArgs, TFactoryReturn>,\n ) => SemanticHandler<TFactoryArgs, TFactoryReturn>) {\n if (!config || typeof config !== 'object') {\n throw new TypeError('traceMessaging: config must be an object');\n }\n if (typeof config.system !== 'string' || config.system.trim() === '') {\n throw new TypeError(\n 'traceMessaging: config.system must be a non-empty string',\n );\n }\n const operation = config.operation ?? 'messaging';\n const spanName = [operation, config.destination].filter(Boolean).join(' ');\n const operationType = operation === 'publish' ? 'send' : operation;\n const spanKind =\n operation === 'publish'\n ? SpanKind.PRODUCER\n : operation === 'process'\n ? SpanKind.CONSUMER\n : operation === 'receive'\n ? SpanKind.CLIENT\n : SpanKind.INTERNAL;\n const configure = (ctx: TraceContext) => {\n ctx.setAttribute('messaging.system', config.system);\n if (config.operation) {\n ctx.setAttribute('messaging.operation.name', config.operation);\n ctx.setAttribute('messaging.operation.type', operationType);\n ctx.setAttribute('messaging.operation', config.operation);\n }\n if (config.destination) {\n ctx.setAttribute('messaging.destination.name', config.destination);\n }\n setConfiguredAttributes(ctx, config.attributes);\n };\n return wrapSemantic('traceMessaging', spanName, spanKind, configure, fn);\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,SAAS,wBACP,KACA,YACM;CACN,IAAI,CAAC,YAAY;CACjB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAAG;EACrD,IAAI,UAAU,UAAa,UAAU,MAAM;EAC3C,MAA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Aa,QAAsB;EACvC,IAAI,aAAa,oBAAoB,OAAO,MAAM;EAClD,IAAI,OAAO,WAAW;GACpB,IAAI,aAAa,4BAA4B,OAAO,SAAS;GAC7D,IAAI,aAAa,4BAA4B,aAAa;GAC1D,IAAI,aAAa,uBAAuB,OAAO,SAAS;EAC1D;EACA,IAAI,OAAO,aACT,IAAI,aAAa,8BAA8B,OAAO,WAAW;EAEnE,wBAAwB,KAAK,OAAO,UAAU;CAChD;CACA,OAAO,aAAa,kBAAkB,UAAU,UAAU,WAAW,EAAE;AACzE"}
@@ -1,7 +1,8 @@
1
- import { n as TraceContext } from "./trace-context-Cijqoi6e.cjs";
1
+ import { n as TraceContext } from "./trace-context-IuyoPyNq.cjs";
2
2
  import { Attributes } from "@opentelemetry/api";
3
-
4
3
  //#region src/semantic-helpers.d.ts
4
+ type SemanticHandler<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn | Promise<TReturn>;
5
+ type SemanticFactory<TArgs extends unknown[], TReturn> = (ctx: TraceContext) => SemanticHandler<TArgs, TReturn>;
5
6
  /**
6
7
  * Configuration for database operations
7
8
  *
@@ -17,6 +18,8 @@ interface DBConfig {
17
18
  database?: string;
18
19
  /** Collection/table name */
19
20
  collection?: string;
21
+ /** Low-cardinality query summary used as the preferred span name */
22
+ querySummary?: string;
20
23
  /** Additional attributes to add to the span */
21
24
  attributes?: Attributes;
22
25
  }
@@ -31,6 +34,10 @@ interface HTTPConfig {
31
34
  method?: string;
32
35
  /** Target URL or URL template */
33
36
  url?: string;
37
+ /** Low-cardinality server route used in the span name */
38
+ route?: string;
39
+ /** Low-cardinality client URL template used in the span name */
40
+ urlTemplate?: string;
34
41
  /** Additional attributes to add to the span */
35
42
  attributes?: Attributes;
36
43
  }
@@ -54,9 +61,9 @@ interface MessagingConfig {
54
61
  * Trace database operations with DB semantic conventions
55
62
  *
56
63
  * Automatically adds standard attributes for database operations:
57
- * - db.system
58
- * - db.operation
59
- * - db.name
64
+ * - db.system.name
65
+ * - db.operation.name
66
+ * - db.namespace
60
67
  * - db.collection.name (for NoSQL)
61
68
  *
62
69
  * **Use Cases:**
@@ -76,11 +83,10 @@ interface MessagingConfig {
76
83
  * system: 'postgresql',
77
84
  * operation: 'SELECT',
78
85
  * database: 'app_db',
79
- * collection: 'users'
86
+ * collection: 'users',
87
+ * querySummary: 'SELECT users'
80
88
  * })(ctx => async (userId: string) => {
81
89
  * const query = 'SELECT * FROM users WHERE id = $1'
82
- * ctx.setAttribute('db.statement', query)
83
- *
84
90
  * const result = await pool.query(query, [userId])
85
91
  * ctx.setAttribute('db.rows_affected', result.rowCount)
86
92
  *
@@ -149,7 +155,8 @@ interface MessagingConfig {
149
155
  *
150
156
  * @public
151
157
  */
152
- declare function traceDB<TArgs extends unknown[], TReturn>(config: DBConfig): (fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
158
+ declare function traceDB(config: DBConfig): <TArgs extends unknown[], TReturn>(factory: SemanticFactory<TArgs, TReturn>) => SemanticHandler<TArgs, TReturn>;
159
+ declare function traceDB<TArgs extends unknown[], TReturn>(config: DBConfig, fn: SemanticHandler<TArgs, TReturn>): SemanticHandler<TArgs, TReturn>;
153
160
  /**
154
161
  * Trace HTTP client operations with HTTP semantic conventions
155
162
  *
@@ -171,7 +178,7 @@ declare function traceDB<TArgs extends unknown[], TReturn>(config: DBConfig): (f
171
178
  *
172
179
  * export const fetchUser = traceHTTP({
173
180
  * method: 'GET',
174
- * url: 'https://api.example.com/users/:id'
181
+ * urlTemplate: '/users/{id}'
175
182
  * })(ctx => async (userId: string) => {
176
183
  * const url = `https://api.example.com/users/${userId}`
177
184
  * ctx.setAttribute('url.full', url)
@@ -218,7 +225,8 @@ declare function traceDB<TArgs extends unknown[], TReturn>(config: DBConfig): (f
218
225
  *
219
226
  * @public
220
227
  */
221
- declare function traceHTTP<TArgs extends unknown[], TReturn>(config: HTTPConfig): (fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
228
+ declare function traceHTTP(config: HTTPConfig): <TArgs extends unknown[], TReturn>(factory: SemanticFactory<TArgs, TReturn>) => SemanticHandler<TArgs, TReturn>;
229
+ declare function traceHTTP<TArgs extends unknown[], TReturn>(config: HTTPConfig, fn: SemanticHandler<TArgs, TReturn>): SemanticHandler<TArgs, TReturn>;
222
230
  /**
223
231
  * Trace messaging operations with Messaging semantic conventions
224
232
  *
@@ -316,7 +324,8 @@ declare function traceHTTP<TArgs extends unknown[], TReturn>(config: HTTPConfig)
316
324
  *
317
325
  * @public
318
326
  */
319
- declare function traceMessaging<TArgs extends unknown[], TReturn>(config: MessagingConfig): (fnFactory: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
327
+ declare function traceMessaging(config: MessagingConfig): <TArgs extends unknown[], TReturn>(factory: SemanticFactory<TArgs, TReturn>) => SemanticHandler<TArgs, TReturn>;
328
+ declare function traceMessaging<TArgs extends unknown[], TReturn>(config: MessagingConfig, fn: SemanticHandler<TArgs, TReturn>): SemanticHandler<TArgs, TReturn>;
320
329
  //#endregion
321
330
  export { DBConfig, HTTPConfig, MessagingConfig, traceDB, traceHTTP, traceMessaging };
322
331
  //# sourceMappingURL=semantic-helpers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-helpers.d.cts","names":[],"sources":["../src/semantic-helpers.ts"],"mappings":";;;;;;;;;AA6ByB;UAVR,QAAA;EAmBU;EAjBzB,MAAA;EAuBuB;EArBvB,SAAA;EAmBA;EAjBA,QAAA;EAmBa;EAjBb,UAAA;EAiBuB;EAfvB,UAAA,GAAa,UAAU;AAAA;;;;;;;UASR,UAAA;EAuBQ;EArBvB,MAAA;EA2Hc;EAzHd,GAAA;EAyHqB;EAvHrB,UAAA,GAAa,UAAU;AAAA;;;;;;;UASR,eAAA;EAiHgB;EA/G/B,MAAA;EA4G+C;EA1G/C,SAAA;EA0GwD;EA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