@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,7 +1,135 @@
1
- require('../http-BsqmhurZ.cjs');
2
- const require_hono = require('../hono-CPHX7FAm.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_instrumentation_http = require("./http.cjs");
3
+ let _opentelemetry_api = require("@opentelemetry/api");
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 = require_instrumentation_http.extractTraceContext(headers);
39
+ const attrs = buildHonoSpanAttributes(c, options);
40
+ const span = require_instrumentation_http.createHttpServerSpan(attrs, parentContext);
41
+ const spanContext = _opentelemetry_api.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 _opentelemetry_api.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
+ require_instrumentation_http.endHttpSpan(span, { statusCode });
58
+ } catch (error) {
59
+ require_instrumentation_http.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) return xForwardedFor.split(",")[0]?.trim();
95
+ const xRealIp = c.req.header("x-real-ip");
96
+ if (xRealIp) return xRealIp;
97
+ const cfConnectingIp = c.req.header("cf-connecting-ip");
98
+ if (cfConnectingIp) return cfConnectingIp;
99
+ }
100
+ /**
101
+ * Check if path should be ignored
102
+ */
103
+ function shouldIgnorePath(path, ignorePaths) {
104
+ for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
105
+ const prefix = pattern.slice(0, -1);
106
+ if (path.startsWith(prefix)) return true;
107
+ } else if (path === pattern) return true;
108
+ return false;
109
+ }
110
+ /**
111
+ * Run a function within the span context from Hono context
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * app.get('/api/users', async (c) => {
116
+ * return withHonoSpanContext(c, async () => {
117
+ * // Any spans created here will be children of the request span
118
+ * const users = await fetchUsers();
119
+ * return c.json(users);
120
+ * });
121
+ * });
122
+ * ```
123
+ */
124
+ async function withHonoSpanContext(c, fn) {
125
+ const ctx = getTraceContextFromHono(c);
126
+ if (!ctx) return fn();
127
+ return _opentelemetry_api.context.with(ctx, fn);
128
+ }
129
+ //#endregion
130
+ exports.getSpanFromContext = getSpanFromContext;
131
+ exports.getTraceContextFromHono = getTraceContextFromHono;
132
+ exports.honoTelemetryMiddleware = honoTelemetryMiddleware;
133
+ exports.withHonoSpanContext = withHonoSpanContext;
3
134
 
4
- exports.getSpanFromContext = require_hono.getSpanFromContext;
5
- exports.getTraceContextFromHono = require_hono.getTraceContextFromHono;
6
- exports.honoTelemetryMiddleware = require_hono.honoTelemetryMiddleware;
7
- exports.withHonoSpanContext = require_hono.withHonoSpanContext;
135
+ //# sourceMappingURL=hono.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.cjs","names":["extractTraceContext","createHttpServerSpan","trace","context"],"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":"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"}
@@ -1,2 +1,67 @@
1
- import { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono-CemCKU87.cjs";
2
- export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
1
+ import { Context, MiddlewareHandler } from "hono";
2
+ import { Span } from "@opentelemetry/api";
3
+ //#region src/instrumentation/hono.d.ts
4
+ /**
5
+ * Options for the Hono telemetry middleware
6
+ */
7
+ export interface HonoTelemetryMiddlewareOptions {
8
+ /**
9
+ * Whether to record request body as span attribute
10
+ * @default false
11
+ */
12
+ recordBody?: boolean;
13
+ /**
14
+ * Whether to record response body as span attribute
15
+ * @default false
16
+ */
17
+ recordResponseBody?: boolean;
18
+ /**
19
+ * Custom function to extract user ID from context
20
+ */
21
+ getUserId?: (c: Context) => string | undefined;
22
+ /**
23
+ * Paths to skip tracing (supports wildcards)
24
+ */
25
+ ignorePaths?: string[];
26
+ /**
27
+ * Whether to skip tracing for this request
28
+ */
29
+ shouldSkip?: (c: Context) => boolean;
30
+ }
31
+ /**
32
+ * Get the current span from Hono context
33
+ */
34
+ export declare function getSpanFromContext(c: Context): Span | undefined;
35
+ /**
36
+ * Get the current trace context from Hono context
37
+ */
38
+ export declare function getTraceContextFromHono(c: Context): any;
39
+ /**
40
+ * Create a telemetry middleware for Hono applications
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
45
+ *
46
+ * const app = new Hono();
47
+ * app.use('*', honoTelemetryMiddleware());
48
+ * ```
49
+ */
50
+ export declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
51
+ /**
52
+ * Run a function within the span context from Hono context
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * app.get('/api/users', async (c) => {
57
+ * return withHonoSpanContext(c, async () => {
58
+ * // Any spans created here will be children of the request span
59
+ * const users = await fetchUsers();
60
+ * return c.json(users);
61
+ * });
62
+ * });
63
+ * ```
64
+ */
65
+ export declare function withHonoSpanContext<T>(c: Context, fn: () => Promise<T>): Promise<T>;
66
+ //#endregion
67
+ //# sourceMappingURL=hono.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.d.cts","names":[],"sources":["../../src/instrumentation/hono.ts"],"mappings":";;;;;;iBAmBiB;;;;;EAKhB;;;;;EAMA;;;;EAKA,aAAa,GAAG;;;;EAKhB;;;;EAKA,cAAc,GAAG;;;;;wBAUF,mBAAmB,GAAG,UAAU;;;;wBAOhC,wBAAwB,GAAG;;;;;;;;;;;;wBAe3B,wBACf,UAAS,iCACP;;;;;;;;;;;;;;;wBAqLmB,oBAAoB,GACzC,GAAG,SACH,UAAU,QAAQ,KAChB,QAAQ"}
@@ -1,2 +1,67 @@
1
- import { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono--uKQ7Jgi.mjs";
2
- export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
1
+ import { Span } from "@opentelemetry/api";
2
+ import { Context as Context$1, MiddlewareHandler } from "hono";
3
+ //#region src/instrumentation/hono.d.ts
4
+ /**
5
+ * Options for the Hono telemetry middleware
6
+ */
7
+ export interface HonoTelemetryMiddlewareOptions {
8
+ /**
9
+ * Whether to record request body as span attribute
10
+ * @default false
11
+ */
12
+ recordBody?: boolean;
13
+ /**
14
+ * Whether to record response body as span attribute
15
+ * @default false
16
+ */
17
+ recordResponseBody?: boolean;
18
+ /**
19
+ * Custom function to extract user ID from context
20
+ */
21
+ getUserId?: (c: Context$1) => string | undefined;
22
+ /**
23
+ * Paths to skip tracing (supports wildcards)
24
+ */
25
+ ignorePaths?: string[];
26
+ /**
27
+ * Whether to skip tracing for this request
28
+ */
29
+ shouldSkip?: (c: Context$1) => boolean;
30
+ }
31
+ /**
32
+ * Get the current span from Hono context
33
+ */
34
+ export declare function getSpanFromContext(c: Context$1): Span | undefined;
35
+ /**
36
+ * Get the current trace context from Hono context
37
+ */
38
+ export declare function getTraceContextFromHono(c: Context$1): any;
39
+ /**
40
+ * Create a telemetry middleware for Hono applications
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
45
+ *
46
+ * const app = new Hono();
47
+ * app.use('*', honoTelemetryMiddleware());
48
+ * ```
49
+ */
50
+ export declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
51
+ /**
52
+ * Run a function within the span context from Hono context
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * app.get('/api/users', async (c) => {
57
+ * return withHonoSpanContext(c, async () => {
58
+ * // Any spans created here will be children of the request span
59
+ * const users = await fetchUsers();
60
+ * return c.json(users);
61
+ * });
62
+ * });
63
+ * ```
64
+ */
65
+ export declare function withHonoSpanContext<T>(c: Context$1, fn: () => Promise<T>): Promise<T>;
66
+ //#endregion
67
+ //# sourceMappingURL=hono.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.d.mts","names":["Context"],"sources":["../../src/instrumentation/hono.ts"],"mappings":";;;;;;iBAmBiB;;;;;EAKhB;;;;;EAMA;;;;EAKA,aAAa,GAAGA;;;;EAKhB;;;;EAKA,cAAc,GAAGA;;;;;wBAUF,mBAAmB,GAAGA,YAAU;;;;wBAOhC,wBAAwB,GAAGA;;;;;;;;;;;;wBAe3B,wBACf,UAAS,iCACP;;;;;;;;;;;;;;;wBAqLmB,oBAAoB,GACzC,GAAGA,WACH,UAAU,QAAQ,KAChB,QAAQ"}
@@ -1,4 +1,131 @@
1
- import "../http-BIvr0YdI.mjs";
2
- import { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono-Bw-ey6CT.mjs";
1
+ import { createHttpServerSpan, endHttpSpan, extractTraceContext } from "./http.mjs";
2
+ import { context, trace } from "@opentelemetry/api";
3
+ //#region src/instrumentation/hono.ts
4
+ const SPAN_KEY = "telemetry.span";
5
+ const CONTEXT_KEY = "telemetry.context";
6
+ /**
7
+ * Get the current span from Hono context
8
+ */
9
+ function getSpanFromContext(c) {
10
+ return c.get(SPAN_KEY);
11
+ }
12
+ /**
13
+ * Get the current trace context from Hono context
14
+ */
15
+ function getTraceContextFromHono(c) {
16
+ return c.get(CONTEXT_KEY);
17
+ }
18
+ /**
19
+ * Create a telemetry middleware for Hono applications
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
24
+ *
25
+ * const app = new Hono();
26
+ * app.use('*', honoTelemetryMiddleware());
27
+ * ```
28
+ */
29
+ function honoTelemetryMiddleware(options = {}) {
30
+ return async (c, next) => {
31
+ if (options.ignorePaths && shouldIgnorePath(c.req.path, options.ignorePaths)) return next();
32
+ if (options.shouldSkip?.(c)) return next();
33
+ const headers = {};
34
+ c.req.raw.headers.forEach((value, key) => {
35
+ headers[key] = value;
36
+ });
37
+ const parentContext = extractTraceContext(headers);
38
+ const attrs = buildHonoSpanAttributes(c, options);
39
+ const span = createHttpServerSpan(attrs, parentContext);
40
+ const spanContext = trace.setSpan(parentContext, span);
41
+ c.set(SPAN_KEY, span);
42
+ c.set(CONTEXT_KEY, spanContext);
43
+ if (options.recordBody) try {
44
+ const body = await c.req.text();
45
+ if (body) span.setAttribute("http.request.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
46
+ } catch {}
47
+ try {
48
+ await context.with(spanContext, async () => {
49
+ await next();
50
+ });
51
+ const statusCode = c.res.status;
52
+ if (options.recordResponseBody) try {
53
+ const body = await c.res.clone().text();
54
+ if (body) span.setAttribute("http.response.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
55
+ } catch {}
56
+ endHttpSpan(span, { statusCode });
57
+ } catch (error) {
58
+ endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
59
+ throw error;
60
+ }
61
+ };
62
+ }
63
+ /**
64
+ * Build span attributes from Hono context
65
+ */
66
+ function buildHonoSpanAttributes(c, options) {
67
+ const req = c.req;
68
+ const url = new URL(req.url);
69
+ const routePath = c.req.routePath;
70
+ const route = routePath && routePath !== "*" && !routePath.includes("/*") ? routePath : url.pathname;
71
+ const attrs = {
72
+ method: req.method,
73
+ url: req.url,
74
+ path: url.pathname,
75
+ route,
76
+ host: url.host,
77
+ scheme: url.protocol.replace(":", ""),
78
+ userAgent: req.header("user-agent"),
79
+ clientIp: getClientIp(c),
80
+ requestId: req.header("x-request-id") || req.header("x-amzn-requestid")
81
+ };
82
+ if (options.getUserId) {
83
+ const userId = options.getUserId(c);
84
+ if (userId) attrs.user = { userId };
85
+ }
86
+ return attrs;
87
+ }
88
+ /**
89
+ * Extract client IP from Hono context
90
+ */
91
+ function getClientIp(c) {
92
+ const xForwardedFor = c.req.header("x-forwarded-for");
93
+ if (xForwardedFor) return xForwardedFor.split(",")[0]?.trim();
94
+ const xRealIp = c.req.header("x-real-ip");
95
+ if (xRealIp) return xRealIp;
96
+ const cfConnectingIp = c.req.header("cf-connecting-ip");
97
+ if (cfConnectingIp) return cfConnectingIp;
98
+ }
99
+ /**
100
+ * Check if path should be ignored
101
+ */
102
+ function shouldIgnorePath(path, ignorePaths) {
103
+ for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
104
+ const prefix = pattern.slice(0, -1);
105
+ if (path.startsWith(prefix)) return true;
106
+ } else if (path === pattern) return true;
107
+ return false;
108
+ }
109
+ /**
110
+ * Run a function within the span context from Hono context
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * app.get('/api/users', async (c) => {
115
+ * return withHonoSpanContext(c, async () => {
116
+ * // Any spans created here will be children of the request span
117
+ * const users = await fetchUsers();
118
+ * return c.json(users);
119
+ * });
120
+ * });
121
+ * ```
122
+ */
123
+ async function withHonoSpanContext(c, fn) {
124
+ const ctx = getTraceContextFromHono(c);
125
+ if (!ctx) return fn();
126
+ return context.with(ctx, fn);
127
+ }
128
+ //#endregion
129
+ export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
3
130
 
4
- export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
131
+ //# sourceMappingURL=hono.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hono.mjs","names":[],"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":"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"}
@@ -1,12 +1,165 @@
1
- const require_http = require('../http-BsqmhurZ.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _opentelemetry_api = require("@opentelemetry/api");
3
+ //#region src/instrumentation/http.ts
4
+ const TRACER_NAME = "@geekmidas/constructs";
5
+ /**
6
+ * Get or create a tracer for constructs instrumentation
7
+ */
8
+ function getConstructsTracer() {
9
+ return _opentelemetry_api.trace.getTracer(TRACER_NAME);
10
+ }
11
+ /**
12
+ * Convert HTTP attributes to OpenTelemetry semantic conventions
13
+ */
14
+ function toOtelAttributes(attrs) {
15
+ const otelAttrs = {};
16
+ if (attrs.method) otelAttrs["http.request.method"] = attrs.method;
17
+ if (attrs.url) otelAttrs["url.full"] = attrs.url;
18
+ if (attrs.path) otelAttrs["url.path"] = attrs.path;
19
+ if (attrs.route) otelAttrs["http.route"] = attrs.route;
20
+ if (attrs.host) otelAttrs["server.address"] = attrs.host;
21
+ if (attrs.scheme) otelAttrs["url.scheme"] = attrs.scheme;
22
+ if (attrs.userAgent) otelAttrs["user_agent.original"] = attrs.userAgent;
23
+ if (attrs.clientIp) otelAttrs["client.address"] = attrs.clientIp;
24
+ if (attrs.requestId) otelAttrs["http.request.id"] = attrs.requestId;
25
+ if (attrs.response?.statusCode) otelAttrs["http.response.status_code"] = attrs.response.statusCode;
26
+ if (attrs.response?.responseSize) otelAttrs["http.response.body.size"] = attrs.response.responseSize;
27
+ if (attrs.endpoint?.name) otelAttrs["endpoint.name"] = attrs.endpoint.name;
28
+ if (attrs.endpoint?.operationId) otelAttrs["endpoint.operation_id"] = attrs.endpoint.operationId;
29
+ if (attrs.endpoint?.tags?.length) otelAttrs["endpoint.tags"] = attrs.endpoint.tags;
30
+ if (attrs.user?.userId) otelAttrs["enduser.id"] = attrs.user.userId;
31
+ if (attrs.user?.sessionId) otelAttrs["session.id"] = attrs.user.sessionId;
32
+ if (attrs.user?.roles?.length) otelAttrs["enduser.role"] = attrs.user.roles.join(",");
33
+ if (attrs.custom) Object.assign(otelAttrs, attrs.custom);
34
+ return otelAttrs;
35
+ }
36
+ /**
37
+ * Extract trace context from HTTP headers
38
+ */
39
+ function extractTraceContext(headers) {
40
+ const normalizedHeaders = {};
41
+ for (const [key, value] of Object.entries(headers)) if (value) {
42
+ const stringValue = Array.isArray(value) ? value[0] : value;
43
+ if (stringValue) normalizedHeaders[key.toLowerCase()] = stringValue;
44
+ }
45
+ return _opentelemetry_api.propagation.extract(_opentelemetry_api.context.active(), normalizedHeaders);
46
+ }
47
+ /**
48
+ * Inject trace context into HTTP headers
49
+ */
50
+ function injectTraceContext(headers, ctx) {
51
+ const result = { ...headers };
52
+ _opentelemetry_api.propagation.inject(ctx ?? _opentelemetry_api.context.active(), result);
53
+ return result;
54
+ }
55
+ /**
56
+ * Create an HTTP server span for an incoming request
57
+ */
58
+ function createHttpServerSpan(attrs, parentContext) {
59
+ const tracer = getConstructsTracer();
60
+ const spanName = attrs.route ? `${attrs.method} ${attrs.route}` : `${attrs.method} ${attrs.path || "/"}`;
61
+ const ctx = parentContext ?? _opentelemetry_api.context.active();
62
+ return tracer.startSpan(spanName, {
63
+ kind: _opentelemetry_api.SpanKind.SERVER,
64
+ attributes: toOtelAttributes(attrs)
65
+ }, ctx);
66
+ }
67
+ /**
68
+ * End an HTTP span with response data
69
+ */
70
+ function endHttpSpan(span, response, error) {
71
+ span.setAttribute("http.response.status_code", response.statusCode);
72
+ if (response.responseSize) span.setAttribute("http.response.body.size", response.responseSize);
73
+ if (error) {
74
+ span.recordException(error);
75
+ span.setStatus({
76
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
77
+ message: error.message
78
+ });
79
+ } else if (response.statusCode >= 400) span.setStatus({
80
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
81
+ message: `HTTP ${response.statusCode}`
82
+ });
83
+ else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
84
+ span.end();
85
+ }
86
+ /**
87
+ * Execute a function within an HTTP server span context
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const result = await withHttpSpan(
92
+ * { method: 'GET', path: '/users', route: '/users' },
93
+ * async (span) => {
94
+ * const users = await getUsers();
95
+ * return { statusCode: 200, body: users };
96
+ * }
97
+ * );
98
+ * ```
99
+ */
100
+ async function withHttpSpan(attrs, fn, parentContext) {
101
+ const span = createHttpServerSpan(attrs, parentContext);
102
+ try {
103
+ const result = await _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(parentContext ?? _opentelemetry_api.context.active(), span), () => fn(span));
104
+ endHttpSpan(span, { statusCode: result.statusCode ?? 200 });
105
+ return result;
106
+ } catch (error) {
107
+ endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
108
+ throw error;
109
+ }
110
+ }
111
+ /**
112
+ * Create a child span for internal operations (middleware, handlers, etc.)
113
+ */
114
+ function createChildSpan(name, attributes) {
115
+ return getConstructsTracer().startSpan(name, {
116
+ kind: _opentelemetry_api.SpanKind.INTERNAL,
117
+ attributes
118
+ });
119
+ }
120
+ /**
121
+ * Execute a function within a child span
122
+ */
123
+ async function withChildSpan(name, fn, attributes) {
124
+ const span = createChildSpan(name, attributes);
125
+ try {
126
+ const result = await _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(_opentelemetry_api.context.active(), span), () => fn(span));
127
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
128
+ return result;
129
+ } catch (error) {
130
+ span.setStatus({
131
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
132
+ message: error instanceof Error ? error.message : "Unknown error"
133
+ });
134
+ span.recordException(error instanceof Error ? error : new Error(String(error)));
135
+ throw error;
136
+ } finally {
137
+ span.end();
138
+ }
139
+ }
140
+ /**
141
+ * Check if tracing is enabled (OpenTelemetry API is available and configured)
142
+ */
143
+ function isTracingEnabled() {
144
+ try {
145
+ const span = _opentelemetry_api.trace.getTracer(TRACER_NAME).startSpan("test");
146
+ const isReal = span.spanContext().traceId !== "00000000000000000000000000000000";
147
+ span.end();
148
+ return isReal;
149
+ } catch {
150
+ return false;
151
+ }
152
+ }
153
+ //#endregion
154
+ exports.createChildSpan = createChildSpan;
155
+ exports.createHttpServerSpan = createHttpServerSpan;
156
+ exports.endHttpSpan = endHttpSpan;
157
+ exports.extractTraceContext = extractTraceContext;
158
+ exports.getConstructsTracer = getConstructsTracer;
159
+ exports.injectTraceContext = injectTraceContext;
160
+ exports.isTracingEnabled = isTracingEnabled;
161
+ exports.toOtelAttributes = toOtelAttributes;
162
+ exports.withChildSpan = withChildSpan;
163
+ exports.withHttpSpan = withHttpSpan;
2
164
 
3
- exports.createChildSpan = require_http.createChildSpan;
4
- exports.createHttpServerSpan = require_http.createHttpServerSpan;
5
- exports.endHttpSpan = require_http.endHttpSpan;
6
- exports.extractTraceContext = require_http.extractTraceContext;
7
- exports.getConstructsTracer = require_http.getConstructsTracer;
8
- exports.injectTraceContext = require_http.injectTraceContext;
9
- exports.isTracingEnabled = require_http.isTracingEnabled;
10
- exports.toOtelAttributes = require_http.toOtelAttributes;
11
- exports.withChildSpan = require_http.withChildSpan;
12
- exports.withHttpSpan = require_http.withHttpSpan;
165
+ //# sourceMappingURL=http.cjs.map