@geekmidas/telescope 10.0.0-alpha.99 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +18 -28
  3. package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts +47 -0
  4. package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts.map +1 -0
  5. package/dist/InMemoryMetricsStorage-C4drxT7G.mjs +247 -0
  6. package/dist/InMemoryMetricsStorage-C4drxT7G.mjs.map +1 -0
  7. package/dist/InMemoryMetricsStorage-D0njWUSi.cjs +252 -0
  8. package/dist/InMemoryMetricsStorage-D0njWUSi.cjs.map +1 -0
  9. package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts +47 -0
  10. package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts.map +1 -0
  11. package/dist/{MetricsAggregator-BJdIvfEv.d.mts → MetricsAggregator-4SqelGcG.d.cts} +6 -3
  12. package/dist/MetricsAggregator-4SqelGcG.d.cts.map +1 -0
  13. package/dist/MetricsAggregator-B7lUICdH.cjs +363 -0
  14. package/dist/MetricsAggregator-B7lUICdH.cjs.map +1 -0
  15. package/dist/{MetricsAggregator-CnC3oT5q.d.cts → MetricsAggregator-DZrW8ls6.d.mts} +6 -3
  16. package/dist/MetricsAggregator-DZrW8ls6.d.mts.map +1 -0
  17. package/dist/MetricsAggregator-S3DQWNas.mjs +357 -0
  18. package/dist/MetricsAggregator-S3DQWNas.mjs.map +1 -0
  19. package/dist/MetricsStorage-B86e4131.d.cts +60 -0
  20. package/dist/MetricsStorage-B86e4131.d.cts.map +1 -0
  21. package/dist/MetricsStorage-BWyP2_12.d.mts +60 -0
  22. package/dist/MetricsStorage-BWyP2_12.d.mts.map +1 -0
  23. package/dist/MetricsStorage-BypQXWiv.mjs +0 -0
  24. package/dist/MetricsStorage-Or8pVCe4.cjs +0 -0
  25. package/dist/Telescope-Cs3fv8jt.cjs +395 -0
  26. package/dist/Telescope-Cs3fv8jt.cjs.map +1 -0
  27. package/dist/{Telescope-BVfDvVvY.d.mts → Telescope-D4nmwDRA.d.cts} +7 -4
  28. package/dist/Telescope-D4nmwDRA.d.cts.map +1 -0
  29. package/dist/Telescope-Dh5av3FC.mjs +389 -0
  30. package/dist/Telescope-Dh5av3FC.mjs.map +1 -0
  31. package/dist/{Telescope-DeqSHfuB.d.cts → Telescope-Dl6VSfxd.d.mts} +7 -4
  32. package/dist/Telescope-Dl6VSfxd.d.mts.map +1 -0
  33. package/dist/Telescope.cjs +4 -385
  34. package/dist/Telescope.d.cts +3 -1
  35. package/dist/Telescope.d.mts +3 -1
  36. package/dist/Telescope.mjs +4 -384
  37. package/dist/adapters/index.d.cts +2 -2
  38. package/dist/adapters/index.d.mts +2 -2
  39. package/dist/adapters/index.mjs +0 -1
  40. package/dist/adapters/lambda.cjs +10 -9
  41. package/dist/adapters/lambda.cjs.map +1 -1
  42. package/dist/adapters/lambda.d.cts +13 -9
  43. package/dist/adapters/lambda.d.cts.map +1 -1
  44. package/dist/adapters/lambda.d.mts +13 -9
  45. package/dist/adapters/lambda.d.mts.map +1 -1
  46. package/dist/adapters/lambda.mjs +4 -3
  47. package/dist/adapters/lambda.mjs.map +1 -1
  48. package/dist/adapters/middy.cjs +4 -236
  49. package/dist/adapters/middy.d.cts +5 -60
  50. package/dist/adapters/middy.d.mts +5 -60
  51. package/dist/adapters/middy.mjs +3 -234
  52. package/dist/adapters/types.d.cts +2 -162
  53. package/dist/adapters/types.d.mts +2 -162
  54. package/dist/adapters/types.mjs +0 -1
  55. package/dist/{rolldown-runtime-VH7oDXx4.cjs → chunk-CUT6urMc.cjs} +10 -8
  56. package/dist/core--quSp5Qr.d.mts +78 -0
  57. package/dist/core--quSp5Qr.d.mts.map +1 -0
  58. package/dist/core-B4Jpia5H.d.cts +78 -0
  59. package/dist/core-B4Jpia5H.d.cts.map +1 -0
  60. package/dist/core-CtVHRJGv.cjs +199 -0
  61. package/dist/core-CtVHRJGv.cjs.map +1 -0
  62. package/dist/core-D6hJ6exL.mjs +139 -0
  63. package/dist/core-D6hJ6exL.mjs.map +1 -0
  64. package/dist/core.cjs +22 -22
  65. package/dist/core.d.cts +4 -4
  66. package/dist/core.d.mts +4 -4
  67. package/dist/core.mjs +4 -3
  68. package/dist/hono--uKQ7Jgi.d.mts +71 -0
  69. package/dist/hono--uKQ7Jgi.d.mts.map +1 -0
  70. package/dist/hono-C4EgpbKQ.cjs +160 -0
  71. package/dist/hono-C4EgpbKQ.cjs.map +1 -0
  72. package/dist/hono-CemCKU87.d.cts +71 -0
  73. package/dist/hono-CemCKU87.d.cts.map +1 -0
  74. package/dist/hono-DxhvnVbF.mjs +136 -0
  75. package/dist/hono-DxhvnVbF.mjs.map +1 -0
  76. package/dist/http-BiNtg85L.d.mts +107 -0
  77. package/dist/http-BiNtg85L.d.mts.map +1 -0
  78. package/dist/http-DQzgLczm.mjs +159 -0
  79. package/dist/http-DQzgLczm.mjs.map +1 -0
  80. package/dist/http-D_Z8sYXZ.cjs +219 -0
  81. package/dist/http-D_Z8sYXZ.cjs.map +1 -0
  82. package/dist/http-Dvca6fC3.d.cts +107 -0
  83. package/dist/http-Dvca6fC3.d.cts.map +1 -0
  84. package/dist/index-BL32-cvv.d.cts +1 -0
  85. package/dist/index-CsuikFeJ.d.mts +1 -0
  86. package/dist/index.cjs +9 -8
  87. package/dist/index.d.cts +6 -5
  88. package/dist/index.d.mts +6 -5
  89. package/dist/index.mjs +7 -5
  90. package/dist/instrumentation/core.cjs +11 -147
  91. package/dist/instrumentation/core.d.cts +3 -74
  92. package/dist/instrumentation/core.d.mts +3 -74
  93. package/dist/instrumentation/core.mjs +2 -137
  94. package/dist/instrumentation/hono.cjs +6 -174
  95. package/dist/instrumentation/hono.d.cts +2 -86
  96. package/dist/instrumentation/hono.d.mts +2 -86
  97. package/dist/instrumentation/hono.mjs +3 -170
  98. package/dist/instrumentation/http.cjs +11 -189
  99. package/dist/instrumentation/http.d.cts +2 -119
  100. package/dist/instrumentation/http.d.mts +2 -119
  101. package/dist/instrumentation/http.mjs +2 -178
  102. package/dist/instrumentation/index.cjs +47 -56
  103. package/dist/instrumentation/index.d.cts +9 -11
  104. package/dist/instrumentation/index.d.mts +9 -11
  105. package/dist/instrumentation/index.mjs +9 -10
  106. package/dist/instrumentation/middleware.cjs +6 -164
  107. package/dist/instrumentation/middleware.d.cts +2 -83
  108. package/dist/instrumentation/middleware.d.mts +2 -83
  109. package/dist/instrumentation/middleware.mjs +3 -160
  110. package/dist/instrumentation/otel.cjs +3 -137
  111. package/dist/instrumentation/otel.d.cts +2 -97
  112. package/dist/instrumentation/otel.d.mts +2 -97
  113. package/dist/instrumentation/otel.mjs +3 -136
  114. package/dist/instrumentation/setup.cjs +4 -142
  115. package/dist/instrumentation/setup.d.cts +3 -139
  116. package/dist/instrumentation/setup.d.mts +3 -139
  117. package/dist/instrumentation/setup.mjs +3 -139
  118. package/dist/instrumentation/tracing.cjs +10 -114
  119. package/dist/instrumentation/tracing.d.cts +2 -49
  120. package/dist/instrumentation/tracing.d.mts +2 -49
  121. package/dist/instrumentation/tracing.mjs +2 -105
  122. package/dist/logger/console.cjs +12 -18
  123. package/dist/logger/console.cjs.map +1 -1
  124. package/dist/logger/console.d.cts +10 -7
  125. package/dist/logger/console.d.cts.map +1 -1
  126. package/dist/logger/console.d.mts +10 -7
  127. package/dist/logger/console.d.mts.map +1 -1
  128. package/dist/logger/console.mjs +11 -17
  129. package/dist/logger/console.mjs.map +1 -1
  130. package/dist/logger/pino.cjs +5 -6
  131. package/dist/logger/pino.cjs.map +1 -1
  132. package/dist/logger/pino.d.cts +10 -6
  133. package/dist/logger/pino.d.cts.map +1 -1
  134. package/dist/logger/pino.d.mts +10 -6
  135. package/dist/logger/pino.d.mts.map +1 -1
  136. package/dist/logger/pino.mjs +3 -2
  137. package/dist/logger/pino.mjs.map +1 -1
  138. package/dist/memory--BK4iWiv.d.cts +40 -0
  139. package/dist/memory--BK4iWiv.d.cts.map +1 -0
  140. package/dist/memory-6S9H-IF5.mjs +123 -0
  141. package/dist/memory-6S9H-IF5.mjs.map +1 -0
  142. package/dist/memory-B0d_n1g5.cjs +129 -0
  143. package/dist/memory-B0d_n1g5.cjs.map +1 -0
  144. package/dist/memory-DCirEVFW.d.mts +40 -0
  145. package/dist/memory-DCirEVFW.d.mts.map +1 -0
  146. package/dist/metrics/MetricsAggregator.cjs +2 -354
  147. package/dist/metrics/MetricsAggregator.d.cts +2 -1
  148. package/dist/metrics/MetricsAggregator.d.mts +2 -1
  149. package/dist/metrics/MetricsAggregator.mjs +2 -353
  150. package/dist/metrics/index.cjs +4 -3
  151. package/dist/metrics/index.d.cts +4 -2
  152. package/dist/metrics/index.d.mts +4 -2
  153. package/dist/metrics/index.mjs +4 -2
  154. package/dist/metrics/storage/InMemoryMetricsStorage.cjs +3 -240
  155. package/dist/metrics/storage/InMemoryMetricsStorage.d.cts +4 -43
  156. package/dist/metrics/storage/InMemoryMetricsStorage.d.mts +4 -43
  157. package/dist/metrics/storage/InMemoryMetricsStorage.mjs +3 -239
  158. package/dist/metrics/storage/MetricsStorage.cjs +1 -0
  159. package/dist/metrics/storage/MetricsStorage.d.cts +3 -56
  160. package/dist/metrics/storage/MetricsStorage.d.mts +3 -56
  161. package/dist/metrics/storage/MetricsStorage.mjs +1 -1
  162. package/dist/metrics/storage/index.cjs +6 -6
  163. package/dist/metrics/storage/index.d.cts +3 -3
  164. package/dist/metrics/storage/index.d.mts +3 -3
  165. package/dist/metrics/storage/index.mjs +5 -4
  166. package/dist/metrics/storage/types.cjs +2 -34
  167. package/dist/metrics/storage/types.d.cts +2 -207
  168. package/dist/metrics/storage/types.d.mts +2 -207
  169. package/dist/metrics/storage/types.mjs +2 -33
  170. package/dist/metrics-D5YT-Rnq.mjs +0 -0
  171. package/dist/metrics-fhD3l3C3.cjs +0 -0
  172. package/dist/middleware-B2jFUukM.cjs +184 -0
  173. package/dist/middleware-B2jFUukM.cjs.map +1 -0
  174. package/dist/middleware-BTDncHwm.mjs +160 -0
  175. package/dist/middleware-BTDncHwm.mjs.map +1 -0
  176. package/dist/middleware-CA84nsNN.d.cts +74 -0
  177. package/dist/middleware-CA84nsNN.d.cts.map +1 -0
  178. package/dist/middleware-DAceVpfw.d.mts +74 -0
  179. package/dist/middleware-DAceVpfw.d.mts.map +1 -0
  180. package/dist/middy-B6Btl8XE.d.mts +64 -0
  181. package/dist/middy-B6Btl8XE.d.mts.map +1 -0
  182. package/dist/middy-BTR3cyvk.mjs +236 -0
  183. package/dist/middy-BTR3cyvk.mjs.map +1 -0
  184. package/dist/middy-Bq0defVg.d.cts +64 -0
  185. package/dist/middy-Bq0defVg.d.cts.map +1 -0
  186. package/dist/middy-y5Zp27eG.cjs +247 -0
  187. package/dist/middy-y5Zp27eG.cjs.map +1 -0
  188. package/dist/otel-1bJPb2Z7.d.mts +101 -0
  189. package/dist/otel-1bJPb2Z7.d.mts.map +1 -0
  190. package/dist/otel-C1HqHA2O.cjs +136 -0
  191. package/dist/otel-C1HqHA2O.cjs.map +1 -0
  192. package/dist/otel-SBVoVEHr.d.cts +101 -0
  193. package/dist/otel-SBVoVEHr.d.cts.map +1 -0
  194. package/dist/otel-wulj5B-X.mjs +130 -0
  195. package/dist/otel-wulj5B-X.mjs.map +1 -0
  196. package/dist/otlp/hono.cjs +15 -9
  197. package/dist/otlp/hono.cjs.map +1 -1
  198. package/dist/otlp/hono.d.cts +13 -3
  199. package/dist/otlp/hono.d.cts.map +1 -1
  200. package/dist/otlp/hono.d.mts +13 -3
  201. package/dist/otlp/hono.d.mts.map +1 -1
  202. package/dist/otlp/hono.mjs +11 -5
  203. package/dist/otlp/hono.mjs.map +1 -1
  204. package/dist/otlp/index.cjs +11 -11
  205. package/dist/otlp/index.d.cts +7 -4
  206. package/dist/otlp/index.d.mts +7 -4
  207. package/dist/otlp/index.mjs +5 -4
  208. package/dist/otlp/receiver.cjs +4 -88
  209. package/dist/otlp/receiver.d.cts +7 -59
  210. package/dist/otlp/receiver.d.mts +7 -59
  211. package/dist/otlp/receiver.mjs +4 -87
  212. package/dist/otlp/transformer.cjs +5 -214
  213. package/dist/otlp/transformer.d.cts +3 -1
  214. package/dist/otlp/transformer.d.mts +3 -1
  215. package/dist/otlp/transformer.mjs +3 -211
  216. package/dist/otlp/types.cjs +5 -57
  217. package/dist/otlp/types.d.cts +1 -1
  218. package/dist/otlp/types.d.mts +1 -1
  219. package/dist/otlp/types.mjs +2 -53
  220. package/dist/receiver-Cj1lbAOO.cjs +94 -0
  221. package/dist/receiver-Cj1lbAOO.cjs.map +1 -0
  222. package/dist/receiver-CxVd_9CB.mjs +89 -0
  223. package/dist/receiver-CxVd_9CB.mjs.map +1 -0
  224. package/dist/receiver-DLICx5uU.d.cts +63 -0
  225. package/dist/receiver-DLICx5uU.d.cts.map +1 -0
  226. package/dist/receiver-UeZT-H8u.d.mts +63 -0
  227. package/dist/receiver-UeZT-H8u.d.mts.map +1 -0
  228. package/dist/redact-BzkITCNW.mjs +83 -0
  229. package/dist/redact-BzkITCNW.mjs.map +1 -0
  230. package/dist/redact-DVaSSPZT.cjs +95 -0
  231. package/dist/redact-DVaSSPZT.cjs.map +1 -0
  232. package/dist/redact.cjs +3 -84
  233. package/dist/redact.d.cts +8 -4
  234. package/dist/redact.d.cts.map +1 -1
  235. package/dist/redact.d.mts +8 -4
  236. package/dist/redact.d.mts.map +1 -1
  237. package/dist/redact.mjs +2 -80
  238. package/dist/server/hono.cjs +54 -33
  239. package/dist/server/hono.cjs.map +1 -1
  240. package/dist/server/hono.d.cts +14 -19
  241. package/dist/server/hono.d.cts.map +1 -1
  242. package/dist/server/hono.d.mts +14 -19
  243. package/dist/server/hono.d.mts.map +1 -1
  244. package/dist/server/hono.mjs +52 -31
  245. package/dist/server/hono.mjs.map +1 -1
  246. package/dist/setup-B9jM77Qk.mjs +98 -0
  247. package/dist/setup-B9jM77Qk.mjs.map +1 -0
  248. package/dist/setup-Bkxm4g6b.d.mts +87 -0
  249. package/dist/setup-Bkxm4g6b.d.mts.map +1 -0
  250. package/dist/setup-CYpff5B9.cjs +110 -0
  251. package/dist/setup-CYpff5B9.cjs.map +1 -0
  252. package/dist/setup-D58N1f9O.d.cts +87 -0
  253. package/dist/setup-D58N1f9O.d.cts.map +1 -0
  254. package/dist/storage/kysely.cjs +70 -82
  255. package/dist/storage/kysely.cjs.map +1 -1
  256. package/dist/storage/kysely.d.cts +20 -36
  257. package/dist/storage/kysely.d.cts.map +1 -1
  258. package/dist/storage/kysely.d.mts +20 -36
  259. package/dist/storage/kysely.d.mts.map +1 -1
  260. package/dist/storage/kysely.mjs +69 -81
  261. package/dist/storage/kysely.mjs.map +1 -1
  262. package/dist/storage/memory.cjs +2 -122
  263. package/dist/storage/memory.d.cts +3 -36
  264. package/dist/storage/memory.d.mts +3 -36
  265. package/dist/storage/memory.mjs +2 -121
  266. package/dist/tracing-BX8uY2nR.d.cts +53 -0
  267. package/dist/tracing-BX8uY2nR.d.cts.map +1 -0
  268. package/dist/tracing-Bt1zWRlb.cjs +167 -0
  269. package/dist/tracing-Bt1zWRlb.cjs.map +1 -0
  270. package/dist/tracing-Cijm_5NI.mjs +113 -0
  271. package/dist/tracing-Cijm_5NI.mjs.map +1 -0
  272. package/dist/tracing-PnECEbEu.d.mts +53 -0
  273. package/dist/tracing-PnECEbEu.d.mts.map +1 -0
  274. package/dist/transformer-BXQPhzql.mjs +215 -0
  275. package/dist/transformer-BXQPhzql.mjs.map +1 -0
  276. package/dist/transformer-CLGZ0EQc.cjs +232 -0
  277. package/dist/transformer-CLGZ0EQc.cjs.map +1 -0
  278. package/dist/{transformer-BtqjAs0b.d.cts → transformer-CTGsaVfV.d.mts} +8 -4
  279. package/dist/transformer-CTGsaVfV.d.mts.map +1 -0
  280. package/dist/{transformer-DI6t8-YA.d.mts → transformer-ICEbxpFf.d.cts} +8 -4
  281. package/dist/transformer-ICEbxpFf.d.cts.map +1 -0
  282. package/dist/{types-BVujq4zd.d.mts → types-B1EIa_cQ.d.mts} +4 -3
  283. package/dist/types-B1EIa_cQ.d.mts.map +1 -0
  284. package/dist/types-BRzW1NM8.d.cts +166 -0
  285. package/dist/types-BRzW1NM8.d.cts.map +1 -0
  286. package/dist/types-BS3Rx8Sk.d.cts +209 -0
  287. package/dist/types-BS3Rx8Sk.d.cts.map +1 -0
  288. package/dist/types-Bwm_jNU7.mjs +54 -0
  289. package/dist/types-Bwm_jNU7.mjs.map +1 -0
  290. package/dist/types-BzQ78Efw.d.mts +166 -0
  291. package/dist/types-BzQ78Efw.d.mts.map +1 -0
  292. package/dist/types-CbNGXnJE.d.mts +209 -0
  293. package/dist/types-CbNGXnJE.d.mts.map +1 -0
  294. package/dist/{types-DVETVdpa.d.cts → types-CmOB7CLO.d.cts} +7 -6
  295. package/dist/types-CmOB7CLO.d.cts.map +1 -0
  296. package/dist/{types-DVETVdpa.d.mts → types-DBc0q5KD.d.mts} +7 -6
  297. package/dist/types-DBc0q5KD.d.mts.map +1 -0
  298. package/dist/types-Dsh-DIO_.cjs +78 -0
  299. package/dist/types-Dsh-DIO_.cjs.map +1 -0
  300. package/dist/types-ZW-nfWf6.cjs +40 -0
  301. package/dist/types-ZW-nfWf6.cjs.map +1 -0
  302. package/dist/{types-BVujq4zd.d.cts → types-l7Rlb5Mg.d.cts} +4 -3
  303. package/dist/types-l7Rlb5Mg.d.cts.map +1 -0
  304. package/dist/types-ojhnLdwz.mjs +34 -0
  305. package/dist/types-ojhnLdwz.mjs.map +1 -0
  306. package/dist/types.d.cts +1 -1
  307. package/dist/types.d.mts +1 -1
  308. package/dist/types.mjs +0 -1
  309. package/dist/ui-assets-BEXqOQLe.cjs +48 -0
  310. package/dist/ui-assets-BEXqOQLe.cjs.map +1 -0
  311. package/dist/ui-assets-BhTDUsrM.mjs +30 -0
  312. package/dist/ui-assets-BhTDUsrM.mjs.map +1 -0
  313. package/dist/ui-assets.cjs +5 -0
  314. package/dist/ui-assets.d.cts +13 -0
  315. package/dist/ui-assets.d.cts.map +1 -0
  316. package/dist/ui-assets.d.mts +13 -0
  317. package/dist/ui-assets.d.mts.map +1 -0
  318. package/dist/ui-assets.mjs +3 -0
  319. package/package.json +46 -46
  320. package/src/Telescope.ts +561 -0
  321. package/src/__tests__/Telescope.spec.ts +438 -0
  322. package/src/__tests__/pino-transport.spec.ts +115 -0
  323. package/src/__tests__/redact.spec.ts +336 -0
  324. package/src/adapters/__tests__/lambda.spec.ts +318 -0
  325. package/src/adapters/__tests__/middy.spec.ts +741 -0
  326. package/src/adapters/index.ts +22 -0
  327. package/src/adapters/lambda.ts +432 -0
  328. package/src/adapters/middy.ts +402 -0
  329. package/src/adapters/types.ts +181 -0
  330. package/src/core.ts +51 -0
  331. package/src/index.ts +34 -0
  332. package/src/instrumentation/__tests__/core.spec.ts +248 -0
  333. package/src/instrumentation/__tests__/hono.spec.ts +348 -0
  334. package/src/instrumentation/__tests__/middleware.spec.ts +528 -0
  335. package/src/instrumentation/__tests__/otel.spec.ts +291 -0
  336. package/src/instrumentation/__tests__/tracing.spec.ts +208 -0
  337. package/src/instrumentation/core.ts +228 -0
  338. package/src/instrumentation/hono.ts +270 -0
  339. package/src/instrumentation/http.ts +306 -0
  340. package/src/instrumentation/index.ts +90 -0
  341. package/src/instrumentation/middleware.ts +297 -0
  342. package/src/instrumentation/otel.ts +271 -0
  343. package/src/instrumentation/setup.ts +246 -0
  344. package/src/instrumentation/tracing.ts +145 -0
  345. package/src/logger/__tests__/console.spec.ts +366 -0
  346. package/src/logger/__tests__/pino.spec.ts +217 -0
  347. package/src/logger/console.ts +230 -0
  348. package/src/logger/pino.ts +201 -0
  349. package/src/metrics/MetricsAggregator.ts +555 -0
  350. package/src/metrics/__tests__/MetricsAggregator.spec.ts +298 -0
  351. package/src/metrics/index.ts +2 -0
  352. package/src/metrics/storage/InMemoryMetricsStorage.ts +380 -0
  353. package/src/metrics/storage/MetricsStorage.ts +74 -0
  354. package/src/metrics/storage/index.ts +3 -0
  355. package/src/metrics/storage/types.ts +243 -0
  356. package/src/otlp/__tests__/receiver.spec.ts +367 -0
  357. package/src/otlp/__tests__/transformer.spec.ts +455 -0
  358. package/src/otlp/hono.ts +120 -0
  359. package/src/otlp/index.ts +22 -0
  360. package/src/otlp/receiver.ts +162 -0
  361. package/src/otlp/transformer.ts +367 -0
  362. package/src/otlp/types.ts +364 -0
  363. package/src/redact.ts +116 -0
  364. package/src/server/__tests__/hono.spec.ts +814 -0
  365. package/src/server/hono.ts +442 -0
  366. package/src/storage/__tests__/kysely.spec.ts +715 -0
  367. package/src/storage/__tests__/memory.spec.ts +694 -0
  368. package/src/storage/kysely.ts +599 -0
  369. package/src/storage/memory.ts +204 -0
  370. package/src/types.ts +447 -0
  371. package/src/ui-assets.ts +40 -0
  372. package/tsconfig.json +9 -0
  373. package/ui/CHANGELOG.md +7 -0
  374. package/ui/index.html +12 -0
  375. package/ui/node_modules/.bin/tsc +21 -0
  376. package/ui/node_modules/.bin/tsserver +21 -0
  377. package/ui/node_modules/.bin/vite +21 -0
  378. package/ui/package.json +24 -0
  379. package/ui/src/App.tsx +595 -0
  380. package/ui/src/api.ts +88 -0
  381. package/ui/src/components/ExceptionDetail.tsx +100 -0
  382. package/ui/src/components/FilterBar.tsx +162 -0
  383. package/ui/src/components/LogDetail.tsx +91 -0
  384. package/ui/src/components/RequestDetail.tsx +143 -0
  385. package/ui/src/main.tsx +10 -0
  386. package/ui/src/styles.css +11 -0
  387. package/ui/src/types.ts +63 -0
  388. package/ui/src/vite-env.d.ts +1 -0
  389. package/ui/src/vite-plugin-gkm-config.ts +54 -0
  390. package/ui/tsconfig.json +20 -0
  391. package/ui/tsconfig.tsbuildinfo +1 -0
  392. package/ui/vite.config.ts +13 -0
  393. package/dist/MetricsAggregator-BJdIvfEv.d.mts.map +0 -1
  394. package/dist/MetricsAggregator-CnC3oT5q.d.cts.map +0 -1
  395. package/dist/Telescope-BVfDvVvY.d.mts.map +0 -1
  396. package/dist/Telescope-DeqSHfuB.d.cts.map +0 -1
  397. package/dist/Telescope.cjs.map +0 -1
  398. package/dist/Telescope.mjs.map +0 -1
  399. package/dist/adapters/middy.cjs.map +0 -1
  400. package/dist/adapters/middy.d.cts.map +0 -1
  401. package/dist/adapters/middy.d.mts.map +0 -1
  402. package/dist/adapters/middy.mjs.map +0 -1
  403. package/dist/adapters/types.d.cts.map +0 -1
  404. package/dist/adapters/types.d.mts.map +0 -1
  405. package/dist/instrumentation/core.cjs.map +0 -1
  406. package/dist/instrumentation/core.d.cts.map +0 -1
  407. package/dist/instrumentation/core.d.mts.map +0 -1
  408. package/dist/instrumentation/core.mjs.map +0 -1
  409. package/dist/instrumentation/hono.cjs.map +0 -1
  410. package/dist/instrumentation/hono.d.cts.map +0 -1
  411. package/dist/instrumentation/hono.d.mts.map +0 -1
  412. package/dist/instrumentation/hono.mjs.map +0 -1
  413. package/dist/instrumentation/http.cjs.map +0 -1
  414. package/dist/instrumentation/http.d.cts.map +0 -1
  415. package/dist/instrumentation/http.d.mts.map +0 -1
  416. package/dist/instrumentation/http.mjs.map +0 -1
  417. package/dist/instrumentation/middleware.cjs.map +0 -1
  418. package/dist/instrumentation/middleware.d.cts.map +0 -1
  419. package/dist/instrumentation/middleware.d.mts.map +0 -1
  420. package/dist/instrumentation/middleware.mjs.map +0 -1
  421. package/dist/instrumentation/otel.cjs.map +0 -1
  422. package/dist/instrumentation/otel.d.cts.map +0 -1
  423. package/dist/instrumentation/otel.d.mts.map +0 -1
  424. package/dist/instrumentation/otel.mjs.map +0 -1
  425. package/dist/instrumentation/sampler.cjs +0 -54
  426. package/dist/instrumentation/sampler.cjs.map +0 -1
  427. package/dist/instrumentation/sampler.d.cts +0 -38
  428. package/dist/instrumentation/sampler.d.cts.map +0 -1
  429. package/dist/instrumentation/sampler.d.mts +0 -38
  430. package/dist/instrumentation/sampler.d.mts.map +0 -1
  431. package/dist/instrumentation/sampler.mjs +0 -52
  432. package/dist/instrumentation/sampler.mjs.map +0 -1
  433. package/dist/instrumentation/setup.cjs.map +0 -1
  434. package/dist/instrumentation/setup.d.cts.map +0 -1
  435. package/dist/instrumentation/setup.d.mts.map +0 -1
  436. package/dist/instrumentation/setup.mjs.map +0 -1
  437. package/dist/instrumentation/tracing.cjs.map +0 -1
  438. package/dist/instrumentation/tracing.d.cts.map +0 -1
  439. package/dist/instrumentation/tracing.d.mts.map +0 -1
  440. package/dist/instrumentation/tracing.mjs.map +0 -1
  441. package/dist/instrumentation/trust.cjs +0 -107
  442. package/dist/instrumentation/trust.cjs.map +0 -1
  443. package/dist/instrumentation/trust.d.cts +0 -57
  444. package/dist/instrumentation/trust.d.cts.map +0 -1
  445. package/dist/instrumentation/trust.d.mts +0 -57
  446. package/dist/instrumentation/trust.d.mts.map +0 -1
  447. package/dist/instrumentation/trust.mjs +0 -104
  448. package/dist/instrumentation/trust.mjs.map +0 -1
  449. package/dist/metrics/MetricsAggregator.cjs.map +0 -1
  450. package/dist/metrics/MetricsAggregator.mjs.map +0 -1
  451. package/dist/metrics/storage/InMemoryMetricsStorage.cjs.map +0 -1
  452. package/dist/metrics/storage/InMemoryMetricsStorage.d.cts.map +0 -1
  453. package/dist/metrics/storage/InMemoryMetricsStorage.d.mts.map +0 -1
  454. package/dist/metrics/storage/InMemoryMetricsStorage.mjs.map +0 -1
  455. package/dist/metrics/storage/MetricsStorage.d.cts.map +0 -1
  456. package/dist/metrics/storage/MetricsStorage.d.mts.map +0 -1
  457. package/dist/metrics/storage/types.cjs.map +0 -1
  458. package/dist/metrics/storage/types.d.cts.map +0 -1
  459. package/dist/metrics/storage/types.d.mts.map +0 -1
  460. package/dist/metrics/storage/types.mjs.map +0 -1
  461. package/dist/otlp/receiver.cjs.map +0 -1
  462. package/dist/otlp/receiver.d.cts.map +0 -1
  463. package/dist/otlp/receiver.d.mts.map +0 -1
  464. package/dist/otlp/receiver.mjs.map +0 -1
  465. package/dist/otlp/transformer.cjs.map +0 -1
  466. package/dist/otlp/transformer.mjs.map +0 -1
  467. package/dist/otlp/types.cjs.map +0 -1
  468. package/dist/otlp/types.mjs.map +0 -1
  469. package/dist/redact.cjs.map +0 -1
  470. package/dist/redact.mjs.map +0 -1
  471. package/dist/storage/memory.cjs.map +0 -1
  472. package/dist/storage/memory.d.cts.map +0 -1
  473. package/dist/storage/memory.d.mts.map +0 -1
  474. package/dist/storage/memory.mjs.map +0 -1
  475. package/dist/transformer-BtqjAs0b.d.cts.map +0 -1
  476. package/dist/transformer-DI6t8-YA.d.mts.map +0 -1
  477. package/dist/types-BVujq4zd.d.cts.map +0 -1
  478. package/dist/types-BVujq4zd.d.mts.map +0 -1
  479. package/dist/types-DVETVdpa.d.cts.map +0 -1
  480. package/dist/types-DVETVdpa.d.mts.map +0 -1
@@ -1,86 +1,2 @@
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
- * The origins whose `traceparent` is continued: the API's own sites, the
32
- * same list its CORS allows. A request from any other origin starts a new
33
- * trace linked to the one it claimed.
34
- *
35
- * A function is read on each request, for a server that learns its origins
36
- * only once the app has loaded its configuration.
37
- */
38
- trustedOrigins?: readonly string[] | (() => readonly string[] | undefined);
39
- /**
40
- * Whether a request with no `Origin` from an internal caller continues its
41
- * `traceparent` — another service on the private network (see `./trust`):
42
- * no `Origin`, no proxy's forwarding header, and a loopback or private
43
- * peer address, read from `@hono/node-server`'s socket.
44
- *
45
- * `false` trusts no caller without an origin; a function decides itself.
46
- * @default true
47
- */
48
- internalCallers?: boolean | ((c: Context) => boolean);
49
- }
50
- /**
51
- * Get the current span from Hono context
52
- */
53
- export declare function getSpanFromContext(c: Context): Span | undefined;
54
- /**
55
- * Get the current trace context from Hono context
56
- */
57
- export declare function getTraceContextFromHono(c: Context): any;
58
- /**
59
- * Create a telemetry middleware for Hono applications
60
- *
61
- * @example
62
- * ```typescript
63
- * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
64
- *
65
- * const app = new Hono();
66
- * app.use('*', honoTelemetryMiddleware());
67
- * ```
68
- */
69
- export declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
70
- /**
71
- * Run a function within the span context from Hono context
72
- *
73
- * @example
74
- * ```typescript
75
- * app.get('/api/users', async (c) => {
76
- * return withHonoSpanContext(c, async () => {
77
- * // Any spans created here will be children of the request span
78
- * const users = await fetchUsers();
79
- * return c.json(users);
80
- * });
81
- * });
82
- * ```
83
- */
84
- export declare function withHonoSpanContext<T>(c: Context, fn: () => Promise<T>): Promise<T>;
85
- //#endregion
86
- //# sourceMappingURL=hono.d.cts.map
1
+ import { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono-CemCKU87.cjs";
2
+ export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
@@ -1,86 +1,2 @@
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
- * The origins whose `traceparent` is continued: the API's own sites, the
32
- * same list its CORS allows. A request from any other origin starts a new
33
- * trace linked to the one it claimed.
34
- *
35
- * A function is read on each request, for a server that learns its origins
36
- * only once the app has loaded its configuration.
37
- */
38
- trustedOrigins?: readonly string[] | (() => readonly string[] | undefined);
39
- /**
40
- * Whether a request with no `Origin` from an internal caller continues its
41
- * `traceparent` — another service on the private network (see `./trust`):
42
- * no `Origin`, no proxy's forwarding header, and a loopback or private
43
- * peer address, read from `@hono/node-server`'s socket.
44
- *
45
- * `false` trusts no caller without an origin; a function decides itself.
46
- * @default true
47
- */
48
- internalCallers?: boolean | ((c: Context$1) => boolean);
49
- }
50
- /**
51
- * Get the current span from Hono context
52
- */
53
- export declare function getSpanFromContext(c: Context$1): Span | undefined;
54
- /**
55
- * Get the current trace context from Hono context
56
- */
57
- export declare function getTraceContextFromHono(c: Context$1): any;
58
- /**
59
- * Create a telemetry middleware for Hono applications
60
- *
61
- * @example
62
- * ```typescript
63
- * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
64
- *
65
- * const app = new Hono();
66
- * app.use('*', honoTelemetryMiddleware());
67
- * ```
68
- */
69
- export declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
70
- /**
71
- * Run a function within the span context from Hono context
72
- *
73
- * @example
74
- * ```typescript
75
- * app.get('/api/users', async (c) => {
76
- * return withHonoSpanContext(c, async () => {
77
- * // Any spans created here will be children of the request span
78
- * const users = await fetchUsers();
79
- * return c.json(users);
80
- * });
81
- * });
82
- * ```
83
- */
84
- export declare function withHonoSpanContext<T>(c: Context$1, fn: () => Promise<T>): Promise<T>;
85
- //#endregion
86
- //# sourceMappingURL=hono.d.mts.map
1
+ import { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono--uKQ7Jgi.mjs";
2
+ export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
@@ -1,171 +1,4 @@
1
- import { createHttpServerSpan, endHttpSpan, incomingTraceContext } from "./http.mjs";
2
- import { isInternalCaller, isTrustedOrigin } from "./trust.mjs";
3
- import { context, trace } from "@opentelemetry/api";
4
- import { routePath } from "hono/route";
5
- //#region src/instrumentation/hono.ts
6
- const SPAN_KEY = "telemetry.span";
7
- const CONTEXT_KEY = "telemetry.context";
8
- /**
9
- * Get the current span from Hono context
10
- */
11
- function getSpanFromContext(c) {
12
- return c.get(SPAN_KEY);
13
- }
14
- /**
15
- * Get the current trace context from Hono context
16
- */
17
- function getTraceContextFromHono(c) {
18
- return c.get(CONTEXT_KEY);
19
- }
20
- /**
21
- * Create a telemetry middleware for Hono applications
22
- *
23
- * @example
24
- * ```typescript
25
- * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
26
- *
27
- * const app = new Hono();
28
- * app.use('*', honoTelemetryMiddleware());
29
- * ```
30
- */
31
- function honoTelemetryMiddleware(options = {}) {
32
- return async (c, next) => {
33
- if (options.ignorePaths && shouldIgnorePath(c.req.path, options.ignorePaths)) return next();
34
- if (options.shouldSkip?.(c)) return next();
35
- const headers = {};
36
- c.req.raw.headers.forEach((value, key) => {
37
- headers[key] = value;
38
- });
39
- const { parent: parentContext, links } = incomingTraceContext(headers, isTrustedCaller(c, options));
40
- const attrs = buildHonoSpanAttributes(c, options);
41
- const span = createHttpServerSpan(attrs, parentContext, links);
42
- const spanContext = trace.setSpan(parentContext, span);
43
- c.set(SPAN_KEY, span);
44
- c.set(CONTEXT_KEY, spanContext);
45
- if (options.recordBody) try {
46
- const body = await c.req.text();
47
- if (body) span.setAttribute("http.request.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
48
- } catch {}
49
- try {
50
- await context.with(spanContext, async () => {
51
- await next();
52
- });
53
- nameAfterRoute(c, span);
54
- const statusCode = c.res.status;
55
- if (options.recordResponseBody) try {
56
- const body = await c.res.clone().text();
57
- if (body) span.setAttribute("http.response.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
58
- } catch {}
59
- endHttpSpan(span, { statusCode }, c.error);
60
- } catch (error) {
61
- nameAfterRoute(c, span);
62
- endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
63
- throw error;
64
- }
65
- };
66
- }
67
- /**
68
- * Whether this request's `traceparent` is continued: from one of the API's
69
- * own origins, or from an internal caller.
70
- */
71
- function isTrustedCaller(c, options) {
72
- const origin = c.req.header("origin");
73
- if (origin) {
74
- const trusted = typeof options.trustedOrigins === "function" ? options.trustedOrigins() : options.trustedOrigins;
75
- return isTrustedOrigin(origin, trusted);
76
- }
77
- const internal = options.internalCallers ?? true;
78
- if (typeof internal === "function") return internal(c);
79
- if (!internal) return false;
80
- return isInternalCaller({
81
- headers: c.req.raw.headers,
82
- remoteAddress: remoteAddressOf(c)
83
- });
84
- }
85
- /** The TCP peer's address under `@hono/node-server`, or undefined. */
86
- function remoteAddressOf(c) {
87
- return c.env?.incoming?.socket?.remoteAddress;
88
- }
89
- /**
90
- * The route the request matched, once the handler has run — `/users/:id`,
91
- * never `/users/42` — or undefined when only middleware ran (a 404).
92
- *
93
- * Read after `next()`: before it, the route is this middleware's own `*`.
94
- */
95
- function matchedRoute(c) {
96
- const path = routePath(c);
97
- return path && !path.includes("*") ? path : void 0;
98
- }
99
- /** `GET /users/:id`, or the bare method when no route matched. */
100
- function nameAfterRoute(c, span) {
101
- const route = matchedRoute(c);
102
- if (route) {
103
- span.setAttribute("http.route", route);
104
- span.updateName(`${c.req.method} ${route}`);
105
- } else span.updateName(c.req.method);
106
- }
107
- /**
108
- * Build span attributes from Hono context
109
- */
110
- function buildHonoSpanAttributes(c, options) {
111
- const req = c.req;
112
- const url = new URL(req.url);
113
- const attrs = {
114
- method: req.method,
115
- path: url.pathname,
116
- host: url.host,
117
- scheme: url.protocol.replace(":", ""),
118
- userAgent: req.header("user-agent"),
119
- clientIp: getClientIp(c),
120
- requestId: req.header("x-request-id") || req.header("x-amzn-requestid")
121
- };
122
- if (options.getUserId) {
123
- const userId = options.getUserId(c);
124
- if (userId) attrs.user = { userId };
125
- }
126
- return attrs;
127
- }
128
- /**
129
- * Extract client IP from Hono context
130
- */
131
- function getClientIp(c) {
132
- const xForwardedFor = c.req.header("x-forwarded-for");
133
- if (xForwardedFor) return xForwardedFor.split(",")[0]?.trim();
134
- const xRealIp = c.req.header("x-real-ip");
135
- if (xRealIp) return xRealIp;
136
- const cfConnectingIp = c.req.header("cf-connecting-ip");
137
- if (cfConnectingIp) return cfConnectingIp;
138
- }
139
- /**
140
- * Check if path should be ignored
141
- */
142
- function shouldIgnorePath(path, ignorePaths) {
143
- for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
144
- const prefix = pattern.slice(0, -1);
145
- if (path.startsWith(prefix)) return true;
146
- } else if (path === pattern) return true;
147
- return false;
148
- }
149
- /**
150
- * Run a function within the span context from Hono context
151
- *
152
- * @example
153
- * ```typescript
154
- * app.get('/api/users', async (c) => {
155
- * return withHonoSpanContext(c, async () => {
156
- * // Any spans created here will be children of the request span
157
- * const users = await fetchUsers();
158
- * return c.json(users);
159
- * });
160
- * });
161
- * ```
162
- */
163
- async function withHonoSpanContext(c, fn) {
164
- const ctx = getTraceContextFromHono(c);
165
- if (!ctx) return fn();
166
- return context.with(ctx, fn);
167
- }
168
- //#endregion
169
- export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
1
+ import "../http-DQzgLczm.mjs";
2
+ import { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext } from "../hono-DxhvnVbF.mjs";
170
3
 
171
- //# sourceMappingURL=hono.mjs.map
4
+ export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
@@ -1,190 +1,12 @@
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
- * The trace a request's span belongs to.
49
- *
50
- * From a trusted caller (see `./trust`) its `traceparent` is continued, and
51
- * the span is its child. From anyone else the span starts a new trace — no
52
- * parent, no baggage — with a link to the context the caller claimed, so the
53
- * hop can still be followed without the caller choosing this trace.
54
- */
55
- function incomingTraceContext(headers, trusted) {
56
- const extracted = extractTraceContext(headers);
57
- if (trusted) return {
58
- parent: extracted,
59
- links: []
60
- };
61
- const claimed = _opentelemetry_api.trace.getSpanContext(extracted);
62
- return {
63
- parent: _opentelemetry_api.trace.deleteSpan(_opentelemetry_api.context.active()),
64
- links: claimed && (0, _opentelemetry_api.isSpanContextValid)(claimed) ? [{
65
- context: claimed,
66
- attributes: { "gkm.trace.untrusted_parent": true }
67
- }] : []
68
- };
69
- }
70
- /**
71
- * Inject trace context into HTTP headers
72
- */
73
- function injectTraceContext(headers, ctx) {
74
- const result = { ...headers };
75
- _opentelemetry_api.propagation.inject(ctx ?? _opentelemetry_api.context.active(), result);
76
- return result;
77
- }
78
- /**
79
- * Create an HTTP server span for an incoming request
80
- */
81
- function createHttpServerSpan(attrs, parentContext, links) {
82
- const tracer = getConstructsTracer();
83
- const spanName = attrs.route ? `${attrs.method} ${attrs.route}` : `${attrs.method} ${attrs.path || "/"}`;
84
- const ctx = parentContext ?? _opentelemetry_api.context.active();
85
- return tracer.startSpan(spanName, {
86
- kind: _opentelemetry_api.SpanKind.SERVER,
87
- attributes: toOtelAttributes(attrs),
88
- ...links?.length ? { links } : {}
89
- }, ctx);
90
- }
91
- /**
92
- * End an HTTP span with response data
93
- */
94
- function endHttpSpan(span, response, error) {
95
- span.setAttribute("http.response.status_code", response.statusCode);
96
- if (response.responseSize) span.setAttribute("http.response.body.size", response.responseSize);
97
- if (error) {
98
- span.recordException(error);
99
- span.setStatus({
100
- code: _opentelemetry_api.SpanStatusCode.ERROR,
101
- message: error.message
102
- });
103
- } else if (response.statusCode >= 500) span.setStatus({
104
- code: _opentelemetry_api.SpanStatusCode.ERROR,
105
- message: `HTTP ${response.statusCode}`
106
- });
107
- else if (response.statusCode < 400) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
108
- span.end();
109
- }
110
- /**
111
- * Execute a function within an HTTP server span context
112
- *
113
- * @example
114
- * ```typescript
115
- * const result = await withHttpSpan(
116
- * { method: 'GET', path: '/users', route: '/users' },
117
- * async (span) => {
118
- * const users = await getUsers();
119
- * return { statusCode: 200, body: users };
120
- * }
121
- * );
122
- * ```
123
- */
124
- async function withHttpSpan(attrs, fn, parentContext) {
125
- const span = createHttpServerSpan(attrs, parentContext);
126
- try {
127
- const result = await _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(parentContext ?? _opentelemetry_api.context.active(), span), () => fn(span));
128
- endHttpSpan(span, { statusCode: result.statusCode ?? 200 });
129
- return result;
130
- } catch (error) {
131
- endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
132
- throw error;
133
- }
134
- }
135
- /**
136
- * Create a child span for internal operations (middleware, handlers, etc.)
137
- */
138
- function createChildSpan(name, attributes) {
139
- return getConstructsTracer().startSpan(name, {
140
- kind: _opentelemetry_api.SpanKind.INTERNAL,
141
- attributes
142
- });
143
- }
144
- /**
145
- * Execute a function within a child span
146
- */
147
- async function withChildSpan(name, fn, attributes) {
148
- const span = createChildSpan(name, attributes);
149
- try {
150
- const result = await _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(_opentelemetry_api.context.active(), span), () => fn(span));
151
- span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
152
- return result;
153
- } catch (error) {
154
- span.setStatus({
155
- code: _opentelemetry_api.SpanStatusCode.ERROR,
156
- message: error instanceof Error ? error.message : "Unknown error"
157
- });
158
- span.recordException(error instanceof Error ? error : new Error(String(error)));
159
- throw error;
160
- } finally {
161
- span.end();
162
- }
163
- }
164
- /**
165
- * Check if tracing is enabled (OpenTelemetry API is available and configured)
166
- */
167
- function isTracingEnabled() {
168
- try {
169
- const span = _opentelemetry_api.trace.getTracer(TRACER_NAME).startSpan("test");
170
- const isReal = span.spanContext().traceId !== "00000000000000000000000000000000";
171
- span.end();
172
- return isReal;
173
- } catch {
174
- return false;
175
- }
176
- }
177
- //#endregion
178
- exports.createChildSpan = createChildSpan;
179
- exports.createHttpServerSpan = createHttpServerSpan;
180
- exports.endHttpSpan = endHttpSpan;
181
- exports.extractTraceContext = extractTraceContext;
182
- exports.getConstructsTracer = getConstructsTracer;
183
- exports.incomingTraceContext = incomingTraceContext;
184
- exports.injectTraceContext = injectTraceContext;
185
- exports.isTracingEnabled = isTracingEnabled;
186
- exports.toOtelAttributes = toOtelAttributes;
187
- exports.withChildSpan = withChildSpan;
188
- exports.withHttpSpan = withHttpSpan;
1
+ const require_http = require('../http-D_Z8sYXZ.cjs');
189
2
 
190
- //# sourceMappingURL=http.cjs.map
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;
@@ -1,119 +1,2 @@
1
- import { Attributes, Context, Link, Span } from "@opentelemetry/api";
2
- //#region src/instrumentation/http.d.ts
3
- /**
4
- * HTTP request attributes following OpenTelemetry semantic conventions
5
- */
6
- export interface HttpRequestAttributes {
7
- method: string;
8
- url?: string;
9
- path?: string;
10
- route?: string;
11
- host?: string;
12
- scheme?: 'http' | 'https';
13
- userAgent?: string;
14
- clientIp?: string;
15
- requestId?: string;
16
- }
17
- /**
18
- * HTTP response attributes
19
- */
20
- export interface HttpResponseAttributes {
21
- statusCode: number;
22
- responseSize?: number;
23
- }
24
- /**
25
- * Endpoint-specific attributes
26
- */
27
- export interface EndpointAttributes {
28
- name?: string;
29
- operationId?: string;
30
- tags?: string[];
31
- }
32
- /**
33
- * User/session attributes
34
- */
35
- export interface UserAttributes {
36
- userId?: string;
37
- sessionId?: string;
38
- roles?: string[];
39
- }
40
- /**
41
- * Full span attributes for HTTP requests
42
- */
43
- export interface HttpSpanAttributes extends HttpRequestAttributes {
44
- response?: HttpResponseAttributes;
45
- endpoint?: EndpointAttributes;
46
- user?: UserAttributes;
47
- custom?: Attributes;
48
- }
49
- /**
50
- * Get or create a tracer for constructs instrumentation
51
- */
52
- export declare function getConstructsTracer(): import("@opentelemetry/api").Tracer;
53
- /**
54
- * Convert HTTP attributes to OpenTelemetry semantic conventions
55
- */
56
- export declare function toOtelAttributes(attrs: HttpSpanAttributes): Attributes;
57
- /**
58
- * Extract trace context from HTTP headers
59
- */
60
- export declare function extractTraceContext(headers: Record<string, string | string[] | undefined>): Context;
61
- /** Where a request's span goes: under a parent, or a new root with links. */
62
- export interface IncomingTraceContext {
63
- /** The context the request span starts in. */
64
- parent: Context;
65
- /** The untrusted caller's context, linked rather than continued. */
66
- links: Link[];
67
- }
68
- /**
69
- * The trace a request's span belongs to.
70
- *
71
- * From a trusted caller (see `./trust`) its `traceparent` is continued, and
72
- * the span is its child. From anyone else the span starts a new trace — no
73
- * parent, no baggage — with a link to the context the caller claimed, so the
74
- * hop can still be followed without the caller choosing this trace.
75
- */
76
- export declare function incomingTraceContext(headers: Record<string, string | string[] | undefined>, trusted: boolean): IncomingTraceContext;
77
- /**
78
- * Inject trace context into HTTP headers
79
- */
80
- export declare function injectTraceContext(headers: Record<string, string>, ctx?: Context): Record<string, string>;
81
- /**
82
- * Create an HTTP server span for an incoming request
83
- */
84
- export declare function createHttpServerSpan(attrs: HttpSpanAttributes, parentContext?: Context, links?: Link[]): Span;
85
- /**
86
- * End an HTTP span with response data
87
- */
88
- export declare function endHttpSpan(span: Span, response: HttpResponseAttributes, error?: Error): void;
89
- /**
90
- * Execute a function within an HTTP server span context
91
- *
92
- * @example
93
- * ```typescript
94
- * const result = await withHttpSpan(
95
- * { method: 'GET', path: '/users', route: '/users' },
96
- * async (span) => {
97
- * const users = await getUsers();
98
- * return { statusCode: 200, body: users };
99
- * }
100
- * );
101
- * ```
102
- */
103
- export declare function withHttpSpan<T>(attrs: HttpSpanAttributes, fn: (span: Span) => Promise<T & {
104
- statusCode?: number;
105
- }>, parentContext?: Context): Promise<T>;
106
- /**
107
- * Create a child span for internal operations (middleware, handlers, etc.)
108
- */
109
- export declare function createChildSpan(name: string, attributes?: Attributes): Span;
110
- /**
111
- * Execute a function within a child span
112
- */
113
- export declare function withChildSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Attributes): Promise<T>;
114
- /**
115
- * Check if tracing is enabled (OpenTelemetry API is available and configured)
116
- */
117
- export declare function isTracingEnabled(): boolean;
118
- //#endregion
119
- //# sourceMappingURL=http.d.cts.map
1
+ import { EndpointAttributes, HttpRequestAttributes, HttpResponseAttributes, HttpSpanAttributes, UserAttributes, createChildSpan, createHttpServerSpan, endHttpSpan, extractTraceContext, getConstructsTracer, injectTraceContext, isTracingEnabled, toOtelAttributes, withChildSpan, withHttpSpan } from "../http-Dvca6fC3.cjs";
2
+ export { EndpointAttributes, HttpRequestAttributes, HttpResponseAttributes, HttpSpanAttributes, UserAttributes, createChildSpan, createHttpServerSpan, endHttpSpan, extractTraceContext, getConstructsTracer, injectTraceContext, isTracingEnabled, toOtelAttributes, withChildSpan, withHttpSpan };