@geekmidas/telescope 10.0.0-alpha.2 → 10.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MetricsAggregator-4SqelGcG.d.cts → MetricsAggregator-BxBLQUPj.d.cts} +3 -6
- package/dist/MetricsAggregator-BxBLQUPj.d.cts.map +1 -0
- package/dist/{MetricsAggregator-DZrW8ls6.d.mts → MetricsAggregator-j9wmZ0K_.d.mts} +3 -6
- package/dist/MetricsAggregator-j9wmZ0K_.d.mts.map +1 -0
- package/dist/{Telescope-D4nmwDRA.d.cts → Telescope-BcrWTaar.d.mts} +4 -7
- package/dist/Telescope-BcrWTaar.d.mts.map +1 -0
- package/dist/{Telescope-Dl6VSfxd.d.mts → Telescope-DnCMZT7V.d.cts} +4 -7
- package/dist/Telescope-DnCMZT7V.d.cts.map +1 -0
- package/dist/Telescope.cjs +385 -4
- package/dist/Telescope.cjs.map +1 -0
- package/dist/Telescope.d.cts +1 -3
- package/dist/Telescope.d.mts +1 -3
- package/dist/Telescope.mjs +384 -4
- package/dist/Telescope.mjs.map +1 -0
- package/dist/adapters/index.d.cts +2 -2
- package/dist/adapters/index.d.mts +2 -2
- package/dist/adapters/index.mjs +1 -0
- package/dist/adapters/lambda.cjs +9 -10
- package/dist/adapters/lambda.cjs.map +1 -1
- package/dist/adapters/lambda.d.cts +9 -13
- package/dist/adapters/lambda.d.cts.map +1 -1
- package/dist/adapters/lambda.d.mts +9 -13
- package/dist/adapters/lambda.d.mts.map +1 -1
- package/dist/adapters/lambda.mjs +3 -4
- package/dist/adapters/lambda.mjs.map +1 -1
- package/dist/adapters/middy.cjs +236 -4
- package/dist/adapters/middy.cjs.map +1 -0
- package/dist/adapters/middy.d.cts +60 -5
- package/dist/adapters/middy.d.cts.map +1 -0
- package/dist/adapters/middy.d.mts +60 -5
- package/dist/adapters/middy.d.mts.map +1 -0
- package/dist/adapters/middy.mjs +234 -3
- package/dist/adapters/middy.mjs.map +1 -0
- package/dist/adapters/types.d.cts +162 -2
- package/dist/adapters/types.d.cts.map +1 -0
- package/dist/adapters/types.d.mts +162 -2
- package/dist/adapters/types.d.mts.map +1 -0
- package/dist/adapters/types.mjs +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 +3 -4
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts +5 -6
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +5 -7
- package/dist/instrumentation/core.cjs +147 -11
- package/dist/instrumentation/core.cjs.map +1 -0
- package/dist/instrumentation/core.d.cts +74 -3
- package/dist/instrumentation/core.d.cts.map +1 -0
- package/dist/instrumentation/core.d.mts +74 -3
- package/dist/instrumentation/core.d.mts.map +1 -0
- package/dist/instrumentation/core.mjs +137 -2
- package/dist/instrumentation/core.mjs.map +1 -0
- package/dist/instrumentation/hono.cjs +134 -6
- package/dist/instrumentation/hono.cjs.map +1 -0
- package/dist/instrumentation/hono.d.cts +67 -2
- package/dist/instrumentation/hono.d.cts.map +1 -0
- package/dist/instrumentation/hono.d.mts +67 -2
- package/dist/instrumentation/hono.d.mts.map +1 -0
- package/dist/instrumentation/hono.mjs +130 -3
- package/dist/instrumentation/hono.mjs.map +1 -0
- package/dist/instrumentation/http.cjs +164 -11
- package/dist/instrumentation/http.cjs.map +1 -0
- package/dist/instrumentation/http.d.cts +103 -2
- package/dist/instrumentation/http.d.cts.map +1 -0
- package/dist/instrumentation/http.d.mts +103 -2
- package/dist/instrumentation/http.d.mts.map +1 -0
- package/dist/instrumentation/http.mjs +154 -2
- package/dist/instrumentation/http.mjs.map +1 -0
- package/dist/instrumentation/index.cjs +47 -47
- package/dist/instrumentation/index.d.cts +9 -9
- package/dist/instrumentation/index.d.mts +9 -9
- package/dist/instrumentation/index.mjs +8 -9
- package/dist/instrumentation/middleware.cjs +162 -6
- package/dist/instrumentation/middleware.cjs.map +1 -0
- package/dist/instrumentation/middleware.d.cts +70 -2
- package/dist/instrumentation/middleware.d.cts.map +1 -0
- package/dist/instrumentation/middleware.d.mts +70 -2
- package/dist/instrumentation/middleware.d.mts.map +1 -0
- package/dist/instrumentation/middleware.mjs +158 -3
- package/dist/instrumentation/middleware.mjs.map +1 -0
- package/dist/instrumentation/otel.cjs +137 -3
- package/dist/instrumentation/otel.cjs.map +1 -0
- package/dist/instrumentation/otel.d.cts +97 -2
- package/dist/instrumentation/otel.d.cts.map +1 -0
- package/dist/instrumentation/otel.d.mts +97 -2
- package/dist/instrumentation/otel.d.mts.map +1 -0
- package/dist/instrumentation/otel.mjs +136 -3
- package/dist/instrumentation/otel.mjs.map +1 -0
- package/dist/instrumentation/setup.cjs +100 -4
- package/dist/instrumentation/setup.cjs.map +1 -0
- package/dist/instrumentation/setup.d.cts +83 -3
- package/dist/instrumentation/setup.d.cts.map +1 -0
- package/dist/instrumentation/setup.d.mts +83 -3
- package/dist/instrumentation/setup.d.mts.map +1 -0
- package/dist/instrumentation/setup.mjs +98 -3
- package/dist/instrumentation/setup.mjs.map +1 -0
- package/dist/instrumentation/tracing.cjs +114 -10
- package/dist/instrumentation/tracing.cjs.map +1 -0
- package/dist/instrumentation/tracing.d.cts +49 -2
- package/dist/instrumentation/tracing.d.cts.map +1 -0
- package/dist/instrumentation/tracing.d.mts +49 -2
- package/dist/instrumentation/tracing.d.mts.map +1 -0
- package/dist/instrumentation/tracing.mjs +105 -2
- package/dist/instrumentation/tracing.mjs.map +1 -0
- package/dist/logger/console.cjs +18 -12
- package/dist/logger/console.cjs.map +1 -1
- package/dist/logger/console.d.cts +7 -10
- package/dist/logger/console.d.cts.map +1 -1
- package/dist/logger/console.d.mts +7 -10
- package/dist/logger/console.d.mts.map +1 -1
- package/dist/logger/console.mjs +17 -11
- package/dist/logger/console.mjs.map +1 -1
- package/dist/logger/pino.cjs +6 -5
- package/dist/logger/pino.cjs.map +1 -1
- package/dist/logger/pino.d.cts +6 -10
- package/dist/logger/pino.d.cts.map +1 -1
- package/dist/logger/pino.d.mts +6 -10
- package/dist/logger/pino.d.mts.map +1 -1
- package/dist/logger/pino.mjs +2 -3
- package/dist/logger/pino.mjs.map +1 -1
- package/dist/metrics/MetricsAggregator.cjs +354 -2
- package/dist/metrics/MetricsAggregator.cjs.map +1 -0
- package/dist/metrics/MetricsAggregator.d.cts +1 -2
- package/dist/metrics/MetricsAggregator.d.mts +1 -2
- package/dist/metrics/MetricsAggregator.mjs +353 -2
- package/dist/metrics/MetricsAggregator.mjs.map +1 -0
- package/dist/metrics/index.cjs +3 -4
- package/dist/metrics/index.d.cts +2 -4
- package/dist/metrics/index.d.mts +2 -4
- package/dist/metrics/index.mjs +2 -4
- package/dist/metrics/storage/InMemoryMetricsStorage.cjs +240 -3
- package/dist/metrics/storage/InMemoryMetricsStorage.cjs.map +1 -0
- package/dist/metrics/storage/InMemoryMetricsStorage.d.cts +43 -4
- package/dist/metrics/storage/InMemoryMetricsStorage.d.cts.map +1 -0
- package/dist/metrics/storage/InMemoryMetricsStorage.d.mts +43 -4
- package/dist/metrics/storage/InMemoryMetricsStorage.d.mts.map +1 -0
- package/dist/metrics/storage/InMemoryMetricsStorage.mjs +239 -3
- package/dist/metrics/storage/InMemoryMetricsStorage.mjs.map +1 -0
- package/dist/metrics/storage/MetricsStorage.cjs +0 -1
- package/dist/metrics/storage/MetricsStorage.d.cts +56 -3
- package/dist/metrics/storage/MetricsStorage.d.cts.map +1 -0
- package/dist/metrics/storage/MetricsStorage.d.mts +56 -3
- package/dist/metrics/storage/MetricsStorage.d.mts.map +1 -0
- 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 +4 -5
- package/dist/metrics/storage/types.cjs +34 -2
- package/dist/metrics/storage/types.cjs.map +1 -0
- package/dist/metrics/storage/types.d.cts +207 -2
- package/dist/metrics/storage/types.d.cts.map +1 -0
- package/dist/metrics/storage/types.d.mts +207 -2
- package/dist/metrics/storage/types.d.mts.map +1 -0
- package/dist/metrics/storage/types.mjs +33 -2
- package/dist/metrics/storage/types.mjs.map +1 -0
- package/dist/otlp/hono.cjs +9 -15
- package/dist/otlp/hono.cjs.map +1 -1
- package/dist/otlp/hono.d.cts +3 -13
- package/dist/otlp/hono.d.cts.map +1 -1
- package/dist/otlp/hono.d.mts +3 -13
- package/dist/otlp/hono.d.mts.map +1 -1
- package/dist/otlp/hono.mjs +5 -11
- package/dist/otlp/hono.mjs.map +1 -1
- package/dist/otlp/index.cjs +11 -11
- package/dist/otlp/index.d.cts +4 -7
- package/dist/otlp/index.d.mts +4 -7
- package/dist/otlp/index.mjs +4 -5
- package/dist/otlp/receiver.cjs +88 -4
- package/dist/otlp/receiver.cjs.map +1 -0
- package/dist/otlp/receiver.d.cts +59 -7
- package/dist/otlp/receiver.d.cts.map +1 -0
- package/dist/otlp/receiver.d.mts +59 -7
- package/dist/otlp/receiver.d.mts.map +1 -0
- package/dist/otlp/receiver.mjs +87 -4
- package/dist/otlp/receiver.mjs.map +1 -0
- package/dist/otlp/transformer.cjs +214 -5
- package/dist/otlp/transformer.cjs.map +1 -0
- package/dist/otlp/transformer.d.cts +1 -3
- package/dist/otlp/transformer.d.mts +1 -3
- package/dist/otlp/transformer.mjs +211 -3
- package/dist/otlp/transformer.mjs.map +1 -0
- package/dist/otlp/types.cjs +57 -5
- package/dist/otlp/types.cjs.map +1 -0
- package/dist/otlp/types.d.cts +1 -1
- package/dist/otlp/types.d.mts +1 -1
- package/dist/otlp/types.mjs +53 -2
- package/dist/otlp/types.mjs.map +1 -0
- package/dist/redact.cjs +84 -3
- package/dist/redact.cjs.map +1 -0
- package/dist/redact.d.cts +4 -8
- package/dist/redact.d.cts.map +1 -1
- package/dist/redact.d.mts +4 -8
- package/dist/redact.d.mts.map +1 -1
- package/dist/redact.mjs +80 -2
- package/dist/redact.mjs.map +1 -0
- package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-VH7oDXx4.cjs} +8 -10
- package/dist/server/hono.cjs +24 -33
- package/dist/server/hono.cjs.map +1 -1
- package/dist/server/hono.d.cts +10 -13
- package/dist/server/hono.d.cts.map +1 -1
- package/dist/server/hono.d.mts +10 -13
- package/dist/server/hono.d.mts.map +1 -1
- package/dist/server/hono.mjs +22 -31
- package/dist/server/hono.mjs.map +1 -1
- package/dist/storage/kysely.cjs +34 -32
- package/dist/storage/kysely.cjs.map +1 -1
- package/dist/storage/kysely.d.cts +8 -12
- package/dist/storage/kysely.d.cts.map +1 -1
- package/dist/storage/kysely.d.mts +8 -12
- package/dist/storage/kysely.d.mts.map +1 -1
- package/dist/storage/kysely.mjs +33 -31
- package/dist/storage/kysely.mjs.map +1 -1
- package/dist/storage/memory.cjs +122 -2
- package/dist/storage/memory.cjs.map +1 -0
- package/dist/storage/memory.d.cts +36 -3
- package/dist/storage/memory.d.cts.map +1 -0
- package/dist/storage/memory.d.mts +36 -3
- package/dist/storage/memory.d.mts.map +1 -0
- package/dist/storage/memory.mjs +121 -2
- package/dist/storage/memory.mjs.map +1 -0
- package/dist/{transformer-CTGsaVfV.d.mts → transformer-BBBXCjHP.d.mts} +4 -8
- package/dist/transformer-BBBXCjHP.d.mts.map +1 -0
- package/dist/{transformer-ICEbxpFf.d.cts → transformer-DlESim6Q.d.cts} +4 -8
- package/dist/transformer-DlESim6Q.d.cts.map +1 -0
- package/dist/{types-CmOB7CLO.d.cts → types-DVETVdpa.d.cts} +6 -7
- package/dist/types-DVETVdpa.d.cts.map +1 -0
- package/dist/{types-DBc0q5KD.d.mts → types-DVETVdpa.d.mts} +6 -7
- package/dist/types-DVETVdpa.d.mts.map +1 -0
- package/dist/{types-B1EIa_cQ.d.mts → types-a9Vistj1.d.cts} +2 -3
- package/dist/types-a9Vistj1.d.cts.map +1 -0
- package/dist/{types-l7Rlb5Mg.d.cts → types-a9Vistj1.d.mts} +2 -3
- package/dist/types-a9Vistj1.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/ui-assets.cjs +31 -4
- package/dist/ui-assets.cjs.map +1 -0
- package/dist/ui-assets.d.cts +4 -6
- package/dist/ui-assets.d.cts.map +1 -1
- package/dist/ui-assets.d.mts +4 -6
- package/dist/ui-assets.d.mts.map +1 -1
- package/dist/ui-assets.mjs +28 -2
- package/dist/ui-assets.mjs.map +1 -0
- package/package.json +39 -37
- package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts +0 -47
- package/dist/InMemoryMetricsStorage-BbKCL3YL.d.mts.map +0 -1
- package/dist/InMemoryMetricsStorage-C4drxT7G.mjs +0 -247
- package/dist/InMemoryMetricsStorage-C4drxT7G.mjs.map +0 -1
- package/dist/InMemoryMetricsStorage-D0njWUSi.cjs +0 -252
- package/dist/InMemoryMetricsStorage-D0njWUSi.cjs.map +0 -1
- package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts +0 -47
- package/dist/InMemoryMetricsStorage-TvPdZjL0.d.cts.map +0 -1
- package/dist/MetricsAggregator-4SqelGcG.d.cts.map +0 -1
- package/dist/MetricsAggregator-B7lUICdH.cjs +0 -363
- package/dist/MetricsAggregator-B7lUICdH.cjs.map +0 -1
- package/dist/MetricsAggregator-DZrW8ls6.d.mts.map +0 -1
- package/dist/MetricsAggregator-S3DQWNas.mjs +0 -357
- package/dist/MetricsAggregator-S3DQWNas.mjs.map +0 -1
- package/dist/MetricsStorage-B86e4131.d.cts +0 -60
- package/dist/MetricsStorage-B86e4131.d.cts.map +0 -1
- package/dist/MetricsStorage-BWyP2_12.d.mts +0 -60
- package/dist/MetricsStorage-BWyP2_12.d.mts.map +0 -1
- package/dist/MetricsStorage-BypQXWiv.mjs +0 -0
- package/dist/MetricsStorage-Or8pVCe4.cjs +0 -0
- package/dist/Telescope-Cs3fv8jt.cjs +0 -395
- package/dist/Telescope-Cs3fv8jt.cjs.map +0 -1
- package/dist/Telescope-D4nmwDRA.d.cts.map +0 -1
- package/dist/Telescope-Dh5av3FC.mjs +0 -389
- package/dist/Telescope-Dh5av3FC.mjs.map +0 -1
- package/dist/Telescope-Dl6VSfxd.d.mts.map +0 -1
- package/dist/core--quSp5Qr.d.mts +0 -78
- package/dist/core--quSp5Qr.d.mts.map +0 -1
- package/dist/core-B4Jpia5H.d.cts +0 -78
- package/dist/core-B4Jpia5H.d.cts.map +0 -1
- package/dist/core-CtVHRJGv.cjs +0 -199
- package/dist/core-CtVHRJGv.cjs.map +0 -1
- package/dist/core-D6hJ6exL.mjs +0 -139
- package/dist/core-D6hJ6exL.mjs.map +0 -1
- package/dist/hono--uKQ7Jgi.d.mts +0 -71
- package/dist/hono--uKQ7Jgi.d.mts.map +0 -1
- package/dist/hono-Bw-ey6CT.mjs +0 -136
- package/dist/hono-Bw-ey6CT.mjs.map +0 -1
- package/dist/hono-CPHX7FAm.cjs +0 -160
- package/dist/hono-CPHX7FAm.cjs.map +0 -1
- package/dist/hono-CemCKU87.d.cts +0 -71
- package/dist/hono-CemCKU87.d.cts.map +0 -1
- package/dist/http-BIvr0YdI.mjs +0 -159
- package/dist/http-BIvr0YdI.mjs.map +0 -1
- package/dist/http-BiNtg85L.d.mts +0 -107
- package/dist/http-BiNtg85L.d.mts.map +0 -1
- package/dist/http-BsqmhurZ.cjs +0 -219
- package/dist/http-BsqmhurZ.cjs.map +0 -1
- package/dist/http-D1oTbfap.d.cts +0 -107
- package/dist/http-D1oTbfap.d.cts.map +0 -1
- package/dist/index-BL32-cvv.d.cts +0 -1
- package/dist/index-CsuikFeJ.d.mts +0 -1
- package/dist/memory--BK4iWiv.d.cts +0 -40
- package/dist/memory--BK4iWiv.d.cts.map +0 -1
- package/dist/memory-6S9H-IF5.mjs +0 -123
- package/dist/memory-6S9H-IF5.mjs.map +0 -1
- package/dist/memory-B0d_n1g5.cjs +0 -129
- package/dist/memory-B0d_n1g5.cjs.map +0 -1
- package/dist/memory-DCirEVFW.d.mts +0 -40
- package/dist/memory-DCirEVFW.d.mts.map +0 -1
- package/dist/metrics-D5YT-Rnq.mjs +0 -0
- package/dist/metrics-fhD3l3C3.cjs +0 -0
- package/dist/middleware-Bcq6XXGG.cjs +0 -184
- package/dist/middleware-Bcq6XXGG.cjs.map +0 -1
- package/dist/middleware-D1XEHvyy.mjs +0 -160
- package/dist/middleware-D1XEHvyy.mjs.map +0 -1
- package/dist/middleware-PeyS-9Ny.d.cts +0 -74
- package/dist/middleware-PeyS-9Ny.d.cts.map +0 -1
- package/dist/middleware-oHvo_ZgU.d.mts +0 -74
- package/dist/middleware-oHvo_ZgU.d.mts.map +0 -1
- package/dist/middy-B6Btl8XE.d.mts +0 -64
- package/dist/middy-B6Btl8XE.d.mts.map +0 -1
- package/dist/middy-Bq0defVg.d.cts +0 -64
- package/dist/middy-Bq0defVg.d.cts.map +0 -1
- package/dist/middy-DHWLmUAD.mjs +0 -236
- package/dist/middy-DHWLmUAD.mjs.map +0 -1
- package/dist/middy-DlWnZilH.cjs +0 -247
- package/dist/middy-DlWnZilH.cjs.map +0 -1
- package/dist/otel-B9bNoeZ2.mjs +0 -130
- package/dist/otel-B9bNoeZ2.mjs.map +0 -1
- package/dist/otel-Bk89b1lX.d.cts +0 -101
- package/dist/otel-Bk89b1lX.d.cts.map +0 -1
- package/dist/otel-BzjOtVxZ.cjs +0 -136
- package/dist/otel-BzjOtVxZ.cjs.map +0 -1
- package/dist/otel-lPMsM26e.d.mts +0 -101
- package/dist/otel-lPMsM26e.d.mts.map +0 -1
- package/dist/receiver-D46dfkYI.mjs +0 -89
- package/dist/receiver-D46dfkYI.mjs.map +0 -1
- package/dist/receiver-DLICx5uU.d.cts +0 -63
- package/dist/receiver-DLICx5uU.d.cts.map +0 -1
- package/dist/receiver-UeZT-H8u.d.mts +0 -63
- package/dist/receiver-UeZT-H8u.d.mts.map +0 -1
- package/dist/receiver-slCoAFat.cjs +0 -94
- package/dist/receiver-slCoAFat.cjs.map +0 -1
- package/dist/redact-BzkITCNW.mjs +0 -83
- package/dist/redact-BzkITCNW.mjs.map +0 -1
- package/dist/redact-DVaSSPZT.cjs +0 -95
- package/dist/redact-DVaSSPZT.cjs.map +0 -1
- package/dist/setup-Bkxm4g6b.d.mts +0 -87
- package/dist/setup-Bkxm4g6b.d.mts.map +0 -1
- package/dist/setup-D58N1f9O.d.cts +0 -87
- package/dist/setup-D58N1f9O.d.cts.map +0 -1
- package/dist/setup-DC9JMEYZ.mjs +0 -98
- package/dist/setup-DC9JMEYZ.mjs.map +0 -1
- package/dist/setup-DufxQpi9.cjs +0 -110
- package/dist/setup-DufxQpi9.cjs.map +0 -1
- package/dist/tracing-BX8uY2nR.d.cts +0 -53
- package/dist/tracing-BX8uY2nR.d.cts.map +0 -1
- package/dist/tracing-Bt1zWRlb.cjs +0 -167
- package/dist/tracing-Bt1zWRlb.cjs.map +0 -1
- package/dist/tracing-Cijm_5NI.mjs +0 -113
- package/dist/tracing-Cijm_5NI.mjs.map +0 -1
- package/dist/tracing-PnECEbEu.d.mts +0 -53
- package/dist/tracing-PnECEbEu.d.mts.map +0 -1
- package/dist/transformer-CFQ4WFk6.mjs +0 -215
- package/dist/transformer-CFQ4WFk6.mjs.map +0 -1
- package/dist/transformer-CTGsaVfV.d.mts.map +0 -1
- package/dist/transformer-Csl6fbgv.cjs +0 -232
- package/dist/transformer-Csl6fbgv.cjs.map +0 -1
- package/dist/transformer-ICEbxpFf.d.cts.map +0 -1
- package/dist/types-B1EIa_cQ.d.mts.map +0 -1
- package/dist/types-BMiHgsi4.cjs +0 -78
- package/dist/types-BMiHgsi4.cjs.map +0 -1
- package/dist/types-BRzW1NM8.d.cts +0 -166
- package/dist/types-BRzW1NM8.d.cts.map +0 -1
- package/dist/types-BS3Rx8Sk.d.cts +0 -209
- package/dist/types-BS3Rx8Sk.d.cts.map +0 -1
- package/dist/types-BzQ78Efw.d.mts +0 -166
- package/dist/types-BzQ78Efw.d.mts.map +0 -1
- package/dist/types-CbNGXnJE.d.mts +0 -209
- package/dist/types-CbNGXnJE.d.mts.map +0 -1
- package/dist/types-Cj59nqy7.mjs +0 -54
- package/dist/types-Cj59nqy7.mjs.map +0 -1
- package/dist/types-CmOB7CLO.d.cts.map +0 -1
- package/dist/types-DBc0q5KD.d.mts.map +0 -1
- package/dist/types-ZW-nfWf6.cjs +0 -40
- package/dist/types-ZW-nfWf6.cjs.map +0 -1
- package/dist/types-l7Rlb5Mg.d.cts.map +0 -1
- package/dist/types-ojhnLdwz.mjs +0 -34
- package/dist/types-ojhnLdwz.mjs.map +0 -1
- package/dist/ui-assets-BEXqOQLe.cjs +0 -48
- package/dist/ui-assets-BEXqOQLe.cjs.map +0 -1
- package/dist/ui-assets-BhTDUsrM.mjs +0 -30
- package/dist/ui-assets-BhTDUsrM.mjs.map +0 -1
package/dist/core.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterConfig, AdapterErrorContext, AdapterLifecycle, AdapterRequestContext, AdapterResponseContext, HonoAdapterConfig, HonoContextWithTelescope, LambdaAdapterConfig, SpanProcessorOptions, SpanProcessorStrategy, TelescopeAdapter, TelescopeEnvironment, TelescopeHonoContext, TelescopeHonoVariables } from "./types
|
|
2
|
-
import { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush } from "./core
|
|
3
|
-
import { addSpanEvent, createSpan, getActiveSpan, getSpanId, getTraceId, recordException, setSpanAttributes, withSpan, withSpanSync } from "./tracing
|
|
4
|
-
export { AdapterConfig, AdapterErrorContext, AdapterLifecycle, AdapterRequestContext, AdapterResponseContext, HonoAdapterConfig, HonoContextWithTelescope, LambdaAdapterConfig, NoopSpanProcessor, SpanProcessorOptions, SpanProcessorStrategy, TelescopeAdapter, TelescopeEnvironment, TelescopeHonoContext, TelescopeHonoVariables, addSpanEvent, createSpan, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getActiveSpan, getRecommendedStrategy, getSpanId, getTraceId, isTelemetryInitialized, recordException, setGlobalLogProcessor, setGlobalSpanProcessor, setSpanAttributes, shutdownTelemetry, withSpan, withSpanSync, withTelemetryFlush };
|
|
1
|
+
import { AdapterConfig, AdapterErrorContext, AdapterLifecycle, AdapterRequestContext, AdapterResponseContext, HonoAdapterConfig, HonoContextWithTelescope, LambdaAdapterConfig, SpanProcessorOptions, SpanProcessorStrategy, TelescopeAdapter, TelescopeEnvironment, TelescopeHonoContext, TelescopeHonoVariables } from "./adapters/types.mjs";
|
|
2
|
+
import { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush } from "./instrumentation/core.mjs";
|
|
3
|
+
import { addSpanEvent, createSpan, getActiveSpan, getSpanId, getTraceId, recordException, setSpanAttributes, withSpan, withSpanSync } from "./instrumentation/tracing.mjs";
|
|
4
|
+
export { type AdapterConfig, type AdapterErrorContext, type AdapterLifecycle, type AdapterRequestContext, type AdapterResponseContext, type HonoAdapterConfig, type HonoContextWithTelescope, type LambdaAdapterConfig, NoopSpanProcessor, type SpanProcessorOptions, type SpanProcessorStrategy, type TelescopeAdapter, type TelescopeEnvironment, type TelescopeHonoContext, type TelescopeHonoVariables, addSpanEvent, createSpan, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getActiveSpan, getRecommendedStrategy, getSpanId, getTraceId, isTelemetryInitialized, recordException, setGlobalLogProcessor, setGlobalSpanProcessor, setSpanAttributes, shutdownTelemetry, withSpan, withSpanSync, withTelemetryFlush };
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush } from "./core
|
|
2
|
-
import { addSpanEvent, createSpan, getActiveSpan, getSpanId, getTraceId, recordException, setSpanAttributes, withSpan, withSpanSync } from "./tracing
|
|
3
|
-
|
|
4
|
-
export { NoopSpanProcessor, addSpanEvent, createSpan, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getActiveSpan, getRecommendedStrategy, getSpanId, getTraceId, isTelemetryInitialized, recordException, setGlobalLogProcessor, setGlobalSpanProcessor, setSpanAttributes, shutdownTelemetry, withSpan, withSpanSync, withTelemetryFlush };
|
|
1
|
+
import { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush } from "./instrumentation/core.mjs";
|
|
2
|
+
import { addSpanEvent, createSpan, getActiveSpan, getSpanId, getTraceId, recordException, setSpanAttributes, withSpan, withSpanSync } from "./instrumentation/tracing.mjs";
|
|
3
|
+
export { NoopSpanProcessor, addSpanEvent, createSpan, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getActiveSpan, getRecommendedStrategy, getSpanId, getTraceId, isTelemetryInitialized, recordException, setGlobalLogProcessor, setGlobalSpanProcessor, setSpanAttributes, shutdownTelemetry, withSpan, withSpanSync, withTelemetryFlush };
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
const require_Telescope = require(
|
|
4
|
-
require(
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.Telescope = require_Telescope.Telescope;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_metrics_MetricsAggregator = require("./metrics/MetricsAggregator.cjs");
|
|
3
|
+
const require_Telescope = require("./Telescope.cjs");
|
|
4
|
+
require("./metrics/index.cjs");
|
|
5
|
+
const require_storage_memory = require("./storage/memory.cjs");
|
|
6
|
+
exports.InMemoryStorage = require_storage_memory.InMemoryStorage;
|
|
7
|
+
exports.MetricsAggregator = require_metrics_MetricsAggregator.MetricsAggregator;
|
|
8
|
+
exports.Telescope = require_Telescope.Telescope;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Telescope } from "./Telescope-
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
export { EndpointBucket, EndpointMetrics, ExceptionEntry, InMemoryStorage, InMemoryStorageOptions, LogEntry, MetricsAggregator, MetricsAggregatorOptions, MetricsBucket, MetricsQueryOptions, NormalizedTelescopeOptions, QueryOptions, RequestContext, RequestEntry, RequestMetrics, SourceContext, StackFrame, StatusDistribution, Telescope, TelescopeEvent, TelescopeEventType, TelescopeOptions, TelescopeStats, TelescopeStorage, TimeRange, TimeSeriesPoint };
|
|
1
|
+
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-a9Vistj1.cjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-BxBLQUPj.cjs";
|
|
3
|
+
import { t as Telescope } from "./Telescope-DnCMZT7V.cjs";
|
|
4
|
+
import { InMemoryStorage, InMemoryStorageOptions } from "./storage/memory.cjs";
|
|
5
|
+
export { type EndpointBucket, type EndpointMetrics, type ExceptionEntry, InMemoryStorage, type InMemoryStorageOptions, type LogEntry, MetricsAggregator, type MetricsAggregatorOptions, type MetricsBucket, type MetricsQueryOptions, type NormalizedTelescopeOptions, type QueryOptions, type RequestContext, type RequestEntry, type RequestMetrics, type SourceContext, type StackFrame, type StatusDistribution, Telescope, type TelescopeEvent, type TelescopeEventType, type TelescopeOptions, type TelescopeStats, type TelescopeStorage, type TimeRange, type TimeSeriesPoint };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Telescope } from "./Telescope-
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
export { EndpointBucket, EndpointMetrics, ExceptionEntry, InMemoryStorage, InMemoryStorageOptions, LogEntry, MetricsAggregator, MetricsAggregatorOptions, MetricsBucket, MetricsQueryOptions, NormalizedTelescopeOptions, QueryOptions, RequestContext, RequestEntry, RequestMetrics, SourceContext, StackFrame, StatusDistribution, Telescope, TelescopeEvent, TelescopeEventType, TelescopeOptions, TelescopeStats, TelescopeStorage, TimeRange, TimeSeriesPoint };
|
|
1
|
+
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-a9Vistj1.mjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-j9wmZ0K_.mjs";
|
|
3
|
+
import { t as Telescope } from "./Telescope-BcrWTaar.mjs";
|
|
4
|
+
import { InMemoryStorage, InMemoryStorageOptions } from "./storage/memory.mjs";
|
|
5
|
+
export { type EndpointBucket, type EndpointMetrics, type ExceptionEntry, InMemoryStorage, type InMemoryStorageOptions, type LogEntry, MetricsAggregator, type MetricsAggregatorOptions, type MetricsBucket, type MetricsQueryOptions, type NormalizedTelescopeOptions, type QueryOptions, type RequestContext, type RequestEntry, type RequestMetrics, type SourceContext, type StackFrame, type StatusDistribution, Telescope, type TelescopeEvent, type TelescopeEventType, type TelescopeOptions, type TelescopeStats, type TelescopeStorage, type TimeRange, type TimeSeriesPoint };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { MetricsAggregator } from "./MetricsAggregator
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { InMemoryStorage, MetricsAggregator, Telescope };
|
|
1
|
+
import { MetricsAggregator } from "./metrics/MetricsAggregator.mjs";
|
|
2
|
+
import { Telescope } from "./Telescope.mjs";
|
|
3
|
+
import "./metrics/index.mjs";
|
|
4
|
+
import { InMemoryStorage } from "./storage/memory.mjs";
|
|
5
|
+
export { InMemoryStorage, MetricsAggregator, Telescope };
|
|
@@ -1,12 +1,148 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
3
|
+
let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
4
|
+
//#region src/instrumentation/core.ts
|
|
5
|
+
const state = {
|
|
6
|
+
spanProcessor: null,
|
|
7
|
+
logProcessor: null,
|
|
8
|
+
initialized: false
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Create a span processor based on the strategy
|
|
12
|
+
*/
|
|
13
|
+
function createSpanProcessor(exporter, options) {
|
|
14
|
+
const { strategy, ...config } = options;
|
|
15
|
+
if (strategy === "simple") return new _opentelemetry_sdk_trace_base.SimpleSpanProcessor(exporter);
|
|
16
|
+
return new _opentelemetry_sdk_trace_base.BatchSpanProcessor(exporter, {
|
|
17
|
+
maxQueueSize: config.maxQueueSize ?? 2048,
|
|
18
|
+
scheduledDelayMillis: config.scheduledDelayMillis ?? 5e3,
|
|
19
|
+
exportTimeoutMillis: config.exportTimeoutMillis ?? 3e4,
|
|
20
|
+
maxExportBatchSize: config.maxExportBatchSize ?? 512
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the recommended span processor strategy for an environment
|
|
25
|
+
*/
|
|
26
|
+
function getRecommendedStrategy(environment) {
|
|
27
|
+
switch (environment) {
|
|
28
|
+
case "lambda":
|
|
29
|
+
case "edge": return "simple";
|
|
30
|
+
default: return "batch";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set the global span processor for flush operations
|
|
35
|
+
*/
|
|
36
|
+
function setGlobalSpanProcessor(processor) {
|
|
37
|
+
state.spanProcessor = processor;
|
|
38
|
+
state.initialized = true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set the global log processor for flush operations
|
|
42
|
+
*/
|
|
43
|
+
function setGlobalLogProcessor(processor) {
|
|
44
|
+
state.logProcessor = processor;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if telemetry is initialized
|
|
48
|
+
*/
|
|
49
|
+
function isTelemetryInitialized() {
|
|
50
|
+
return state.initialized;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Flush all pending telemetry data.
|
|
54
|
+
* This is critical for serverless environments where the process may freeze.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // In a Lambda handler
|
|
59
|
+
* export const handler = async (event, context) => {
|
|
60
|
+
* try {
|
|
61
|
+
* const result = await processRequest(event);
|
|
62
|
+
* return result;
|
|
63
|
+
* } finally {
|
|
64
|
+
* // Flush before Lambda freezes
|
|
65
|
+
* await flushTelemetry();
|
|
66
|
+
* }
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
async function flushTelemetry(timeoutMs = 3e4) {
|
|
71
|
+
const promises = [];
|
|
72
|
+
if (state.spanProcessor) promises.push(Promise.race([state.spanProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Span flush timeout")), timeoutMs))]).catch((error) => {
|
|
73
|
+
if (_opentelemetry_api.diag.debug) _opentelemetry_api.diag.debug(`Span flush error: ${error.message}`);
|
|
74
|
+
}));
|
|
75
|
+
if (state.logProcessor && typeof state.logProcessor.forceFlush === "function") promises.push(Promise.race([state.logProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Log flush timeout")), timeoutMs))]).catch((error) => {
|
|
76
|
+
if (_opentelemetry_api.diag.debug) _opentelemetry_api.diag.debug(`Log flush error: ${error.message}`);
|
|
77
|
+
}));
|
|
78
|
+
await Promise.all(promises);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Shutdown all telemetry processors
|
|
82
|
+
*/
|
|
83
|
+
async function shutdownTelemetry() {
|
|
84
|
+
const promises = [];
|
|
85
|
+
if (state.spanProcessor) {
|
|
86
|
+
promises.push(state.spanProcessor.shutdown());
|
|
87
|
+
state.spanProcessor = null;
|
|
88
|
+
}
|
|
89
|
+
if (state.logProcessor && typeof state.logProcessor.shutdown === "function") {
|
|
90
|
+
promises.push(state.logProcessor.shutdown());
|
|
91
|
+
state.logProcessor = null;
|
|
92
|
+
}
|
|
93
|
+
state.initialized = false;
|
|
94
|
+
await Promise.all(promises);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enable debug logging for telemetry
|
|
98
|
+
*/
|
|
99
|
+
function enableTelemetryDebug() {
|
|
100
|
+
_opentelemetry_api.diag.setLogger(new _opentelemetry_api.DiagConsoleLogger(), _opentelemetry_api.DiagLogLevel.DEBUG);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Wraps a handler function to ensure telemetry is flushed before returning.
|
|
104
|
+
* Useful for Lambda handlers.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* export const handler = withTelemetryFlush(async (event, context) => {
|
|
109
|
+
* // Your Lambda logic here
|
|
110
|
+
* return { statusCode: 200, body: 'OK' };
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function withTelemetryFlush(handler) {
|
|
115
|
+
return async (event, context) => {
|
|
116
|
+
try {
|
|
117
|
+
return await handler(event, context);
|
|
118
|
+
} finally {
|
|
119
|
+
await flushTelemetry();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Noop span processor for testing or when telemetry is disabled
|
|
125
|
+
*/
|
|
126
|
+
var NoopSpanProcessor = class {
|
|
127
|
+
forceFlush() {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
onStart(_span) {}
|
|
131
|
+
onEnd(_span) {}
|
|
132
|
+
shutdown() {
|
|
133
|
+
return Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
exports.NoopSpanProcessor = NoopSpanProcessor;
|
|
138
|
+
exports.createSpanProcessor = createSpanProcessor;
|
|
139
|
+
exports.enableTelemetryDebug = enableTelemetryDebug;
|
|
140
|
+
exports.flushTelemetry = flushTelemetry;
|
|
141
|
+
exports.getRecommendedStrategy = getRecommendedStrategy;
|
|
142
|
+
exports.isTelemetryInitialized = isTelemetryInitialized;
|
|
143
|
+
exports.setGlobalLogProcessor = setGlobalLogProcessor;
|
|
144
|
+
exports.setGlobalSpanProcessor = setGlobalSpanProcessor;
|
|
145
|
+
exports.shutdownTelemetry = shutdownTelemetry;
|
|
146
|
+
exports.withTelemetryFlush = withTelemetryFlush;
|
|
2
147
|
|
|
3
|
-
|
|
4
|
-
exports.createSpanProcessor = require_core.createSpanProcessor;
|
|
5
|
-
exports.enableTelemetryDebug = require_core.enableTelemetryDebug;
|
|
6
|
-
exports.flushTelemetry = require_core.flushTelemetry;
|
|
7
|
-
exports.getRecommendedStrategy = require_core.getRecommendedStrategy;
|
|
8
|
-
exports.isTelemetryInitialized = require_core.isTelemetryInitialized;
|
|
9
|
-
exports.setGlobalLogProcessor = require_core.setGlobalLogProcessor;
|
|
10
|
-
exports.setGlobalSpanProcessor = require_core.setGlobalSpanProcessor;
|
|
11
|
-
exports.shutdownTelemetry = require_core.shutdownTelemetry;
|
|
12
|
-
exports.withTelemetryFlush = require_core.withTelemetryFlush;
|
|
148
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.cjs","names":["SimpleSpanProcessor","BatchSpanProcessor","diag","DiagConsoleLogger","DiagLogLevel"],"sources":["../../src/instrumentation/core.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport {\n\tBatchSpanProcessor,\n\ttype ReadableSpan,\n\tSimpleSpanProcessor,\n\ttype Span,\n\ttype SpanExporter,\n\ttype SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type {\n\tSpanProcessorOptions,\n\tSpanProcessorStrategy,\n} from '../adapters/types';\n\n/**\n * Global telemetry state for flush operations\n */\ninterface TelemetryState {\n\tspanProcessor: SpanProcessor | null;\n\tlogProcessor: unknown | null;\n\tinitialized: boolean;\n}\n\nconst state: TelemetryState = {\n\tspanProcessor: null,\n\tlogProcessor: null,\n\tinitialized: false,\n};\n\n/**\n * Create a span processor based on the strategy\n */\nexport function createSpanProcessor(\n\texporter: SpanExporter,\n\toptions: SpanProcessorOptions,\n): SpanProcessor {\n\tconst { strategy, ...config } = options;\n\n\tif (strategy === 'simple') {\n\t\treturn new SimpleSpanProcessor(exporter);\n\t}\n\n\treturn new BatchSpanProcessor(exporter, {\n\t\tmaxQueueSize: config.maxQueueSize ?? 2048,\n\t\tscheduledDelayMillis: config.scheduledDelayMillis ?? 5000,\n\t\texportTimeoutMillis: config.exportTimeoutMillis ?? 30000,\n\t\tmaxExportBatchSize: config.maxExportBatchSize ?? 512,\n\t});\n}\n\n/**\n * Get the recommended span processor strategy for an environment\n */\nexport function getRecommendedStrategy(\n\tenvironment: 'server' | 'lambda' | 'edge' | 'custom',\n): SpanProcessorStrategy {\n\tswitch (environment) {\n\t\tcase 'lambda':\n\t\tcase 'edge':\n\t\t\t// Use simple processor for serverless - immediate export\n\t\t\treturn 'simple';\n\t\tdefault:\n\t\t\t// Use batch processor for long-running servers - efficient batching\n\t\t\treturn 'batch';\n\t}\n}\n\n/**\n * Set the global span processor for flush operations\n */\nexport function setGlobalSpanProcessor(processor: SpanProcessor): void {\n\tstate.spanProcessor = processor;\n\tstate.initialized = true;\n}\n\n/**\n * Set the global log processor for flush operations\n */\nexport function setGlobalLogProcessor(processor: unknown): void {\n\tstate.logProcessor = processor;\n}\n\n/**\n * Check if telemetry is initialized\n */\nexport function isTelemetryInitialized(): boolean {\n\treturn state.initialized;\n}\n\n/**\n * Flush all pending telemetry data.\n * This is critical for serverless environments where the process may freeze.\n *\n * @example\n * ```typescript\n * // In a Lambda handler\n * export const handler = async (event, context) => {\n * try {\n * const result = await processRequest(event);\n * return result;\n * } finally {\n * // Flush before Lambda freezes\n * await flushTelemetry();\n * }\n * };\n * ```\n */\nexport async function flushTelemetry(timeoutMs = 30000): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\t// Flush span processor\n\tif (state.spanProcessor) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\tstate.spanProcessor.forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Span flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Span flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Flush log processor if it has forceFlush method\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { forceFlush?: () => Promise<void> })\n\t\t\t.forceFlush === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\t(\n\t\t\t\t\tstate.logProcessor as { forceFlush: () => Promise<void> }\n\t\t\t\t).forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Log flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Log flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\tawait Promise.all(promises);\n}\n\n/**\n * Shutdown all telemetry processors\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tif (state.spanProcessor) {\n\t\tpromises.push(state.spanProcessor.shutdown());\n\t\tstate.spanProcessor = null;\n\t}\n\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { shutdown?: () => Promise<void> })\n\t\t\t.shutdown === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\t(state.logProcessor as { shutdown: () => Promise<void> }).shutdown(),\n\t\t);\n\t\tstate.logProcessor = null;\n\t}\n\n\tstate.initialized = false;\n\tawait Promise.all(promises);\n}\n\n/**\n * Enable debug logging for telemetry\n */\nexport function enableTelemetryDebug(): void {\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n}\n\n/**\n * Wraps a handler function to ensure telemetry is flushed before returning.\n * Useful for Lambda handlers.\n *\n * @example\n * ```typescript\n * export const handler = withTelemetryFlush(async (event, context) => {\n * // Your Lambda logic here\n * return { statusCode: 200, body: 'OK' };\n * });\n * ```\n */\nexport function withTelemetryFlush<TEvent, TResult>(\n\thandler: (event: TEvent, context: unknown) => Promise<TResult>,\n): (event: TEvent, context: unknown) => Promise<TResult> {\n\treturn async (event: TEvent, context: unknown): Promise<TResult> => {\n\t\ttry {\n\t\t\treturn await handler(event, context);\n\t\t} finally {\n\t\t\tawait flushTelemetry();\n\t\t}\n\t};\n}\n\n/**\n * Noop span processor for testing or when telemetry is disabled\n */\nexport class NoopSpanProcessor implements SpanProcessor {\n\tforceFlush(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n\n\tonStart(_span: Span): void {\n\t\t// noop\n\t}\n\n\tonEnd(_span: ReadableSpan): void {\n\t\t// noop\n\t}\n\n\tshutdown(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n}\n"],"mappings":";;;;AAuBA,MAAM,QAAwB;CAC7B,eAAe;CACf,cAAc;CACd,aAAa;AACd;;;;AAKA,SAAgB,oBACf,UACA,SACgB;CAChB,MAAM,EAAE,UAAU,GAAG,WAAW;CAEhC,IAAI,aAAa,UAChB,OAAO,IAAIA,8BAAAA,oBAAoB,QAAQ;CAGxC,OAAO,IAAIC,8BAAAA,mBAAmB,UAAU;EACvC,cAAc,OAAO,gBAAgB;EACrC,sBAAsB,OAAO,wBAAwB;EACrD,qBAAqB,OAAO,uBAAuB;EACnD,oBAAoB,OAAO,sBAAsB;CAClD,CAAC;AACF;;;;AAKA,SAAgB,uBACf,aACwB;CACxB,QAAQ,aAAR;EACC,KAAK;EACL,KAAK,QAEJ,OAAO;EACR,SAEC,OAAO;CACT;AACD;;;;AAKA,SAAgB,uBAAuB,WAAgC;CACtE,MAAM,gBAAgB;CACtB,MAAM,cAAc;AACrB;;;;AAKA,SAAgB,sBAAsB,WAA0B;CAC/D,MAAM,eAAe;AACtB;;;;AAKA,SAAgB,yBAAkC;CACjD,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,eAAe,YAAY,KAAsB;CACtE,MAAM,WAA4B,CAAC;CAGnC,IAAI,MAAM,eACT,SAAS,KACR,QAAQ,KAAK,CACZ,MAAM,cAAc,WAAW,GAC/B,IAAI,SAAe,GAAG,WACrB,iBAAiB,uBAAO,IAAI,MAAM,oBAAoB,CAAC,GAAG,SAAS,CACpE,CACD,CAAC,CAAC,CAAC,OAAO,UAAU;EACnB,IAAIC,mBAAAA,KAAK,OACR,mBAAA,KAAK,MAAM,qBAAqB,MAAM,SAAS;CAEjD,CAAC,CACF;CAID,IACC,MAAM,gBACN,OAAQ,MAAM,aACZ,eAAe,YAEjB,SAAS,KACR,QAAQ,KAAK,CAEX,MAAM,aACL,WAAW,GACb,IAAI,SAAe,GAAG,WACrB,iBAAiB,uBAAO,IAAI,MAAM,mBAAmB,CAAC,GAAG,SAAS,CACnE,CACD,CAAC,CAAC,CAAC,OAAO,UAAU;EACnB,IAAIA,mBAAAA,KAAK,OACR,mBAAA,KAAK,MAAM,oBAAoB,MAAM,SAAS;CAEhD,CAAC,CACF;CAGD,MAAM,QAAQ,IAAI,QAAQ;AAC3B;;;;AAKA,eAAsB,oBAAmC;CACxD,MAAM,WAA4B,CAAC;CAEnC,IAAI,MAAM,eAAe;EACxB,SAAS,KAAK,MAAM,cAAc,SAAS,CAAC;EAC5C,MAAM,gBAAgB;CACvB;CAEA,IACC,MAAM,gBACN,OAAQ,MAAM,aACZ,aAAa,YACd;EACD,SAAS,KACP,MAAM,aAAmD,SAAS,CACpE;EACA,MAAM,eAAe;CACtB;CAEA,MAAM,cAAc;CACpB,MAAM,QAAQ,IAAI,QAAQ;AAC3B;;;;AAKA,SAAgB,uBAA6B;CAC5C,mBAAA,KAAK,UAAU,IAAIC,mBAAAA,kBAAkB,GAAGC,mBAAAA,aAAa,KAAK;AAC3D;;;;;;;;;;;;;AAcA,SAAgB,mBACf,SACwD;CACxD,OAAO,OAAO,OAAe,YAAuC;EACnE,IAAI;GACH,OAAO,MAAM,QAAQ,OAAO,OAAO;EACpC,UAAU;GACT,MAAM,eAAe;EACtB;CACD;AACD;;;;AAKA,IAAa,oBAAb,MAAwD;CACvD,aAA4B;EAC3B,OAAO,QAAQ,QAAQ;CACxB;CAEA,QAAQ,OAAmB,CAE3B;CAEA,MAAM,OAA2B,CAEjC;CAEA,WAA0B;EACzB,OAAO,QAAQ,QAAQ;CACxB;AACD"}
|
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
import "../types
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { SpanProcessorOptions, SpanProcessorStrategy } from "../adapters/types.cjs";
|
|
2
|
+
import { ReadableSpan, Span, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
//#region src/instrumentation/core.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a span processor based on the strategy
|
|
6
|
+
*/
|
|
7
|
+
export declare function createSpanProcessor(exporter: SpanExporter, options: SpanProcessorOptions): SpanProcessor;
|
|
8
|
+
/**
|
|
9
|
+
* Get the recommended span processor strategy for an environment
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRecommendedStrategy(environment: 'server' | 'lambda' | 'edge' | 'custom'): SpanProcessorStrategy;
|
|
12
|
+
/**
|
|
13
|
+
* Set the global span processor for flush operations
|
|
14
|
+
*/
|
|
15
|
+
export declare function setGlobalSpanProcessor(processor: SpanProcessor): void;
|
|
16
|
+
/**
|
|
17
|
+
* Set the global log processor for flush operations
|
|
18
|
+
*/
|
|
19
|
+
export declare function setGlobalLogProcessor(processor: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Check if telemetry is initialized
|
|
22
|
+
*/
|
|
23
|
+
export declare function isTelemetryInitialized(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Flush all pending telemetry data.
|
|
26
|
+
* This is critical for serverless environments where the process may freeze.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // In a Lambda handler
|
|
31
|
+
* export const handler = async (event, context) => {
|
|
32
|
+
* try {
|
|
33
|
+
* const result = await processRequest(event);
|
|
34
|
+
* return result;
|
|
35
|
+
* } finally {
|
|
36
|
+
* // Flush before Lambda freezes
|
|
37
|
+
* await flushTelemetry();
|
|
38
|
+
* }
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function flushTelemetry(timeoutMs?: number): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Shutdown all telemetry processors
|
|
45
|
+
*/
|
|
46
|
+
export declare function shutdownTelemetry(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Enable debug logging for telemetry
|
|
49
|
+
*/
|
|
50
|
+
export declare function enableTelemetryDebug(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Wraps a handler function to ensure telemetry is flushed before returning.
|
|
53
|
+
* Useful for Lambda handlers.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* export const handler = withTelemetryFlush(async (event, context) => {
|
|
58
|
+
* // Your Lambda logic here
|
|
59
|
+
* return { statusCode: 200, body: 'OK' };
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function withTelemetryFlush<TEvent, TResult>(handler: (event: TEvent, context: unknown) => Promise<TResult>): (event: TEvent, context: unknown) => Promise<TResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Noop span processor for testing or when telemetry is disabled
|
|
66
|
+
*/
|
|
67
|
+
export declare class NoopSpanProcessor implements SpanProcessor {
|
|
68
|
+
forceFlush(): Promise<void>;
|
|
69
|
+
onStart(_span: Span): void;
|
|
70
|
+
onEnd(_span: ReadableSpan): void;
|
|
71
|
+
shutdown(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//# sourceMappingURL=core.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.cts","names":[],"sources":["../../src/instrumentation/core.ts"],"mappings":";;;;;;wBAgCgB,oBACf,UAAU,cACV,SAAS,uBACP;;;;wBAkBa,uBACf,uDACE;;;;wBAea,uBAAuB,WAAW;;;;wBAQlC,sBAAsB;;;;wBAOtB;;;;;;;;;;;;;;;;;;;wBAsBM,eAAe,qBAAoB;;;;wBA+CnC,qBAAqB;;;;wBA0B3B;;;;;;;;;;;;;wBAgBA,mBAAmB,QAAQ,SAC1C,UAAU,OAAO,QAAQ,qBAAqB,QAAQ,YACnD,OAAO,QAAQ,qBAAqB,QAAQ;;;;qBAanC,6BAA6B;EACzC,cAAc;EAId,QAAQ,OAAO;EAIf,MAAM,OAAO;EAIb,YAAY"}
|
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
import "../types
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { SpanProcessorOptions, SpanProcessorStrategy } from "../adapters/types.mjs";
|
|
2
|
+
import { ReadableSpan, Span, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
//#region src/instrumentation/core.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a span processor based on the strategy
|
|
6
|
+
*/
|
|
7
|
+
export declare function createSpanProcessor(exporter: SpanExporter, options: SpanProcessorOptions): SpanProcessor;
|
|
8
|
+
/**
|
|
9
|
+
* Get the recommended span processor strategy for an environment
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRecommendedStrategy(environment: 'server' | 'lambda' | 'edge' | 'custom'): SpanProcessorStrategy;
|
|
12
|
+
/**
|
|
13
|
+
* Set the global span processor for flush operations
|
|
14
|
+
*/
|
|
15
|
+
export declare function setGlobalSpanProcessor(processor: SpanProcessor): void;
|
|
16
|
+
/**
|
|
17
|
+
* Set the global log processor for flush operations
|
|
18
|
+
*/
|
|
19
|
+
export declare function setGlobalLogProcessor(processor: unknown): void;
|
|
20
|
+
/**
|
|
21
|
+
* Check if telemetry is initialized
|
|
22
|
+
*/
|
|
23
|
+
export declare function isTelemetryInitialized(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Flush all pending telemetry data.
|
|
26
|
+
* This is critical for serverless environments where the process may freeze.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // In a Lambda handler
|
|
31
|
+
* export const handler = async (event, context) => {
|
|
32
|
+
* try {
|
|
33
|
+
* const result = await processRequest(event);
|
|
34
|
+
* return result;
|
|
35
|
+
* } finally {
|
|
36
|
+
* // Flush before Lambda freezes
|
|
37
|
+
* await flushTelemetry();
|
|
38
|
+
* }
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function flushTelemetry(timeoutMs?: number): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Shutdown all telemetry processors
|
|
45
|
+
*/
|
|
46
|
+
export declare function shutdownTelemetry(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Enable debug logging for telemetry
|
|
49
|
+
*/
|
|
50
|
+
export declare function enableTelemetryDebug(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Wraps a handler function to ensure telemetry is flushed before returning.
|
|
53
|
+
* Useful for Lambda handlers.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* export const handler = withTelemetryFlush(async (event, context) => {
|
|
58
|
+
* // Your Lambda logic here
|
|
59
|
+
* return { statusCode: 200, body: 'OK' };
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function withTelemetryFlush<TEvent, TResult>(handler: (event: TEvent, context: unknown) => Promise<TResult>): (event: TEvent, context: unknown) => Promise<TResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Noop span processor for testing or when telemetry is disabled
|
|
66
|
+
*/
|
|
67
|
+
export declare class NoopSpanProcessor implements SpanProcessor {
|
|
68
|
+
forceFlush(): Promise<void>;
|
|
69
|
+
onStart(_span: Span): void;
|
|
70
|
+
onEnd(_span: ReadableSpan): void;
|
|
71
|
+
shutdown(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//# sourceMappingURL=core.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.mts","names":[],"sources":["../../src/instrumentation/core.ts"],"mappings":";;;;;;wBAgCgB,oBACf,UAAU,cACV,SAAS,uBACP;;;;wBAkBa,uBACf,uDACE;;;;wBAea,uBAAuB,WAAW;;;;wBAQlC,sBAAsB;;;;wBAOtB;;;;;;;;;;;;;;;;;;;wBAsBM,eAAe,qBAAoB;;;;wBA+CnC,qBAAqB;;;;wBA0B3B;;;;;;;;;;;;;wBAgBA,mBAAmB,QAAQ,SAC1C,UAAU,OAAO,QAAQ,qBAAqB,QAAQ,YACnD,OAAO,QAAQ,qBAAqB,QAAQ;;;;qBAanC,6BAA6B;EACzC,cAAc;EAId,QAAQ,OAAO;EAIf,MAAM,OAAO;EAIb,YAAY"}
|
|
@@ -1,3 +1,138 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiagConsoleLogger, DiagLogLevel, diag } from "@opentelemetry/api";
|
|
2
|
+
import { BatchSpanProcessor, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
//#region src/instrumentation/core.ts
|
|
4
|
+
const state = {
|
|
5
|
+
spanProcessor: null,
|
|
6
|
+
logProcessor: null,
|
|
7
|
+
initialized: false
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a span processor based on the strategy
|
|
11
|
+
*/
|
|
12
|
+
function createSpanProcessor(exporter, options) {
|
|
13
|
+
const { strategy, ...config } = options;
|
|
14
|
+
if (strategy === "simple") return new SimpleSpanProcessor(exporter);
|
|
15
|
+
return new BatchSpanProcessor(exporter, {
|
|
16
|
+
maxQueueSize: config.maxQueueSize ?? 2048,
|
|
17
|
+
scheduledDelayMillis: config.scheduledDelayMillis ?? 5e3,
|
|
18
|
+
exportTimeoutMillis: config.exportTimeoutMillis ?? 3e4,
|
|
19
|
+
maxExportBatchSize: config.maxExportBatchSize ?? 512
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the recommended span processor strategy for an environment
|
|
24
|
+
*/
|
|
25
|
+
function getRecommendedStrategy(environment) {
|
|
26
|
+
switch (environment) {
|
|
27
|
+
case "lambda":
|
|
28
|
+
case "edge": return "simple";
|
|
29
|
+
default: return "batch";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the global span processor for flush operations
|
|
34
|
+
*/
|
|
35
|
+
function setGlobalSpanProcessor(processor) {
|
|
36
|
+
state.spanProcessor = processor;
|
|
37
|
+
state.initialized = true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Set the global log processor for flush operations
|
|
41
|
+
*/
|
|
42
|
+
function setGlobalLogProcessor(processor) {
|
|
43
|
+
state.logProcessor = processor;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if telemetry is initialized
|
|
47
|
+
*/
|
|
48
|
+
function isTelemetryInitialized() {
|
|
49
|
+
return state.initialized;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Flush all pending telemetry data.
|
|
53
|
+
* This is critical for serverless environments where the process may freeze.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // In a Lambda handler
|
|
58
|
+
* export const handler = async (event, context) => {
|
|
59
|
+
* try {
|
|
60
|
+
* const result = await processRequest(event);
|
|
61
|
+
* return result;
|
|
62
|
+
* } finally {
|
|
63
|
+
* // Flush before Lambda freezes
|
|
64
|
+
* await flushTelemetry();
|
|
65
|
+
* }
|
|
66
|
+
* };
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
async function flushTelemetry(timeoutMs = 3e4) {
|
|
70
|
+
const promises = [];
|
|
71
|
+
if (state.spanProcessor) promises.push(Promise.race([state.spanProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Span flush timeout")), timeoutMs))]).catch((error) => {
|
|
72
|
+
if (diag.debug) diag.debug(`Span flush error: ${error.message}`);
|
|
73
|
+
}));
|
|
74
|
+
if (state.logProcessor && typeof state.logProcessor.forceFlush === "function") promises.push(Promise.race([state.logProcessor.forceFlush(), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Log flush timeout")), timeoutMs))]).catch((error) => {
|
|
75
|
+
if (diag.debug) diag.debug(`Log flush error: ${error.message}`);
|
|
76
|
+
}));
|
|
77
|
+
await Promise.all(promises);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shutdown all telemetry processors
|
|
81
|
+
*/
|
|
82
|
+
async function shutdownTelemetry() {
|
|
83
|
+
const promises = [];
|
|
84
|
+
if (state.spanProcessor) {
|
|
85
|
+
promises.push(state.spanProcessor.shutdown());
|
|
86
|
+
state.spanProcessor = null;
|
|
87
|
+
}
|
|
88
|
+
if (state.logProcessor && typeof state.logProcessor.shutdown === "function") {
|
|
89
|
+
promises.push(state.logProcessor.shutdown());
|
|
90
|
+
state.logProcessor = null;
|
|
91
|
+
}
|
|
92
|
+
state.initialized = false;
|
|
93
|
+
await Promise.all(promises);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Enable debug logging for telemetry
|
|
97
|
+
*/
|
|
98
|
+
function enableTelemetryDebug() {
|
|
99
|
+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Wraps a handler function to ensure telemetry is flushed before returning.
|
|
103
|
+
* Useful for Lambda handlers.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* export const handler = withTelemetryFlush(async (event, context) => {
|
|
108
|
+
* // Your Lambda logic here
|
|
109
|
+
* return { statusCode: 200, body: 'OK' };
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function withTelemetryFlush(handler) {
|
|
114
|
+
return async (event, context) => {
|
|
115
|
+
try {
|
|
116
|
+
return await handler(event, context);
|
|
117
|
+
} finally {
|
|
118
|
+
await flushTelemetry();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Noop span processor for testing or when telemetry is disabled
|
|
124
|
+
*/
|
|
125
|
+
var NoopSpanProcessor = class {
|
|
126
|
+
forceFlush() {
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
129
|
+
onStart(_span) {}
|
|
130
|
+
onEnd(_span) {}
|
|
131
|
+
shutdown() {
|
|
132
|
+
return Promise.resolve();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
//#endregion
|
|
136
|
+
export { NoopSpanProcessor, createSpanProcessor, enableTelemetryDebug, flushTelemetry, getRecommendedStrategy, isTelemetryInitialized, setGlobalLogProcessor, setGlobalSpanProcessor, shutdownTelemetry, withTelemetryFlush };
|
|
2
137
|
|
|
3
|
-
|
|
138
|
+
//# sourceMappingURL=core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.mjs","names":[],"sources":["../../src/instrumentation/core.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport {\n\tBatchSpanProcessor,\n\ttype ReadableSpan,\n\tSimpleSpanProcessor,\n\ttype Span,\n\ttype SpanExporter,\n\ttype SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type {\n\tSpanProcessorOptions,\n\tSpanProcessorStrategy,\n} from '../adapters/types';\n\n/**\n * Global telemetry state for flush operations\n */\ninterface TelemetryState {\n\tspanProcessor: SpanProcessor | null;\n\tlogProcessor: unknown | null;\n\tinitialized: boolean;\n}\n\nconst state: TelemetryState = {\n\tspanProcessor: null,\n\tlogProcessor: null,\n\tinitialized: false,\n};\n\n/**\n * Create a span processor based on the strategy\n */\nexport function createSpanProcessor(\n\texporter: SpanExporter,\n\toptions: SpanProcessorOptions,\n): SpanProcessor {\n\tconst { strategy, ...config } = options;\n\n\tif (strategy === 'simple') {\n\t\treturn new SimpleSpanProcessor(exporter);\n\t}\n\n\treturn new BatchSpanProcessor(exporter, {\n\t\tmaxQueueSize: config.maxQueueSize ?? 2048,\n\t\tscheduledDelayMillis: config.scheduledDelayMillis ?? 5000,\n\t\texportTimeoutMillis: config.exportTimeoutMillis ?? 30000,\n\t\tmaxExportBatchSize: config.maxExportBatchSize ?? 512,\n\t});\n}\n\n/**\n * Get the recommended span processor strategy for an environment\n */\nexport function getRecommendedStrategy(\n\tenvironment: 'server' | 'lambda' | 'edge' | 'custom',\n): SpanProcessorStrategy {\n\tswitch (environment) {\n\t\tcase 'lambda':\n\t\tcase 'edge':\n\t\t\t// Use simple processor for serverless - immediate export\n\t\t\treturn 'simple';\n\t\tdefault:\n\t\t\t// Use batch processor for long-running servers - efficient batching\n\t\t\treturn 'batch';\n\t}\n}\n\n/**\n * Set the global span processor for flush operations\n */\nexport function setGlobalSpanProcessor(processor: SpanProcessor): void {\n\tstate.spanProcessor = processor;\n\tstate.initialized = true;\n}\n\n/**\n * Set the global log processor for flush operations\n */\nexport function setGlobalLogProcessor(processor: unknown): void {\n\tstate.logProcessor = processor;\n}\n\n/**\n * Check if telemetry is initialized\n */\nexport function isTelemetryInitialized(): boolean {\n\treturn state.initialized;\n}\n\n/**\n * Flush all pending telemetry data.\n * This is critical for serverless environments where the process may freeze.\n *\n * @example\n * ```typescript\n * // In a Lambda handler\n * export const handler = async (event, context) => {\n * try {\n * const result = await processRequest(event);\n * return result;\n * } finally {\n * // Flush before Lambda freezes\n * await flushTelemetry();\n * }\n * };\n * ```\n */\nexport async function flushTelemetry(timeoutMs = 30000): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\t// Flush span processor\n\tif (state.spanProcessor) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\tstate.spanProcessor.forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Span flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Span flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Flush log processor if it has forceFlush method\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { forceFlush?: () => Promise<void> })\n\t\t\t.forceFlush === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\tPromise.race([\n\t\t\t\t(\n\t\t\t\t\tstate.logProcessor as { forceFlush: () => Promise<void> }\n\t\t\t\t).forceFlush(),\n\t\t\t\tnew Promise<void>((_, reject) =>\n\t\t\t\t\tsetTimeout(() => reject(new Error('Log flush timeout')), timeoutMs),\n\t\t\t\t),\n\t\t\t]).catch((error) => {\n\t\t\t\tif (diag.debug) {\n\t\t\t\t\tdiag.debug(`Log flush error: ${error.message}`);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\tawait Promise.all(promises);\n}\n\n/**\n * Shutdown all telemetry processors\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tif (state.spanProcessor) {\n\t\tpromises.push(state.spanProcessor.shutdown());\n\t\tstate.spanProcessor = null;\n\t}\n\n\tif (\n\t\tstate.logProcessor &&\n\t\ttypeof (state.logProcessor as { shutdown?: () => Promise<void> })\n\t\t\t.shutdown === 'function'\n\t) {\n\t\tpromises.push(\n\t\t\t(state.logProcessor as { shutdown: () => Promise<void> }).shutdown(),\n\t\t);\n\t\tstate.logProcessor = null;\n\t}\n\n\tstate.initialized = false;\n\tawait Promise.all(promises);\n}\n\n/**\n * Enable debug logging for telemetry\n */\nexport function enableTelemetryDebug(): void {\n\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n}\n\n/**\n * Wraps a handler function to ensure telemetry is flushed before returning.\n * Useful for Lambda handlers.\n *\n * @example\n * ```typescript\n * export const handler = withTelemetryFlush(async (event, context) => {\n * // Your Lambda logic here\n * return { statusCode: 200, body: 'OK' };\n * });\n * ```\n */\nexport function withTelemetryFlush<TEvent, TResult>(\n\thandler: (event: TEvent, context: unknown) => Promise<TResult>,\n): (event: TEvent, context: unknown) => Promise<TResult> {\n\treturn async (event: TEvent, context: unknown): Promise<TResult> => {\n\t\ttry {\n\t\t\treturn await handler(event, context);\n\t\t} finally {\n\t\t\tawait flushTelemetry();\n\t\t}\n\t};\n}\n\n/**\n * Noop span processor for testing or when telemetry is disabled\n */\nexport class NoopSpanProcessor implements SpanProcessor {\n\tforceFlush(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n\n\tonStart(_span: Span): void {\n\t\t// noop\n\t}\n\n\tonEnd(_span: ReadableSpan): void {\n\t\t// noop\n\t}\n\n\tshutdown(): Promise<void> {\n\t\treturn Promise.resolve();\n\t}\n}\n"],"mappings":";;;AAuBA,MAAM,QAAwB;CAC7B,eAAe;CACf,cAAc;CACd,aAAa;AACd;;;;AAKA,SAAgB,oBACf,UACA,SACgB;CAChB,MAAM,EAAE,UAAU,GAAG,WAAW;CAEhC,IAAI,aAAa,UAChB,OAAO,IAAI,oBAAoB,QAAQ;CAGxC,OAAO,IAAI,mBAAmB,UAAU;EACvC,cAAc,OAAO,gBAAgB;EACrC,sBAAsB,OAAO,wBAAwB;EACrD,qBAAqB,OAAO,uBAAuB;EACnD,oBAAoB,OAAO,sBAAsB;CAClD,CAAC;AACF;;;;AAKA,SAAgB,uBACf,aACwB;CACxB,QAAQ,aAAR;EACC,KAAK;EACL,KAAK,QAEJ,OAAO;EACR,SAEC,OAAO;CACT;AACD;;;;AAKA,SAAgB,uBAAuB,WAAgC;CACtE,MAAM,gBAAgB;CACtB,MAAM,cAAc;AACrB;;;;AAKA,SAAgB,sBAAsB,WAA0B;CAC/D,MAAM,eAAe;AACtB;;;;AAKA,SAAgB,yBAAkC;CACjD,OAAO,MAAM;AACd;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,eAAe,YAAY,KAAsB;CACtE,MAAM,WAA4B,CAAC;CAGnC,IAAI,MAAM,eACT,SAAS,KACR,QAAQ,KAAK,CACZ,MAAM,cAAc,WAAW,GAC/B,IAAI,SAAe,GAAG,WACrB,iBAAiB,uBAAO,IAAI,MAAM,oBAAoB,CAAC,GAAG,SAAS,CACpE,CACD,CAAC,CAAC,CAAC,OAAO,UAAU;EACnB,IAAI,KAAK,OACR,KAAK,MAAM,qBAAqB,MAAM,SAAS;CAEjD,CAAC,CACF;CAID,IACC,MAAM,gBACN,OAAQ,MAAM,aACZ,eAAe,YAEjB,SAAS,KACR,QAAQ,KAAK,CAEX,MAAM,aACL,WAAW,GACb,IAAI,SAAe,GAAG,WACrB,iBAAiB,uBAAO,IAAI,MAAM,mBAAmB,CAAC,GAAG,SAAS,CACnE,CACD,CAAC,CAAC,CAAC,OAAO,UAAU;EACnB,IAAI,KAAK,OACR,KAAK,MAAM,oBAAoB,MAAM,SAAS;CAEhD,CAAC,CACF;CAGD,MAAM,QAAQ,IAAI,QAAQ;AAC3B;;;;AAKA,eAAsB,oBAAmC;CACxD,MAAM,WAA4B,CAAC;CAEnC,IAAI,MAAM,eAAe;EACxB,SAAS,KAAK,MAAM,cAAc,SAAS,CAAC;EAC5C,MAAM,gBAAgB;CACvB;CAEA,IACC,MAAM,gBACN,OAAQ,MAAM,aACZ,aAAa,YACd;EACD,SAAS,KACP,MAAM,aAAmD,SAAS,CACpE;EACA,MAAM,eAAe;CACtB;CAEA,MAAM,cAAc;CACpB,MAAM,QAAQ,IAAI,QAAQ;AAC3B;;;;AAKA,SAAgB,uBAA6B;CAC5C,KAAK,UAAU,IAAI,kBAAkB,GAAG,aAAa,KAAK;AAC3D;;;;;;;;;;;;;AAcA,SAAgB,mBACf,SACwD;CACxD,OAAO,OAAO,OAAe,YAAuC;EACnE,IAAI;GACH,OAAO,MAAM,QAAQ,OAAO,OAAO;EACpC,UAAU;GACT,MAAM,eAAe;EACtB;CACD;AACD;;;;AAKA,IAAa,oBAAb,MAAwD;CACvD,aAA4B;EAC3B,OAAO,QAAQ,QAAQ;CACxB;CAEA,QAAQ,OAAmB,CAE3B;CAEA,MAAM,OAA2B,CAEjC;CAEA,WAA0B;EACzB,OAAO,QAAQ,QAAQ;CACxB;AACD"}
|