@geekmidas/telescope 10.0.0-alpha.98 → 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,336 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { createRedactor, DEFAULT_REDACT_PATHS } from '../redact';
|
|
3
|
+
import { InMemoryStorage } from '../storage/memory';
|
|
4
|
+
import { Telescope } from '../Telescope';
|
|
5
|
+
|
|
6
|
+
describe('createRedactor', () => {
|
|
7
|
+
it('should return undefined when options is undefined', () => {
|
|
8
|
+
expect(createRedactor(undefined)).toBeUndefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should return undefined when options is false', () => {
|
|
12
|
+
expect(createRedactor(false)).toBeUndefined();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should create redactor with default paths when options is true', () => {
|
|
16
|
+
const redactor = createRedactor(true);
|
|
17
|
+
expect(redactor).toBeDefined();
|
|
18
|
+
|
|
19
|
+
const data = { headers: { authorization: 'Bearer secret' } };
|
|
20
|
+
const result = redactor?.(data);
|
|
21
|
+
expect(result.headers.authorization).toBe('[REDACTED]');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should merge custom paths with defaults when array is provided', () => {
|
|
25
|
+
const redactor = createRedactor(['custom.secret']);
|
|
26
|
+
expect(redactor).toBeDefined();
|
|
27
|
+
|
|
28
|
+
// Should redact default paths
|
|
29
|
+
const data1 = { headers: { authorization: 'Bearer token' } };
|
|
30
|
+
expect(redactor?.(data1).headers.authorization).toBe('[REDACTED]');
|
|
31
|
+
|
|
32
|
+
// Should redact custom paths
|
|
33
|
+
const data2 = { custom: { secret: 'mysecret' } };
|
|
34
|
+
expect(redactor?.(data2).custom.secret).toBe('[REDACTED]');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should use custom censor value', () => {
|
|
38
|
+
const redactor = createRedactor({ paths: [], censor: '***' });
|
|
39
|
+
expect(redactor).toBeDefined();
|
|
40
|
+
|
|
41
|
+
const data = { headers: { authorization: 'Bearer token' } };
|
|
42
|
+
const result = redactor?.(data);
|
|
43
|
+
expect(result.headers.authorization).toBe('***');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should not modify unmatched paths', () => {
|
|
47
|
+
const redactor = createRedactor(true);
|
|
48
|
+
|
|
49
|
+
const data = {
|
|
50
|
+
headers: { 'content-type': 'application/json' },
|
|
51
|
+
body: { username: 'john', email: 'john@example.com' },
|
|
52
|
+
};
|
|
53
|
+
const result = redactor?.(data);
|
|
54
|
+
|
|
55
|
+
expect(result.headers['content-type']).toBe('application/json');
|
|
56
|
+
expect(result.body.username).toBe('john');
|
|
57
|
+
expect(result.body.email).toBe('john@example.com');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('DEFAULT_REDACT_PATHS', () => {
|
|
62
|
+
it('should include common HTTP header paths', () => {
|
|
63
|
+
expect(DEFAULT_REDACT_PATHS).toContain('headers.authorization');
|
|
64
|
+
expect(DEFAULT_REDACT_PATHS).toContain('headers.cookie');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should include body sensitive field paths', () => {
|
|
68
|
+
expect(DEFAULT_REDACT_PATHS).toContain('body.password');
|
|
69
|
+
expect(DEFAULT_REDACT_PATHS).toContain('body.token');
|
|
70
|
+
expect(DEFAULT_REDACT_PATHS).toContain('body.apiKey');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should include context paths for log redaction', () => {
|
|
74
|
+
expect(DEFAULT_REDACT_PATHS).toContain('context.password');
|
|
75
|
+
expect(DEFAULT_REDACT_PATHS).toContain('context.token');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('Telescope with redaction', () => {
|
|
80
|
+
let telescope: Telescope;
|
|
81
|
+
let storage: InMemoryStorage;
|
|
82
|
+
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
storage = new InMemoryStorage();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
afterEach(() => {
|
|
88
|
+
telescope?.destroy();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('recordRequest', () => {
|
|
92
|
+
it('should redact sensitive headers when redact is enabled', async () => {
|
|
93
|
+
telescope = new Telescope({ storage, redact: true });
|
|
94
|
+
|
|
95
|
+
await telescope.recordRequest({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
path: '/api/users',
|
|
98
|
+
url: 'http://localhost/api/users',
|
|
99
|
+
headers: {
|
|
100
|
+
authorization: 'Bearer supersecrettoken',
|
|
101
|
+
cookie: 'session=abc123',
|
|
102
|
+
'content-type': 'application/json',
|
|
103
|
+
},
|
|
104
|
+
query: {},
|
|
105
|
+
status: 200,
|
|
106
|
+
responseHeaders: { 'content-type': 'application/json' },
|
|
107
|
+
duration: 50,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const requests = await telescope.getRequests();
|
|
111
|
+
expect(requests).toHaveLength(1);
|
|
112
|
+
|
|
113
|
+
const req = requests[0];
|
|
114
|
+
expect(req.headers.authorization).toBe('[REDACTED]');
|
|
115
|
+
expect(req.headers.cookie).toBe('[REDACTED]');
|
|
116
|
+
expect(req.headers['content-type']).toBe('application/json');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should redact sensitive body fields', async () => {
|
|
120
|
+
telescope = new Telescope({ storage, redact: true });
|
|
121
|
+
|
|
122
|
+
await telescope.recordRequest({
|
|
123
|
+
method: 'POST',
|
|
124
|
+
path: '/api/login',
|
|
125
|
+
url: 'http://localhost/api/login',
|
|
126
|
+
headers: {},
|
|
127
|
+
query: {},
|
|
128
|
+
body: {
|
|
129
|
+
username: 'john',
|
|
130
|
+
password: 'secret123',
|
|
131
|
+
token: 'refresh-token-value',
|
|
132
|
+
},
|
|
133
|
+
status: 200,
|
|
134
|
+
responseHeaders: {},
|
|
135
|
+
responseBody: {
|
|
136
|
+
accessToken: 'jwt-token',
|
|
137
|
+
user: { id: '123', name: 'John' },
|
|
138
|
+
},
|
|
139
|
+
duration: 100,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const requests = await telescope.getRequests();
|
|
143
|
+
const req = requests[0];
|
|
144
|
+
|
|
145
|
+
expect(req.body).toEqual({
|
|
146
|
+
username: 'john',
|
|
147
|
+
password: '[REDACTED]',
|
|
148
|
+
token: '[REDACTED]',
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
expect(req.responseBody).toEqual({
|
|
152
|
+
accessToken: '[REDACTED]',
|
|
153
|
+
user: { id: '123', name: 'John' },
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should redact query parameters', async () => {
|
|
158
|
+
telescope = new Telescope({ storage, redact: true });
|
|
159
|
+
|
|
160
|
+
await telescope.recordRequest({
|
|
161
|
+
method: 'GET',
|
|
162
|
+
path: '/api/data',
|
|
163
|
+
url: 'http://localhost/api/data?token=secret&page=1',
|
|
164
|
+
headers: {},
|
|
165
|
+
query: {
|
|
166
|
+
token: 'secret-token',
|
|
167
|
+
api_key: 'my-api-key',
|
|
168
|
+
page: '1',
|
|
169
|
+
},
|
|
170
|
+
status: 200,
|
|
171
|
+
responseHeaders: {},
|
|
172
|
+
duration: 50,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const requests = await telescope.getRequests();
|
|
176
|
+
const req = requests[0];
|
|
177
|
+
|
|
178
|
+
expect(req.query?.token).toBe('[REDACTED]');
|
|
179
|
+
expect(req.query?.api_key).toBe('[REDACTED]');
|
|
180
|
+
expect(req.query?.page).toBe('1');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should not redact when redact option is not set', async () => {
|
|
184
|
+
telescope = new Telescope({ storage }); // No redact option
|
|
185
|
+
|
|
186
|
+
await telescope.recordRequest({
|
|
187
|
+
method: 'GET',
|
|
188
|
+
path: '/api/users',
|
|
189
|
+
url: 'http://localhost/api/users',
|
|
190
|
+
headers: { authorization: 'Bearer token' },
|
|
191
|
+
query: {},
|
|
192
|
+
status: 200,
|
|
193
|
+
responseHeaders: {},
|
|
194
|
+
duration: 50,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const requests = await telescope.getRequests();
|
|
198
|
+
expect(requests[0].headers.authorization).toBe('Bearer token');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should use custom censor value', async () => {
|
|
202
|
+
telescope = new Telescope({
|
|
203
|
+
storage,
|
|
204
|
+
redact: { paths: [], censor: '***HIDDEN***' },
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await telescope.recordRequest({
|
|
208
|
+
method: 'GET',
|
|
209
|
+
path: '/api/users',
|
|
210
|
+
url: 'http://localhost/api/users',
|
|
211
|
+
headers: { authorization: 'Bearer token' },
|
|
212
|
+
query: {},
|
|
213
|
+
status: 200,
|
|
214
|
+
responseHeaders: {},
|
|
215
|
+
duration: 50,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const requests = await telescope.getRequests();
|
|
219
|
+
expect(requests[0].headers.authorization).toBe('***HIDDEN***');
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('logging', () => {
|
|
224
|
+
it('should redact sensitive context in info()', async () => {
|
|
225
|
+
telescope = new Telescope({ storage, redact: true });
|
|
226
|
+
|
|
227
|
+
await telescope.info('User authenticated', {
|
|
228
|
+
userId: '123',
|
|
229
|
+
password: 'shouldnotshow',
|
|
230
|
+
token: 'sensitive-token',
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const logs = await telescope.getLogs();
|
|
234
|
+
expect(logs).toHaveLength(1);
|
|
235
|
+
|
|
236
|
+
const log = logs[0];
|
|
237
|
+
expect(log.context?.userId).toBe('123');
|
|
238
|
+
expect(log.context?.password).toBe('[REDACTED]');
|
|
239
|
+
expect(log.context?.token).toBe('[REDACTED]');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should redact context in debug()', async () => {
|
|
243
|
+
telescope = new Telescope({ storage, redact: true });
|
|
244
|
+
|
|
245
|
+
await telescope.debug('Debug info', { secret: 'mysecret' });
|
|
246
|
+
|
|
247
|
+
const logs = await telescope.getLogs();
|
|
248
|
+
expect(logs[0].context?.secret).toBe('[REDACTED]');
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('should redact context in warn()', async () => {
|
|
252
|
+
telescope = new Telescope({ storage, redact: true });
|
|
253
|
+
|
|
254
|
+
await telescope.warn('Warning', { apiKey: 'key123' });
|
|
255
|
+
|
|
256
|
+
const logs = await telescope.getLogs();
|
|
257
|
+
expect(logs[0].context?.apiKey).toBe('[REDACTED]');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should redact context in error()', async () => {
|
|
261
|
+
telescope = new Telescope({ storage, redact: true });
|
|
262
|
+
|
|
263
|
+
await telescope.error('Error occurred', { password: 'pass' });
|
|
264
|
+
|
|
265
|
+
const logs = await telescope.getLogs();
|
|
266
|
+
expect(logs[0].context?.password).toBe('[REDACTED]');
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('should redact batch log entries', async () => {
|
|
270
|
+
telescope = new Telescope({ storage, redact: true });
|
|
271
|
+
|
|
272
|
+
await telescope.log([
|
|
273
|
+
{ level: 'info', message: 'First', context: { token: 'abc' } },
|
|
274
|
+
{ level: 'debug', message: 'Second', context: { password: 'xyz' } },
|
|
275
|
+
]);
|
|
276
|
+
|
|
277
|
+
const logs = await telescope.getLogs();
|
|
278
|
+
expect(logs).toHaveLength(2);
|
|
279
|
+
expect(logs.find((l) => l.message === 'First')?.context?.token).toBe(
|
|
280
|
+
'[REDACTED]',
|
|
281
|
+
);
|
|
282
|
+
expect(logs.find((l) => l.message === 'Second')?.context?.password).toBe(
|
|
283
|
+
'[REDACTED]',
|
|
284
|
+
);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('should not redact log message', async () => {
|
|
288
|
+
telescope = new Telescope({ storage, redact: true });
|
|
289
|
+
|
|
290
|
+
await telescope.info('Password changed for user');
|
|
291
|
+
|
|
292
|
+
const logs = await telescope.getLogs();
|
|
293
|
+
expect(logs[0].message).toBe('Password changed for user');
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('custom paths', () => {
|
|
298
|
+
it('should redact custom paths merged with defaults', async () => {
|
|
299
|
+
telescope = new Telescope({
|
|
300
|
+
storage,
|
|
301
|
+
redact: ['body.customSecret', 'context.privateData'],
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
await telescope.recordRequest({
|
|
305
|
+
method: 'POST',
|
|
306
|
+
path: '/api/data',
|
|
307
|
+
url: 'http://localhost/api/data',
|
|
308
|
+
headers: { authorization: 'Bearer token' },
|
|
309
|
+
query: {},
|
|
310
|
+
body: {
|
|
311
|
+
customSecret: 'my-custom-secret',
|
|
312
|
+
normalField: 'visible',
|
|
313
|
+
},
|
|
314
|
+
status: 200,
|
|
315
|
+
responseHeaders: {},
|
|
316
|
+
duration: 50,
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
await telescope.info('Log with custom field', {
|
|
320
|
+
privateData: 'hidden',
|
|
321
|
+
publicData: 'visible',
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const requests = await telescope.getRequests();
|
|
325
|
+
expect(requests[0].headers.authorization).toBe('[REDACTED]');
|
|
326
|
+
expect(requests[0].body).toEqual({
|
|
327
|
+
customSecret: '[REDACTED]',
|
|
328
|
+
normalField: 'visible',
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const logs = await telescope.getLogs();
|
|
332
|
+
expect(logs[0].context?.privateData).toBe('[REDACTED]');
|
|
333
|
+
expect(logs[0].context?.publicData).toBe('visible');
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { Context as LambdaContext } from 'aws-lambda';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { InMemoryStorage } from '../../storage/memory';
|
|
4
|
+
import { Telescope } from '../../Telescope';
|
|
5
|
+
import {
|
|
6
|
+
detectLambdaResources,
|
|
7
|
+
extractLambdaInvocationContext,
|
|
8
|
+
LambdaAdapter,
|
|
9
|
+
wrapLambdaHandler,
|
|
10
|
+
} from '../lambda';
|
|
11
|
+
|
|
12
|
+
describe('Lambda Adapter', () => {
|
|
13
|
+
let telescope: Telescope;
|
|
14
|
+
let storage: InMemoryStorage;
|
|
15
|
+
let mockContext: LambdaContext;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
storage = new InMemoryStorage();
|
|
19
|
+
telescope = new Telescope({ storage });
|
|
20
|
+
|
|
21
|
+
mockContext = {
|
|
22
|
+
callbackWaitsForEmptyEventLoop: true,
|
|
23
|
+
functionName: 'test-function',
|
|
24
|
+
functionVersion: '1',
|
|
25
|
+
invokedFunctionArn: 'arn:aws:lambda:us-east-1:123456789:function:test',
|
|
26
|
+
memoryLimitInMB: '256',
|
|
27
|
+
awsRequestId: 'test-request-id-123',
|
|
28
|
+
logGroupName: '/aws/lambda/test',
|
|
29
|
+
logStreamName: '2024/01/01/[$LATEST]abc123',
|
|
30
|
+
getRemainingTimeInMillis: () => 10000,
|
|
31
|
+
done: vi.fn(),
|
|
32
|
+
fail: vi.fn(),
|
|
33
|
+
succeed: vi.fn(),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('detectLambdaResources', () => {
|
|
38
|
+
it('should detect Lambda environment variables', () => {
|
|
39
|
+
const originalEnv = { ...process.env };
|
|
40
|
+
|
|
41
|
+
process.env.AWS_REGION = 'us-west-2';
|
|
42
|
+
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-function';
|
|
43
|
+
process.env.AWS_LAMBDA_FUNCTION_VERSION = '$LATEST';
|
|
44
|
+
process.env.AWS_LAMBDA_LOG_STREAM_NAME = 'log-stream-123';
|
|
45
|
+
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '512';
|
|
46
|
+
|
|
47
|
+
const resources = detectLambdaResources();
|
|
48
|
+
|
|
49
|
+
expect(resources['cloud.provider']).toBe('aws');
|
|
50
|
+
expect(resources['cloud.region']).toBe('us-west-2');
|
|
51
|
+
expect(resources['faas.name']).toBe('my-function');
|
|
52
|
+
expect(resources['faas.version']).toBe('$LATEST');
|
|
53
|
+
expect(resources['faas.instance']).toBe('log-stream-123');
|
|
54
|
+
expect(resources['faas.max_memory']).toBe(512);
|
|
55
|
+
|
|
56
|
+
process.env = originalEnv;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return defaults when environment variables are missing', () => {
|
|
60
|
+
const originalEnv = { ...process.env };
|
|
61
|
+
|
|
62
|
+
delete process.env.AWS_REGION;
|
|
63
|
+
delete process.env.AWS_LAMBDA_FUNCTION_NAME;
|
|
64
|
+
delete process.env.AWS_LAMBDA_FUNCTION_VERSION;
|
|
65
|
+
delete process.env.AWS_LAMBDA_LOG_STREAM_NAME;
|
|
66
|
+
delete process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;
|
|
67
|
+
|
|
68
|
+
const resources = detectLambdaResources();
|
|
69
|
+
|
|
70
|
+
expect(resources['cloud.provider']).toBe('aws');
|
|
71
|
+
expect(resources['cloud.region']).toBe('unknown');
|
|
72
|
+
expect(resources['faas.name']).toBe('unknown');
|
|
73
|
+
expect(resources['faas.version']).toBe('unknown');
|
|
74
|
+
expect(resources['faas.instance']).toBe('unknown');
|
|
75
|
+
expect(resources['faas.max_memory']).toBe(128); // Default memory
|
|
76
|
+
|
|
77
|
+
process.env = originalEnv;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('extractLambdaInvocationContext', () => {
|
|
82
|
+
it('should extract invocation context from Lambda context', () => {
|
|
83
|
+
const result = extractLambdaInvocationContext({}, mockContext);
|
|
84
|
+
|
|
85
|
+
expect(result.requestId).toBe('test-request-id-123');
|
|
86
|
+
expect(result.remainingTimeMs).toBe(10000);
|
|
87
|
+
expect(result.memoryLimitMB).toBe(256);
|
|
88
|
+
expect(result.functionName).toBe('test-function');
|
|
89
|
+
expect(result.functionVersion).toBe('1');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('LambdaAdapter', () => {
|
|
94
|
+
it('should create adapter with default config', () => {
|
|
95
|
+
const adapter = new LambdaAdapter(telescope);
|
|
96
|
+
|
|
97
|
+
expect(adapter.config.environment).toBe('lambda');
|
|
98
|
+
expect(adapter.config.autoFlush).toBe(true);
|
|
99
|
+
expect(adapter.config.detectResource).toBe(true);
|
|
100
|
+
expect(adapter.config.spanProcessor?.strategy).toBe('simple');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should merge custom config with defaults', () => {
|
|
104
|
+
const adapter = new LambdaAdapter(telescope, {
|
|
105
|
+
autoFlush: false,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(adapter.config.autoFlush).toBe(false);
|
|
109
|
+
expect(adapter.config.environment).toBe('lambda'); // Default preserved
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('extractRequestContext', () => {
|
|
113
|
+
it('should extract context from API Gateway v1 event', () => {
|
|
114
|
+
const adapter = new LambdaAdapter(telescope);
|
|
115
|
+
const event = {
|
|
116
|
+
httpMethod: 'POST',
|
|
117
|
+
path: '/api/users',
|
|
118
|
+
headers: { 'Content-Type': 'application/json' },
|
|
119
|
+
queryStringParameters: { page: '1' },
|
|
120
|
+
body: JSON.stringify({ name: 'John' }),
|
|
121
|
+
requestContext: {
|
|
122
|
+
requestId: 'req-123',
|
|
123
|
+
identity: { sourceIp: '192.168.1.1' },
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const context = adapter.extractRequestContext(event);
|
|
128
|
+
|
|
129
|
+
expect(context.method).toBe('POST');
|
|
130
|
+
expect(context.path).toBe('/api/users');
|
|
131
|
+
expect(context.query).toEqual({ page: '1' });
|
|
132
|
+
expect(context.body).toEqual({ name: 'John' });
|
|
133
|
+
expect(context.ip).toBe('192.168.1.1');
|
|
134
|
+
expect(context.id).toBe('req-123');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should extract context from API Gateway v2 event', () => {
|
|
138
|
+
const adapter = new LambdaAdapter(telescope);
|
|
139
|
+
const event = {
|
|
140
|
+
rawPath: '/api/items',
|
|
141
|
+
headers: { 'content-type': 'application/json' },
|
|
142
|
+
queryStringParameters: { limit: '10' },
|
|
143
|
+
body: JSON.stringify({ data: 'test' }),
|
|
144
|
+
requestContext: {
|
|
145
|
+
requestId: 'req-456',
|
|
146
|
+
http: {
|
|
147
|
+
method: 'GET',
|
|
148
|
+
sourceIp: '10.0.0.1',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const context = adapter.extractRequestContext(event);
|
|
154
|
+
|
|
155
|
+
expect(context.method).toBe('GET');
|
|
156
|
+
expect(context.path).toBe('/api/items');
|
|
157
|
+
expect(context.query).toEqual({ limit: '10' });
|
|
158
|
+
expect(context.body).toEqual({ data: 'test' });
|
|
159
|
+
expect(context.ip).toBe('10.0.0.1');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should extract context from ALB event', () => {
|
|
163
|
+
const adapter = new LambdaAdapter(telescope);
|
|
164
|
+
// ALB events don't have requestContext, so the adapter falls back to generic handling
|
|
165
|
+
const event = {
|
|
166
|
+
httpMethod: 'DELETE',
|
|
167
|
+
path: '/api/resource/123',
|
|
168
|
+
headers: {},
|
|
169
|
+
queryStringParameters: null,
|
|
170
|
+
body: null,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const context = adapter.extractRequestContext(event);
|
|
174
|
+
|
|
175
|
+
expect(context.method).toBe('DELETE');
|
|
176
|
+
expect(context.path).toBe('/api/resource/123');
|
|
177
|
+
// ALB without x-forwarded-for will have undefined IP
|
|
178
|
+
expect(context.ip).toBeUndefined();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should handle generic Lambda invocation', () => {
|
|
182
|
+
const adapter = new LambdaAdapter(telescope);
|
|
183
|
+
const event = { customField: 'value' };
|
|
184
|
+
|
|
185
|
+
const context = adapter.extractRequestContext(event);
|
|
186
|
+
|
|
187
|
+
expect(context.method).toBe('INVOKE');
|
|
188
|
+
expect(context.path).toBe('/');
|
|
189
|
+
expect(context.body).toEqual({ customField: 'value' });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should handle base64 encoded body', () => {
|
|
193
|
+
const adapter = new LambdaAdapter(telescope);
|
|
194
|
+
const bodyContent = { encoded: true };
|
|
195
|
+
const event = {
|
|
196
|
+
httpMethod: 'POST',
|
|
197
|
+
path: '/upload',
|
|
198
|
+
headers: {},
|
|
199
|
+
body: Buffer.from(JSON.stringify(bodyContent)).toString('base64'),
|
|
200
|
+
isBase64Encoded: true,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const context = adapter.extractRequestContext(event);
|
|
204
|
+
|
|
205
|
+
expect(context.body).toEqual({ encoded: true });
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('extractResponseContext', () => {
|
|
210
|
+
it('should extract context from API Gateway response', () => {
|
|
211
|
+
const adapter = new LambdaAdapter(telescope);
|
|
212
|
+
const response = {
|
|
213
|
+
statusCode: 201,
|
|
214
|
+
headers: { 'x-custom': 'header' },
|
|
215
|
+
body: JSON.stringify({ created: true }),
|
|
216
|
+
};
|
|
217
|
+
const startTime = Date.now() - 100;
|
|
218
|
+
|
|
219
|
+
const context = adapter.extractResponseContext(response, startTime);
|
|
220
|
+
|
|
221
|
+
expect(context.status).toBe(201);
|
|
222
|
+
expect(context.headers).toEqual({ 'x-custom': 'header' });
|
|
223
|
+
expect(context.body).toBe('{"created":true}');
|
|
224
|
+
expect(context.duration).toBeGreaterThanOrEqual(100);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should handle generic response', () => {
|
|
228
|
+
const adapter = new LambdaAdapter(telescope);
|
|
229
|
+
const response = { data: 'raw' };
|
|
230
|
+
const startTime = Date.now() - 50;
|
|
231
|
+
|
|
232
|
+
const context = adapter.extractResponseContext(response, startTime);
|
|
233
|
+
|
|
234
|
+
expect(context.status).toBe(200);
|
|
235
|
+
expect(context.body).toEqual({ data: 'raw' });
|
|
236
|
+
// Use 45ms threshold to account for timing variations
|
|
237
|
+
expect(context.duration).toBeGreaterThanOrEqual(45);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('onSetup', () => {
|
|
242
|
+
it('should detect resources when detectResource is true', async () => {
|
|
243
|
+
const adapter = new LambdaAdapter(telescope, { detectResource: true });
|
|
244
|
+
|
|
245
|
+
await adapter.onSetup();
|
|
246
|
+
|
|
247
|
+
expect(adapter.getResourceAttributes()).not.toBeNull();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should not detect resources when detectResource is false', async () => {
|
|
251
|
+
const adapter = new LambdaAdapter(telescope, { detectResource: false });
|
|
252
|
+
|
|
253
|
+
await adapter.onSetup();
|
|
254
|
+
|
|
255
|
+
expect(adapter.getResourceAttributes()).toBeNull();
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
describe('wrapLambdaHandler', () => {
|
|
261
|
+
it('should wrap handler and record successful request', async () => {
|
|
262
|
+
const baseHandler = async () => ({
|
|
263
|
+
statusCode: 200,
|
|
264
|
+
body: JSON.stringify({ ok: true }),
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const wrappedHandler = wrapLambdaHandler(telescope, baseHandler);
|
|
268
|
+
|
|
269
|
+
const event = {
|
|
270
|
+
httpMethod: 'GET',
|
|
271
|
+
path: '/health',
|
|
272
|
+
headers: {},
|
|
273
|
+
queryStringParameters: null,
|
|
274
|
+
body: null,
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const result = await wrappedHandler(event, mockContext);
|
|
278
|
+
|
|
279
|
+
expect(result).toEqual({
|
|
280
|
+
statusCode: 200,
|
|
281
|
+
body: JSON.stringify({ ok: true }),
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const requests = await storage.getRequests();
|
|
285
|
+
expect(requests).toHaveLength(1);
|
|
286
|
+
expect(requests[0].method).toBe('GET');
|
|
287
|
+
expect(requests[0].path).toBe('/health');
|
|
288
|
+
expect(requests[0].status).toBe(200);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('should record exception and rethrow on error', async () => {
|
|
292
|
+
const error = new Error('Handler error');
|
|
293
|
+
const baseHandler = async () => {
|
|
294
|
+
throw error;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const wrappedHandler = wrapLambdaHandler(telescope, baseHandler);
|
|
298
|
+
|
|
299
|
+
await expect(wrappedHandler({}, mockContext)).rejects.toThrow(
|
|
300
|
+
'Handler error',
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
const exceptions = await storage.getExceptions();
|
|
304
|
+
expect(exceptions).toHaveLength(1);
|
|
305
|
+
expect(exceptions[0].message).toBe('Handler error');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should pass event and context to handler', async () => {
|
|
309
|
+
const baseHandler = vi.fn().mockResolvedValue({ statusCode: 200 });
|
|
310
|
+
const wrappedHandler = wrapLambdaHandler(telescope, baseHandler);
|
|
311
|
+
|
|
312
|
+
const event = { test: 'event' };
|
|
313
|
+
await wrappedHandler(event, mockContext);
|
|
314
|
+
|
|
315
|
+
expect(baseHandler).toHaveBeenCalledWith(event, mockContext);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|