@geekmidas/telescope 10.0.0-alpha.2 → 10.0.0-alpha.21

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 (391) hide show
  1. package/dist/{MetricsAggregator-4SqelGcG.d.cts → MetricsAggregator-BxBLQUPj.d.cts} +3 -6
  2. package/dist/MetricsAggregator-BxBLQUPj.d.cts.map +1 -0
  3. package/dist/{MetricsAggregator-DZrW8ls6.d.mts → MetricsAggregator-j9wmZ0K_.d.mts} +3 -6
  4. package/dist/MetricsAggregator-j9wmZ0K_.d.mts.map +1 -0
  5. package/dist/{Telescope-D4nmwDRA.d.cts → Telescope-BcrWTaar.d.mts} +4 -7
  6. package/dist/Telescope-BcrWTaar.d.mts.map +1 -0
  7. package/dist/{Telescope-Dl6VSfxd.d.mts → Telescope-DnCMZT7V.d.cts} +4 -7
  8. package/dist/Telescope-DnCMZT7V.d.cts.map +1 -0
  9. package/dist/Telescope.cjs +385 -4
  10. package/dist/Telescope.cjs.map +1 -0
  11. package/dist/Telescope.d.cts +1 -3
  12. package/dist/Telescope.d.mts +1 -3
  13. package/dist/Telescope.mjs +384 -4
  14. package/dist/Telescope.mjs.map +1 -0
  15. package/dist/adapters/index.d.cts +2 -2
  16. package/dist/adapters/index.d.mts +2 -2
  17. package/dist/adapters/index.mjs +1 -0
  18. package/dist/adapters/lambda.cjs +9 -10
  19. package/dist/adapters/lambda.cjs.map +1 -1
  20. package/dist/adapters/lambda.d.cts +9 -13
  21. package/dist/adapters/lambda.d.cts.map +1 -1
  22. package/dist/adapters/lambda.d.mts +9 -13
  23. package/dist/adapters/lambda.d.mts.map +1 -1
  24. package/dist/adapters/lambda.mjs +3 -4
  25. package/dist/adapters/lambda.mjs.map +1 -1
  26. package/dist/adapters/middy.cjs +236 -4
  27. package/dist/adapters/middy.cjs.map +1 -0
  28. package/dist/adapters/middy.d.cts +60 -5
  29. package/dist/adapters/middy.d.cts.map +1 -0
  30. package/dist/adapters/middy.d.mts +60 -5
  31. package/dist/adapters/middy.d.mts.map +1 -0
  32. package/dist/adapters/middy.mjs +234 -3
  33. package/dist/adapters/middy.mjs.map +1 -0
  34. package/dist/adapters/types.d.cts +162 -2
  35. package/dist/adapters/types.d.cts.map +1 -0
  36. package/dist/adapters/types.d.mts +162 -2
  37. package/dist/adapters/types.d.mts.map +1 -0
  38. package/dist/adapters/types.mjs +1 -0
  39. package/dist/core.cjs +22 -22
  40. package/dist/core.d.cts +4 -4
  41. package/dist/core.d.mts +4 -4
  42. package/dist/core.mjs +3 -4
  43. package/dist/index.cjs +8 -9
  44. package/dist/index.d.cts +5 -6
  45. package/dist/index.d.mts +5 -6
  46. package/dist/index.mjs +5 -7
  47. package/dist/instrumentation/core.cjs +147 -11
  48. package/dist/instrumentation/core.cjs.map +1 -0
  49. package/dist/instrumentation/core.d.cts +74 -3
  50. package/dist/instrumentation/core.d.cts.map +1 -0
  51. package/dist/instrumentation/core.d.mts +74 -3
  52. package/dist/instrumentation/core.d.mts.map +1 -0
  53. package/dist/instrumentation/core.mjs +137 -2
  54. package/dist/instrumentation/core.mjs.map +1 -0
  55. package/dist/instrumentation/hono.cjs +134 -6
  56. package/dist/instrumentation/hono.cjs.map +1 -0
  57. package/dist/instrumentation/hono.d.cts +67 -2
  58. package/dist/instrumentation/hono.d.cts.map +1 -0
  59. package/dist/instrumentation/hono.d.mts +67 -2
  60. package/dist/instrumentation/hono.d.mts.map +1 -0
  61. package/dist/instrumentation/hono.mjs +130 -3
  62. package/dist/instrumentation/hono.mjs.map +1 -0
  63. package/dist/instrumentation/http.cjs +164 -11
  64. package/dist/instrumentation/http.cjs.map +1 -0
  65. package/dist/instrumentation/http.d.cts +103 -2
  66. package/dist/instrumentation/http.d.cts.map +1 -0
  67. package/dist/instrumentation/http.d.mts +103 -2
  68. package/dist/instrumentation/http.d.mts.map +1 -0
  69. package/dist/instrumentation/http.mjs +154 -2
  70. package/dist/instrumentation/http.mjs.map +1 -0
  71. package/dist/instrumentation/index.cjs +47 -47
  72. package/dist/instrumentation/index.d.cts +9 -9
  73. package/dist/instrumentation/index.d.mts +9 -9
  74. package/dist/instrumentation/index.mjs +8 -9
  75. package/dist/instrumentation/middleware.cjs +162 -6
  76. package/dist/instrumentation/middleware.cjs.map +1 -0
  77. package/dist/instrumentation/middleware.d.cts +70 -2
  78. package/dist/instrumentation/middleware.d.cts.map +1 -0
  79. package/dist/instrumentation/middleware.d.mts +70 -2
  80. package/dist/instrumentation/middleware.d.mts.map +1 -0
  81. package/dist/instrumentation/middleware.mjs +158 -3
  82. package/dist/instrumentation/middleware.mjs.map +1 -0
  83. package/dist/instrumentation/otel.cjs +137 -3
  84. package/dist/instrumentation/otel.cjs.map +1 -0
  85. package/dist/instrumentation/otel.d.cts +97 -2
  86. package/dist/instrumentation/otel.d.cts.map +1 -0
  87. package/dist/instrumentation/otel.d.mts +97 -2
  88. package/dist/instrumentation/otel.d.mts.map +1 -0
  89. package/dist/instrumentation/otel.mjs +136 -3
  90. package/dist/instrumentation/otel.mjs.map +1 -0
  91. package/dist/instrumentation/setup.cjs +100 -4
  92. package/dist/instrumentation/setup.cjs.map +1 -0
  93. package/dist/instrumentation/setup.d.cts +83 -3
  94. package/dist/instrumentation/setup.d.cts.map +1 -0
  95. package/dist/instrumentation/setup.d.mts +83 -3
  96. package/dist/instrumentation/setup.d.mts.map +1 -0
  97. package/dist/instrumentation/setup.mjs +98 -3
  98. package/dist/instrumentation/setup.mjs.map +1 -0
  99. package/dist/instrumentation/tracing.cjs +114 -10
  100. package/dist/instrumentation/tracing.cjs.map +1 -0
  101. package/dist/instrumentation/tracing.d.cts +49 -2
  102. package/dist/instrumentation/tracing.d.cts.map +1 -0
  103. package/dist/instrumentation/tracing.d.mts +49 -2
  104. package/dist/instrumentation/tracing.d.mts.map +1 -0
  105. package/dist/instrumentation/tracing.mjs +105 -2
  106. package/dist/instrumentation/tracing.mjs.map +1 -0
  107. package/dist/logger/console.cjs +18 -12
  108. package/dist/logger/console.cjs.map +1 -1
  109. package/dist/logger/console.d.cts +7 -10
  110. package/dist/logger/console.d.cts.map +1 -1
  111. package/dist/logger/console.d.mts +7 -10
  112. package/dist/logger/console.d.mts.map +1 -1
  113. package/dist/logger/console.mjs +17 -11
  114. package/dist/logger/console.mjs.map +1 -1
  115. package/dist/logger/pino.cjs +6 -5
  116. package/dist/logger/pino.cjs.map +1 -1
  117. package/dist/logger/pino.d.cts +6 -10
  118. package/dist/logger/pino.d.cts.map +1 -1
  119. package/dist/logger/pino.d.mts +6 -10
  120. package/dist/logger/pino.d.mts.map +1 -1
  121. package/dist/logger/pino.mjs +2 -3
  122. package/dist/logger/pino.mjs.map +1 -1
  123. package/dist/metrics/MetricsAggregator.cjs +354 -2
  124. package/dist/metrics/MetricsAggregator.cjs.map +1 -0
  125. package/dist/metrics/MetricsAggregator.d.cts +1 -2
  126. package/dist/metrics/MetricsAggregator.d.mts +1 -2
  127. package/dist/metrics/MetricsAggregator.mjs +353 -2
  128. package/dist/metrics/MetricsAggregator.mjs.map +1 -0
  129. package/dist/metrics/index.cjs +3 -4
  130. package/dist/metrics/index.d.cts +2 -4
  131. package/dist/metrics/index.d.mts +2 -4
  132. package/dist/metrics/index.mjs +2 -4
  133. package/dist/metrics/storage/InMemoryMetricsStorage.cjs +240 -3
  134. package/dist/metrics/storage/InMemoryMetricsStorage.cjs.map +1 -0
  135. package/dist/metrics/storage/InMemoryMetricsStorage.d.cts +43 -4
  136. package/dist/metrics/storage/InMemoryMetricsStorage.d.cts.map +1 -0
  137. package/dist/metrics/storage/InMemoryMetricsStorage.d.mts +43 -4
  138. package/dist/metrics/storage/InMemoryMetricsStorage.d.mts.map +1 -0
  139. package/dist/metrics/storage/InMemoryMetricsStorage.mjs +239 -3
  140. package/dist/metrics/storage/InMemoryMetricsStorage.mjs.map +1 -0
  141. package/dist/metrics/storage/MetricsStorage.cjs +0 -1
  142. package/dist/metrics/storage/MetricsStorage.d.cts +56 -3
  143. package/dist/metrics/storage/MetricsStorage.d.cts.map +1 -0
  144. package/dist/metrics/storage/MetricsStorage.d.mts +56 -3
  145. package/dist/metrics/storage/MetricsStorage.d.mts.map +1 -0
  146. package/dist/metrics/storage/MetricsStorage.mjs +1 -1
  147. package/dist/metrics/storage/index.cjs +6 -6
  148. package/dist/metrics/storage/index.d.cts +3 -3
  149. package/dist/metrics/storage/index.d.mts +3 -3
  150. package/dist/metrics/storage/index.mjs +4 -5
  151. package/dist/metrics/storage/types.cjs +34 -2
  152. package/dist/metrics/storage/types.cjs.map +1 -0
  153. package/dist/metrics/storage/types.d.cts +207 -2
  154. package/dist/metrics/storage/types.d.cts.map +1 -0
  155. package/dist/metrics/storage/types.d.mts +207 -2
  156. package/dist/metrics/storage/types.d.mts.map +1 -0
  157. package/dist/metrics/storage/types.mjs +33 -2
  158. package/dist/metrics/storage/types.mjs.map +1 -0
  159. package/dist/otlp/hono.cjs +9 -15
  160. package/dist/otlp/hono.cjs.map +1 -1
  161. package/dist/otlp/hono.d.cts +3 -13
  162. package/dist/otlp/hono.d.cts.map +1 -1
  163. package/dist/otlp/hono.d.mts +3 -13
  164. package/dist/otlp/hono.d.mts.map +1 -1
  165. package/dist/otlp/hono.mjs +5 -11
  166. package/dist/otlp/hono.mjs.map +1 -1
  167. package/dist/otlp/index.cjs +11 -11
  168. package/dist/otlp/index.d.cts +4 -7
  169. package/dist/otlp/index.d.mts +4 -7
  170. package/dist/otlp/index.mjs +4 -5
  171. package/dist/otlp/receiver.cjs +88 -4
  172. package/dist/otlp/receiver.cjs.map +1 -0
  173. package/dist/otlp/receiver.d.cts +59 -7
  174. package/dist/otlp/receiver.d.cts.map +1 -0
  175. package/dist/otlp/receiver.d.mts +59 -7
  176. package/dist/otlp/receiver.d.mts.map +1 -0
  177. package/dist/otlp/receiver.mjs +87 -4
  178. package/dist/otlp/receiver.mjs.map +1 -0
  179. package/dist/otlp/transformer.cjs +214 -5
  180. package/dist/otlp/transformer.cjs.map +1 -0
  181. package/dist/otlp/transformer.d.cts +1 -3
  182. package/dist/otlp/transformer.d.mts +1 -3
  183. package/dist/otlp/transformer.mjs +211 -3
  184. package/dist/otlp/transformer.mjs.map +1 -0
  185. package/dist/otlp/types.cjs +57 -5
  186. package/dist/otlp/types.cjs.map +1 -0
  187. package/dist/otlp/types.d.cts +1 -1
  188. package/dist/otlp/types.d.mts +1 -1
  189. package/dist/otlp/types.mjs +53 -2
  190. package/dist/otlp/types.mjs.map +1 -0
  191. package/dist/redact.cjs +84 -3
  192. package/dist/redact.cjs.map +1 -0
  193. package/dist/redact.d.cts +4 -8
  194. package/dist/redact.d.cts.map +1 -1
  195. package/dist/redact.d.mts +4 -8
  196. package/dist/redact.d.mts.map +1 -1
  197. package/dist/redact.mjs +80 -2
  198. package/dist/redact.mjs.map +1 -0
  199. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
  200. package/dist/server/hono.cjs +24 -33
  201. package/dist/server/hono.cjs.map +1 -1
  202. package/dist/server/hono.d.cts +10 -13
  203. package/dist/server/hono.d.cts.map +1 -1
  204. package/dist/server/hono.d.mts +10 -13
  205. package/dist/server/hono.d.mts.map +1 -1
  206. package/dist/server/hono.mjs +22 -31
  207. package/dist/server/hono.mjs.map +1 -1
  208. package/dist/storage/kysely.cjs +34 -32
  209. package/dist/storage/kysely.cjs.map +1 -1
  210. package/dist/storage/kysely.d.cts +8 -12
  211. package/dist/storage/kysely.d.cts.map +1 -1
  212. package/dist/storage/kysely.d.mts +8 -12
  213. package/dist/storage/kysely.d.mts.map +1 -1
  214. package/dist/storage/kysely.mjs +33 -31
  215. package/dist/storage/kysely.mjs.map +1 -1
  216. package/dist/storage/memory.cjs +122 -2
  217. package/dist/storage/memory.cjs.map +1 -0
  218. package/dist/storage/memory.d.cts +36 -3
  219. package/dist/storage/memory.d.cts.map +1 -0
  220. package/dist/storage/memory.d.mts +36 -3
  221. package/dist/storage/memory.d.mts.map +1 -0
  222. package/dist/storage/memory.mjs +121 -2
  223. package/dist/storage/memory.mjs.map +1 -0
  224. package/dist/{transformer-CTGsaVfV.d.mts → transformer-BBBXCjHP.d.mts} +4 -8
  225. package/dist/transformer-BBBXCjHP.d.mts.map +1 -0
  226. package/dist/{transformer-ICEbxpFf.d.cts → transformer-DlESim6Q.d.cts} +4 -8
  227. package/dist/transformer-DlESim6Q.d.cts.map +1 -0
  228. package/dist/{types-CmOB7CLO.d.cts → types-DVETVdpa.d.cts} +6 -7
  229. package/dist/types-DVETVdpa.d.cts.map +1 -0
  230. package/dist/{types-DBc0q5KD.d.mts → types-DVETVdpa.d.mts} +6 -7
  231. package/dist/types-DVETVdpa.d.mts.map +1 -0
  232. package/dist/{types-B1EIa_cQ.d.mts → types-a9Vistj1.d.cts} +2 -3
  233. package/dist/types-a9Vistj1.d.cts.map +1 -0
  234. package/dist/{types-l7Rlb5Mg.d.cts → types-a9Vistj1.d.mts} +2 -3
  235. package/dist/types-a9Vistj1.d.mts.map +1 -0
  236. package/dist/types.d.cts +1 -1
  237. package/dist/types.d.mts +1 -1
  238. package/dist/types.mjs +1 -0
  239. package/dist/ui-assets.cjs +31 -4
  240. package/dist/ui-assets.cjs.map +1 -0
  241. package/dist/ui-assets.d.cts +4 -6
  242. package/dist/ui-assets.d.cts.map +1 -1
  243. package/dist/ui-assets.d.mts +4 -6
  244. package/dist/ui-assets.d.mts.map +1 -1
  245. package/dist/ui-assets.mjs +28 -2
  246. package/dist/ui-assets.mjs.map +1 -0
  247. package/package.json +39 -37
  248. package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts +0 -47
  249. package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts.map +0 -1
  250. package/dist/InMemoryMetricsStorage-C4drxT7G.mjs +0 -247
  251. package/dist/InMemoryMetricsStorage-C4drxT7G.mjs.map +0 -1
  252. package/dist/InMemoryMetricsStorage-D0njWUSi.cjs +0 -252
  253. package/dist/InMemoryMetricsStorage-D0njWUSi.cjs.map +0 -1
  254. package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts +0 -47
  255. package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts.map +0 -1
  256. package/dist/MetricsAggregator-4SqelGcG.d.cts.map +0 -1
  257. package/dist/MetricsAggregator-B7lUICdH.cjs +0 -363
  258. package/dist/MetricsAggregator-B7lUICdH.cjs.map +0 -1
  259. package/dist/MetricsAggregator-DZrW8ls6.d.mts.map +0 -1
  260. package/dist/MetricsAggregator-S3DQWNas.mjs +0 -357
  261. package/dist/MetricsAggregator-S3DQWNas.mjs.map +0 -1
  262. package/dist/MetricsStorage-B86e4131.d.cts +0 -60
  263. package/dist/MetricsStorage-B86e4131.d.cts.map +0 -1
  264. package/dist/MetricsStorage-BWyP2_12.d.mts +0 -60
  265. package/dist/MetricsStorage-BWyP2_12.d.mts.map +0 -1
  266. package/dist/MetricsStorage-BypQXWiv.mjs +0 -0
  267. package/dist/MetricsStorage-Or8pVCe4.cjs +0 -0
  268. package/dist/Telescope-Cs3fv8jt.cjs +0 -395
  269. package/dist/Telescope-Cs3fv8jt.cjs.map +0 -1
  270. package/dist/Telescope-D4nmwDRA.d.cts.map +0 -1
  271. package/dist/Telescope-Dh5av3FC.mjs +0 -389
  272. package/dist/Telescope-Dh5av3FC.mjs.map +0 -1
  273. package/dist/Telescope-Dl6VSfxd.d.mts.map +0 -1
  274. package/dist/core--quSp5Qr.d.mts +0 -78
  275. package/dist/core--quSp5Qr.d.mts.map +0 -1
  276. package/dist/core-B4Jpia5H.d.cts +0 -78
  277. package/dist/core-B4Jpia5H.d.cts.map +0 -1
  278. package/dist/core-CtVHRJGv.cjs +0 -199
  279. package/dist/core-CtVHRJGv.cjs.map +0 -1
  280. package/dist/core-D6hJ6exL.mjs +0 -139
  281. package/dist/core-D6hJ6exL.mjs.map +0 -1
  282. package/dist/hono--uKQ7Jgi.d.mts +0 -71
  283. package/dist/hono--uKQ7Jgi.d.mts.map +0 -1
  284. package/dist/hono-Bw-ey6CT.mjs +0 -136
  285. package/dist/hono-Bw-ey6CT.mjs.map +0 -1
  286. package/dist/hono-CPHX7FAm.cjs +0 -160
  287. package/dist/hono-CPHX7FAm.cjs.map +0 -1
  288. package/dist/hono-CemCKU87.d.cts +0 -71
  289. package/dist/hono-CemCKU87.d.cts.map +0 -1
  290. package/dist/http-BIvr0YdI.mjs +0 -159
  291. package/dist/http-BIvr0YdI.mjs.map +0 -1
  292. package/dist/http-BiNtg85L.d.mts +0 -107
  293. package/dist/http-BiNtg85L.d.mts.map +0 -1
  294. package/dist/http-BsqmhurZ.cjs +0 -219
  295. package/dist/http-BsqmhurZ.cjs.map +0 -1
  296. package/dist/http-D1oTbfap.d.cts +0 -107
  297. package/dist/http-D1oTbfap.d.cts.map +0 -1
  298. package/dist/index-BL32-cvv.d.cts +0 -1
  299. package/dist/index-CsuikFeJ.d.mts +0 -1
  300. package/dist/memory--BK4iWiv.d.cts +0 -40
  301. package/dist/memory--BK4iWiv.d.cts.map +0 -1
  302. package/dist/memory-6S9H-IF5.mjs +0 -123
  303. package/dist/memory-6S9H-IF5.mjs.map +0 -1
  304. package/dist/memory-B0d_n1g5.cjs +0 -129
  305. package/dist/memory-B0d_n1g5.cjs.map +0 -1
  306. package/dist/memory-DCirEVFW.d.mts +0 -40
  307. package/dist/memory-DCirEVFW.d.mts.map +0 -1
  308. package/dist/metrics-D5YT-Rnq.mjs +0 -0
  309. package/dist/metrics-fhD3l3C3.cjs +0 -0
  310. package/dist/middleware-Bcq6XXGG.cjs +0 -184
  311. package/dist/middleware-Bcq6XXGG.cjs.map +0 -1
  312. package/dist/middleware-D1XEHvyy.mjs +0 -160
  313. package/dist/middleware-D1XEHvyy.mjs.map +0 -1
  314. package/dist/middleware-PeyS-9Ny.d.cts +0 -74
  315. package/dist/middleware-PeyS-9Ny.d.cts.map +0 -1
  316. package/dist/middleware-oHvo_ZgU.d.mts +0 -74
  317. package/dist/middleware-oHvo_ZgU.d.mts.map +0 -1
  318. package/dist/middy-B6Btl8XE.d.mts +0 -64
  319. package/dist/middy-B6Btl8XE.d.mts.map +0 -1
  320. package/dist/middy-Bq0defVg.d.cts +0 -64
  321. package/dist/middy-Bq0defVg.d.cts.map +0 -1
  322. package/dist/middy-DHWLmUAD.mjs +0 -236
  323. package/dist/middy-DHWLmUAD.mjs.map +0 -1
  324. package/dist/middy-DlWnZilH.cjs +0 -247
  325. package/dist/middy-DlWnZilH.cjs.map +0 -1
  326. package/dist/otel-B9bNoeZ2.mjs +0 -130
  327. package/dist/otel-B9bNoeZ2.mjs.map +0 -1
  328. package/dist/otel-Bk89b1lX.d.cts +0 -101
  329. package/dist/otel-Bk89b1lX.d.cts.map +0 -1
  330. package/dist/otel-BzjOtVxZ.cjs +0 -136
  331. package/dist/otel-BzjOtVxZ.cjs.map +0 -1
  332. package/dist/otel-lPMsM26e.d.mts +0 -101
  333. package/dist/otel-lPMsM26e.d.mts.map +0 -1
  334. package/dist/receiver-D46dfkYI.mjs +0 -89
  335. package/dist/receiver-D46dfkYI.mjs.map +0 -1
  336. package/dist/receiver-DLICx5uU.d.cts +0 -63
  337. package/dist/receiver-DLICx5uU.d.cts.map +0 -1
  338. package/dist/receiver-UeZT-H8u.d.mts +0 -63
  339. package/dist/receiver-UeZT-H8u.d.mts.map +0 -1
  340. package/dist/receiver-slCoAFat.cjs +0 -94
  341. package/dist/receiver-slCoAFat.cjs.map +0 -1
  342. package/dist/redact-BzkITCNW.mjs +0 -83
  343. package/dist/redact-BzkITCNW.mjs.map +0 -1
  344. package/dist/redact-DVaSSPZT.cjs +0 -95
  345. package/dist/redact-DVaSSPZT.cjs.map +0 -1
  346. package/dist/setup-Bkxm4g6b.d.mts +0 -87
  347. package/dist/setup-Bkxm4g6b.d.mts.map +0 -1
  348. package/dist/setup-D58N1f9O.d.cts +0 -87
  349. package/dist/setup-D58N1f9O.d.cts.map +0 -1
  350. package/dist/setup-DC9JMEYZ.mjs +0 -98
  351. package/dist/setup-DC9JMEYZ.mjs.map +0 -1
  352. package/dist/setup-DufxQpi9.cjs +0 -110
  353. package/dist/setup-DufxQpi9.cjs.map +0 -1
  354. package/dist/tracing-BX8uY2nR.d.cts +0 -53
  355. package/dist/tracing-BX8uY2nR.d.cts.map +0 -1
  356. package/dist/tracing-Bt1zWRlb.cjs +0 -167
  357. package/dist/tracing-Bt1zWRlb.cjs.map +0 -1
  358. package/dist/tracing-Cijm_5NI.mjs +0 -113
  359. package/dist/tracing-Cijm_5NI.mjs.map +0 -1
  360. package/dist/tracing-PnECEbEu.d.mts +0 -53
  361. package/dist/tracing-PnECEbEu.d.mts.map +0 -1
  362. package/dist/transformer-CFQ4WFk6.mjs +0 -215
  363. package/dist/transformer-CFQ4WFk6.mjs.map +0 -1
  364. package/dist/transformer-CTGsaVfV.d.mts.map +0 -1
  365. package/dist/transformer-Csl6fbgv.cjs +0 -232
  366. package/dist/transformer-Csl6fbgv.cjs.map +0 -1
  367. package/dist/transformer-ICEbxpFf.d.cts.map +0 -1
  368. package/dist/types-B1EIa_cQ.d.mts.map +0 -1
  369. package/dist/types-BMiHgsi4.cjs +0 -78
  370. package/dist/types-BMiHgsi4.cjs.map +0 -1
  371. package/dist/types-BRzW1NM8.d.cts +0 -166
  372. package/dist/types-BRzW1NM8.d.cts.map +0 -1
  373. package/dist/types-BS3Rx8Sk.d.cts +0 -209
  374. package/dist/types-BS3Rx8Sk.d.cts.map +0 -1
  375. package/dist/types-BzQ78Efw.d.mts +0 -166
  376. package/dist/types-BzQ78Efw.d.mts.map +0 -1
  377. package/dist/types-CbNGXnJE.d.mts +0 -209
  378. package/dist/types-CbNGXnJE.d.mts.map +0 -1
  379. package/dist/types-Cj59nqy7.mjs +0 -54
  380. package/dist/types-Cj59nqy7.mjs.map +0 -1
  381. package/dist/types-CmOB7CLO.d.cts.map +0 -1
  382. package/dist/types-DBc0q5KD.d.mts.map +0 -1
  383. package/dist/types-ZW-nfWf6.cjs +0 -40
  384. package/dist/types-ZW-nfWf6.cjs.map +0 -1
  385. package/dist/types-l7Rlb5Mg.d.cts.map +0 -1
  386. package/dist/types-ojhnLdwz.mjs +0 -34
  387. package/dist/types-ojhnLdwz.mjs.map +0 -1
  388. package/dist/ui-assets-BEXqOQLe.cjs +0 -48
  389. package/dist/ui-assets-BEXqOQLe.cjs.map +0 -1
  390. package/dist/ui-assets-BhTDUsrM.mjs +0 -30
  391. package/dist/ui-assets-BhTDUsrM.mjs.map +0 -1
@@ -1,199 +0,0 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
3
- const __opentelemetry_sdk_trace_base = require_chunk.__toESM(require("@opentelemetry/sdk-trace-base"));
4
-
5
- //#region src/instrumentation/core.ts
6
- const state = {
7
- spanProcessor: null,
8
- logProcessor: null,
9
- initialized: false
10
- };
11
- /**
12
- * Create a span processor based on the strategy
13
- */
14
- function createSpanProcessor(exporter, options) {
15
- const { strategy,...config } = options;
16
- if (strategy === "simple") return new __opentelemetry_sdk_trace_base.SimpleSpanProcessor(exporter);
17
- return new __opentelemetry_sdk_trace_base.BatchSpanProcessor(exporter, {
18
- maxQueueSize: config.maxQueueSize ?? 2048,
19
- scheduledDelayMillis: config.scheduledDelayMillis ?? 5e3,
20
- exportTimeoutMillis: config.exportTimeoutMillis ?? 3e4,
21
- maxExportBatchSize: config.maxExportBatchSize ?? 512
22
- });
23
- }
24
- /**
25
- * Get the recommended span processor strategy for an environment
26
- */
27
- function getRecommendedStrategy(environment) {
28
- switch (environment) {
29
- case "lambda":
30
- case "edge": return "simple";
31
- default: return "batch";
32
- }
33
- }
34
- /**
35
- * Set the global span processor for flush operations
36
- */
37
- function setGlobalSpanProcessor(processor) {
38
- state.spanProcessor = processor;
39
- state.initialized = true;
40
- }
41
- /**
42
- * Set the global log processor for flush operations
43
- */
44
- function setGlobalLogProcessor(processor) {
45
- state.logProcessor = processor;
46
- }
47
- /**
48
- * Check if telemetry is initialized
49
- */
50
- function isTelemetryInitialized() {
51
- return state.initialized;
52
- }
53
- /**
54
- * Flush all pending telemetry data.
55
- * This is critical for serverless environments where the process may freeze.
56
- *
57
- * @example
58
- * ```typescript
59
- * // In a Lambda handler
60
- * export const handler = async (event, context) => {
61
- * try {
62
- * const result = await processRequest(event);
63
- * return result;
64
- * } finally {
65
- * // Flush before Lambda freezes
66
- * await flushTelemetry();
67
- * }
68
- * };
69
- * ```
70
- */
71
- async function flushTelemetry(timeoutMs = 3e4) {
72
- const promises = [];
73
- if (state.spanProcessor) promises.push(Promise.race([state.spanProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(new Error("Span flush timeout")), timeoutMs))]).catch((error) => {
74
- if (__opentelemetry_api.diag.debug) __opentelemetry_api.diag.debug(`Span flush error: ${error.message}`);
75
- }));
76
- if (state.logProcessor && typeof state.logProcessor.forceFlush === "function") promises.push(Promise.race([state.logProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(new Error("Log flush timeout")), timeoutMs))]).catch((error) => {
77
- if (__opentelemetry_api.diag.debug) __opentelemetry_api.diag.debug(`Log flush error: ${error.message}`);
78
- }));
79
- await Promise.all(promises);
80
- }
81
- /**
82
- * Shutdown all telemetry processors
83
- */
84
- async function shutdownTelemetry() {
85
- const promises = [];
86
- if (state.spanProcessor) {
87
- promises.push(state.spanProcessor.shutdown());
88
- state.spanProcessor = null;
89
- }
90
- if (state.logProcessor && typeof state.logProcessor.shutdown === "function") {
91
- promises.push(state.logProcessor.shutdown());
92
- state.logProcessor = null;
93
- }
94
- state.initialized = false;
95
- await Promise.all(promises);
96
- }
97
- /**
98
- * Enable debug logging for telemetry
99
- */
100
- function enableTelemetryDebug() {
101
- __opentelemetry_api.diag.setLogger(new __opentelemetry_api.DiagConsoleLogger(), __opentelemetry_api.DiagLogLevel.DEBUG);
102
- }
103
- /**
104
- * Wraps a handler function to ensure telemetry is flushed before returning.
105
- * Useful for Lambda handlers.
106
- *
107
- * @example
108
- * ```typescript
109
- * export const handler = withTelemetryFlush(async (event, context) => {
110
- * // Your Lambda logic here
111
- * return { statusCode: 200, body: 'OK' };
112
- * });
113
- * ```
114
- */
115
- function withTelemetryFlush(handler) {
116
- return async (event, context) => {
117
- try {
118
- return await handler(event, context);
119
- } finally {
120
- await flushTelemetry();
121
- }
122
- };
123
- }
124
- /**
125
- * Noop span processor for testing or when telemetry is disabled
126
- */
127
- var NoopSpanProcessor = class {
128
- forceFlush() {
129
- return Promise.resolve();
130
- }
131
- onStart(_span) {}
132
- onEnd(_span) {}
133
- shutdown() {
134
- return Promise.resolve();
135
- }
136
- };
137
-
138
- //#endregion
139
- Object.defineProperty(exports, 'NoopSpanProcessor', {
140
- enumerable: true,
141
- get: function () {
142
- return NoopSpanProcessor;
143
- }
144
- });
145
- Object.defineProperty(exports, 'createSpanProcessor', {
146
- enumerable: true,
147
- get: function () {
148
- return createSpanProcessor;
149
- }
150
- });
151
- Object.defineProperty(exports, 'enableTelemetryDebug', {
152
- enumerable: true,
153
- get: function () {
154
- return enableTelemetryDebug;
155
- }
156
- });
157
- Object.defineProperty(exports, 'flushTelemetry', {
158
- enumerable: true,
159
- get: function () {
160
- return flushTelemetry;
161
- }
162
- });
163
- Object.defineProperty(exports, 'getRecommendedStrategy', {
164
- enumerable: true,
165
- get: function () {
166
- return getRecommendedStrategy;
167
- }
168
- });
169
- Object.defineProperty(exports, 'isTelemetryInitialized', {
170
- enumerable: true,
171
- get: function () {
172
- return isTelemetryInitialized;
173
- }
174
- });
175
- Object.defineProperty(exports, 'setGlobalLogProcessor', {
176
- enumerable: true,
177
- get: function () {
178
- return setGlobalLogProcessor;
179
- }
180
- });
181
- Object.defineProperty(exports, 'setGlobalSpanProcessor', {
182
- enumerable: true,
183
- get: function () {
184
- return setGlobalSpanProcessor;
185
- }
186
- });
187
- Object.defineProperty(exports, 'shutdownTelemetry', {
188
- enumerable: true,
189
- get: function () {
190
- return shutdownTelemetry;
191
- }
192
- });
193
- Object.defineProperty(exports, 'withTelemetryFlush', {
194
- enumerable: true,
195
- get: function () {
196
- return withTelemetryFlush;
197
- }
198
- });
199
- //# sourceMappingURL=core-CtVHRJGv.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-CtVHRJGv.cjs","names":["state: TelemetryState","exporter: SpanExporter","options: SpanProcessorOptions","SimpleSpanProcessor","BatchSpanProcessor","environment: 'server' | 'lambda' | 'edge' | 'custom'","processor: SpanProcessor","processor: unknown","promises: Promise<void>[]","diag","DiagConsoleLogger","DiagLogLevel","handler: (event: TEvent, context: unknown) => Promise<TResult>","event: TEvent","context: unknown","_span: Span","_span: ReadableSpan"],"sources":["../src/instrumentation/core.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport {\n\tBatchSpanProcessor,\n\ttype ReadableSpan,\n\tSimpleSpanProcessor,\n\ttype Span,\n\ttype SpanExporter,\n\ttype SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type {\n\tSpanProcessorOptions,\n\tSpanProcessorStrategy,\n} from '../adapters/types';\n\n/**\n * Global telemetry state for flush operations\n */\ninterface TelemetryState {\n\tspanProcessor: SpanProcessor | null;\n\tlogProcessor: unknown | null;\n\tinitialized: boolean;\n}\n\nconst state: TelemetryState = {\n\tspanProcessor: null,\n\tlogProcessor: null,\n\tinitialized: false,\n};\n\n/**\n * Create a span processor based on the strategy\n */\nexport function createSpanProcessor(\n\texporter: SpanExporter,\n\toptions: SpanProcessorOptions,\n): SpanProcessor {\n\tconst { strategy, ...config } = options;\n\n\tif (strategy === 'simple') {\n\t\treturn new SimpleSpanProcessor(exporter);\n\t}\n\n\treturn new BatchSpanProcessor(exporter, {\n\t\tmaxQueueSize: config.maxQueueSize ?? 2048,\n\t\tscheduledDelayMillis: config.scheduledDelayMillis ?? 5000,\n\t\texportTimeoutMillis: config.exportTimeoutMillis ?? 30000,\n\t\tmaxExportBatchSize: config.maxExportBatchSize ?? 512,\n\t});\n}\n\n/**\n * Get the recommended span processor strategy for an environment\n */\nexport function getRecommendedStrategy(\n\tenvironment: 'server' | 'lambda' | 'edge' | 'custom',\n): SpanProcessorStrategy {\n\tswitch (environment) {\n\t\tcase 'lambda':\n\t\tcase 'edge':\n\t\t\t// Use simple processor for serverless - immediate export\n\t\t\treturn 'simple';\n\t\tdefault:\n\t\t\t// Use batch processor for long-running servers - efficient batching\n\t\t\treturn 'batch';\n\t}\n}\n\n/**\n * Set the global span processor for flush operations\n */\nexport function setGlobalSpanProcessor(processor: SpanProcessor): void {\n\tstate.spanProcessor = processor;\n\tstate.initialized = true;\n}\n\n/**\n * Set the global log processor for flush operations\n */\nexport function setGlobalLogProcessor(processor: unknown): void {\n\tstate.logProcessor = processor;\n}\n\n/**\n * Check if telemetry is initialized\n */\nexport function isTelemetryInitialized(): boolean {\n\treturn state.initialized;\n}\n\n/**\n * Flush all pending telemetry data.\n * This is critical for serverless environments where the process may freeze.\n *\n * @example\n * ```typescript\n * // In a Lambda handler\n * export const handler = async (event, context) => {\n * try {\n * const result = await processRequest(event);\n * return result;\n * } finally {\n * // Flush before Lambda freezes\n * await flushTelemetry();\n * }\n * };\n * ```\n */\nexport async function flushTelemetry(timeoutMs = 30000): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\t// Flush span processor\n\tif (state.spanProcessor) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\tstate.spanProcessor.forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Span flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Span flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Flush log processor if it has forceFlush method\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { forceFlush?: () => Promise<void> })\n\t\t\t.forceFlush === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\t(\n\t\t\t\t\tstate.logProcessor as { forceFlush: () => Promise<void> }\n\t\t\t\t).forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Log flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Log flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\tawait Promise.all(promises);\n}\n\n/**\n * Shutdown all telemetry processors\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tif (state.spanProcessor) {\n\t\tpromises.push(state.spanProcessor.shutdown());\n\t\tstate.spanProcessor = null;\n\t}\n\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { shutdown?: () => Promise<void> })\n\t\t\t.shutdown === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\t(state.logProcessor as { shutdown: () => Promise<void> }).shutdown(),\n\t\t);\n\t\tstate.logProcessor = null;\n\t}\n\n\tstate.initialized = false;\n\tawait Promise.all(promises);\n}\n\n/**\n * Enable debug logging for telemetry\n */\nexport function enableTelemetryDebug(): void {\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n}\n\n/**\n * Wraps a handler function to ensure telemetry is flushed before returning.\n * Useful for Lambda handlers.\n *\n * @example\n * ```typescript\n * export const handler = withTelemetryFlush(async (event, context) => {\n * // Your Lambda logic here\n * return { statusCode: 200, body: 'OK' };\n * });\n * ```\n */\nexport function withTelemetryFlush<TEvent, TResult>(\n\thandler: (event: TEvent, context: unknown) => Promise<TResult>,\n): (event: TEvent, context: unknown) => Promise<TResult> {\n\treturn async (event: TEvent, context: unknown): Promise<TResult> => {\n\t\ttry {\n\t\t\treturn await handler(event, context);\n\t\t} finally {\n\t\t\tawait flushTelemetry();\n\t\t}\n\t};\n}\n\n/**\n * Noop span processor for testing or when telemetry is disabled\n */\nexport class NoopSpanProcessor implements SpanProcessor {\n\tforceFlush(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n\n\tonStart(_span: Span): void {\n\t\t// noop\n\t}\n\n\tonEnd(_span: ReadableSpan): void {\n\t\t// noop\n\t}\n\n\tshutdown(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n}\n"],"mappings":";;;;;AAuBA,MAAMA,QAAwB;CAC7B,eAAe;CACf,cAAc;CACd,aAAa;AACb;;;;AAKD,SAAgB,oBACfC,UACAC,SACgB;CAChB,MAAM,EAAE,SAAU,GAAG,QAAQ,GAAG;AAEhC,KAAI,aAAa,SAChB,QAAO,IAAIC,mDAAoB;AAGhC,QAAO,IAAIC,kDAAmB,UAAU;EACvC,cAAc,OAAO,gBAAgB;EACrC,sBAAsB,OAAO,wBAAwB;EACrD,qBAAqB,OAAO,uBAAuB;EACnD,oBAAoB,OAAO,sBAAsB;CACjD;AACD;;;;AAKD,SAAgB,uBACfC,aACwB;AACxB,SAAQ,aAAR;EACC,KAAK;EACL,KAAK,OAEJ,QAAO;EACR,QAEC,QAAO;CACR;AACD;;;;AAKD,SAAgB,uBAAuBC,WAAgC;AACtE,OAAM,gBAAgB;AACtB,OAAM,cAAc;AACpB;;;;AAKD,SAAgB,sBAAsBC,WAA0B;AAC/D,OAAM,eAAe;AACrB;;;;AAKD,SAAgB,yBAAkC;AACjD,QAAO,MAAM;AACb;;;;;;;;;;;;;;;;;;;AAoBD,eAAsB,eAAe,YAAY,KAAsB;CACtE,MAAMC,WAA4B,CAAE;AAGpC,KAAI,MAAM,cACT,UAAS,KACR,QAAQ,KAAK,CACZ,MAAM,cAAc,YAAY,EAChC,IAAI,QAAc,CAAC,GAAG,WACrB,WAAW,MAAM,OAAO,IAAI,MAAM,sBAAsB,EAAE,UAAU,CAErE,EAAC,CAAC,MAAM,CAAC,UAAU;AACnB,MAAIC,yBAAK,MACR,0BAAK,OAAO,oBAAoB,MAAM,QAAQ,EAAE;CAEjD,EAAC,CACF;AAIF,KACC,MAAM,uBACE,MAAM,aACZ,eAAe,WAEjB,UAAS,KACR,QAAQ,KAAK,CACZ,AACC,MAAM,aACL,YAAY,EACd,IAAI,QAAc,CAAC,GAAG,WACrB,WAAW,MAAM,OAAO,IAAI,MAAM,qBAAqB,EAAE,UAAU,CAEpE,EAAC,CAAC,MAAM,CAAC,UAAU;AACnB,MAAIA,yBAAK,MACR,0BAAK,OAAO,mBAAmB,MAAM,QAAQ,EAAE;CAEhD,EAAC,CACF;AAGF,OAAM,QAAQ,IAAI,SAAS;AAC3B;;;;AAKD,eAAsB,oBAAmC;CACxD,MAAMD,WAA4B,CAAE;AAEpC,KAAI,MAAM,eAAe;AACxB,WAAS,KAAK,MAAM,cAAc,UAAU,CAAC;AAC7C,QAAM,gBAAgB;CACtB;AAED,KACC,MAAM,uBACE,MAAM,aACZ,aAAa,YACd;AACD,WAAS,KACR,AAAC,MAAM,aAAmD,UAAU,CACpE;AACD,QAAM,eAAe;CACrB;AAED,OAAM,cAAc;AACpB,OAAM,QAAQ,IAAI,SAAS;AAC3B;;;;AAKD,SAAgB,uBAA6B;AAC5C,0BAAK,UAAU,IAAIE,yCAAqBC,iCAAa,MAAM;AAC3D;;;;;;;;;;;;;AAcD,SAAgB,mBACfC,SACwD;AACxD,QAAO,OAAOC,OAAeC,YAAuC;AACnE,MAAI;AACH,UAAO,MAAM,QAAQ,OAAO,QAAQ;EACpC,UAAS;AACT,SAAM,gBAAgB;EACtB;CACD;AACD;;;;AAKD,IAAa,oBAAb,MAAwD;CACvD,aAA4B;AAC3B,SAAO,QAAQ,SAAS;CACxB;CAED,QAAQC,OAAmB,CAE1B;CAED,MAAMC,OAA2B,CAEhC;CAED,WAA0B;AACzB,SAAO,QAAQ,SAAS;CACxB;AACD"}
@@ -1,139 +0,0 @@
1
- import { DiagConsoleLogger, DiagLogLevel, diag } from "@opentelemetry/api";
2
- import { BatchSpanProcessor, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
3
-
4
- //#region src/instrumentation/core.ts
5
- const state = {
6
- spanProcessor: null,
7
- logProcessor: null,
8
- initialized: false
9
- };
10
- /**
11
- * Create a span processor based on the strategy
12
- */
13
- function createSpanProcessor(exporter, options) {
14
- const { strategy,...config } = options;
15
- if (strategy === "simple") return new SimpleSpanProcessor(exporter);
16
- return new BatchSpanProcessor(exporter, {
17
- maxQueueSize: config.maxQueueSize ?? 2048,
18
- scheduledDelayMillis: config.scheduledDelayMillis ?? 5e3,
19
- exportTimeoutMillis: config.exportTimeoutMillis ?? 3e4,
20
- maxExportBatchSize: config.maxExportBatchSize ?? 512
21
- });
22
- }
23
- /**
24
- * Get the recommended span processor strategy for an environment
25
- */
26
- function getRecommendedStrategy(environment) {
27
- switch (environment) {
28
- case "lambda":
29
- case "edge": return "simple";
30
- default: return "batch";
31
- }
32
- }
33
- /**
34
- * Set the global span processor for flush operations
35
- */
36
- function setGlobalSpanProcessor(processor) {
37
- state.spanProcessor = processor;
38
- state.initialized = true;
39
- }
40
- /**
41
- * Set the global log processor for flush operations
42
- */
43
- function setGlobalLogProcessor(processor) {
44
- state.logProcessor = processor;
45
- }
46
- /**
47
- * Check if telemetry is initialized
48
- */
49
- function isTelemetryInitialized() {
50
- return state.initialized;
51
- }
52
- /**
53
- * Flush all pending telemetry data.
54
- * This is critical for serverless environments where the process may freeze.
55
- *
56
- * @example
57
- * ```typescript
58
- * // In a Lambda handler
59
- * export const handler = async (event, context) => {
60
- * try {
61
- * const result = await processRequest(event);
62
- * return result;
63
- * } finally {
64
- * // Flush before Lambda freezes
65
- * await flushTelemetry();
66
- * }
67
- * };
68
- * ```
69
- */
70
- async function flushTelemetry(timeoutMs = 3e4) {
71
- const promises = [];
72
- if (state.spanProcessor) promises.push(Promise.race([state.spanProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(new Error("Span flush timeout")), timeoutMs))]).catch((error) => {
73
- if (diag.debug) diag.debug(`Span flush error: ${error.message}`);
74
- }));
75
- if (state.logProcessor && typeof state.logProcessor.forceFlush === "function") promises.push(Promise.race([state.logProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(new Error("Log flush timeout")), timeoutMs))]).catch((error) => {
76
- if (diag.debug) diag.debug(`Log flush error: ${error.message}`);
77
- }));
78
- await Promise.all(promises);
79
- }
80
- /**
81
- * Shutdown all telemetry processors
82
- */
83
- async function shutdownTelemetry() {
84
- const promises = [];
85
- if (state.spanProcessor) {
86
- promises.push(state.spanProcessor.shutdown());
87
- state.spanProcessor = null;
88
- }
89
- if (state.logProcessor && typeof state.logProcessor.shutdown === "function") {
90
- promises.push(state.logProcessor.shutdown());
91
- state.logProcessor = null;
92
- }
93
- state.initialized = false;
94
- await Promise.all(promises);
95
- }
96
- /**
97
- * Enable debug logging for telemetry
98
- */
99
- function enableTelemetryDebug() {
100
- diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
101
- }
102
- /**
103
- * Wraps a handler function to ensure telemetry is flushed before returning.
104
- * Useful for Lambda handlers.
105
- *
106
- * @example
107
- * ```typescript
108
- * export const handler = withTelemetryFlush(async (event, context) => {
109
- * // Your Lambda logic here
110
- * return { statusCode: 200, body: 'OK' };
111
- * });
112
- * ```
113
- */
114
- function withTelemetryFlush(handler) {
115
- return async (event, context$1) => {
116
- try {
117
- return await handler(event, context$1);
118
- } finally {
119
- await flushTelemetry();
120
- }
121
- };
122
- }
123
- /**
124
- * Noop span processor for testing or when telemetry is disabled
125
- */
126
- var NoopSpanProcessor = class {
127
- forceFlush() {
128
- return Promise.resolve();
129
- }
130
- onStart(_span) {}
131
- onEnd(_span) {}
132
- shutdown() {
133
- return Promise.resolve();
134
- }
135
- };
136
-
137
- //#endregion
138
- export { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush };
139
- //# sourceMappingURL=core-D6hJ6exL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-D6hJ6exL.mjs","names":["state: TelemetryState","exporter: SpanExporter","options: SpanProcessorOptions","environment: 'server' | 'lambda' | 'edge' | 'custom'","processor: SpanProcessor","processor: unknown","promises: Promise<void>[]","handler: (event: TEvent, context: unknown) => Promise<TResult>","event: TEvent","context: unknown","context","_span: Span","_span: ReadableSpan"],"sources":["../src/instrumentation/core.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport {\n\tBatchSpanProcessor,\n\ttype ReadableSpan,\n\tSimpleSpanProcessor,\n\ttype Span,\n\ttype SpanExporter,\n\ttype SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type {\n\tSpanProcessorOptions,\n\tSpanProcessorStrategy,\n} from '../adapters/types';\n\n/**\n * Global telemetry state for flush operations\n */\ninterface TelemetryState {\n\tspanProcessor: SpanProcessor | null;\n\tlogProcessor: unknown | null;\n\tinitialized: boolean;\n}\n\nconst state: TelemetryState = {\n\tspanProcessor: null,\n\tlogProcessor: null,\n\tinitialized: false,\n};\n\n/**\n * Create a span processor based on the strategy\n */\nexport function createSpanProcessor(\n\texporter: SpanExporter,\n\toptions: SpanProcessorOptions,\n): SpanProcessor {\n\tconst { strategy, ...config } = options;\n\n\tif (strategy === 'simple') {\n\t\treturn new SimpleSpanProcessor(exporter);\n\t}\n\n\treturn new BatchSpanProcessor(exporter, {\n\t\tmaxQueueSize: config.maxQueueSize ?? 2048,\n\t\tscheduledDelayMillis: config.scheduledDelayMillis ?? 5000,\n\t\texportTimeoutMillis: config.exportTimeoutMillis ?? 30000,\n\t\tmaxExportBatchSize: config.maxExportBatchSize ?? 512,\n\t});\n}\n\n/**\n * Get the recommended span processor strategy for an environment\n */\nexport function getRecommendedStrategy(\n\tenvironment: 'server' | 'lambda' | 'edge' | 'custom',\n): SpanProcessorStrategy {\n\tswitch (environment) {\n\t\tcase 'lambda':\n\t\tcase 'edge':\n\t\t\t// Use simple processor for serverless - immediate export\n\t\t\treturn 'simple';\n\t\tdefault:\n\t\t\t// Use batch processor for long-running servers - efficient batching\n\t\t\treturn 'batch';\n\t}\n}\n\n/**\n * Set the global span processor for flush operations\n */\nexport function setGlobalSpanProcessor(processor: SpanProcessor): void {\n\tstate.spanProcessor = processor;\n\tstate.initialized = true;\n}\n\n/**\n * Set the global log processor for flush operations\n */\nexport function setGlobalLogProcessor(processor: unknown): void {\n\tstate.logProcessor = processor;\n}\n\n/**\n * Check if telemetry is initialized\n */\nexport function isTelemetryInitialized(): boolean {\n\treturn state.initialized;\n}\n\n/**\n * Flush all pending telemetry data.\n * This is critical for serverless environments where the process may freeze.\n *\n * @example\n * ```typescript\n * // In a Lambda handler\n * export const handler = async (event, context) => {\n * try {\n * const result = await processRequest(event);\n * return result;\n * } finally {\n * // Flush before Lambda freezes\n * await flushTelemetry();\n * }\n * };\n * ```\n */\nexport async function flushTelemetry(timeoutMs = 30000): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\t// Flush span processor\n\tif (state.spanProcessor) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\tstate.spanProcessor.forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Span flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Span flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Flush log processor if it has forceFlush method\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { forceFlush?: () => Promise<void> })\n\t\t\t.forceFlush === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\t(\n\t\t\t\t\tstate.logProcessor as { forceFlush: () => Promise<void> }\n\t\t\t\t).forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Log flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Log flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\tawait Promise.all(promises);\n}\n\n/**\n * Shutdown all telemetry processors\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tif (state.spanProcessor) {\n\t\tpromises.push(state.spanProcessor.shutdown());\n\t\tstate.spanProcessor = null;\n\t}\n\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { shutdown?: () => Promise<void> })\n\t\t\t.shutdown === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\t(state.logProcessor as { shutdown: () => Promise<void> }).shutdown(),\n\t\t);\n\t\tstate.logProcessor = null;\n\t}\n\n\tstate.initialized = false;\n\tawait Promise.all(promises);\n}\n\n/**\n * Enable debug logging for telemetry\n */\nexport function enableTelemetryDebug(): void {\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n}\n\n/**\n * Wraps a handler function to ensure telemetry is flushed before returning.\n * Useful for Lambda handlers.\n *\n * @example\n * ```typescript\n * export const handler = withTelemetryFlush(async (event, context) => {\n * // Your Lambda logic here\n * return { statusCode: 200, body: 'OK' };\n * });\n * ```\n */\nexport function withTelemetryFlush<TEvent, TResult>(\n\thandler: (event: TEvent, context: unknown) => Promise<TResult>,\n): (event: TEvent, context: unknown) => Promise<TResult> {\n\treturn async (event: TEvent, context: unknown): Promise<TResult> => {\n\t\ttry {\n\t\t\treturn await handler(event, context);\n\t\t} finally {\n\t\t\tawait flushTelemetry();\n\t\t}\n\t};\n}\n\n/**\n * Noop span processor for testing or when telemetry is disabled\n */\nexport class NoopSpanProcessor implements SpanProcessor {\n\tforceFlush(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n\n\tonStart(_span: Span): void {\n\t\t// noop\n\t}\n\n\tonEnd(_span: ReadableSpan): void {\n\t\t// noop\n\t}\n\n\tshutdown(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n}\n"],"mappings":";;;;AAuBA,MAAMA,QAAwB;CAC7B,eAAe;CACf,cAAc;CACd,aAAa;AACb;;;;AAKD,SAAgB,oBACfC,UACAC,SACgB;CAChB,MAAM,EAAE,SAAU,GAAG,QAAQ,GAAG;AAEhC,KAAI,aAAa,SAChB,QAAO,IAAI,oBAAoB;AAGhC,QAAO,IAAI,mBAAmB,UAAU;EACvC,cAAc,OAAO,gBAAgB;EACrC,sBAAsB,OAAO,wBAAwB;EACrD,qBAAqB,OAAO,uBAAuB;EACnD,oBAAoB,OAAO,sBAAsB;CACjD;AACD;;;;AAKD,SAAgB,uBACfC,aACwB;AACxB,SAAQ,aAAR;EACC,KAAK;EACL,KAAK,OAEJ,QAAO;EACR,QAEC,QAAO;CACR;AACD;;;;AAKD,SAAgB,uBAAuBC,WAAgC;AACtE,OAAM,gBAAgB;AACtB,OAAM,cAAc;AACpB;;;;AAKD,SAAgB,sBAAsBC,WAA0B;AAC/D,OAAM,eAAe;AACrB;;;;AAKD,SAAgB,yBAAkC;AACjD,QAAO,MAAM;AACb;;;;;;;;;;;;;;;;;;;AAoBD,eAAsB,eAAe,YAAY,KAAsB;CACtE,MAAMC,WAA4B,CAAE;AAGpC,KAAI,MAAM,cACT,UAAS,KACR,QAAQ,KAAK,CACZ,MAAM,cAAc,YAAY,EAChC,IAAI,QAAc,CAAC,GAAG,WACrB,WAAW,MAAM,OAAO,IAAI,MAAM,sBAAsB,EAAE,UAAU,CAErE,EAAC,CAAC,MAAM,CAAC,UAAU;AACnB,MAAI,KAAK,MACR,MAAK,OAAO,oBAAoB,MAAM,QAAQ,EAAE;CAEjD,EAAC,CACF;AAIF,KACC,MAAM,uBACE,MAAM,aACZ,eAAe,WAEjB,UAAS,KACR,QAAQ,KAAK,CACZ,AACC,MAAM,aACL,YAAY,EACd,IAAI,QAAc,CAAC,GAAG,WACrB,WAAW,MAAM,OAAO,IAAI,MAAM,qBAAqB,EAAE,UAAU,CAEpE,EAAC,CAAC,MAAM,CAAC,UAAU;AACnB,MAAI,KAAK,MACR,MAAK,OAAO,mBAAmB,MAAM,QAAQ,EAAE;CAEhD,EAAC,CACF;AAGF,OAAM,QAAQ,IAAI,SAAS;AAC3B;;;;AAKD,eAAsB,oBAAmC;CACxD,MAAMA,WAA4B,CAAE;AAEpC,KAAI,MAAM,eAAe;AACxB,WAAS,KAAK,MAAM,cAAc,UAAU,CAAC;AAC7C,QAAM,gBAAgB;CACtB;AAED,KACC,MAAM,uBACE,MAAM,aACZ,aAAa,YACd;AACD,WAAS,KACR,AAAC,MAAM,aAAmD,UAAU,CACpE;AACD,QAAM,eAAe;CACrB;AAED,OAAM,cAAc;AACpB,OAAM,QAAQ,IAAI,SAAS;AAC3B;;;;AAKD,SAAgB,uBAA6B;AAC5C,MAAK,UAAU,IAAI,qBAAqB,aAAa,MAAM;AAC3D;;;;;;;;;;;;;AAcD,SAAgB,mBACfC,SACwD;AACxD,QAAO,OAAOC,OAAeC,cAAuC;AACnE,MAAI;AACH,UAAO,MAAM,QAAQ,OAAOC,UAAQ;EACpC,UAAS;AACT,SAAM,gBAAgB;EACtB;CACD;AACD;;;;AAKD,IAAa,oBAAb,MAAwD;CACvD,aAA4B;AAC3B,SAAO,QAAQ,SAAS;CACxB;CAED,QAAQC,OAAmB,CAE1B;CAED,MAAMC,OAA2B,CAEhC;CAED,WAA0B;AACzB,SAAO,QAAQ,SAAS;CACxB;AACD"}
@@ -1,71 +0,0 @@
1
- import { Span } from "@opentelemetry/api";
2
- import { Context as Context$1, MiddlewareHandler } from "hono";
3
-
4
- //#region src/instrumentation/hono.d.ts
5
-
6
- /**
7
- * Options for the Hono telemetry middleware
8
- */
9
- interface HonoTelemetryMiddlewareOptions {
10
- /**
11
- * Whether to record request body as span attribute
12
- * @default false
13
- */
14
- recordBody?: boolean;
15
- /**
16
- * Whether to record response body as span attribute
17
- * @default false
18
- */
19
- recordResponseBody?: boolean;
20
- /**
21
- * Custom function to extract user ID from context
22
- */
23
- getUserId?: (c: Context$1) => string | undefined;
24
- /**
25
- * Paths to skip tracing (supports wildcards)
26
- */
27
- ignorePaths?: string[];
28
- /**
29
- * Whether to skip tracing for this request
30
- */
31
- shouldSkip?: (c: Context$1) => boolean;
32
- }
33
- /**
34
- * Get the current span from Hono context
35
- */
36
- declare function getSpanFromContext(c: Context$1): Span | undefined;
37
- /**
38
- * Get the current trace context from Hono context
39
- */
40
- declare function getTraceContextFromHono(c: Context$1): any;
41
- /**
42
- * Create a telemetry middleware for Hono applications
43
- *
44
- * @example
45
- * ```typescript
46
- * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
47
- *
48
- * const app = new Hono();
49
- * app.use('*', honoTelemetryMiddleware());
50
- * ```
51
- */
52
- declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
53
- /**
54
- * Run a function within the span context from Hono context
55
- *
56
- * @example
57
- * ```typescript
58
- * app.get('/api/users', async (c) => {
59
- * return withHonoSpanContext(c, async () => {
60
- * // Any spans created here will be children of the request span
61
- * const users = await fetchUsers();
62
- * return c.json(users);
63
- * });
64
- * });
65
- * ```
66
- */
67
- declare function withHonoSpanContext<T>(c: Context$1, fn: () => Promise<T>): Promise<T>;
68
- //# sourceMappingURL=hono.d.ts.map
69
- //#endregion
70
- export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
71
- //# sourceMappingURL=hono--uKQ7Jgi.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hono--uKQ7Jgi.d.mts","names":[],"sources":["../src/instrumentation/hono.ts"],"sourcesContent":[],"mappings":";;;;;AAuDA;;;AAAgD,UApC/B,8BAAA,CAoC+B;EAAI;AAOpD;AAeA;;EAAuC,UAC7B,CAAA,EAAA,OAAA;EAAmC;AACzB;AAqLpB;;EAAyC,kBACrC,CAAA,EAAA,OAAA;EAAO;;;EAEC,SAAT,CAAA,EAAA,CAAA,CAAA,EApOc,SAoOd,EAAA,GAAA,MAAA,GAAA,SAAA;EAAO;;;;;;;mBA1NQ;;;;;iBAUF,kBAAA,IAAsB,YAAU;;;;iBAOhC,uBAAA,IAA2B;;;;;;;;;;;;iBAe3B,uBAAA,WACN,iCACP;;;;;;;;;;;;;;;iBAqLmB,0BAClB,qBACO,QAAQ,KAChB,QAAQ"}
@@ -1,136 +0,0 @@
1
- import { createHttpServerSpan, endHttpSpan, extractTraceContext } from "./http-BIvr0YdI.mjs";
2
- import { context, trace } from "@opentelemetry/api";
3
-
4
- //#region src/instrumentation/hono.ts
5
- const SPAN_KEY = "telemetry.span";
6
- const CONTEXT_KEY = "telemetry.context";
7
- /**
8
- * Get the current span from Hono context
9
- */
10
- function getSpanFromContext(c) {
11
- return c.get(SPAN_KEY);
12
- }
13
- /**
14
- * Get the current trace context from Hono context
15
- */
16
- function getTraceContextFromHono(c) {
17
- return c.get(CONTEXT_KEY);
18
- }
19
- /**
20
- * Create a telemetry middleware for Hono applications
21
- *
22
- * @example
23
- * ```typescript
24
- * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
25
- *
26
- * const app = new Hono();
27
- * app.use('*', honoTelemetryMiddleware());
28
- * ```
29
- */
30
- function honoTelemetryMiddleware(options = {}) {
31
- return async (c, next) => {
32
- if (options.ignorePaths && shouldIgnorePath(c.req.path, options.ignorePaths)) return next();
33
- if (options.shouldSkip?.(c)) return next();
34
- const headers = {};
35
- c.req.raw.headers.forEach((value, key) => {
36
- headers[key] = value;
37
- });
38
- const parentContext = extractTraceContext(headers);
39
- const attrs = buildHonoSpanAttributes(c, options);
40
- const span = createHttpServerSpan(attrs, parentContext);
41
- const spanContext = trace.setSpan(parentContext, span);
42
- c.set(SPAN_KEY, span);
43
- c.set(CONTEXT_KEY, spanContext);
44
- if (options.recordBody) try {
45
- const body = await c.req.text();
46
- if (body) span.setAttribute("http.request.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
47
- } catch {}
48
- try {
49
- await context.with(spanContext, async () => {
50
- await next();
51
- });
52
- const statusCode = c.res.status;
53
- if (options.recordResponseBody) try {
54
- const body = await c.res.clone().text();
55
- if (body) span.setAttribute("http.response.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
56
- } catch {}
57
- endHttpSpan(span, { statusCode });
58
- } catch (error) {
59
- endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
60
- throw error;
61
- }
62
- };
63
- }
64
- /**
65
- * Build span attributes from Hono context
66
- */
67
- function buildHonoSpanAttributes(c, options) {
68
- const req = c.req;
69
- const url = new URL(req.url);
70
- const routePath = c.req.routePath;
71
- const route = routePath && routePath !== "*" && !routePath.includes("/*") ? routePath : url.pathname;
72
- const attrs = {
73
- method: req.method,
74
- url: req.url,
75
- path: url.pathname,
76
- route,
77
- host: url.host,
78
- scheme: url.protocol.replace(":", ""),
79
- userAgent: req.header("user-agent"),
80
- clientIp: getClientIp(c),
81
- requestId: req.header("x-request-id") || req.header("x-amzn-requestid")
82
- };
83
- if (options.getUserId) {
84
- const userId = options.getUserId(c);
85
- if (userId) attrs.user = { userId };
86
- }
87
- return attrs;
88
- }
89
- /**
90
- * Extract client IP from Hono context
91
- */
92
- function getClientIp(c) {
93
- const xForwardedFor = c.req.header("x-forwarded-for");
94
- if (xForwardedFor) {
95
- const first = xForwardedFor.split(",")[0];
96
- return first?.trim();
97
- }
98
- const xRealIp = c.req.header("x-real-ip");
99
- if (xRealIp) return xRealIp;
100
- const cfConnectingIp = c.req.header("cf-connecting-ip");
101
- if (cfConnectingIp) return cfConnectingIp;
102
- return void 0;
103
- }
104
- /**
105
- * Check if path should be ignored
106
- */
107
- function shouldIgnorePath(path, ignorePaths) {
108
- for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
109
- const prefix = pattern.slice(0, -1);
110
- if (path.startsWith(prefix)) return true;
111
- } else if (path === pattern) return true;
112
- return false;
113
- }
114
- /**
115
- * Run a function within the span context from Hono context
116
- *
117
- * @example
118
- * ```typescript
119
- * app.get('/api/users', async (c) => {
120
- * return withHonoSpanContext(c, async () => {
121
- * // Any spans created here will be children of the request span
122
- * const users = await fetchUsers();
123
- * return c.json(users);
124
- * });
125
- * });
126
- * ```
127
- */
128
- async function withHonoSpanContext(c, fn) {
129
- const ctx = getTraceContextFromHono(c);
130
- if (!ctx) return fn();
131
- return context.with(ctx, fn);
132
- }
133
-
134
- //#endregion
135
- export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
136
- //# sourceMappingURL=hono-Bw-ey6CT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hono-Bw-ey6CT.mjs","names":["c: Context","options: HonoTelemetryMiddlewareOptions","headers: Record<string, string | string[] | undefined>","attrs: HttpSpanAttributes","path: string","ignorePaths: string[]","fn: () => Promise<T>"],"sources":["../src/instrumentation/hono.ts"],"sourcesContent":["import { context, type Span, trace } from '@opentelemetry/api';\n/**\n * OpenTelemetry instrumentation middleware for Hono\n *\n * This middleware automatically creates spans for HTTP requests,\n * extracts trace context from incoming headers, and records\n * request/response metadata as span attributes.\n */\nimport type { Context, MiddlewareHandler } from 'hono';\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for the Hono telemetry middleware\n */\nexport interface HonoTelemetryMiddlewareOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from context\n\t */\n\tgetUserId?: (c: Context) => string | undefined;\n\n\t/**\n\t * Paths to skip tracing (supports wildcards)\n\t */\n\tignorePaths?: string[];\n\n\t/**\n\t * Whether to skip tracing for this request\n\t */\n\tshouldSkip?: (c: Context) => boolean;\n}\n\n// Key for storing span on context\nconst SPAN_KEY = 'telemetry.span';\nconst CONTEXT_KEY = 'telemetry.context';\n\n/**\n * Get the current span from Hono context\n */\nexport function getSpanFromContext(c: Context): Span | undefined {\n\treturn c.get(SPAN_KEY);\n}\n\n/**\n * Get the current trace context from Hono context\n */\nexport function getTraceContextFromHono(c: Context): any {\n\treturn c.get(CONTEXT_KEY);\n}\n\n/**\n * Create a telemetry middleware for Hono applications\n *\n * @example\n * ```typescript\n * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';\n *\n * const app = new Hono();\n * app.use('*', honoTelemetryMiddleware());\n * ```\n */\nexport function honoTelemetryMiddleware(\n\toptions: HonoTelemetryMiddlewareOptions = {},\n): MiddlewareHandler {\n\treturn async (c, next) => {\n\t\t// Check if path should be ignored\n\t\tif (\n\t\t\toptions.ignorePaths &&\n\t\t\tshouldIgnorePath(c.req.path, options.ignorePaths)\n\t\t) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Skip if custom skip function returns true\n\t\tif (options.shouldSkip?.(c)) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Extract trace context from headers\n\t\tconst headers: Record<string, string | string[] | undefined> = {};\n\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\theaders[key] = value;\n\t\t});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from request\n\t\tconst attrs = buildHonoSpanAttributes(c, options);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst spanContext = trace.setSpan(parentContext, span);\n\n\t\t// Store span and context on Hono context\n\t\tc.set(SPAN_KEY, span);\n\t\tc.set(CONTEXT_KEY, spanContext);\n\n\t\t// Record body if requested\n\t\tif (options.recordBody) {\n\t\t\ttry {\n\t\t\t\tconst body = await c.req.text();\n\t\t\t\tif (body) {\n\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t'http.request.body',\n\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Body may have already been consumed\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Execute the rest of the middleware chain within span context\n\t\t\tawait context.with(spanContext, async () => {\n\t\t\t\tawait next();\n\t\t\t});\n\n\t\t\t// Record response\n\t\t\tconst statusCode = c.res.status;\n\n\t\t\tif (options.recordResponseBody) {\n\t\t\t\ttry {\n\t\t\t\t\tconst body = await c.res.clone().text();\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t\t'http.response.body',\n\t\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Response body may not be available\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tendHttpSpan(span, { statusCode });\n\t\t} catch (error) {\n\t\t\tendHttpSpan(\n\t\t\t\tspan,\n\t\t\t\t{ statusCode: 500 },\n\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Build span attributes from Hono context\n */\nfunction buildHonoSpanAttributes(\n\tc: Context,\n\toptions: HonoTelemetryMiddlewareOptions,\n): HttpSpanAttributes {\n\tconst req = c.req;\n\tconst url = new URL(req.url);\n\n\t// Use actual path for route unless it's a specific route pattern\n\tconst routePath = c.req.routePath;\n\tconst route =\n\t\troutePath && routePath !== '*' && !routePath.includes('/*')\n\t\t\t? routePath\n\t\t\t: url.pathname;\n\n\tconst attrs: HttpSpanAttributes = {\n\t\tmethod: req.method,\n\t\turl: req.url,\n\t\tpath: url.pathname,\n\t\troute,\n\t\thost: url.host,\n\t\tscheme: url.protocol.replace(':', '') as 'http' | 'https',\n\t\tuserAgent: req.header('user-agent'),\n\t\tclientIp: getClientIp(c),\n\t\trequestId: req.header('x-request-id') || req.header('x-amzn-requestid'),\n\t};\n\n\t// Add user metadata if extractor provided\n\tif (options.getUserId) {\n\t\tconst userId = options.getUserId(c);\n\t\tif (userId) {\n\t\t\tattrs.user = { userId };\n\t\t}\n\t}\n\n\treturn attrs;\n}\n\n/**\n * Extract client IP from Hono context\n */\nfunction getClientIp(c: Context): string | undefined {\n\t// Try various headers in order of preference\n\tconst xForwardedFor = c.req.header('x-forwarded-for');\n\tif (xForwardedFor) {\n\t\tconst first = xForwardedFor.split(',')[0];\n\t\treturn first?.trim();\n\t}\n\n\tconst xRealIp = c.req.header('x-real-ip');\n\tif (xRealIp) {\n\t\treturn xRealIp;\n\t}\n\n\t// Try CF-Connecting-IP (Cloudflare)\n\tconst cfConnectingIp = c.req.header('cf-connecting-ip');\n\tif (cfConnectingIp) {\n\t\treturn cfConnectingIp;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Check if path should be ignored\n */\nfunction shouldIgnorePath(path: string, ignorePaths: string[]): boolean {\n\tfor (const pattern of ignorePaths) {\n\t\tif (pattern.endsWith('*')) {\n\t\t\t// Wildcard match\n\t\t\tconst prefix = pattern.slice(0, -1);\n\t\t\tif (path.startsWith(prefix)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (path === pattern) {\n\t\t\t// Exact match\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Run a function within the span context from Hono context\n *\n * @example\n * ```typescript\n * app.get('/api/users', async (c) => {\n * return withHonoSpanContext(c, async () => {\n * // Any spans created here will be children of the request span\n * const users = await fetchUsers();\n * return c.json(users);\n * });\n * });\n * ```\n */\nexport async function withHonoSpanContext<T>(\n\tc: Context,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst ctx = getTraceContextFromHono(c);\n\tif (!ctx) {\n\t\treturn fn();\n\t}\n\treturn context.with(ctx, fn);\n}\n"],"mappings":";;;;AAiDA,MAAM,WAAW;AACjB,MAAM,cAAc;;;;AAKpB,SAAgB,mBAAmBA,GAA8B;AAChE,QAAO,EAAE,IAAI,SAAS;AACtB;;;;AAKD,SAAgB,wBAAwBA,GAAiB;AACxD,QAAO,EAAE,IAAI,YAAY;AACzB;;;;;;;;;;;;AAaD,SAAgB,wBACfC,UAA0C,CAAE,GACxB;AACpB,QAAO,OAAO,GAAG,SAAS;AAEzB,MACC,QAAQ,eACR,iBAAiB,EAAE,IAAI,MAAM,QAAQ,YAAY,CAEjD,QAAO,MAAM;AAId,MAAI,QAAQ,aAAa,EAAE,CAC1B,QAAO,MAAM;EAId,MAAMC,UAAyD,CAAE;AACjE,IAAE,IAAI,IAAI,QAAQ,QAAQ,CAAC,OAAO,QAAQ;AACzC,WAAQ,OAAO;EACf,EAAC;EACF,MAAM,gBAAgB,oBAAoB,QAAQ;EAGlD,MAAM,QAAQ,wBAAwB,GAAG,QAAQ;EAGjD,MAAM,OAAO,qBAAqB,OAAO,cAAc;EACvD,MAAM,cAAc,MAAM,QAAQ,eAAe,KAAK;AAGtD,IAAE,IAAI,UAAU,KAAK;AACrB,IAAE,IAAI,aAAa,YAAY;AAG/B,MAAI,QAAQ,WACX,KAAI;GACH,MAAM,OAAO,MAAM,EAAE,IAAI,MAAM;AAC/B,OAAI,KACH,MAAK,aACJ,qBACA,KAAK,SAAS,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK,CAAC,OAAO,KACnD;EAEF,QAAO,CAEP;AAGF,MAAI;AAEH,SAAM,QAAQ,KAAK,aAAa,YAAY;AAC3C,UAAM,MAAM;GACZ,EAAC;GAGF,MAAM,aAAa,EAAE,IAAI;AAEzB,OAAI,QAAQ,mBACX,KAAI;IACH,MAAM,OAAO,MAAM,EAAE,IAAI,OAAO,CAAC,MAAM;AACvC,QAAI,KACH,MAAK,aACJ,sBACA,KAAK,SAAS,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK,CAAC,OAAO,KACnD;GAEF,QAAO,CAEP;AAGF,eAAY,MAAM,EAAE,WAAY,EAAC;EACjC,SAAQ,OAAO;AACf,eACC,MACA,EAAE,YAAY,IAAK,GACnB,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,EACxD;AACD,SAAM;EACN;CACD;AACD;;;;AAKD,SAAS,wBACRF,GACAC,SACqB;CACrB,MAAM,MAAM,EAAE;CACd,MAAM,MAAM,IAAI,IAAI,IAAI;CAGxB,MAAM,YAAY,EAAE,IAAI;CACxB,MAAM,QACL,aAAa,cAAc,QAAQ,UAAU,SAAS,KAAK,GACxD,YACA,IAAI;CAER,MAAME,QAA4B;EACjC,QAAQ,IAAI;EACZ,KAAK,IAAI;EACT,MAAM,IAAI;EACV;EACA,MAAM,IAAI;EACV,QAAQ,IAAI,SAAS,QAAQ,KAAK,GAAG;EACrC,WAAW,IAAI,OAAO,aAAa;EACnC,UAAU,YAAY,EAAE;EACxB,WAAW,IAAI,OAAO,eAAe,IAAI,IAAI,OAAO,mBAAmB;CACvE;AAGD,KAAI,QAAQ,WAAW;EACtB,MAAM,SAAS,QAAQ,UAAU,EAAE;AACnC,MAAI,OACH,OAAM,OAAO,EAAE,OAAQ;CAExB;AAED,QAAO;AACP;;;;AAKD,SAAS,YAAYH,GAAgC;CAEpD,MAAM,gBAAgB,EAAE,IAAI,OAAO,kBAAkB;AACrD,KAAI,eAAe;EAClB,MAAM,QAAQ,cAAc,MAAM,IAAI,CAAC;AACvC,SAAO,OAAO,MAAM;CACpB;CAED,MAAM,UAAU,EAAE,IAAI,OAAO,YAAY;AACzC,KAAI,QACH,QAAO;CAIR,MAAM,iBAAiB,EAAE,IAAI,OAAO,mBAAmB;AACvD,KAAI,eACH,QAAO;AAGR;AACA;;;;AAKD,SAAS,iBAAiBI,MAAcC,aAAgC;AACvE,MAAK,MAAM,WAAW,YACrB,KAAI,QAAQ,SAAS,IAAI,EAAE;EAE1B,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;AACnC,MAAI,KAAK,WAAW,OAAO,CAC1B,QAAO;CAER,WAAU,SAAS,QAEnB,QAAO;AAGT,QAAO;AACP;;;;;;;;;;;;;;;AAgBD,eAAsB,oBACrBL,GACAM,IACa;CACb,MAAM,MAAM,wBAAwB,EAAE;AACtC,MAAK,IACJ,QAAO,IAAI;AAEZ,QAAO,QAAQ,KAAK,KAAK,GAAG;AAC5B"}