@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/otlp/receiver.mjs
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { transformLogs, transformMetrics, transformTraces } from "./transformer.mjs";
|
|
2
|
+
//#region src/otlp/receiver.ts
|
|
3
|
+
/**
|
|
4
|
+
* OTLP Receiver for ingesting OpenTelemetry data into Telescope.
|
|
5
|
+
*
|
|
6
|
+
* Supports the OTLP/JSON protocol for:
|
|
7
|
+
* - Traces (POST /v1/traces) - HTTP server spans become RequestEntries
|
|
8
|
+
* - Logs (POST /v1/logs) - Log records become LogEntries
|
|
9
|
+
* - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers
|
|
10
|
+
*/
|
|
11
|
+
var OTLPReceiver = class {
|
|
12
|
+
telescope;
|
|
13
|
+
onMetrics;
|
|
14
|
+
logMetrics;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.telescope = options.telescope;
|
|
17
|
+
this.onMetrics = options.onMetrics;
|
|
18
|
+
this.logMetrics = options.logMetrics ?? false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Handle incoming trace data
|
|
22
|
+
* Transforms HTTP server spans to Telescope request entries
|
|
23
|
+
*/
|
|
24
|
+
async receiveTraces(request) {
|
|
25
|
+
const entries = transformTraces(request);
|
|
26
|
+
let rejected = 0;
|
|
27
|
+
for (const entry of entries) try {
|
|
28
|
+
await this.telescope.recordRequest(entry);
|
|
29
|
+
} catch {
|
|
30
|
+
rejected++;
|
|
31
|
+
}
|
|
32
|
+
return rejected > 0 ? { partialSuccess: { rejectedSpans: String(rejected) } } : {};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Handle incoming log data
|
|
36
|
+
* Transforms OTLP log records to Telescope log entries
|
|
37
|
+
*/
|
|
38
|
+
async receiveLogs(request) {
|
|
39
|
+
const entries = transformLogs(request);
|
|
40
|
+
let rejected = 0;
|
|
41
|
+
const batchEntries = entries.map((entry) => ({
|
|
42
|
+
level: entry.level,
|
|
43
|
+
message: entry.message,
|
|
44
|
+
context: entry.context,
|
|
45
|
+
requestId: entry.requestId
|
|
46
|
+
}));
|
|
47
|
+
try {
|
|
48
|
+
await this.telescope.log(batchEntries);
|
|
49
|
+
} catch {
|
|
50
|
+
rejected = entries.length;
|
|
51
|
+
}
|
|
52
|
+
return rejected > 0 ? { partialSuccess: { rejectedLogRecords: String(rejected) } } : {};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Handle incoming metrics data
|
|
56
|
+
* Forwards to custom handler and optionally logs to Telescope
|
|
57
|
+
*/
|
|
58
|
+
async receiveMetrics(request) {
|
|
59
|
+
const points = transformMetrics(request);
|
|
60
|
+
let rejected = 0;
|
|
61
|
+
if (this.onMetrics) try {
|
|
62
|
+
await this.onMetrics(points);
|
|
63
|
+
} catch {
|
|
64
|
+
rejected = points.length;
|
|
65
|
+
}
|
|
66
|
+
if (this.logMetrics && points.length > 0) {
|
|
67
|
+
const logEntries = points.map((point) => ({
|
|
68
|
+
level: "debug",
|
|
69
|
+
message: `OTLP Metric: ${point.name}`,
|
|
70
|
+
context: {
|
|
71
|
+
name: point.name,
|
|
72
|
+
value: point.value,
|
|
73
|
+
type: point.type,
|
|
74
|
+
unit: point.unit,
|
|
75
|
+
attributes: point.attributes
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
try {
|
|
79
|
+
await this.telescope.log(logEntries);
|
|
80
|
+
} catch {}
|
|
81
|
+
}
|
|
82
|
+
return rejected > 0 ? { partialSuccess: { rejectedDataPoints: String(rejected) } } : {};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { OTLPReceiver };
|
|
4
87
|
|
|
5
|
-
|
|
88
|
+
//# sourceMappingURL=receiver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receiver.mjs","names":[],"sources":["../../src/otlp/receiver.ts"],"sourcesContent":["import type { Telescope } from '../Telescope';\nimport {\n\ttype MetricDataPoint,\n\ttransformLogs,\n\ttransformMetrics,\n\ttransformTraces,\n} from './transformer';\nimport type {\n\tExportLogsServiceRequest,\n\tExportLogsServiceResponse,\n\tExportMetricsServiceRequest,\n\tExportMetricsServiceResponse,\n\tExportTraceServiceRequest,\n\tExportTraceServiceResponse,\n} from './types';\n\n/**\n * Callback for handling OTLP metrics\n */\nexport type MetricsHandler = (\n\tpoints: MetricDataPoint[],\n) => void | Promise<void>;\n\n/**\n * Options for OTLPReceiver\n */\nexport interface OTLPReceiverOptions {\n\t/**\n\t * The Telescope instance to record data to\n\t */\n\ttelescope: Telescope;\n\n\t/**\n\t * Optional callback for handling OTLP metrics.\n\t * OTLP metrics are more granular than Telescope's request metrics,\n\t * so a custom handler allows integration with metrics systems like Prometheus.\n\t */\n\tonMetrics?: MetricsHandler;\n\n\t/**\n\t * Whether to also log OTLP metrics to Telescope as log entries.\n\t * Useful for debugging OTLP integration. Default: false\n\t */\n\tlogMetrics?: boolean;\n}\n\n/**\n * OTLP Receiver for ingesting OpenTelemetry data into Telescope.\n *\n * Supports the OTLP/JSON protocol for:\n * - Traces (POST /v1/traces) - HTTP server spans become RequestEntries\n * - Logs (POST /v1/logs) - Log records become LogEntries\n * - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers\n */\nexport class OTLPReceiver {\n\tprivate telescope: Telescope;\n\tprivate onMetrics?: MetricsHandler;\n\tprivate logMetrics: boolean;\n\n\tconstructor(options: OTLPReceiverOptions) {\n\t\tthis.telescope = options.telescope;\n\t\tthis.onMetrics = options.onMetrics;\n\t\tthis.logMetrics = options.logMetrics ?? false;\n\t}\n\n\t/**\n\t * Handle incoming trace data\n\t * Transforms HTTP server spans to Telescope request entries\n\t */\n\tasync receiveTraces(\n\t\trequest: ExportTraceServiceRequest,\n\t): Promise<ExportTraceServiceResponse> {\n\t\tconst entries = transformTraces(request);\n\t\tlet rejected = 0;\n\n\t\tfor (const entry of entries) {\n\t\t\ttry {\n\t\t\t\tawait this.telescope.recordRequest(entry);\n\t\t\t} catch {\n\t\t\t\trejected++;\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedSpans: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming log data\n\t * Transforms OTLP log records to Telescope log entries\n\t */\n\tasync receiveLogs(\n\t\trequest: ExportLogsServiceRequest,\n\t): Promise<ExportLogsServiceResponse> {\n\t\tconst entries = transformLogs(request);\n\t\tlet rejected = 0;\n\n\t\t// Batch log entries for efficiency\n\t\tconst batchEntries = entries.map((entry) => ({\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message,\n\t\t\tcontext: entry.context,\n\t\t\trequestId: entry.requestId,\n\t\t}));\n\n\t\ttry {\n\t\t\tawait this.telescope.log(batchEntries);\n\t\t} catch {\n\t\t\trejected = entries.length;\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedLogRecords: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming metrics data\n\t * Forwards to custom handler and optionally logs to Telescope\n\t */\n\tasync receiveMetrics(\n\t\trequest: ExportMetricsServiceRequest,\n\t): Promise<ExportMetricsServiceResponse> {\n\t\tconst points = transformMetrics(request);\n\t\tlet rejected = 0;\n\n\t\t// Forward to custom metrics handler\n\t\tif (this.onMetrics) {\n\t\t\ttry {\n\t\t\t\tawait this.onMetrics(points);\n\t\t\t} catch {\n\t\t\t\trejected = points.length;\n\t\t\t}\n\t\t}\n\n\t\t// Optionally log metrics to Telescope for debugging\n\t\tif (this.logMetrics && points.length > 0) {\n\t\t\tconst logEntries = points.map((point) => ({\n\t\t\t\tlevel: 'debug' as const,\n\t\t\t\tmessage: `OTLP Metric: ${point.name}`,\n\t\t\t\tcontext: {\n\t\t\t\t\tname: point.name,\n\t\t\t\t\tvalue: point.value,\n\t\t\t\t\ttype: point.type,\n\t\t\t\t\tunit: point.unit,\n\t\t\t\t\tattributes: point.attributes,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\ttry {\n\t\t\t\tawait this.telescope.log(logEntries);\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedDataPoints: String(rejected) } }\n\t\t\t: {};\n\t}\n}\n"],"mappings":";;;;;;;;;;AAsDA,IAAa,eAAb,MAA0B;CACzB;CACA;CACA;CAEA,YAAY,SAA8B;EACzC,KAAK,YAAY,QAAQ;EACzB,KAAK,YAAY,QAAQ;EACzB,KAAK,aAAa,QAAQ,cAAc;CACzC;;;;;CAMA,MAAM,cACL,SACsC;EACtC,MAAM,UAAU,gBAAgB,OAAO;EACvC,IAAI,WAAW;EAEf,KAAK,MAAM,SAAS,SACnB,IAAI;GACH,MAAM,KAAK,UAAU,cAAc,KAAK;EACzC,QAAQ;GACP;EACD;EAGD,OAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,eAAe,OAAO,QAAQ,EAAE,EAAE,IACtD,CAAC;CACL;;;;;CAMA,MAAM,YACL,SACqC;EACrC,MAAM,UAAU,cAAc,OAAO;EACrC,IAAI,WAAW;EAGf,MAAM,eAAe,QAAQ,KAAK,WAAW;GAC5C,OAAO,MAAM;GACb,SAAS,MAAM;GACf,SAAS,MAAM;GACf,WAAW,MAAM;EAClB,EAAE;EAEF,IAAI;GACH,MAAM,KAAK,UAAU,IAAI,YAAY;EACtC,QAAQ;GACP,WAAW,QAAQ;EACpB;EAEA,OAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,QAAQ,EAAE,EAAE,IAC3D,CAAC;CACL;;;;;CAMA,MAAM,eACL,SACwC;EACxC,MAAM,SAAS,iBAAiB,OAAO;EACvC,IAAI,WAAW;EAGf,IAAI,KAAK,WACR,IAAI;GACH,MAAM,KAAK,UAAU,MAAM;EAC5B,QAAQ;GACP,WAAW,OAAO;EACnB;EAID,IAAI,KAAK,cAAc,OAAO,SAAS,GAAG;GACzC,MAAM,aAAa,OAAO,KAAK,WAAW;IACzC,OAAO;IACP,SAAS,gBAAgB,MAAM;IAC/B,SAAS;KACR,MAAM,MAAM;KACZ,OAAO,MAAM;KACb,MAAM,MAAM;KACZ,MAAM,MAAM;KACZ,YAAY,MAAM;IACnB;GACD,EAAE;GAEF,IAAI;IACH,MAAM,KAAK,UAAU,IAAI,UAAU;GACpC,QAAQ,CAER;EACD;EAEA,OAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,QAAQ,EAAE,EAAE,IAC3D,CAAC;CACL;AACD"}
|
|
@@ -1,6 +1,215 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./types.cjs");
|
|
3
|
+
//#region src/otlp/transformer.ts
|
|
4
|
+
/**
|
|
5
|
+
* Extract a primitive value from an AnyValue
|
|
6
|
+
*/
|
|
7
|
+
function extractValue(value) {
|
|
8
|
+
if (!value) return void 0;
|
|
9
|
+
if (value.stringValue !== void 0) return value.stringValue;
|
|
10
|
+
if (value.boolValue !== void 0) return value.boolValue;
|
|
11
|
+
if (value.intValue !== void 0) return parseInt(value.intValue, 10);
|
|
12
|
+
if (value.doubleValue !== void 0) return value.doubleValue;
|
|
13
|
+
if (value.bytesValue !== void 0) return value.bytesValue;
|
|
14
|
+
if (value.arrayValue) return value.arrayValue.values.map(extractValue);
|
|
15
|
+
if (value.kvlistValue) return attributesToObject(value.kvlistValue.values);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert KeyValue array to a plain object
|
|
19
|
+
*/
|
|
20
|
+
function attributesToObject(attrs) {
|
|
21
|
+
if (!attrs) return {};
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const attr of attrs) result[attr.key] = extractValue(attr.value);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert nanoseconds string to Date
|
|
28
|
+
*/
|
|
29
|
+
function nanoToDate(nanoStr) {
|
|
30
|
+
const nano = BigInt(nanoStr);
|
|
31
|
+
const ms = Number(nano / BigInt(1e6));
|
|
32
|
+
return new Date(ms);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert nanoseconds string to milliseconds number
|
|
36
|
+
*/
|
|
37
|
+
function nanoToMs(nanoStr) {
|
|
38
|
+
const nano = BigInt(nanoStr);
|
|
39
|
+
return Number(nano / BigInt(1e6));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Map OTLP severity number to Telescope log level
|
|
43
|
+
*/
|
|
44
|
+
function mapSeverity(severity) {
|
|
45
|
+
if (severity === void 0) return "info";
|
|
46
|
+
if (severity <= 8) return "debug";
|
|
47
|
+
if (severity <= 12) return "info";
|
|
48
|
+
if (severity <= 16) return "warn";
|
|
49
|
+
return "error";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Determine HTTP status from span attributes and status
|
|
53
|
+
*/
|
|
54
|
+
function getHttpStatus(span) {
|
|
55
|
+
const attrs = attributesToObject(span.attributes);
|
|
56
|
+
const statusCode = attrs["http.status_code"] ?? attrs["http.response.status_code"] ?? attrs["http.response_status_code"];
|
|
57
|
+
if (typeof statusCode === "number") return statusCode;
|
|
58
|
+
if (typeof statusCode === "string") return parseInt(statusCode, 10) || 200;
|
|
59
|
+
if (span.status?.code === 2) return 500;
|
|
60
|
+
if (span.status?.code === 1) return 200;
|
|
61
|
+
return 200;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a span represents an HTTP server request
|
|
65
|
+
*/
|
|
66
|
+
function isHttpServerSpan(span) {
|
|
67
|
+
if (span.kind !== 2) return false;
|
|
68
|
+
const attrs = attributesToObject(span.attributes);
|
|
69
|
+
return !!(attrs["http.method"] || attrs["http.request.method"] || attrs["http.url"] || attrs["http.target"] || attrs["url.path"]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Transform HTTP-related span attributes to RequestEntry format
|
|
73
|
+
*/
|
|
74
|
+
function transformHttpSpan(span, resourceAttrs) {
|
|
75
|
+
const attrs = attributesToObject(span.attributes);
|
|
76
|
+
const method = String(attrs["http.method"] ?? attrs["http.request.method"] ?? "GET").toUpperCase();
|
|
77
|
+
const path = String(attrs["http.target"] ?? attrs["url.path"] ?? attrs["http.route"] ?? "/");
|
|
78
|
+
const url = String(attrs["http.url"] ?? attrs["url.full"] ?? `http://localhost${path}`);
|
|
79
|
+
const headers = {};
|
|
80
|
+
const userAgent = attrs["http.user_agent"] ?? attrs["user_agent.original"];
|
|
81
|
+
if (userAgent) headers["user-agent"] = String(userAgent);
|
|
82
|
+
const contentType = attrs["http.request.header.content_type"];
|
|
83
|
+
if (contentType) headers["content-type"] = String(contentType);
|
|
84
|
+
const startTime = nanoToMs(span.startTimeUnixNano);
|
|
85
|
+
const duration = nanoToMs(span.endTimeUnixNano) - startTime;
|
|
86
|
+
const status = getHttpStatus(span);
|
|
87
|
+
const ip = attrs["net.peer.ip"] ?? attrs["client.address"] ?? attrs["http.client_ip"];
|
|
88
|
+
return {
|
|
89
|
+
method,
|
|
90
|
+
path,
|
|
91
|
+
url,
|
|
92
|
+
headers,
|
|
93
|
+
query: {},
|
|
94
|
+
status,
|
|
95
|
+
responseHeaders: {},
|
|
96
|
+
duration,
|
|
97
|
+
ip: ip ? String(ip) : void 0,
|
|
98
|
+
tags: [
|
|
99
|
+
`trace:${span.traceId}`,
|
|
100
|
+
`span:${span.spanId}`,
|
|
101
|
+
...resourceAttrs["service.name"] ? [`service:${resourceAttrs["service.name"]}`] : []
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Transform OTLP traces to Telescope RequestEntries
|
|
107
|
+
* Only transforms HTTP server spans to request entries
|
|
108
|
+
*/
|
|
109
|
+
function transformTraces(request) {
|
|
110
|
+
const entries = [];
|
|
111
|
+
for (const resourceSpans of request.resourceSpans ?? []) {
|
|
112
|
+
const resourceAttrs = attributesToObject(resourceSpans.resource?.attributes);
|
|
113
|
+
for (const scopeSpans of resourceSpans.scopeSpans ?? []) for (const span of scopeSpans.spans ?? []) if (isHttpServerSpan(span)) entries.push(transformHttpSpan(span, resourceAttrs));
|
|
114
|
+
}
|
|
115
|
+
return entries;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Transform a single OTLP log record to Telescope LogEntry
|
|
119
|
+
*/
|
|
120
|
+
function transformLogRecord(record, resourceAttrs, scopeName) {
|
|
121
|
+
const attrs = attributesToObject(record.attributes);
|
|
122
|
+
let message = "";
|
|
123
|
+
if (record.body) {
|
|
124
|
+
const bodyValue = extractValue(record.body);
|
|
125
|
+
message = typeof bodyValue === "string" ? bodyValue : JSON.stringify(bodyValue);
|
|
126
|
+
}
|
|
127
|
+
const context = {
|
|
128
|
+
...attrs,
|
|
129
|
+
...resourceAttrs
|
|
130
|
+
};
|
|
131
|
+
if (scopeName) context["instrumentation.scope"] = scopeName;
|
|
132
|
+
if (record.severityText) context["severity.text"] = record.severityText;
|
|
133
|
+
return {
|
|
134
|
+
level: mapSeverity(record.severityNumber),
|
|
135
|
+
message,
|
|
136
|
+
context: Object.keys(context).length > 0 ? context : void 0,
|
|
137
|
+
requestId: record.spanId ? `span:${record.spanId}` : void 0
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Transform OTLP logs to Telescope LogEntries
|
|
142
|
+
*/
|
|
143
|
+
function transformLogs(request) {
|
|
144
|
+
const entries = [];
|
|
145
|
+
for (const resourceLogs of request.resourceLogs ?? []) {
|
|
146
|
+
const resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);
|
|
147
|
+
for (const scopeLogs of resourceLogs.scopeLogs ?? []) {
|
|
148
|
+
const scopeName = scopeLogs.scope?.name;
|
|
149
|
+
for (const record of scopeLogs.logRecords ?? []) entries.push(transformLogRecord(record, resourceAttrs, scopeName));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return entries;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Transform OTLP metrics to normalized data points
|
|
156
|
+
* These can be used for custom metrics processing or forwarding
|
|
157
|
+
*/
|
|
158
|
+
function transformMetrics(request) {
|
|
159
|
+
const points = [];
|
|
160
|
+
for (const resourceMetrics of request.resourceMetrics ?? []) {
|
|
161
|
+
const resourceAttrs = attributesToObject(resourceMetrics.resource?.attributes);
|
|
162
|
+
for (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) for (const metric of scopeMetrics.metrics ?? []) {
|
|
163
|
+
const baseMeta = {
|
|
164
|
+
name: metric.name,
|
|
165
|
+
description: metric.description,
|
|
166
|
+
unit: metric.unit,
|
|
167
|
+
resourceAttributes: resourceAttrs
|
|
168
|
+
};
|
|
169
|
+
if (metric.gauge) for (const dp of metric.gauge.dataPoints) points.push({
|
|
170
|
+
...baseMeta,
|
|
171
|
+
value: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),
|
|
172
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
173
|
+
attributes: attributesToObject(dp.attributes),
|
|
174
|
+
type: "gauge"
|
|
175
|
+
});
|
|
176
|
+
if (metric.sum) for (const dp of metric.sum.dataPoints) points.push({
|
|
177
|
+
...baseMeta,
|
|
178
|
+
value: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),
|
|
179
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
180
|
+
attributes: attributesToObject(dp.attributes),
|
|
181
|
+
type: "sum"
|
|
182
|
+
});
|
|
183
|
+
if (metric.histogram) for (const dp of metric.histogram.dataPoints) points.push({
|
|
184
|
+
...baseMeta,
|
|
185
|
+
value: dp.sum ?? 0,
|
|
186
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
187
|
+
attributes: {
|
|
188
|
+
...attributesToObject(dp.attributes),
|
|
189
|
+
count: parseInt(dp.count, 10),
|
|
190
|
+
min: dp.min,
|
|
191
|
+
max: dp.max
|
|
192
|
+
},
|
|
193
|
+
type: "histogram"
|
|
194
|
+
});
|
|
195
|
+
if (metric.summary) for (const dp of metric.summary.dataPoints) points.push({
|
|
196
|
+
...baseMeta,
|
|
197
|
+
value: dp.sum ?? 0,
|
|
198
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
199
|
+
attributes: {
|
|
200
|
+
...attributesToObject(dp.attributes),
|
|
201
|
+
count: parseInt(dp.count, 10),
|
|
202
|
+
quantiles: dp.quantileValues
|
|
203
|
+
},
|
|
204
|
+
type: "summary"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return points;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
exports.transformLogs = transformLogs;
|
|
212
|
+
exports.transformMetrics = transformMetrics;
|
|
213
|
+
exports.transformTraces = transformTraces;
|
|
3
214
|
|
|
4
|
-
|
|
5
|
-
exports.transformMetrics = require_transformer.transformMetrics;
|
|
6
|
-
exports.transformTraces = require_transformer.transformTraces;
|
|
215
|
+
//# sourceMappingURL=transformer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer.cjs","names":[],"sources":["../../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'summary',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn points;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,aAAa,OAA2B;CAChD,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI,MAAM,gBAAgB,KAAA,GAAW,OAAO,MAAM;CAClD,IAAI,MAAM,cAAc,KAAA,GAAW,OAAO,MAAM;CAChD,IAAI,MAAM,aAAa,KAAA,GAAW,OAAO,SAAS,MAAM,UAAU,EAAE;CACpE,IAAI,MAAM,gB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formMetrics, transformTraces } from "../transformer-ICEbxpFf.cjs";
|
|
1
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-DlESim6Q.cjs";
|
|
4
2
|
export { MetricDataPoint, transformLogs, transformMetrics, transformTraces };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../types-DBc0q5KD.mjs";
|
|
3
|
-
import { MetricDataPoint, transformLogs, transformMetrics, transformTraces } from "../transformer-CTGsaVfV.mjs";
|
|
1
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-BBBXCjHP.mjs";
|
|
4
2
|
export { MetricDataPoint, transformLogs, transformMetrics, transformTraces };
|
|
@@ -1,4 +1,212 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
1
|
+
import "./types.mjs";
|
|
2
|
+
//#region src/otlp/transformer.ts
|
|
3
|
+
/**
|
|
4
|
+
* Extract a primitive value from an AnyValue
|
|
5
|
+
*/
|
|
6
|
+
function extractValue(value) {
|
|
7
|
+
if (!value) return void 0;
|
|
8
|
+
if (value.stringValue !== void 0) return value.stringValue;
|
|
9
|
+
if (value.boolValue !== void 0) return value.boolValue;
|
|
10
|
+
if (value.intValue !== void 0) return parseInt(value.intValue, 10);
|
|
11
|
+
if (value.doubleValue !== void 0) return value.doubleValue;
|
|
12
|
+
if (value.bytesValue !== void 0) return value.bytesValue;
|
|
13
|
+
if (value.arrayValue) return value.arrayValue.values.map(extractValue);
|
|
14
|
+
if (value.kvlistValue) return attributesToObject(value.kvlistValue.values);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convert KeyValue array to a plain object
|
|
18
|
+
*/
|
|
19
|
+
function attributesToObject(attrs) {
|
|
20
|
+
if (!attrs) return {};
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const attr of attrs) result[attr.key] = extractValue(attr.value);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert nanoseconds string to Date
|
|
27
|
+
*/
|
|
28
|
+
function nanoToDate(nanoStr) {
|
|
29
|
+
const nano = BigInt(nanoStr);
|
|
30
|
+
const ms = Number(nano / BigInt(1e6));
|
|
31
|
+
return new Date(ms);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert nanoseconds string to milliseconds number
|
|
35
|
+
*/
|
|
36
|
+
function nanoToMs(nanoStr) {
|
|
37
|
+
const nano = BigInt(nanoStr);
|
|
38
|
+
return Number(nano / BigInt(1e6));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Map OTLP severity number to Telescope log level
|
|
42
|
+
*/
|
|
43
|
+
function mapSeverity(severity) {
|
|
44
|
+
if (severity === void 0) return "info";
|
|
45
|
+
if (severity <= 8) return "debug";
|
|
46
|
+
if (severity <= 12) return "info";
|
|
47
|
+
if (severity <= 16) return "warn";
|
|
48
|
+
return "error";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Determine HTTP status from span attributes and status
|
|
52
|
+
*/
|
|
53
|
+
function getHttpStatus(span) {
|
|
54
|
+
const attrs = attributesToObject(span.attributes);
|
|
55
|
+
const statusCode = attrs["http.status_code"] ?? attrs["http.response.status_code"] ?? attrs["http.response_status_code"];
|
|
56
|
+
if (typeof statusCode === "number") return statusCode;
|
|
57
|
+
if (typeof statusCode === "string") return parseInt(statusCode, 10) || 200;
|
|
58
|
+
if (span.status?.code === 2) return 500;
|
|
59
|
+
if (span.status?.code === 1) return 200;
|
|
60
|
+
return 200;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if a span represents an HTTP server request
|
|
64
|
+
*/
|
|
65
|
+
function isHttpServerSpan(span) {
|
|
66
|
+
if (span.kind !== 2) return false;
|
|
67
|
+
const attrs = attributesToObject(span.attributes);
|
|
68
|
+
return !!(attrs["http.method"] || attrs["http.request.method"] || attrs["http.url"] || attrs["http.target"] || attrs["url.path"]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Transform HTTP-related span attributes to RequestEntry format
|
|
72
|
+
*/
|
|
73
|
+
function transformHttpSpan(span, resourceAttrs) {
|
|
74
|
+
const attrs = attributesToObject(span.attributes);
|
|
75
|
+
const method = String(attrs["http.method"] ?? attrs["http.request.method"] ?? "GET").toUpperCase();
|
|
76
|
+
const path = String(attrs["http.target"] ?? attrs["url.path"] ?? attrs["http.route"] ?? "/");
|
|
77
|
+
const url = String(attrs["http.url"] ?? attrs["url.full"] ?? `http://localhost${path}`);
|
|
78
|
+
const headers = {};
|
|
79
|
+
const userAgent = attrs["http.user_agent"] ?? attrs["user_agent.original"];
|
|
80
|
+
if (userAgent) headers["user-agent"] = String(userAgent);
|
|
81
|
+
const contentType = attrs["http.request.header.content_type"];
|
|
82
|
+
if (contentType) headers["content-type"] = String(contentType);
|
|
83
|
+
const startTime = nanoToMs(span.startTimeUnixNano);
|
|
84
|
+
const duration = nanoToMs(span.endTimeUnixNano) - startTime;
|
|
85
|
+
const status = getHttpStatus(span);
|
|
86
|
+
const ip = attrs["net.peer.ip"] ?? attrs["client.address"] ?? attrs["http.client_ip"];
|
|
87
|
+
return {
|
|
88
|
+
method,
|
|
89
|
+
path,
|
|
90
|
+
url,
|
|
91
|
+
headers,
|
|
92
|
+
query: {},
|
|
93
|
+
status,
|
|
94
|
+
responseHeaders: {},
|
|
95
|
+
duration,
|
|
96
|
+
ip: ip ? String(ip) : void 0,
|
|
97
|
+
tags: [
|
|
98
|
+
`trace:${span.traceId}`,
|
|
99
|
+
`span:${span.spanId}`,
|
|
100
|
+
...resourceAttrs["service.name"] ? [`service:${resourceAttrs["service.name"]}`] : []
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Transform OTLP traces to Telescope RequestEntries
|
|
106
|
+
* Only transforms HTTP server spans to request entries
|
|
107
|
+
*/
|
|
108
|
+
function transformTraces(request) {
|
|
109
|
+
const entries = [];
|
|
110
|
+
for (const resourceSpans of request.resourceSpans ?? []) {
|
|
111
|
+
const resourceAttrs = attributesToObject(resourceSpans.resource?.attributes);
|
|
112
|
+
for (const scopeSpans of resourceSpans.scopeSpans ?? []) for (const span of scopeSpans.spans ?? []) if (isHttpServerSpan(span)) entries.push(transformHttpSpan(span, resourceAttrs));
|
|
113
|
+
}
|
|
114
|
+
return entries;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Transform a single OTLP log record to Telescope LogEntry
|
|
118
|
+
*/
|
|
119
|
+
function transformLogRecord(record, resourceAttrs, scopeName) {
|
|
120
|
+
const attrs = attributesToObject(record.attributes);
|
|
121
|
+
let message = "";
|
|
122
|
+
if (record.body) {
|
|
123
|
+
const bodyValue = extractValue(record.body);
|
|
124
|
+
message = typeof bodyValue === "string" ? bodyValue : JSON.stringify(bodyValue);
|
|
125
|
+
}
|
|
126
|
+
const context = {
|
|
127
|
+
...attrs,
|
|
128
|
+
...resourceAttrs
|
|
129
|
+
};
|
|
130
|
+
if (scopeName) context["instrumentation.scope"] = scopeName;
|
|
131
|
+
if (record.severityText) context["severity.text"] = record.severityText;
|
|
132
|
+
return {
|
|
133
|
+
level: mapSeverity(record.severityNumber),
|
|
134
|
+
message,
|
|
135
|
+
context: Object.keys(context).length > 0 ? context : void 0,
|
|
136
|
+
requestId: record.spanId ? `span:${record.spanId}` : void 0
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Transform OTLP logs to Telescope LogEntries
|
|
141
|
+
*/
|
|
142
|
+
function transformLogs(request) {
|
|
143
|
+
const entries = [];
|
|
144
|
+
for (const resourceLogs of request.resourceLogs ?? []) {
|
|
145
|
+
const resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);
|
|
146
|
+
for (const scopeLogs of resourceLogs.scopeLogs ?? []) {
|
|
147
|
+
const scopeName = scopeLogs.scope?.name;
|
|
148
|
+
for (const record of scopeLogs.logRecords ?? []) entries.push(transformLogRecord(record, resourceAttrs, scopeName));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return entries;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Transform OTLP metrics to normalized data points
|
|
155
|
+
* These can be used for custom metrics processing or forwarding
|
|
156
|
+
*/
|
|
157
|
+
function transformMetrics(request) {
|
|
158
|
+
const points = [];
|
|
159
|
+
for (const resourceMetrics of request.resourceMetrics ?? []) {
|
|
160
|
+
const resourceAttrs = attributesToObject(resourceMetrics.resource?.attributes);
|
|
161
|
+
for (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) for (const metric of scopeMetrics.metrics ?? []) {
|
|
162
|
+
const baseMeta = {
|
|
163
|
+
name: metric.name,
|
|
164
|
+
description: metric.description,
|
|
165
|
+
unit: metric.unit,
|
|
166
|
+
resourceAttributes: resourceAttrs
|
|
167
|
+
};
|
|
168
|
+
if (metric.gauge) for (const dp of metric.gauge.dataPoints) points.push({
|
|
169
|
+
...baseMeta,
|
|
170
|
+
value: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),
|
|
171
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
172
|
+
attributes: attributesToObject(dp.attributes),
|
|
173
|
+
type: "gauge"
|
|
174
|
+
});
|
|
175
|
+
if (metric.sum) for (const dp of metric.sum.dataPoints) points.push({
|
|
176
|
+
...baseMeta,
|
|
177
|
+
value: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),
|
|
178
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
179
|
+
attributes: attributesToObject(dp.attributes),
|
|
180
|
+
type: "sum"
|
|
181
|
+
});
|
|
182
|
+
if (metric.histogram) for (const dp of metric.histogram.dataPoints) points.push({
|
|
183
|
+
...baseMeta,
|
|
184
|
+
value: dp.sum ?? 0,
|
|
185
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
186
|
+
attributes: {
|
|
187
|
+
...attributesToObject(dp.attributes),
|
|
188
|
+
count: parseInt(dp.count, 10),
|
|
189
|
+
min: dp.min,
|
|
190
|
+
max: dp.max
|
|
191
|
+
},
|
|
192
|
+
type: "histogram"
|
|
193
|
+
});
|
|
194
|
+
if (metric.summary) for (const dp of metric.summary.dataPoints) points.push({
|
|
195
|
+
...baseMeta,
|
|
196
|
+
value: dp.sum ?? 0,
|
|
197
|
+
timestamp: nanoToDate(dp.timeUnixNano),
|
|
198
|
+
attributes: {
|
|
199
|
+
...attributesToObject(dp.attributes),
|
|
200
|
+
count: parseInt(dp.count, 10),
|
|
201
|
+
quantiles: dp.quantileValues
|
|
202
|
+
},
|
|
203
|
+
type: "summary"
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return points;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
export { transformLogs, transformMetrics, transformTraces };
|
|
3
211
|
|
|
4
|
-
|
|
212
|
+
//# sourceMappingURL=transformer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer.mjs","names":[],"sources":["../../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'summary',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn points;\n}\n"],"mappings":";;;;;AAiBA,SAAS,aAAa,OAA2B;CAChD,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI,MAAM,gBAAgB,KAAA,GAAW,OAAO,MAAM;CAClD,IAAI,MAAM,cAAc,KAAA,GAAW,OAAO,MAAM;CAChD,IAAI,MAAM,aAAa,KAAA,GAAW,OAAO,SAAS,MAAM,UAAU,EAAE;CACpE,IAAI,MAAM,gBAAgB,KAAA,GAAW,OAAO,MAAM;CAClD,IAAI,MAAM,eAAe,KAAA,GAAW,OAAO,MAAM;CACjD,IAAI,MAAM,YAAY,OAAO,MAAM,WAAW,OAAO,IAAI,YAAY;CACrE,IAAI,MAAM,aAAa,OAAO,mBAAmB,MAAM,YAAY,MAAM;AAE1E;;;;AAKA,SAAS,mBAAmB,OAA6C;CACxE,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,OAClB,OAAO,KAAK,OAAO,aAAa,KAAK,KAAK;CAE3C,OAAO;AACR;;;;AAKA,SAAS,WAAW,SAAuB;CAC1C,MAAM,OAAO,OAAO,OAAO;CAC3B,MAAM,KAAK,OAAO,OAAO,OAAO,GAAS,CAAC;CAC1C,OAAO,IAAI,KAAK,EAAE;AACnB;;;;AAKA,SAAS,SAAS,SAAyB;CAC1C,MAAM,OAAO,OAAO,OAAO;CAC3B,OA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