@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.
- package/CHANGELOG.md +79 -0
- package/README.md +18 -28
- package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts +47 -0
- package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts.map +1 -0
- package/dist/InMemoryMetricsStorage-C4drxT7G.mjs +247 -0
- package/dist/InMemoryMetricsStorage-C4drxT7G.mjs.map +1 -0
- package/dist/InMemoryMetricsStorage-D0njWUSi.cjs +252 -0
- package/dist/InMemoryMetricsStorage-D0njWUSi.cjs.map +1 -0
- package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts +47 -0
- package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts.map +1 -0
- package/dist/{MetricsAggregator-BJdIvfEv.d.mts → MetricsAggregator-4SqelGcG.d.cts} +6 -3
- package/dist/MetricsAggregator-4SqelGcG.d.cts.map +1 -0
- package/dist/MetricsAggregator-B7lUICdH.cjs +363 -0
- package/dist/MetricsAggregator-B7lUICdH.cjs.map +1 -0
- package/dist/{MetricsAggregator-CnC3oT5q.d.cts → MetricsAggregator-DZrW8ls6.d.mts} +6 -3
- package/dist/MetricsAggregator-DZrW8ls6.d.mts.map +1 -0
- package/dist/MetricsAggregator-S3DQWNas.mjs +357 -0
- package/dist/MetricsAggregator-S3DQWNas.mjs.map +1 -0
- package/dist/MetricsStorage-B86e4131.d.cts +60 -0
- package/dist/MetricsStorage-B86e4131.d.cts.map +1 -0
- package/dist/MetricsStorage-BWyP2_12.d.mts +60 -0
- package/dist/MetricsStorage-BWyP2_12.d.mts.map +1 -0
- package/dist/MetricsStorage-BypQXWiv.mjs +0 -0
- package/dist/MetricsStorage-Or8pVCe4.cjs +0 -0
- package/dist/Telescope-Cs3fv8jt.cjs +395 -0
- package/dist/Telescope-Cs3fv8jt.cjs.map +1 -0
- package/dist/{Telescope-BVfDvVvY.d.mts → Telescope-D4nmwDRA.d.cts} +7 -4
- package/dist/Telescope-D4nmwDRA.d.cts.map +1 -0
- package/dist/Telescope-Dh5av3FC.mjs +389 -0
- package/dist/Telescope-Dh5av3FC.mjs.map +1 -0
- package/dist/{Telescope-DeqSHfuB.d.cts → Telescope-Dl6VSfxd.d.mts} +7 -4
- package/dist/Telescope-Dl6VSfxd.d.mts.map +1 -0
- package/dist/Telescope.cjs +4 -385
- package/dist/Telescope.d.cts +3 -1
- package/dist/Telescope.d.mts +3 -1
- package/dist/Telescope.mjs +4 -384
- package/dist/adapters/index.d.cts +2 -2
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.mjs +0 -1
- package/dist/adapters/lambda.cjs +10 -9
- package/dist/adapters/lambda.cjs.map +1 -1
- package/dist/adapters/lambda.d.cts +13 -9
- package/dist/adapters/lambda.d.cts.map +1 -1
- package/dist/adapters/lambda.d.mts +13 -9
- package/dist/adapters/lambda.d.mts.map +1 -1
- package/dist/adapters/lambda.mjs +4 -3
- package/dist/adapters/lambda.mjs.map +1 -1
- package/dist/adapters/middy.cjs +4 -236
- package/dist/adapters/middy.d.cts +5 -60
- package/dist/adapters/middy.d.mts +5 -60
- package/dist/adapters/middy.mjs +3 -234
- package/dist/adapters/types.d.cts +2 -162
- package/dist/adapters/types.d.mts +2 -162
- package/dist/adapters/types.mjs +0 -1
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → chunk-CUT6urMc.cjs} +10 -8
- package/dist/core--quSp5Qr.d.mts +78 -0
- package/dist/core--quSp5Qr.d.mts.map +1 -0
- package/dist/core-B4Jpia5H.d.cts +78 -0
- package/dist/core-B4Jpia5H.d.cts.map +1 -0
- package/dist/core-CtVHRJGv.cjs +199 -0
- package/dist/core-CtVHRJGv.cjs.map +1 -0
- package/dist/core-D6hJ6exL.mjs +139 -0
- package/dist/core-D6hJ6exL.mjs.map +1 -0
- package/dist/core.cjs +22 -22
- package/dist/core.d.cts +4 -4
- package/dist/core.d.mts +4 -4
- package/dist/core.mjs +4 -3
- package/dist/hono--uKQ7Jgi.d.mts +71 -0
- package/dist/hono--uKQ7Jgi.d.mts.map +1 -0
- package/dist/hono-C4EgpbKQ.cjs +160 -0
- package/dist/hono-C4EgpbKQ.cjs.map +1 -0
- package/dist/hono-CemCKU87.d.cts +71 -0
- package/dist/hono-CemCKU87.d.cts.map +1 -0
- package/dist/hono-DxhvnVbF.mjs +136 -0
- package/dist/hono-DxhvnVbF.mjs.map +1 -0
- package/dist/http-BiNtg85L.d.mts +107 -0
- package/dist/http-BiNtg85L.d.mts.map +1 -0
- package/dist/http-DQzgLczm.mjs +159 -0
- package/dist/http-DQzgLczm.mjs.map +1 -0
- package/dist/http-D_Z8sYXZ.cjs +219 -0
- package/dist/http-D_Z8sYXZ.cjs.map +1 -0
- package/dist/http-Dvca6fC3.d.cts +107 -0
- package/dist/http-Dvca6fC3.d.cts.map +1 -0
- package/dist/index-BL32-cvv.d.cts +1 -0
- package/dist/index-CsuikFeJ.d.mts +1 -0
- package/dist/index.cjs +9 -8
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +7 -5
- package/dist/instrumentation/core.cjs +11 -147
- package/dist/instrumentation/core.d.cts +3 -74
- package/dist/instrumentation/core.d.mts +3 -74
- package/dist/instrumentation/core.mjs +2 -137
- package/dist/instrumentation/hono.cjs +6 -174
- package/dist/instrumentation/hono.d.cts +2 -86
- package/dist/instrumentation/hono.d.mts +2 -86
- package/dist/instrumentation/hono.mjs +3 -170
- package/dist/instrumentation/http.cjs +11 -189
- package/dist/instrumentation/http.d.cts +2 -119
- package/dist/instrumentation/http.d.mts +2 -119
- package/dist/instrumentation/http.mjs +2 -178
- package/dist/instrumentation/index.cjs +47 -56
- package/dist/instrumentation/index.d.cts +9 -11
- package/dist/instrumentation/index.d.mts +9 -11
- package/dist/instrumentation/index.mjs +9 -10
- package/dist/instrumentation/middleware.cjs +6 -164
- package/dist/instrumentation/middleware.d.cts +2 -83
- package/dist/instrumentation/middleware.d.mts +2 -83
- package/dist/instrumentation/middleware.mjs +3 -160
- package/dist/instrumentation/otel.cjs +3 -137
- package/dist/instrumentation/otel.d.cts +2 -97
- package/dist/instrumentation/otel.d.mts +2 -97
- package/dist/instrumentation/otel.mjs +3 -136
- package/dist/instrumentation/setup.cjs +4 -142
- package/dist/instrumentation/setup.d.cts +3 -139
- package/dist/instrumentation/setup.d.mts +3 -139
- package/dist/instrumentation/setup.mjs +3 -139
- package/dist/instrumentation/tracing.cjs +10 -114
- package/dist/instrumentation/tracing.d.cts +2 -49
- package/dist/instrumentation/tracing.d.mts +2 -49
- package/dist/instrumentation/tracing.mjs +2 -105
- package/dist/logger/console.cjs +12 -18
- package/dist/logger/console.cjs.map +1 -1
- package/dist/logger/console.d.cts +10 -7
- package/dist/logger/console.d.cts.map +1 -1
- package/dist/logger/console.d.mts +10 -7
- package/dist/logger/console.d.mts.map +1 -1
- package/dist/logger/console.mjs +11 -17
- package/dist/logger/console.mjs.map +1 -1
- package/dist/logger/pino.cjs +5 -6
- package/dist/logger/pino.cjs.map +1 -1
- package/dist/logger/pino.d.cts +10 -6
- package/dist/logger/pino.d.cts.map +1 -1
- package/dist/logger/pino.d.mts +10 -6
- package/dist/logger/pino.d.mts.map +1 -1
- package/dist/logger/pino.mjs +3 -2
- package/dist/logger/pino.mjs.map +1 -1
- package/dist/memory--BK4iWiv.d.cts +40 -0
- package/dist/memory--BK4iWiv.d.cts.map +1 -0
- package/dist/memory-6S9H-IF5.mjs +123 -0
- package/dist/memory-6S9H-IF5.mjs.map +1 -0
- package/dist/memory-B0d_n1g5.cjs +129 -0
- package/dist/memory-B0d_n1g5.cjs.map +1 -0
- package/dist/memory-DCirEVFW.d.mts +40 -0
- package/dist/memory-DCirEVFW.d.mts.map +1 -0
- package/dist/metrics/MetricsAggregator.cjs +2 -354
- package/dist/metrics/MetricsAggregator.d.cts +2 -1
- package/dist/metrics/MetricsAggregator.d.mts +2 -1
- package/dist/metrics/MetricsAggregator.mjs +2 -353
- package/dist/metrics/index.cjs +4 -3
- package/dist/metrics/index.d.cts +4 -2
- package/dist/metrics/index.d.mts +4 -2
- package/dist/metrics/index.mjs +4 -2
- package/dist/metrics/storage/InMemoryMetricsStorage.cjs +3 -240
- package/dist/metrics/storage/InMemoryMetricsStorage.d.cts +4 -43
- package/dist/metrics/storage/InMemoryMetricsStorage.d.mts +4 -43
- package/dist/metrics/storage/InMemoryMetricsStorage.mjs +3 -239
- package/dist/metrics/storage/MetricsStorage.cjs +1 -0
- package/dist/metrics/storage/MetricsStorage.d.cts +3 -56
- package/dist/metrics/storage/MetricsStorage.d.mts +3 -56
- package/dist/metrics/storage/MetricsStorage.mjs +1 -1
- package/dist/metrics/storage/index.cjs +6 -6
- package/dist/metrics/storage/index.d.cts +3 -3
- package/dist/metrics/storage/index.d.mts +3 -3
- package/dist/metrics/storage/index.mjs +5 -4
- package/dist/metrics/storage/types.cjs +2 -34
- package/dist/metrics/storage/types.d.cts +2 -207
- package/dist/metrics/storage/types.d.mts +2 -207
- package/dist/metrics/storage/types.mjs +2 -33
- package/dist/metrics-D5YT-Rnq.mjs +0 -0
- package/dist/metrics-fhD3l3C3.cjs +0 -0
- package/dist/middleware-B2jFUukM.cjs +184 -0
- package/dist/middleware-B2jFUukM.cjs.map +1 -0
- package/dist/middleware-BTDncHwm.mjs +160 -0
- package/dist/middleware-BTDncHwm.mjs.map +1 -0
- package/dist/middleware-CA84nsNN.d.cts +74 -0
- package/dist/middleware-CA84nsNN.d.cts.map +1 -0
- package/dist/middleware-DAceVpfw.d.mts +74 -0
- package/dist/middleware-DAceVpfw.d.mts.map +1 -0
- package/dist/middy-B6Btl8XE.d.mts +64 -0
- package/dist/middy-B6Btl8XE.d.mts.map +1 -0
- package/dist/middy-BTR3cyvk.mjs +236 -0
- package/dist/middy-BTR3cyvk.mjs.map +1 -0
- package/dist/middy-Bq0defVg.d.cts +64 -0
- package/dist/middy-Bq0defVg.d.cts.map +1 -0
- package/dist/middy-y5Zp27eG.cjs +247 -0
- package/dist/middy-y5Zp27eG.cjs.map +1 -0
- package/dist/otel-1bJPb2Z7.d.mts +101 -0
- package/dist/otel-1bJPb2Z7.d.mts.map +1 -0
- package/dist/otel-C1HqHA2O.cjs +136 -0
- package/dist/otel-C1HqHA2O.cjs.map +1 -0
- package/dist/otel-SBVoVEHr.d.cts +101 -0
- package/dist/otel-SBVoVEHr.d.cts.map +1 -0
- package/dist/otel-wulj5B-X.mjs +130 -0
- package/dist/otel-wulj5B-X.mjs.map +1 -0
- package/dist/otlp/hono.cjs +15 -9
- package/dist/otlp/hono.cjs.map +1 -1
- package/dist/otlp/hono.d.cts +13 -3
- package/dist/otlp/hono.d.cts.map +1 -1
- package/dist/otlp/hono.d.mts +13 -3
- package/dist/otlp/hono.d.mts.map +1 -1
- package/dist/otlp/hono.mjs +11 -5
- package/dist/otlp/hono.mjs.map +1 -1
- package/dist/otlp/index.cjs +11 -11
- package/dist/otlp/index.d.cts +7 -4
- package/dist/otlp/index.d.mts +7 -4
- package/dist/otlp/index.mjs +5 -4
- package/dist/otlp/receiver.cjs +4 -88
- package/dist/otlp/receiver.d.cts +7 -59
- package/dist/otlp/receiver.d.mts +7 -59
- package/dist/otlp/receiver.mjs +4 -87
- package/dist/otlp/transformer.cjs +5 -214
- package/dist/otlp/transformer.d.cts +3 -1
- package/dist/otlp/transformer.d.mts +3 -1
- package/dist/otlp/transformer.mjs +3 -211
- package/dist/otlp/types.cjs +5 -57
- package/dist/otlp/types.d.cts +1 -1
- package/dist/otlp/types.d.mts +1 -1
- package/dist/otlp/types.mjs +2 -53
- package/dist/receiver-Cj1lbAOO.cjs +94 -0
- package/dist/receiver-Cj1lbAOO.cjs.map +1 -0
- package/dist/receiver-CxVd_9CB.mjs +89 -0
- package/dist/receiver-CxVd_9CB.mjs.map +1 -0
- package/dist/receiver-DLICx5uU.d.cts +63 -0
- package/dist/receiver-DLICx5uU.d.cts.map +1 -0
- package/dist/receiver-UeZT-H8u.d.mts +63 -0
- package/dist/receiver-UeZT-H8u.d.mts.map +1 -0
- package/dist/redact-BzkITCNW.mjs +83 -0
- package/dist/redact-BzkITCNW.mjs.map +1 -0
- package/dist/redact-DVaSSPZT.cjs +95 -0
- package/dist/redact-DVaSSPZT.cjs.map +1 -0
- package/dist/redact.cjs +3 -84
- package/dist/redact.d.cts +8 -4
- package/dist/redact.d.cts.map +1 -1
- package/dist/redact.d.mts +8 -4
- package/dist/redact.d.mts.map +1 -1
- package/dist/redact.mjs +2 -80
- package/dist/server/hono.cjs +54 -33
- package/dist/server/hono.cjs.map +1 -1
- package/dist/server/hono.d.cts +14 -19
- package/dist/server/hono.d.cts.map +1 -1
- package/dist/server/hono.d.mts +14 -19
- package/dist/server/hono.d.mts.map +1 -1
- package/dist/server/hono.mjs +52 -31
- package/dist/server/hono.mjs.map +1 -1
- package/dist/setup-B9jM77Qk.mjs +98 -0
- package/dist/setup-B9jM77Qk.mjs.map +1 -0
- package/dist/setup-Bkxm4g6b.d.mts +87 -0
- package/dist/setup-Bkxm4g6b.d.mts.map +1 -0
- package/dist/setup-CYpff5B9.cjs +110 -0
- package/dist/setup-CYpff5B9.cjs.map +1 -0
- package/dist/setup-D58N1f9O.d.cts +87 -0
- package/dist/setup-D58N1f9O.d.cts.map +1 -0
- package/dist/storage/kysely.cjs +70 -82
- package/dist/storage/kysely.cjs.map +1 -1
- package/dist/storage/kysely.d.cts +20 -36
- package/dist/storage/kysely.d.cts.map +1 -1
- package/dist/storage/kysely.d.mts +20 -36
- package/dist/storage/kysely.d.mts.map +1 -1
- package/dist/storage/kysely.mjs +69 -81
- package/dist/storage/kysely.mjs.map +1 -1
- package/dist/storage/memory.cjs +2 -122
- package/dist/storage/memory.d.cts +3 -36
- package/dist/storage/memory.d.mts +3 -36
- package/dist/storage/memory.mjs +2 -121
- package/dist/tracing-BX8uY2nR.d.cts +53 -0
- package/dist/tracing-BX8uY2nR.d.cts.map +1 -0
- package/dist/tracing-Bt1zWRlb.cjs +167 -0
- package/dist/tracing-Bt1zWRlb.cjs.map +1 -0
- package/dist/tracing-Cijm_5NI.mjs +113 -0
- package/dist/tracing-Cijm_5NI.mjs.map +1 -0
- package/dist/tracing-PnECEbEu.d.mts +53 -0
- package/dist/tracing-PnECEbEu.d.mts.map +1 -0
- package/dist/transformer-BXQPhzql.mjs +215 -0
- package/dist/transformer-BXQPhzql.mjs.map +1 -0
- package/dist/transformer-CLGZ0EQc.cjs +232 -0
- package/dist/transformer-CLGZ0EQc.cjs.map +1 -0
- package/dist/{transformer-BtqjAs0b.d.cts → transformer-CTGsaVfV.d.mts} +8 -4
- package/dist/transformer-CTGsaVfV.d.mts.map +1 -0
- package/dist/{transformer-DI6t8-YA.d.mts → transformer-ICEbxpFf.d.cts} +8 -4
- package/dist/transformer-ICEbxpFf.d.cts.map +1 -0
- package/dist/{types-BVujq4zd.d.mts → types-B1EIa_cQ.d.mts} +4 -3
- package/dist/types-B1EIa_cQ.d.mts.map +1 -0
- package/dist/types-BRzW1NM8.d.cts +166 -0
- package/dist/types-BRzW1NM8.d.cts.map +1 -0
- package/dist/types-BS3Rx8Sk.d.cts +209 -0
- package/dist/types-BS3Rx8Sk.d.cts.map +1 -0
- package/dist/types-Bwm_jNU7.mjs +54 -0
- package/dist/types-Bwm_jNU7.mjs.map +1 -0
- package/dist/types-BzQ78Efw.d.mts +166 -0
- package/dist/types-BzQ78Efw.d.mts.map +1 -0
- package/dist/types-CbNGXnJE.d.mts +209 -0
- package/dist/types-CbNGXnJE.d.mts.map +1 -0
- package/dist/{types-DVETVdpa.d.cts → types-CmOB7CLO.d.cts} +7 -6
- package/dist/types-CmOB7CLO.d.cts.map +1 -0
- package/dist/{types-DVETVdpa.d.mts → types-DBc0q5KD.d.mts} +7 -6
- package/dist/types-DBc0q5KD.d.mts.map +1 -0
- package/dist/types-Dsh-DIO_.cjs +78 -0
- package/dist/types-Dsh-DIO_.cjs.map +1 -0
- package/dist/types-ZW-nfWf6.cjs +40 -0
- package/dist/types-ZW-nfWf6.cjs.map +1 -0
- package/dist/{types-BVujq4zd.d.cts → types-l7Rlb5Mg.d.cts} +4 -3
- package/dist/types-l7Rlb5Mg.d.cts.map +1 -0
- package/dist/types-ojhnLdwz.mjs +34 -0
- package/dist/types-ojhnLdwz.mjs.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +0 -1
- package/dist/ui-assets-BEXqOQLe.cjs +48 -0
- package/dist/ui-assets-BEXqOQLe.cjs.map +1 -0
- package/dist/ui-assets-BhTDUsrM.mjs +30 -0
- package/dist/ui-assets-BhTDUsrM.mjs.map +1 -0
- package/dist/ui-assets.cjs +5 -0
- package/dist/ui-assets.d.cts +13 -0
- package/dist/ui-assets.d.cts.map +1 -0
- package/dist/ui-assets.d.mts +13 -0
- package/dist/ui-assets.d.mts.map +1 -0
- package/dist/ui-assets.mjs +3 -0
- package/package.json +46 -46
- package/src/Telescope.ts +561 -0
- package/src/__tests__/Telescope.spec.ts +438 -0
- package/src/__tests__/pino-transport.spec.ts +115 -0
- package/src/__tests__/redact.spec.ts +336 -0
- package/src/adapters/__tests__/lambda.spec.ts +318 -0
- package/src/adapters/__tests__/middy.spec.ts +741 -0
- package/src/adapters/index.ts +22 -0
- package/src/adapters/lambda.ts +432 -0
- package/src/adapters/middy.ts +402 -0
- package/src/adapters/types.ts +181 -0
- package/src/core.ts +51 -0
- package/src/index.ts +34 -0
- package/src/instrumentation/__tests__/core.spec.ts +248 -0
- package/src/instrumentation/__tests__/hono.spec.ts +348 -0
- package/src/instrumentation/__tests__/middleware.spec.ts +528 -0
- package/src/instrumentation/__tests__/otel.spec.ts +291 -0
- package/src/instrumentation/__tests__/tracing.spec.ts +208 -0
- package/src/instrumentation/core.ts +228 -0
- package/src/instrumentation/hono.ts +270 -0
- package/src/instrumentation/http.ts +306 -0
- package/src/instrumentation/index.ts +90 -0
- package/src/instrumentation/middleware.ts +297 -0
- package/src/instrumentation/otel.ts +271 -0
- package/src/instrumentation/setup.ts +246 -0
- package/src/instrumentation/tracing.ts +145 -0
- package/src/logger/__tests__/console.spec.ts +366 -0
- package/src/logger/__tests__/pino.spec.ts +217 -0
- package/src/logger/console.ts +230 -0
- package/src/logger/pino.ts +201 -0
- package/src/metrics/MetricsAggregator.ts +555 -0
- package/src/metrics/__tests__/MetricsAggregator.spec.ts +298 -0
- package/src/metrics/index.ts +2 -0
- package/src/metrics/storage/InMemoryMetricsStorage.ts +380 -0
- package/src/metrics/storage/MetricsStorage.ts +74 -0
- package/src/metrics/storage/index.ts +3 -0
- package/src/metrics/storage/types.ts +243 -0
- package/src/otlp/__tests__/receiver.spec.ts +367 -0
- package/src/otlp/__tests__/transformer.spec.ts +455 -0
- package/src/otlp/hono.ts +120 -0
- package/src/otlp/index.ts +22 -0
- package/src/otlp/receiver.ts +162 -0
- package/src/otlp/transformer.ts +367 -0
- package/src/otlp/types.ts +364 -0
- package/src/redact.ts +116 -0
- package/src/server/__tests__/hono.spec.ts +814 -0
- package/src/server/hono.ts +442 -0
- package/src/storage/__tests__/kysely.spec.ts +715 -0
- package/src/storage/__tests__/memory.spec.ts +694 -0
- package/src/storage/kysely.ts +599 -0
- package/src/storage/memory.ts +204 -0
- package/src/types.ts +447 -0
- package/src/ui-assets.ts +40 -0
- package/tsconfig.json +9 -0
- package/ui/CHANGELOG.md +7 -0
- package/ui/index.html +12 -0
- package/ui/node_modules/.bin/tsc +21 -0
- package/ui/node_modules/.bin/tsserver +21 -0
- package/ui/node_modules/.bin/vite +21 -0
- package/ui/package.json +24 -0
- package/ui/src/App.tsx +595 -0
- package/ui/src/api.ts +88 -0
- package/ui/src/components/ExceptionDetail.tsx +100 -0
- package/ui/src/components/FilterBar.tsx +162 -0
- package/ui/src/components/LogDetail.tsx +91 -0
- package/ui/src/components/RequestDetail.tsx +143 -0
- package/ui/src/main.tsx +10 -0
- package/ui/src/styles.css +11 -0
- package/ui/src/types.ts +63 -0
- package/ui/src/vite-env.d.ts +1 -0
- package/ui/src/vite-plugin-gkm-config.ts +54 -0
- package/ui/tsconfig.json +20 -0
- package/ui/tsconfig.tsbuildinfo +1 -0
- package/ui/vite.config.ts +13 -0
- package/dist/MetricsAggregator-BJdIvfEv.d.mts.map +0 -1
- package/dist/MetricsAggregator-CnC3oT5q.d.cts.map +0 -1
- package/dist/Telescope-BVfDvVvY.d.mts.map +0 -1
- package/dist/Telescope-DeqSHfuB.d.cts.map +0 -1
- package/dist/Telescope.cjs.map +0 -1
- package/dist/Telescope.mjs.map +0 -1
- package/dist/adapters/middy.cjs.map +0 -1
- package/dist/adapters/middy.d.cts.map +0 -1
- package/dist/adapters/middy.d.mts.map +0 -1
- package/dist/adapters/middy.mjs.map +0 -1
- package/dist/adapters/types.d.cts.map +0 -1
- package/dist/adapters/types.d.mts.map +0 -1
- package/dist/instrumentation/core.cjs.map +0 -1
- package/dist/instrumentation/core.d.cts.map +0 -1
- package/dist/instrumentation/core.d.mts.map +0 -1
- package/dist/instrumentation/core.mjs.map +0 -1
- package/dist/instrumentation/hono.cjs.map +0 -1
- package/dist/instrumentation/hono.d.cts.map +0 -1
- package/dist/instrumentation/hono.d.mts.map +0 -1
- package/dist/instrumentation/hono.mjs.map +0 -1
- package/dist/instrumentation/http.cjs.map +0 -1
- package/dist/instrumentation/http.d.cts.map +0 -1
- package/dist/instrumentation/http.d.mts.map +0 -1
- package/dist/instrumentation/http.mjs.map +0 -1
- package/dist/instrumentation/middleware.cjs.map +0 -1
- package/dist/instrumentation/middleware.d.cts.map +0 -1
- package/dist/instrumentation/middleware.d.mts.map +0 -1
- package/dist/instrumentation/middleware.mjs.map +0 -1
- package/dist/instrumentation/otel.cjs.map +0 -1
- package/dist/instrumentation/otel.d.cts.map +0 -1
- package/dist/instrumentation/otel.d.mts.map +0 -1
- package/dist/instrumentation/otel.mjs.map +0 -1
- package/dist/instrumentation/sampler.cjs +0 -54
- package/dist/instrumentation/sampler.cjs.map +0 -1
- package/dist/instrumentation/sampler.d.cts +0 -38
- package/dist/instrumentation/sampler.d.cts.map +0 -1
- package/dist/instrumentation/sampler.d.mts +0 -38
- package/dist/instrumentation/sampler.d.mts.map +0 -1
- package/dist/instrumentation/sampler.mjs +0 -52
- package/dist/instrumentation/sampler.mjs.map +0 -1
- package/dist/instrumentation/setup.cjs.map +0 -1
- package/dist/instrumentation/setup.d.cts.map +0 -1
- package/dist/instrumentation/setup.d.mts.map +0 -1
- package/dist/instrumentation/setup.mjs.map +0 -1
- package/dist/instrumentation/tracing.cjs.map +0 -1
- package/dist/instrumentation/tracing.d.cts.map +0 -1
- package/dist/instrumentation/tracing.d.mts.map +0 -1
- package/dist/instrumentation/tracing.mjs.map +0 -1
- package/dist/instrumentation/trust.cjs +0 -107
- package/dist/instrumentation/trust.cjs.map +0 -1
- package/dist/instrumentation/trust.d.cts +0 -57
- package/dist/instrumentation/trust.d.cts.map +0 -1
- package/dist/instrumentation/trust.d.mts +0 -57
- package/dist/instrumentation/trust.d.mts.map +0 -1
- package/dist/instrumentation/trust.mjs +0 -104
- package/dist/instrumentation/trust.mjs.map +0 -1
- package/dist/metrics/MetricsAggregator.cjs.map +0 -1
- package/dist/metrics/MetricsAggregator.mjs.map +0 -1
- package/dist/metrics/storage/InMemoryMetricsStorage.cjs.map +0 -1
- package/dist/metrics/storage/InMemoryMetricsStorage.d.cts.map +0 -1
- package/dist/metrics/storage/InMemoryMetricsStorage.d.mts.map +0 -1
- package/dist/metrics/storage/InMemoryMetricsStorage.mjs.map +0 -1
- package/dist/metrics/storage/MetricsStorage.d.cts.map +0 -1
- package/dist/metrics/storage/MetricsStorage.d.mts.map +0 -1
- package/dist/metrics/storage/types.cjs.map +0 -1
- package/dist/metrics/storage/types.d.cts.map +0 -1
- package/dist/metrics/storage/types.d.mts.map +0 -1
- package/dist/metrics/storage/types.mjs.map +0 -1
- package/dist/otlp/receiver.cjs.map +0 -1
- package/dist/otlp/receiver.d.cts.map +0 -1
- package/dist/otlp/receiver.d.mts.map +0 -1
- package/dist/otlp/receiver.mjs.map +0 -1
- package/dist/otlp/transformer.cjs.map +0 -1
- package/dist/otlp/transformer.mjs.map +0 -1
- package/dist/otlp/types.cjs.map +0 -1
- package/dist/otlp/types.mjs.map +0 -1
- package/dist/redact.cjs.map +0 -1
- package/dist/redact.mjs.map +0 -1
- package/dist/storage/memory.cjs.map +0 -1
- package/dist/storage/memory.d.cts.map +0 -1
- package/dist/storage/memory.d.mts.map +0 -1
- package/dist/storage/memory.mjs.map +0 -1
- package/dist/transformer-BtqjAs0b.d.cts.map +0 -1
- package/dist/transformer-DI6t8-YA.d.mts.map +0 -1
- package/dist/types-BVujq4zd.d.cts.map +0 -1
- package/dist/types-BVujq4zd.d.mts.map +0 -1
- package/dist/types-DVETVdpa.d.cts.map +0 -1
- package/dist/types-DVETVdpa.d.mts.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_http = require('./http-D_Z8sYXZ.cjs');
|
|
3
|
+
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
4
|
+
|
|
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 parentContext = require_http.extractTraceContext(headers);
|
|
40
|
+
const attrs = buildHonoSpanAttributes(c, options);
|
|
41
|
+
const span = require_http.createHttpServerSpan(attrs, parentContext);
|
|
42
|
+
const spanContext = __opentelemetry_api.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 __opentelemetry_api.context.with(spanContext, async () => {
|
|
51
|
+
await next();
|
|
52
|
+
});
|
|
53
|
+
const statusCode = c.res.status;
|
|
54
|
+
if (options.recordResponseBody) try {
|
|
55
|
+
const body = await c.res.clone().text();
|
|
56
|
+
if (body) span.setAttribute("http.response.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
|
|
57
|
+
} catch {}
|
|
58
|
+
require_http.endHttpSpan(span, { statusCode });
|
|
59
|
+
} catch (error) {
|
|
60
|
+
require_http.endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build span attributes from Hono context
|
|
67
|
+
*/
|
|
68
|
+
function buildHonoSpanAttributes(c, options) {
|
|
69
|
+
const req = c.req;
|
|
70
|
+
const url = new URL(req.url);
|
|
71
|
+
const routePath = c.req.routePath;
|
|
72
|
+
const route = routePath && routePath !== "*" && !routePath.includes("/*") ? routePath : url.pathname;
|
|
73
|
+
const attrs = {
|
|
74
|
+
method: req.method,
|
|
75
|
+
url: req.url,
|
|
76
|
+
path: url.pathname,
|
|
77
|
+
route,
|
|
78
|
+
host: url.host,
|
|
79
|
+
scheme: url.protocol.replace(":", ""),
|
|
80
|
+
userAgent: req.header("user-agent"),
|
|
81
|
+
clientIp: getClientIp(c),
|
|
82
|
+
requestId: req.header("x-request-id") || req.header("x-amzn-requestid")
|
|
83
|
+
};
|
|
84
|
+
if (options.getUserId) {
|
|
85
|
+
const userId = options.getUserId(c);
|
|
86
|
+
if (userId) attrs.user = { userId };
|
|
87
|
+
}
|
|
88
|
+
return attrs;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract client IP from Hono context
|
|
92
|
+
*/
|
|
93
|
+
function getClientIp(c) {
|
|
94
|
+
const xForwardedFor = c.req.header("x-forwarded-for");
|
|
95
|
+
if (xForwardedFor) {
|
|
96
|
+
const first = xForwardedFor.split(",")[0];
|
|
97
|
+
return first?.trim();
|
|
98
|
+
}
|
|
99
|
+
const xRealIp = c.req.header("x-real-ip");
|
|
100
|
+
if (xRealIp) return xRealIp;
|
|
101
|
+
const cfConnectingIp = c.req.header("cf-connecting-ip");
|
|
102
|
+
if (cfConnectingIp) return cfConnectingIp;
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Check if path should be ignored
|
|
107
|
+
*/
|
|
108
|
+
function shouldIgnorePath(path, ignorePaths) {
|
|
109
|
+
for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
|
|
110
|
+
const prefix = pattern.slice(0, -1);
|
|
111
|
+
if (path.startsWith(prefix)) return true;
|
|
112
|
+
} else if (path === pattern) return true;
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Run a function within the span context from Hono context
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* app.get('/api/users', async (c) => {
|
|
121
|
+
* return withHonoSpanContext(c, async () => {
|
|
122
|
+
* // Any spans created here will be children of the request span
|
|
123
|
+
* const users = await fetchUsers();
|
|
124
|
+
* return c.json(users);
|
|
125
|
+
* });
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
async function withHonoSpanContext(c, fn) {
|
|
130
|
+
const ctx = getTraceContextFromHono(c);
|
|
131
|
+
if (!ctx) return fn();
|
|
132
|
+
return __opentelemetry_api.context.with(ctx, fn);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
Object.defineProperty(exports, 'getSpanFromContext', {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () {
|
|
139
|
+
return getSpanFromContext;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(exports, 'getTraceContextFromHono', {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return getTraceContextFromHono;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, 'honoTelemetryMiddleware', {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function () {
|
|
151
|
+
return honoTelemetryMiddleware;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(exports, 'withHonoSpanContext', {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function () {
|
|
157
|
+
return withHonoSpanContext;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
//# sourceMappingURL=hono-C4EgpbKQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-C4EgpbKQ.cjs","names":["c: Context","options: HonoTelemetryMiddlewareOptions","headers: Record<string, string | string[] | undefined>","attrs: HttpSpanAttributes","path: string","ignorePaths: string[]","fn: () => Promise<T>"],"sources":["../src/instrumentation/hono.ts"],"sourcesContent":["import { context, type Span, trace } from '@opentelemetry/api';\n/**\n * OpenTelemetry instrumentation middleware for Hono\n *\n * This middleware automatically creates spans for HTTP requests,\n * extracts trace context from incoming headers, and records\n * request/response metadata as span attributes.\n */\nimport type { Context, MiddlewareHandler } from 'hono';\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for the Hono telemetry middleware\n */\nexport interface HonoTelemetryMiddlewareOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from context\n\t */\n\tgetUserId?: (c: Context) => string | undefined;\n\n\t/**\n\t * Paths to skip tracing (supports wildcards)\n\t */\n\tignorePaths?: string[];\n\n\t/**\n\t * Whether to skip tracing for this request\n\t */\n\tshouldSkip?: (c: Context) => boolean;\n}\n\n// Key for storing span on context\nconst SPAN_KEY = 'telemetry.span';\nconst CONTEXT_KEY = 'telemetry.context';\n\n/**\n * Get the current span from Hono context\n */\nexport function getSpanFromContext(c: Context): Span | undefined {\n\treturn c.get(SPAN_KEY);\n}\n\n/**\n * Get the current trace context from Hono context\n */\nexport function getTraceContextFromHono(c: Context): any {\n\treturn c.get(CONTEXT_KEY);\n}\n\n/**\n * Create a telemetry middleware for Hono applications\n *\n * @example\n * ```typescript\n * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';\n *\n * const app = new Hono();\n * app.use('*', honoTelemetryMiddleware());\n * ```\n */\nexport function honoTelemetryMiddleware(\n\toptions: HonoTelemetryMiddlewareOptions = {},\n): MiddlewareHandler {\n\treturn async (c, next) => {\n\t\t// Check if path should be ignored\n\t\tif (\n\t\t\toptions.ignorePaths &&\n\t\t\tshouldIgnorePath(c.req.path, options.ignorePaths)\n\t\t) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Skip if custom skip function returns true\n\t\tif (options.shouldSkip?.(c)) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Extract trace context from headers\n\t\tconst headers: Record<string, string | string[] | undefined> = {};\n\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\theaders[key] = value;\n\t\t});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from request\n\t\tconst attrs = buildHonoSpanAttributes(c, options);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst spanContext = trace.setSpan(parentContext, span);\n\n\t\t// Store span and context on Hono context\n\t\tc.set(SPAN_KEY, span);\n\t\tc.set(CONTEXT_KEY, spanContext);\n\n\t\t// Record body if requested\n\t\tif (options.recordBody) {\n\t\t\ttry {\n\t\t\t\tconst body = await c.req.text();\n\t\t\t\tif (body) {\n\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t'http.request.body',\n\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Body may have already been consumed\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Execute the rest of the middleware chain within span context\n\t\t\tawait context.with(spanContext, async () => {\n\t\t\t\tawait next();\n\t\t\t});\n\n\t\t\t// Record response\n\t\t\tconst statusCode = c.res.status;\n\n\t\t\tif (options.recordResponseBody) {\n\t\t\t\ttry {\n\t\t\t\t\tconst body = await c.res.clone().text();\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t\t'http.response.body',\n\t\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Response body may not be available\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tendHttpSpan(span, { statusCode });\n\t\t} catch (error) {\n\t\t\tendHttpSpan(\n\t\t\t\tspan,\n\t\t\t\t{ statusCode: 500 },\n\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Build span attributes from Hono context\n */\nfunction buildHonoSpanAttributes(\n\tc: Context,\n\toptions: HonoTelemetryMiddlewareOptions,\n): HttpSpanAttributes {\n\tconst req = c.req;\n\tconst url = new URL(req.url);\n\n\t// Use actual path for route unless it's a specific route pattern\n\tconst routePath = c.req.routePath;\n\tconst route =\n\t\troutePath && routePath !== '*' && !routePath.includes('/*')\n\t\t\t? routePath\n\t\t\t: url.pathname;\n\n\tconst attrs: HttpSpanAttributes = {\n\t\tmethod: req.method,\n\t\turl: req.url,\n\t\tpath: url.pathname,\n\t\troute,\n\t\thost: url.host,\n\t\tscheme: url.protocol.replace(':', '') as 'http' | 'https',\n\t\tuserAgent: req.header('user-agent'),\n\t\tclientIp: getClientIp(c),\n\t\trequestId: req.header('x-request-id') || req.header('x-amzn-requestid'),\n\t};\n\n\t// Add user metadata if extractor provided\n\tif (options.getUserId) {\n\t\tconst userId = options.getUserId(c);\n\t\tif (userId) {\n\t\t\tattrs.user = { userId };\n\t\t}\n\t}\n\n\treturn attrs;\n}\n\n/**\n * Extract client IP from Hono context\n */\nfunction getClientIp(c: Context): string | undefined {\n\t// Try various headers in order of preference\n\tconst xForwardedFor = c.req.header('x-forwarded-for');\n\tif (xForwardedFor) {\n\t\tconst first = xForwardedFor.split(',')[0];\n\t\treturn first?.trim();\n\t}\n\n\tconst xRealIp = c.req.header('x-real-ip');\n\tif (xRealIp) {\n\t\treturn xRealIp;\n\t}\n\n\t// Try CF-Connecting-IP (Cloudflare)\n\tconst cfConnectingIp = c.req.header('cf-connecting-ip');\n\tif (cfConnectingIp) {\n\t\treturn cfConnectingIp;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Check if path should be ignored\n */\nfunction shouldIgnorePath(path: string, ignorePaths: string[]): boolean {\n\tfor (const pattern of ignorePaths) {\n\t\tif (pattern.endsWith('*')) {\n\t\t\t// Wildcard match\n\t\t\tconst prefix = pattern.slice(0, -1);\n\t\t\tif (path.startsWith(prefix)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (path === pattern) {\n\t\t\t// Exact match\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Run a function within the span context from Hono context\n *\n * @example\n * ```typescript\n * app.get('/api/users', async (c) => {\n * return withHonoSpanContext(c, async () => {\n * // Any spans created here will be children of the request span\n * const users = await fetchUsers();\n * return c.json(users);\n * });\n * });\n * ```\n */\nexport async function withHonoSpanContext<T>(\n\tc: Context,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst ctx = getTraceContextFromHono(c);\n\tif (!ctx) {\n\t\treturn fn();\n\t}\n\treturn context.with(ctx, fn);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Context, MiddlewareHandler } from "hono";
|
|
2
|
+
import { Span } from "@opentelemetry/api";
|
|
3
|
+
|
|
4
|
+
//#region src/instrumentation/hono.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for the Hono telemetry middleware
|
|
8
|
+
*/
|
|
9
|
+
interface HonoTelemetryMiddlewareOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to record request body as span attribute
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
recordBody?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to record response body as span attribute
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
recordResponseBody?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom function to extract user ID from context
|
|
22
|
+
*/
|
|
23
|
+
getUserId?: (c: Context) => string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Paths to skip tracing (supports wildcards)
|
|
26
|
+
*/
|
|
27
|
+
ignorePaths?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether to skip tracing for this request
|
|
30
|
+
*/
|
|
31
|
+
shouldSkip?: (c: Context) => boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the current span from Hono context
|
|
35
|
+
*/
|
|
36
|
+
declare function getSpanFromContext(c: Context): Span | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get the current trace context from Hono context
|
|
39
|
+
*/
|
|
40
|
+
declare function getTraceContextFromHono(c: Context): any;
|
|
41
|
+
/**
|
|
42
|
+
* Create a telemetry middleware for Hono applications
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
|
|
47
|
+
*
|
|
48
|
+
* const app = new Hono();
|
|
49
|
+
* app.use('*', honoTelemetryMiddleware());
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function honoTelemetryMiddleware(options?: HonoTelemetryMiddlewareOptions): MiddlewareHandler;
|
|
53
|
+
/**
|
|
54
|
+
* Run a function within the span context from Hono context
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* app.get('/api/users', async (c) => {
|
|
59
|
+
* return withHonoSpanContext(c, async () => {
|
|
60
|
+
* // Any spans created here will be children of the request span
|
|
61
|
+
* const users = await fetchUsers();
|
|
62
|
+
* return c.json(users);
|
|
63
|
+
* });
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function withHonoSpanContext<T>(c: Context, fn: () => Promise<T>): Promise<T>;
|
|
68
|
+
//# sourceMappingURL=hono.d.ts.map
|
|
69
|
+
//#endregion
|
|
70
|
+
export { HonoTelemetryMiddlewareOptions, getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
|
|
71
|
+
//# sourceMappingURL=hono-CemCKU87.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-CemCKU87.d.cts","names":[],"sources":["../src/instrumentation/hono.ts"],"sourcesContent":[],"mappings":";;;;;AAuDA;;;AAAgD,UApC/B,8BAAA,CAoC+B;EAAI;AAOpD;AAeA;;EAAuC,UAC7B,CAAA,EAAA,OAAA;EAAmC;AACzB;AAqLpB;;EAAyC,kBACrC,CAAA,EAAA,OAAA;EAAO;;;EAEC,SAAT,CAAA,EAAA,CAAA,CAAA,EApOc,OAoOd,EAAA,GAAA,MAAA,GAAA,SAAA;EAAO;;;;;;;mBA1NQ;;;;;iBAUF,kBAAA,IAAsB,UAAU;;;;iBAOhC,uBAAA,IAA2B;;;;;;;;;;;;iBAe3B,uBAAA,WACN,iCACP;;;;;;;;;;;;;;;iBAqLmB,0BAClB,mBACO,QAAQ,KAChB,QAAQ"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createHttpServerSpan, endHttpSpan, extractTraceContext } from "./http-DQzgLczm.mjs";
|
|
2
|
+
import { context, trace } from "@opentelemetry/api";
|
|
3
|
+
|
|
4
|
+
//#region src/instrumentation/hono.ts
|
|
5
|
+
const SPAN_KEY = "telemetry.span";
|
|
6
|
+
const CONTEXT_KEY = "telemetry.context";
|
|
7
|
+
/**
|
|
8
|
+
* Get the current span from Hono context
|
|
9
|
+
*/
|
|
10
|
+
function getSpanFromContext(c) {
|
|
11
|
+
return c.get(SPAN_KEY);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the current trace context from Hono context
|
|
15
|
+
*/
|
|
16
|
+
function getTraceContextFromHono(c) {
|
|
17
|
+
return c.get(CONTEXT_KEY);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a telemetry middleware for Hono applications
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';
|
|
25
|
+
*
|
|
26
|
+
* const app = new Hono();
|
|
27
|
+
* app.use('*', honoTelemetryMiddleware());
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function honoTelemetryMiddleware(options = {}) {
|
|
31
|
+
return async (c, next) => {
|
|
32
|
+
if (options.ignorePaths && shouldIgnorePath(c.req.path, options.ignorePaths)) return next();
|
|
33
|
+
if (options.shouldSkip?.(c)) return next();
|
|
34
|
+
const headers = {};
|
|
35
|
+
c.req.raw.headers.forEach((value, key) => {
|
|
36
|
+
headers[key] = value;
|
|
37
|
+
});
|
|
38
|
+
const parentContext = extractTraceContext(headers);
|
|
39
|
+
const attrs = buildHonoSpanAttributes(c, options);
|
|
40
|
+
const span = createHttpServerSpan(attrs, parentContext);
|
|
41
|
+
const spanContext = trace.setSpan(parentContext, span);
|
|
42
|
+
c.set(SPAN_KEY, span);
|
|
43
|
+
c.set(CONTEXT_KEY, spanContext);
|
|
44
|
+
if (options.recordBody) try {
|
|
45
|
+
const body = await c.req.text();
|
|
46
|
+
if (body) span.setAttribute("http.request.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
|
|
47
|
+
} catch {}
|
|
48
|
+
try {
|
|
49
|
+
await context.with(spanContext, async () => {
|
|
50
|
+
await next();
|
|
51
|
+
});
|
|
52
|
+
const statusCode = c.res.status;
|
|
53
|
+
if (options.recordResponseBody) try {
|
|
54
|
+
const body = await c.res.clone().text();
|
|
55
|
+
if (body) span.setAttribute("http.response.body", body.length > 4096 ? `${body.slice(0, 4096)}...` : body);
|
|
56
|
+
} catch {}
|
|
57
|
+
endHttpSpan(span, { statusCode });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
endHttpSpan(span, { statusCode: 500 }, error instanceof Error ? error : new Error(String(error)));
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build span attributes from Hono context
|
|
66
|
+
*/
|
|
67
|
+
function buildHonoSpanAttributes(c, options) {
|
|
68
|
+
const req = c.req;
|
|
69
|
+
const url = new URL(req.url);
|
|
70
|
+
const routePath = c.req.routePath;
|
|
71
|
+
const route = routePath && routePath !== "*" && !routePath.includes("/*") ? routePath : url.pathname;
|
|
72
|
+
const attrs = {
|
|
73
|
+
method: req.method,
|
|
74
|
+
url: req.url,
|
|
75
|
+
path: url.pathname,
|
|
76
|
+
route,
|
|
77
|
+
host: url.host,
|
|
78
|
+
scheme: url.protocol.replace(":", ""),
|
|
79
|
+
userAgent: req.header("user-agent"),
|
|
80
|
+
clientIp: getClientIp(c),
|
|
81
|
+
requestId: req.header("x-request-id") || req.header("x-amzn-requestid")
|
|
82
|
+
};
|
|
83
|
+
if (options.getUserId) {
|
|
84
|
+
const userId = options.getUserId(c);
|
|
85
|
+
if (userId) attrs.user = { userId };
|
|
86
|
+
}
|
|
87
|
+
return attrs;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Extract client IP from Hono context
|
|
91
|
+
*/
|
|
92
|
+
function getClientIp(c) {
|
|
93
|
+
const xForwardedFor = c.req.header("x-forwarded-for");
|
|
94
|
+
if (xForwardedFor) {
|
|
95
|
+
const first = xForwardedFor.split(",")[0];
|
|
96
|
+
return first?.trim();
|
|
97
|
+
}
|
|
98
|
+
const xRealIp = c.req.header("x-real-ip");
|
|
99
|
+
if (xRealIp) return xRealIp;
|
|
100
|
+
const cfConnectingIp = c.req.header("cf-connecting-ip");
|
|
101
|
+
if (cfConnectingIp) return cfConnectingIp;
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if path should be ignored
|
|
106
|
+
*/
|
|
107
|
+
function shouldIgnorePath(path, ignorePaths) {
|
|
108
|
+
for (const pattern of ignorePaths) if (pattern.endsWith("*")) {
|
|
109
|
+
const prefix = pattern.slice(0, -1);
|
|
110
|
+
if (path.startsWith(prefix)) return true;
|
|
111
|
+
} else if (path === pattern) return true;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Run a function within the span context from Hono context
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* app.get('/api/users', async (c) => {
|
|
120
|
+
* return withHonoSpanContext(c, async () => {
|
|
121
|
+
* // Any spans created here will be children of the request span
|
|
122
|
+
* const users = await fetchUsers();
|
|
123
|
+
* return c.json(users);
|
|
124
|
+
* });
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
async function withHonoSpanContext(c, fn) {
|
|
129
|
+
const ctx = getTraceContextFromHono(c);
|
|
130
|
+
if (!ctx) return fn();
|
|
131
|
+
return context.with(ctx, fn);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { getSpanFromContext, getTraceContextFromHono, honoTelemetryMiddleware, withHonoSpanContext };
|
|
136
|
+
//# sourceMappingURL=hono-DxhvnVbF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-DxhvnVbF.mjs","names":["c: Context","options: HonoTelemetryMiddlewareOptions","headers: Record<string, string | string[] | undefined>","attrs: HttpSpanAttributes","path: string","ignorePaths: string[]","fn: () => Promise<T>"],"sources":["../src/instrumentation/hono.ts"],"sourcesContent":["import { context, type Span, trace } from '@opentelemetry/api';\n/**\n * OpenTelemetry instrumentation middleware for Hono\n *\n * This middleware automatically creates spans for HTTP requests,\n * extracts trace context from incoming headers, and records\n * request/response metadata as span attributes.\n */\nimport type { Context, MiddlewareHandler } from 'hono';\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for the Hono telemetry middleware\n */\nexport interface HonoTelemetryMiddlewareOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from context\n\t */\n\tgetUserId?: (c: Context) => string | undefined;\n\n\t/**\n\t * Paths to skip tracing (supports wildcards)\n\t */\n\tignorePaths?: string[];\n\n\t/**\n\t * Whether to skip tracing for this request\n\t */\n\tshouldSkip?: (c: Context) => boolean;\n}\n\n// Key for storing span on context\nconst SPAN_KEY = 'telemetry.span';\nconst CONTEXT_KEY = 'telemetry.context';\n\n/**\n * Get the current span from Hono context\n */\nexport function getSpanFromContext(c: Context): Span | undefined {\n\treturn c.get(SPAN_KEY);\n}\n\n/**\n * Get the current trace context from Hono context\n */\nexport function getTraceContextFromHono(c: Context): any {\n\treturn c.get(CONTEXT_KEY);\n}\n\n/**\n * Create a telemetry middleware for Hono applications\n *\n * @example\n * ```typescript\n * import { honoTelemetryMiddleware } from '@geekmidas/telescope/instrumentation';\n *\n * const app = new Hono();\n * app.use('*', honoTelemetryMiddleware());\n * ```\n */\nexport function honoTelemetryMiddleware(\n\toptions: HonoTelemetryMiddlewareOptions = {},\n): MiddlewareHandler {\n\treturn async (c, next) => {\n\t\t// Check if path should be ignored\n\t\tif (\n\t\t\toptions.ignorePaths &&\n\t\t\tshouldIgnorePath(c.req.path, options.ignorePaths)\n\t\t) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Skip if custom skip function returns true\n\t\tif (options.shouldSkip?.(c)) {\n\t\t\treturn next();\n\t\t}\n\n\t\t// Extract trace context from headers\n\t\tconst headers: Record<string, string | string[] | undefined> = {};\n\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\theaders[key] = value;\n\t\t});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from request\n\t\tconst attrs = buildHonoSpanAttributes(c, options);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst spanContext = trace.setSpan(parentContext, span);\n\n\t\t// Store span and context on Hono context\n\t\tc.set(SPAN_KEY, span);\n\t\tc.set(CONTEXT_KEY, spanContext);\n\n\t\t// Record body if requested\n\t\tif (options.recordBody) {\n\t\t\ttry {\n\t\t\t\tconst body = await c.req.text();\n\t\t\t\tif (body) {\n\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t'http.request.body',\n\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Body may have already been consumed\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Execute the rest of the middleware chain within span context\n\t\t\tawait context.with(spanContext, async () => {\n\t\t\t\tawait next();\n\t\t\t});\n\n\t\t\t// Record response\n\t\t\tconst statusCode = c.res.status;\n\n\t\t\tif (options.recordResponseBody) {\n\t\t\t\ttry {\n\t\t\t\t\tconst body = await c.res.clone().text();\n\t\t\t\t\tif (body) {\n\t\t\t\t\t\tspan.setAttribute(\n\t\t\t\t\t\t\t'http.response.body',\n\t\t\t\t\t\t\tbody.length > 4096 ? `${body.slice(0, 4096)}...` : body,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Response body may not be available\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tendHttpSpan(span, { statusCode });\n\t\t} catch (error) {\n\t\t\tendHttpSpan(\n\t\t\t\tspan,\n\t\t\t\t{ statusCode: 500 },\n\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t);\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Build span attributes from Hono context\n */\nfunction buildHonoSpanAttributes(\n\tc: Context,\n\toptions: HonoTelemetryMiddlewareOptions,\n): HttpSpanAttributes {\n\tconst req = c.req;\n\tconst url = new URL(req.url);\n\n\t// Use actual path for route unless it's a specific route pattern\n\tconst routePath = c.req.routePath;\n\tconst route =\n\t\troutePath && routePath !== '*' && !routePath.includes('/*')\n\t\t\t? routePath\n\t\t\t: url.pathname;\n\n\tconst attrs: HttpSpanAttributes = {\n\t\tmethod: req.method,\n\t\turl: req.url,\n\t\tpath: url.pathname,\n\t\troute,\n\t\thost: url.host,\n\t\tscheme: url.protocol.replace(':', '') as 'http' | 'https',\n\t\tuserAgent: req.header('user-agent'),\n\t\tclientIp: getClientIp(c),\n\t\trequestId: req.header('x-request-id') || req.header('x-amzn-requestid'),\n\t};\n\n\t// Add user metadata if extractor provided\n\tif (options.getUserId) {\n\t\tconst userId = options.getUserId(c);\n\t\tif (userId) {\n\t\t\tattrs.user = { userId };\n\t\t}\n\t}\n\n\treturn attrs;\n}\n\n/**\n * Extract client IP from Hono context\n */\nfunction getClientIp(c: Context): string | undefined {\n\t// Try various headers in order of preference\n\tconst xForwardedFor = c.req.header('x-forwarded-for');\n\tif (xForwardedFor) {\n\t\tconst first = xForwardedFor.split(',')[0];\n\t\treturn first?.trim();\n\t}\n\n\tconst xRealIp = c.req.header('x-real-ip');\n\tif (xRealIp) {\n\t\treturn xRealIp;\n\t}\n\n\t// Try CF-Connecting-IP (Cloudflare)\n\tconst cfConnectingIp = c.req.header('cf-connecting-ip');\n\tif (cfConnectingIp) {\n\t\treturn cfConnectingIp;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Check if path should be ignored\n */\nfunction shouldIgnorePath(path: string, ignorePaths: string[]): boolean {\n\tfor (const pattern of ignorePaths) {\n\t\tif (pattern.endsWith('*')) {\n\t\t\t// Wildcard match\n\t\t\tconst prefix = pattern.slice(0, -1);\n\t\t\tif (path.startsWith(prefix)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (path === pattern) {\n\t\t\t// Exact match\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Run a function within the span context from Hono context\n *\n * @example\n * ```typescript\n * app.get('/api/users', async (c) => {\n * return withHonoSpanContext(c, async () => {\n * // Any spans created here will be children of the request span\n * const users = await fetchUsers();\n * return c.json(users);\n * });\n * });\n * ```\n */\nexport async function withHonoSpanContext<T>(\n\tc: Context,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst ctx = getTraceContextFromHono(c);\n\tif (!ctx) {\n\t\treturn fn();\n\t}\n\treturn context.with(ctx, fn);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as _opentelemetry_api1 from "@opentelemetry/api";
|
|
2
|
+
import { Attributes, Context, Span } from "@opentelemetry/api";
|
|
3
|
+
|
|
4
|
+
//#region src/instrumentation/http.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* HTTP request attributes following OpenTelemetry semantic conventions
|
|
7
|
+
*/
|
|
8
|
+
interface HttpRequestAttributes {
|
|
9
|
+
method: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
route?: string;
|
|
13
|
+
host?: string;
|
|
14
|
+
scheme?: 'http' | 'https';
|
|
15
|
+
userAgent?: string;
|
|
16
|
+
clientIp?: string;
|
|
17
|
+
requestId?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* HTTP response attributes
|
|
21
|
+
*/
|
|
22
|
+
interface HttpResponseAttributes {
|
|
23
|
+
statusCode: number;
|
|
24
|
+
responseSize?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Endpoint-specific attributes
|
|
28
|
+
*/
|
|
29
|
+
interface EndpointAttributes {
|
|
30
|
+
name?: string;
|
|
31
|
+
operationId?: string;
|
|
32
|
+
tags?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* User/session attributes
|
|
36
|
+
*/
|
|
37
|
+
interface UserAttributes {
|
|
38
|
+
userId?: string;
|
|
39
|
+
sessionId?: string;
|
|
40
|
+
roles?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Full span attributes for HTTP requests
|
|
44
|
+
*/
|
|
45
|
+
interface HttpSpanAttributes extends HttpRequestAttributes {
|
|
46
|
+
response?: HttpResponseAttributes;
|
|
47
|
+
endpoint?: EndpointAttributes;
|
|
48
|
+
user?: UserAttributes;
|
|
49
|
+
custom?: Attributes;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get or create a tracer for constructs instrumentation
|
|
53
|
+
*/
|
|
54
|
+
declare function getConstructsTracer(): _opentelemetry_api1.Tracer;
|
|
55
|
+
/**
|
|
56
|
+
* Convert HTTP attributes to OpenTelemetry semantic conventions
|
|
57
|
+
*/
|
|
58
|
+
declare function toOtelAttributes(attrs: HttpSpanAttributes): Attributes;
|
|
59
|
+
/**
|
|
60
|
+
* Extract trace context from HTTP headers
|
|
61
|
+
*/
|
|
62
|
+
declare function extractTraceContext(headers: Record<string, string | string[] | undefined>): Context;
|
|
63
|
+
/**
|
|
64
|
+
* Inject trace context into HTTP headers
|
|
65
|
+
*/
|
|
66
|
+
declare function injectTraceContext(headers: Record<string, string>, ctx?: Context): Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Create an HTTP server span for an incoming request
|
|
69
|
+
*/
|
|
70
|
+
declare function createHttpServerSpan(attrs: HttpSpanAttributes, parentContext?: Context): Span;
|
|
71
|
+
/**
|
|
72
|
+
* End an HTTP span with response data
|
|
73
|
+
*/
|
|
74
|
+
declare function endHttpSpan(span: Span, response: HttpResponseAttributes, error?: Error): void;
|
|
75
|
+
/**
|
|
76
|
+
* Execute a function within an HTTP server span context
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const result = await withHttpSpan(
|
|
81
|
+
* { method: 'GET', path: '/users', route: '/users' },
|
|
82
|
+
* async (span) => {
|
|
83
|
+
* const users = await getUsers();
|
|
84
|
+
* return { statusCode: 200, body: users };
|
|
85
|
+
* }
|
|
86
|
+
* );
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function withHttpSpan<T>(attrs: HttpSpanAttributes, fn: (span: Span) => Promise<T & {
|
|
90
|
+
statusCode?: number;
|
|
91
|
+
}>, parentContext?: Context): Promise<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Create a child span for internal operations (middleware, handlers, etc.)
|
|
94
|
+
*/
|
|
95
|
+
declare function createChildSpan(name: string, attributes?: Attributes): Span;
|
|
96
|
+
/**
|
|
97
|
+
* Execute a function within a child span
|
|
98
|
+
*/
|
|
99
|
+
declare function withChildSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Attributes): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Check if tracing is enabled (OpenTelemetry API is available and configured)
|
|
102
|
+
*/
|
|
103
|
+
declare function isTracingEnabled(): boolean;
|
|
104
|
+
//# sourceMappingURL=http.d.ts.map
|
|
105
|
+
//#endregion
|
|
106
|
+
export { EndpointAttributes, HttpRequestAttributes, HttpResponseAttributes, HttpSpanAttributes, UserAttributes, createChildSpan, createHttpServerSpan, endHttpSpan, extractTraceContext, getConstructsTracer, injectTraceContext, isTracingEnabled, toOtelAttributes, withChildSpan, withHttpSpan };
|
|
107
|
+
//# sourceMappingURL=http-BiNtg85L.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-BiNtg85L.d.mts","names":[],"sources":["../src/instrumentation/http.ts"],"sourcesContent":[],"mappings":";;;;;;;AAciB,UAAA,qBAAA,CAAqB;EAerB,MAAA,EAAA,MAAA;EAQA,GAAA,CAAA,EAAA,MAAA;EASA,IAAA,CAAA,EAAA,MAAA;EASA,KAAA,CAAA,EAAA,MAAA;EAAmB,IAAA,CAAA,EAAA,MAAA;EAAA,MACxB,CAAA,EAAA,MAAA,GAAA,OAAA;EAAsB,SACtB,CAAA,EAAA,MAAA;EAAkB,QACtB,CAAA,EAAA,MAAA;EAAc,SACZ,CAAA,EAAA,MAAA;;AAJuD;AAYjE;AAOA;AAAgC,UA7Cf,sBAAA,CA6Ce;EAAA,UAAQ,EAAA,MAAA;EAAkB,YAAG,CAAA,EAAA,MAAA;AAAU;AAgDvE;;;AAEG,UAvFc,kBAAA,CAuFd;EAAO,IAAA,CAAA,EAAA,MAAA;EAkBM,WAAA,CAAA,EAAA,MAAA;EAAkB,IAAA,CAAA,EAAA,MAAA,EAAA;;;;AAGzB;AASO,UA5GC,cAAA,CA4GmB;EAAA,MAAA,CAAA,EAAA,MAAA;EAAA,SAC5B,CAAA,EAAA,MAAA;EAAkB,KACT,CAAA,EAAA,MAAA,EAAA;;AACV;AAqBP;;AACO,UA5HU,kBAAA,SAA2B,qBA4HrC,CAAA;EAAI,QACA,CAAA,EA5HC,sBA4HD;EAAsB,QACxB,CAAA,EA5HG,kBA4HH;EAAK,IAAA,CAAA,EA3HN,cA2HM;EAwCQ,MAAA,CAAA,EAlKZ,UAkKwB;;;;;AAEb,iBA5JL,mBAAA,CAAA,CA4JK,EA5Jc,mBAAA,CAAA,MA4Jd;;;;AAEX,iBAvJM,gBAAA,CAuJN,KAAA,EAvJ8B,kBAuJ9B,CAAA,EAvJmD,UAuJnD;AA0BV;;;AAAwE,iBAjIxD,mBAAA,CAiIwD,OAAA,EAhI9D,MAgI8D,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA,CAAA,CAAA,EA/HrE,OA+HqE;AAAI;AAW5E;;AAEY,iBA1HI,kBAAA,CA0HJ,OAAA,EAzHF,MAyHE,CAAA,MAAA,EAAA,MAAA,CAAA,EAAA,GAAA,CAAA,EAxHL,OAwHK,CAAA,EAvHT,MAuHS,CAAA,MAAA,EAAA,MAAA,CAAA;;;;AAED,iBAhHK,oBAAA,CAgHL,KAAA,EA/GH,kBA+GG,EAAA,aAAA,CAAA,EA9GM,OA8GN,CAAA,EA7GR,IA6GQ;;AAAD;AA2BV;iBAnHgB,WAAA,OACT,gBACI,gCACF;;;;;;;;;;;;;;;iBAwCa,uBACd,+BACI,SAAS,QAAQ;;oBACZ,UACd,QAAQ;;;;iBA0BK,eAAA,4BAA2C,aAAa;;;;iBAWlD,0CAEV,SAAS,QAAQ,iBACf,aACX,QAAQ;;;;iBA2BK,gBAAA,CAAA"}
|