@utk09/ui-observability 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/{batch-D3NHhF9L.js → batch-120Kc9jr.js} +3 -3
- package/dist/{batch-D3NHhF9L.js.map → batch-120Kc9jr.js.map} +1 -1
- package/dist/{batch-DnYRJqhU.cjs → batch-C3uNp5kU.cjs} +2 -2
- package/dist/{batch-DnYRJqhU.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +5 -0
- package/dist/bus/bus.d.ts +5 -0
- package/dist/bus-Dj8IEVcC.cjs +2 -0
- package/dist/bus-Dj8IEVcC.cjs.map +1 -0
- package/dist/{bus-dw7T92sO.js → bus-DyNafxZN.js} +104 -94
- package/dist/bus-DyNafxZN.js.map +1 -0
- package/dist/capture/errors.d.cts +10 -0
- package/dist/capture/errors.d.ts +10 -0
- package/dist/capture/replay.d.cts +1 -1
- package/dist/capture/replay.d.ts +1 -1
- package/dist/capture/types.d.cts +5 -0
- package/dist/capture/types.d.ts +5 -0
- package/dist/capture/web-vitals.d.cts +1 -0
- package/dist/capture/web-vitals.d.ts +1 -0
- package/dist/{compression-SHPAvS4U.js → compression-BWkDWY3v.js} +2 -2
- package/dist/{compression-SHPAvS4U.js.map → compression-BWkDWY3v.js.map} +1 -1
- package/dist/{compression-C0hUHKR-.cjs → compression-CEVe7NPX.cjs} +2 -2
- package/dist/{compression-C0hUHKR-.cjs.map → compression-CEVe7NPX.cjs.map} +1 -1
- package/dist/config-C0PtemvC.cjs +2 -0
- package/dist/config-C0PtemvC.cjs.map +1 -0
- package/dist/{config-CSNcS7OZ.js → config-DK1Zf7jn.js} +83 -85
- package/dist/config-DK1Zf7jn.js.map +1 -0
- package/dist/{console-BsM-fSCQ.js → console-CAyCQOpm.js} +5 -5
- package/dist/{console-BsM-fSCQ.js.map → console-CAyCQOpm.js.map} +1 -1
- package/dist/{console-Dkxs6IVQ.cjs → console-Dk6GH4yj.cjs} +2 -2
- package/dist/{console-Dkxs6IVQ.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
- package/dist/{constants-BwJDXzj6.js → constants-CEHN6KuY.js} +42 -21
- package/dist/constants-CEHN6KuY.js.map +1 -0
- package/dist/constants-NtiQDWL_.cjs +2 -0
- package/dist/constants-NtiQDWL_.cjs.map +1 -0
- package/dist/constants.d.cts +11 -0
- package/dist/constants.d.ts +11 -0
- package/dist/core/config.d.cts +9 -3
- package/dist/core/config.d.ts +9 -3
- package/dist/core/diagnostics.d.cts +1 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/pipeline.d.cts +11 -0
- package/dist/core/pipeline.d.ts +11 -0
- package/dist/core/record.d.cts +2 -2
- package/dist/core/record.d.ts +2 -2
- package/dist/core/sender.d.cts +3 -2
- package/dist/core/sender.d.ts +3 -2
- package/dist/{debug-bundle-B2v6Cym-.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
- package/dist/{debug-bundle-B2v6Cym-.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
- package/dist/{debug-bundle-Cs_YWzTa.js → debug-bundle-w78W46zr.js} +4 -4
- package/dist/{debug-bundle-Cs_YWzTa.js.map → debug-bundle-w78W46zr.js.map} +1 -1
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.js +22 -22
- package/dist/doctor.js.map +1 -1
- package/dist/errors-07pmZ7VY.cjs +3 -0
- package/dist/errors-07pmZ7VY.cjs.map +1 -0
- package/dist/{errors-Q3Ng1ciC.js → errors-C-LYbqyB.js} +27 -24
- package/dist/errors-C-LYbqyB.js.map +1 -0
- package/dist/{factory-DV17sm2p.js → factory-BHYrcSaU.js} +42 -31
- package/dist/factory-BHYrcSaU.js.map +1 -0
- package/dist/factory-DsaNdcXp.cjs +2 -0
- package/dist/factory-DsaNdcXp.cjs.map +1 -0
- package/dist/{identity-BgtHyY4u.js → identity-Byh3gCdT.js} +11 -11
- package/dist/{identity-BgtHyY4u.js.map → identity-Byh3gCdT.js.map} +1 -1
- package/dist/{identity-CvuyqZk7.cjs → identity-BzAzdQyv.cjs} +2 -2
- package/dist/{identity-CvuyqZk7.cjs.map → identity-BzAzdQyv.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +539 -534
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-e-13ZLWm.js → indexeddb-storage-BYywz-v6.js} +4 -4
- package/dist/{indexeddb-storage-e-13ZLWm.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
- package/dist/{indexeddb-storage-D4KVcqdD.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
- package/dist/{indexeddb-storage-D4KVcqdD.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
- package/dist/{interactions-OK85T-Dk.cjs → interactions-BXzEel4F.cjs} +2 -2
- package/dist/interactions-BXzEel4F.cjs.map +1 -0
- package/dist/{interactions-Byxf1C82.js → interactions-DdKPMWIN.js} +12 -12
- package/dist/interactions-DdKPMWIN.js.map +1 -0
- package/dist/{journey-nMbob3OB.cjs → journey-BUmsrgaw.cjs} +2 -2
- package/dist/{journey-nMbob3OB.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
- package/dist/{journey-C93FTYcs.js → journey-Nu655gEO.js} +3 -3
- package/dist/{journey-C93FTYcs.js.map → journey-Nu655gEO.js.map} +1 -1
- package/dist/{library-console-DJUQzcgM.cjs → library-console-DdIlzzph.cjs} +2 -2
- package/dist/{library-console-DJUQzcgM.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
- package/dist/{library-console-DklSmucS.js → library-console-amePMnP8.js} +2 -2
- package/dist/{library-console-DklSmucS.js.map → library-console-amePMnP8.js.map} +1 -1
- package/dist/{library-request-UGEwOHpf.js → library-request-Cv7C05jf.js} +2 -2
- package/dist/{library-request-UGEwOHpf.js.map → library-request-Cv7C05jf.js.map} +1 -1
- package/dist/{library-request-kY9iTpIF.cjs → library-request-DO3Ec7KE.cjs} +2 -2
- package/dist/{library-request-kY9iTpIF.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
- package/dist/{lifecycle-DaMdH_X7.cjs → lifecycle-B5yfH5is.cjs} +2 -2
- package/dist/{lifecycle-DaMdH_X7.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
- package/dist/{lifecycle-B2PlIuQu.js → lifecycle-CMHz2Zbs.js} +2 -2
- package/dist/{lifecycle-B2PlIuQu.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
- package/dist/{log-record-DSt2P-Sr.js → log-record-B_nSqxoe.js} +2 -2
- package/dist/{log-record-DSt2P-Sr.js.map → log-record-B_nSqxoe.js.map} +1 -1
- package/dist/{log-record-Bmx6etMh.cjs → log-record-Bdywwg0k.cjs} +2 -2
- package/dist/{log-record-Bmx6etMh.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
- package/dist/{long-frames-Bamjs1WV.js → long-frames-6NGl1-uN.js} +3 -3
- package/dist/{long-frames-Bamjs1WV.js.map → long-frames-6NGl1-uN.js.map} +1 -1
- package/dist/{long-frames-lhtONgGt.cjs → long-frames-D9DfSWqv.cjs} +2 -2
- package/dist/{long-frames-lhtONgGt.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
- package/dist/models/config.d.cts +4 -3
- package/dist/models/config.d.ts +4 -3
- package/dist/{network-BCn8Gn47.cjs → network-BNHBI0Fc.cjs} +2 -2
- package/dist/{network-BCn8Gn47.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
- package/dist/{network-Cg1L2w2r.js → network-Cc3tSB7e.js} +13 -13
- package/dist/{network-Cg1L2w2r.js.map → network-Cc3tSB7e.js.map} +1 -1
- package/dist/{observed-windows-BrwaJNlj.js → observed-windows-8JtCsIr1.js} +3 -3
- package/dist/{observed-windows-BrwaJNlj.js.map → observed-windows-8JtCsIr1.js.map} +1 -1
- package/dist/{observed-windows-B3gJkdql.cjs → observed-windows-BlE25nrn.cjs} +2 -2
- package/dist/{observed-windows-B3gJkdql.cjs.map → observed-windows-BlE25nrn.cjs.map} +1 -1
- package/dist/openfin-Bxelt0yg.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/{otlp-D6dRZyB8.js → otlp-Btix3EBa.js} +7 -7
- package/dist/{otlp-D6dRZyB8.js.map → otlp-Btix3EBa.js.map} +1 -1
- package/dist/{otlp-CrAWkQdO.cjs → otlp-CFSW-Dno.cjs} +2 -2
- package/dist/{otlp-CrAWkQdO.cjs.map → otlp-CFSW-Dno.cjs.map} +1 -1
- package/dist/patch-DlcKzIi-.cjs +2 -0
- package/dist/patch-DlcKzIi-.cjs.map +1 -0
- package/dist/patch-Sr1wKg7W.js +9 -0
- package/dist/patch-Sr1wKg7W.js.map +1 -0
- package/dist/platform-BZjp9wp1.cjs +2 -0
- package/dist/platform-BZjp9wp1.cjs.map +1 -0
- package/dist/{platform-8DLhjddo.js → platform-Dba6R3Hp.js} +22 -9
- package/dist/platform-Dba6R3Hp.js.map +1 -0
- package/dist/{profiler-BaXSqCfz.js → profiler-DNKcqu09.js} +19 -19
- package/dist/{profiler-BaXSqCfz.js.map → profiler-DNKcqu09.js.map} +1 -1
- package/dist/{profiler-BvWW2kNM.cjs → profiler-DpoPi1hH.cjs} +2 -2
- package/dist/{profiler-BvWW2kNM.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
- package/dist/{profiler-frames-DeaBiB-5.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
- package/dist/{profiler-frames-DeaBiB-5.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
- package/dist/{profiler-frames-C4ySHN0X.js → profiler-frames-CGXZeZ_3.js} +4 -4
- package/dist/{profiler-frames-C4ySHN0X.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
- package/dist/{remote-rules-Dq9xe7Qn.js → remote-rules-DNK96vLa.js} +15 -15
- package/dist/{remote-rules-Dq9xe7Qn.js.map → remote-rules-DNK96vLa.js.map} +1 -1
- package/dist/{remote-rules-D7L6D_D2.cjs → remote-rules-DuMFRlit.cjs} +2 -2
- package/dist/{remote-rules-D7L6D_D2.cjs.map → remote-rules-DuMFRlit.cjs.map} +1 -1
- package/dist/replay-Cab-lSit.cjs +2 -0
- package/dist/replay-Cab-lSit.cjs.map +1 -0
- package/dist/{replay-B0M8kWz_.js → replay-Dy6OiaOZ.js} +89 -62
- package/dist/replay-Dy6OiaOZ.js.map +1 -0
- package/dist/{reports-ojuMKGO7.cjs → reports-CGK9YQch.cjs} +2 -2
- package/dist/{reports-ojuMKGO7.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
- package/dist/{reports--8APRLa-.js → reports-CX57-S9s.js} +3 -3
- package/dist/{reports--8APRLa-.js.map → reports-CX57-S9s.js.map} +1 -1
- package/dist/{resource-timing-BzR05rE-.js → resource-timing-CWVDCbrY.js} +4 -4
- package/dist/{resource-timing-BzR05rE-.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
- package/dist/{resource-timing-pAG3ZhB5.cjs → resource-timing-DalulXiR.cjs} +2 -2
- package/dist/{resource-timing-pAG3ZhB5.cjs.map → resource-timing-DalulXiR.cjs.map} +1 -1
- package/dist/response-body-Cpz5__4g.cjs +3 -0
- package/dist/response-body-Cpz5__4g.cjs.map +1 -0
- package/dist/{response-body-BWvwKQ2p.js → response-body-yi92Rpvo.js} +100 -100
- package/dist/response-body-yi92Rpvo.js.map +1 -0
- package/dist/{rotation-BylN1B9e.js → rotation-ChBbNDE2.js} +24 -24
- package/dist/rotation-ChBbNDE2.js.map +1 -0
- package/dist/rotation-fTnNJcfH.cjs +2 -0
- package/dist/rotation-fTnNJcfH.cjs.map +1 -0
- package/dist/{sampling-zXA6r-Nw.js → sampling-DZTOD28D.js} +6 -6
- package/dist/{sampling-zXA6r-Nw.js.map → sampling-DZTOD28D.js.map} +1 -1
- package/dist/{sampling-B46LW0cy.cjs → sampling-wAVJIZXp.cjs} +2 -2
- package/dist/{sampling-B46LW0cy.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
- package/dist/{sanitize-DjnR6RXR.js → sanitize-B2GKlSFp.js} +2 -2
- package/dist/{sanitize-DjnR6RXR.js.map → sanitize-B2GKlSFp.js.map} +1 -1
- package/dist/{sanitize-Qj6LuZqp.cjs → sanitize-BZdhoghq.cjs} +2 -2
- package/dist/{sanitize-Qj6LuZqp.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
- package/dist/{sender-Bdp-TAS4.js → sender-BRSpc7R8.js} +175 -161
- package/dist/sender-BRSpc7R8.js.map +1 -0
- package/dist/sender-CFu98DAB.cjs +2 -0
- package/dist/sender-CFu98DAB.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.cts +3 -1
- package/dist/storage/emergency-queue.d.ts +3 -1
- package/dist/storage/stored-context.d.cts +3 -2
- package/dist/storage/stored-context.d.ts +3 -2
- package/dist/stored-context-CPLlzgpm.cjs +2 -0
- package/dist/stored-context-CPLlzgpm.cjs.map +1 -0
- package/dist/{stored-context-CSttrAsw.js → stored-context-df1dEnht.js} +10 -8
- package/dist/stored-context-df1dEnht.js.map +1 -0
- package/dist/{storm-DKlpv0FL.js → storm-U3_ek1nA.js} +2 -2
- package/dist/{storm-DKlpv0FL.js.map → storm-U3_ek1nA.js.map} +1 -1
- package/dist/{storm-BHgI12iS.cjs → storm-qiE_AMC7.cjs} +2 -2
- package/dist/{storm-BHgI12iS.cjs.map → storm-qiE_AMC7.cjs.map} +1 -1
- package/dist/transport/exit-flush.d.cts +23 -0
- package/dist/transport/exit-flush.d.ts +23 -0
- package/dist/transport/http-transport.d.cts +3 -2
- package/dist/transport/http-transport.d.ts +3 -2
- package/dist/transport/retry-engine.d.cts +11 -3
- package/dist/transport/retry-engine.d.ts +11 -3
- package/dist/types-BAerHgCq.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-BcOB8A2e.js → unclean-exit-Bj6gYHeL.js} +2 -2
- package/dist/{unclean-exit-BcOB8A2e.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
- package/dist/{unclean-exit-BYPYYkQ5.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
- package/dist/{unclean-exit-BYPYYkQ5.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
- package/dist/{user-timing-BsU2wQKE.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
- package/dist/{user-timing-BsU2wQKE.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
- package/dist/{user-timing-4KIJ74Vi.js → user-timing-Duz0d-OA.js} +2 -2
- package/dist/{user-timing-4KIJ74Vi.js.map → user-timing-Duz0d-OA.js.map} +1 -1
- package/dist/utils/lock.d.cts +3 -2
- package/dist/utils/lock.d.ts +3 -2
- package/dist/utils/openfin.d.cts +18 -6
- package/dist/utils/openfin.d.ts +18 -6
- package/dist/utils/patch.d.cts +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/platform.d.cts +6 -0
- package/dist/utils/platform.d.ts +6 -0
- package/dist/{web-socket-Zg0hj1LB.js → web-socket-CE_9Q22z.js} +5 -5
- package/dist/{web-socket-Zg0hj1LB.js.map → web-socket-CE_9Q22z.js.map} +1 -1
- package/dist/{web-socket-Cs1ZbmmN.cjs → web-socket-sm3rD-A_.cjs} +2 -2
- package/dist/{web-socket-Cs1ZbmmN.cjs.map → web-socket-sm3rD-A_.cjs.map} +1 -1
- package/dist/{web-vitals-4pWACwaR.js → web-vitals-CGwXGF-M.js} +4 -4
- package/dist/web-vitals-CGwXGF-M.js.map +1 -0
- package/dist/web-vitals-Df4Wsfx9.cjs +2 -0
- package/dist/web-vitals-Df4Wsfx9.cjs.map +1 -0
- package/dist/{worker-protocol-DFYXIFus.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
- package/dist/{worker-protocol-DFYXIFus.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
- package/dist/{worker-protocol-CYpAbrVl.js → worker-protocol-h4-tRWqy.js} +6 -6
- package/dist/{worker-protocol-CYpAbrVl.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
- package/dist/{worker-server--yGTadTA.cjs → worker-server-CF1yatXq.cjs} +2 -2
- package/dist/{worker-server--yGTadTA.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
- package/dist/worker-server-FYfKHQhJ.js +94 -0
- package/dist/{worker-server-BokySIII.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
- package/dist/{worker-transport-BdEvh_-a.cjs → worker-transport-COgY4RX8.cjs} +2 -2
- package/dist/{worker-transport-BdEvh_-a.cjs.map → worker-transport-COgY4RX8.cjs.map} +1 -1
- package/dist/{worker-transport-JK-Fby9J.js → worker-transport-jzX1IusG.js} +34 -34
- package/dist/{worker-transport-JK-Fby9J.js.map → worker-transport-jzX1IusG.js.map} +1 -1
- package/llms.txt +1 -2
- package/package.json +1 -1
- package/dist/bus-B__467mL.cjs +0 -2
- package/dist/bus-B__467mL.cjs.map +0 -1
- package/dist/bus-dw7T92sO.js.map +0 -1
- package/dist/config-CSNcS7OZ.js.map +0 -1
- package/dist/config-CybPP5VM.cjs +0 -2
- package/dist/config-CybPP5VM.cjs.map +0 -1
- package/dist/constants-BwJDXzj6.js.map +0 -1
- package/dist/constants-CtF52hIV.cjs +0 -2
- package/dist/constants-CtF52hIV.cjs.map +0 -1
- package/dist/errors-DP2RUm4V.cjs +0 -3
- package/dist/errors-DP2RUm4V.cjs.map +0 -1
- package/dist/errors-Q3Ng1ciC.js.map +0 -1
- package/dist/factory-DV17sm2p.js.map +0 -1
- package/dist/factory-K8O6gpux.cjs +0 -2
- package/dist/factory-K8O6gpux.cjs.map +0 -1
- package/dist/interactions-Byxf1C82.js.map +0 -1
- package/dist/interactions-OK85T-Dk.cjs.map +0 -1
- package/dist/patch-BX8KrPCT.cjs +0 -2
- package/dist/patch-BX8KrPCT.cjs.map +0 -1
- package/dist/patch-UdPz1ea8.js +0 -8
- package/dist/patch-UdPz1ea8.js.map +0 -1
- package/dist/platform-8DLhjddo.js.map +0 -1
- package/dist/platform-BqRc-7RO.cjs +0 -2
- package/dist/platform-BqRc-7RO.cjs.map +0 -1
- package/dist/replay-B0M8kWz_.js.map +0 -1
- package/dist/replay-QOFBpAXh.cjs +0 -2
- package/dist/replay-QOFBpAXh.cjs.map +0 -1
- package/dist/response-body-BWvwKQ2p.js.map +0 -1
- package/dist/response-body-CKEJ5itk.cjs +0 -3
- package/dist/response-body-CKEJ5itk.cjs.map +0 -1
- package/dist/rotation-BylN1B9e.js.map +0 -1
- package/dist/rotation-E2eKClIs.cjs +0 -2
- package/dist/rotation-E2eKClIs.cjs.map +0 -1
- package/dist/sender-Bdp-TAS4.js.map +0 -1
- package/dist/sender-DR7ZycZY.cjs +0 -2
- package/dist/sender-DR7ZycZY.cjs.map +0 -1
- package/dist/stored-context-BOu54M8Y.cjs +0 -2
- package/dist/stored-context-BOu54M8Y.cjs.map +0 -1
- package/dist/stored-context-CSttrAsw.js.map +0 -1
- package/dist/web-vitals-4pWACwaR.js.map +0 -1
- package/dist/web-vitals-__X7t4pj.cjs +0 -2
- package/dist/web-vitals-__X7t4pj.cjs.map +0 -1
- package/dist/worker-server-BokySIII.js +0 -94
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as e, B as t, Bt as n,
|
|
1
|
+
import { $ as e, B as t, Bt as n, Gt as r, Ht as i, Kn as a, Q as o, Tn as s, Wt as c, a as l, bn as u, g as d, ir as f, ln as p, rr as ee, vn as te, wn as m, z as h, zn as g, zt as _ } from "./constants-CEHN6KuY.js";
|
|
2
2
|
import { n as v } from "./guards-BlYGRK4l.js";
|
|
3
3
|
import { t as y } from "./defineProperty-s2S8BXUc.js";
|
|
4
|
-
import { i as b } from "./sanitize-
|
|
5
|
-
import { t as
|
|
6
|
-
import { i as
|
|
4
|
+
import { i as b } from "./sanitize-B2GKlSFp.js";
|
|
5
|
+
import { t as x } from "./batch-120Kc9jr.js";
|
|
6
|
+
import { i as S, n as ne, r as re, t as C } from "./otlp-Btix3EBa.js";
|
|
7
7
|
// src/transport/errors.ts
|
|
8
|
-
var
|
|
8
|
+
var w = class extends Error {
|
|
9
9
|
constructor(e, t, n, r, i, a) {
|
|
10
10
|
super(t), y(this, "kind", void 0), y(this, "status", void 0), y(this, "retryAfterMs", void 0), y(this, "maxBytes", void 0), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError", a !== void 0 && Object.defineProperty(this, "cause", {
|
|
11
11
|
value: a,
|
|
@@ -14,109 +14,109 @@ var re = class extends Error {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
function
|
|
17
|
+
function T(e) {
|
|
18
18
|
if (!e) return;
|
|
19
19
|
let t = Number(e);
|
|
20
|
-
if (Number.isFinite(t)) return Math.max(0, t *
|
|
20
|
+
if (Number.isFinite(t)) return Math.max(0, t * i);
|
|
21
21
|
let n = Date.parse(e);
|
|
22
22
|
return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
|
|
23
23
|
}
|
|
24
24
|
// src/transport/serializers/ecs.ts
|
|
25
|
-
var
|
|
25
|
+
var E = {
|
|
26
26
|
"error.type": "type",
|
|
27
27
|
"error.message": "message",
|
|
28
28
|
"error.stack_trace": "stack_trace"
|
|
29
|
-
},
|
|
30
|
-
function D(e) {
|
|
31
|
-
return l.test(e) ? Number(BigInt(e) / a) : Date.now();
|
|
32
|
-
}
|
|
29
|
+
}, D = /* @__PURE__ */ new Set([l, ...Object.keys(E)]);
|
|
33
30
|
function O(e) {
|
|
31
|
+
return c.test(e) ? Number(BigInt(e) / r) : Date.now();
|
|
32
|
+
}
|
|
33
|
+
function k(e) {
|
|
34
34
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function A(e, t, n) {
|
|
37
37
|
let r = e[t];
|
|
38
38
|
r === void 0 ? e[t] = n : Array.isArray(r) ? r.push(n) : e[t] = [r, n];
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
let i =
|
|
42
|
-
if (i !== null)
|
|
40
|
+
function j(e, t, n, r) {
|
|
41
|
+
let i = k(n);
|
|
42
|
+
if (i !== null) A(e, t, i);
|
|
43
43
|
else if (typeof n == "object" && n && !r.has(n)) {
|
|
44
|
-
if (r.add(n), Array.isArray(n)) for (let i of n)
|
|
45
|
-
else for (let [i, a] of Object.entries(n))
|
|
44
|
+
if (r.add(n), Array.isArray(n)) for (let i of n) j(e, t, i, r);
|
|
45
|
+
else for (let [i, a] of Object.entries(n)) j(e, `${t}.${i}`, a, r);
|
|
46
46
|
r.delete(n);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function M(e) {
|
|
50
50
|
let t = Object.create(null), n = /* @__PURE__ */ new WeakSet();
|
|
51
|
-
for (let [r, i] of Object.entries(e))
|
|
51
|
+
for (let [r, i] of Object.entries(e)) j(t, r, i, n);
|
|
52
52
|
return t;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function N(e) {
|
|
55
55
|
let t = [];
|
|
56
|
-
for (let [n, r] of Object.entries(
|
|
56
|
+
for (let [n, r] of Object.entries(E)) {
|
|
57
57
|
let i = e[n];
|
|
58
58
|
typeof i == "string" && t.push([r, i]);
|
|
59
59
|
}
|
|
60
60
|
return t.length > 0 ? Object.fromEntries(t) : void 0;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return Object.fromEntries(Object.entries(e).filter(([e, t]) => !(
|
|
62
|
+
function P(e) {
|
|
63
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => !(D.has(e) && typeof t == "string")));
|
|
64
64
|
}
|
|
65
|
-
var
|
|
65
|
+
var F = {
|
|
66
66
|
name: "ecs",
|
|
67
67
|
serialize(n) {
|
|
68
68
|
return {
|
|
69
69
|
body: `${n.map((t) => {
|
|
70
|
-
let n =
|
|
70
|
+
let n = O(t.timeUnixNano), { attributes: r } = t, i = r[l];
|
|
71
71
|
return JSON.stringify({
|
|
72
72
|
"@timestamp": new Date(n).toISOString(),
|
|
73
73
|
message: t.body,
|
|
74
74
|
ecs: { version: e },
|
|
75
75
|
log: {
|
|
76
|
-
level:
|
|
77
|
-
logger: typeof
|
|
76
|
+
level: o[t.severityText] ?? t.severityText.toLowerCase(),
|
|
77
|
+
logger: typeof i == "string" ? i : void 0
|
|
78
78
|
},
|
|
79
|
-
event: { kind:
|
|
80
|
-
error:
|
|
79
|
+
event: { kind: r["log.type"] === "metric" ? "metric" : "event" },
|
|
80
|
+
error: N(r),
|
|
81
81
|
trace: { id: t.traceId },
|
|
82
82
|
span: { id: t.spanId },
|
|
83
83
|
service: {
|
|
84
|
-
name: t.resource[
|
|
85
|
-
version: t.resource[
|
|
86
|
-
environment: t.resource[
|
|
84
|
+
name: t.resource[m],
|
|
85
|
+
version: t.resource[s],
|
|
86
|
+
environment: t.resource[u]
|
|
87
87
|
},
|
|
88
|
-
user_agent: { original: t.resource[
|
|
89
|
-
url: { full:
|
|
88
|
+
user_agent: { original: t.resource[te] },
|
|
89
|
+
url: { full: r["url.full"] ?? r["page.url"] },
|
|
90
90
|
labels: {
|
|
91
|
-
...
|
|
92
|
-
...
|
|
91
|
+
...M(t.resource),
|
|
92
|
+
...M(P(r))
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
}).join("\n")}\n`,
|
|
96
96
|
contentType: t
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
},
|
|
100
|
-
function
|
|
99
|
+
}, I = 1, L = /* @__PURE__ */ new Set([..._, ...p]);
|
|
100
|
+
function R(e, t) {
|
|
101
101
|
let n = e.attributes[t];
|
|
102
102
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function z(e) {
|
|
105
105
|
return Array.isArray(e) && e.every((e) => typeof e == "number" && Number.isFinite(e));
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function B(e) {
|
|
108
108
|
let t = e.attributes[n.attributeKeys], r = {};
|
|
109
109
|
if (!Array.isArray(t)) return r;
|
|
110
110
|
for (let n of t) {
|
|
111
|
-
let t = typeof n == "string" && !
|
|
111
|
+
let t = typeof n == "string" && !L.has(n) ? e.attributes[n] : void 0;
|
|
112
112
|
(typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (r[n] = t);
|
|
113
113
|
}
|
|
114
114
|
return r;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
let t =
|
|
116
|
+
function V(e) {
|
|
117
|
+
let t = R(e, n.count);
|
|
118
118
|
if (t === void 0) {
|
|
119
|
-
let t =
|
|
119
|
+
let t = R(e, "metric.value");
|
|
120
120
|
return t === void 0 ? null : {
|
|
121
121
|
count: "1",
|
|
122
122
|
sum: t < 0 ? void 0 : t,
|
|
@@ -127,38 +127,38 @@ function z(e) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
let r = e.attributes[n.bounds], i = e.attributes[n.buckets];
|
|
130
|
-
if (!
|
|
131
|
-
let a =
|
|
130
|
+
if (!z(r) || !z(i) || i.length !== r.length + 1) return null;
|
|
131
|
+
let a = R(e, n.min);
|
|
132
132
|
return {
|
|
133
133
|
count: String(t),
|
|
134
|
-
sum: a !== void 0 && a < 0 ? void 0 :
|
|
134
|
+
sum: a !== void 0 && a < 0 ? void 0 : R(e, n.sum),
|
|
135
135
|
min: a,
|
|
136
|
-
max:
|
|
136
|
+
max: R(e, n.max),
|
|
137
137
|
bucketCounts: i.map(String),
|
|
138
138
|
explicitBounds: r
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
let t =
|
|
141
|
+
function H(e) {
|
|
142
|
+
let t = R(e, "metric.value");
|
|
143
143
|
return t === void 0 ? null : { asDouble: t };
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
let r = e.attributes[n.start], i = t === "histogram" ?
|
|
145
|
+
function U(e, t) {
|
|
146
|
+
let r = e.attributes[n.start], i = t === "histogram" ? V(e) : H(e);
|
|
147
147
|
return i === null ? null : {
|
|
148
|
-
attributes:
|
|
148
|
+
attributes: S(B(e)),
|
|
149
149
|
startTimeUnixNano: typeof r == "string" ? r : e.timeUnixNano,
|
|
150
150
|
timeUnixNano: e.timeUnixNano,
|
|
151
151
|
...i
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function ie({ name: e, unit: t, field: n, points: r }) {
|
|
155
155
|
if (n === "gauge") return {
|
|
156
156
|
name: e,
|
|
157
157
|
unit: t,
|
|
158
158
|
gauge: { dataPoints: r }
|
|
159
159
|
};
|
|
160
160
|
let i = {
|
|
161
|
-
aggregationTemporality:
|
|
161
|
+
aggregationTemporality: I,
|
|
162
162
|
dataPoints: r
|
|
163
163
|
};
|
|
164
164
|
return n === "sum" && (i.isMonotonic = r.every((e) => e.asDouble >= 0)), {
|
|
@@ -167,13 +167,13 @@ function H({ name: e, unit: t, field: n, points: r }) {
|
|
|
167
167
|
[n]: i
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
var
|
|
171
|
-
name:
|
|
170
|
+
var W = {
|
|
171
|
+
name: g,
|
|
172
172
|
serialize(e) {
|
|
173
173
|
let t = C(e).map((e) => {
|
|
174
174
|
let t = /* @__PURE__ */ new Map();
|
|
175
175
|
for (let n of e.records) {
|
|
176
|
-
let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i =
|
|
176
|
+
let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i = U(n, r);
|
|
177
177
|
if (i === null) continue;
|
|
178
178
|
let a = n.attributes["metric.name"], o = n.attributes["metric.unit"], s = {
|
|
179
179
|
name: typeof a == "string" ? a : n.body,
|
|
@@ -188,104 +188,104 @@ var U = {
|
|
|
188
188
|
l.points.push(i), t.set(c, l);
|
|
189
189
|
}
|
|
190
190
|
return {
|
|
191
|
-
resource: { attributes:
|
|
191
|
+
resource: { attributes: S(e.resource) },
|
|
192
192
|
scopeMetrics: [{
|
|
193
193
|
scope: {
|
|
194
|
-
name:
|
|
195
|
-
version:
|
|
194
|
+
name: ee,
|
|
195
|
+
version: f
|
|
196
196
|
},
|
|
197
|
-
metrics: [...t.values()].map(
|
|
197
|
+
metrics: [...t.values()].map(ie)
|
|
198
198
|
}]
|
|
199
199
|
};
|
|
200
200
|
});
|
|
201
201
|
return {
|
|
202
202
|
body: JSON.stringify({ resourceMetrics: t }),
|
|
203
|
-
contentType:
|
|
203
|
+
contentType: h
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
},
|
|
206
|
+
}, G = {
|
|
207
207
|
internal: 1,
|
|
208
208
|
client: 3
|
|
209
|
-
},
|
|
210
|
-
function
|
|
209
|
+
}, K = 2, q = 0, J = /* @__PURE__ */ new Set([d, ...Object.values(a)]);
|
|
210
|
+
function Y(e, t) {
|
|
211
211
|
let n = e.attributes[t];
|
|
212
212
|
return typeof n == "string" ? n : void 0;
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
let t = Object.fromEntries(Object.entries(e.attributes).filter(([e]) => !
|
|
214
|
+
function ae(e) {
|
|
215
|
+
let t = Object.fromEntries(Object.entries(e.attributes).filter(([e]) => !J.has(e))), n = Y(e, a.parentId), r = Y(e, a.linkTraceId), i = Y(e, a.linkSpanId);
|
|
216
216
|
return {
|
|
217
217
|
traceId: e.traceId,
|
|
218
218
|
spanId: e.spanId,
|
|
219
219
|
...n ? { parentSpanId: n } : {},
|
|
220
|
-
...r &&
|
|
220
|
+
...r && i ? { links: [{
|
|
221
221
|
traceId: r,
|
|
222
|
-
spanId:
|
|
222
|
+
spanId: i
|
|
223
223
|
}] } : {},
|
|
224
224
|
name: e.body,
|
|
225
|
-
kind:
|
|
226
|
-
startTimeUnixNano:
|
|
227
|
-
endTimeUnixNano:
|
|
228
|
-
attributes:
|
|
229
|
-
status: { code:
|
|
225
|
+
kind: Y(e, a.kind) === "client" ? G.client : G.internal,
|
|
226
|
+
startTimeUnixNano: Y(e, a.start) ?? e.timeUnixNano,
|
|
227
|
+
endTimeUnixNano: Y(e, a.end) ?? e.timeUnixNano,
|
|
228
|
+
attributes: S(t),
|
|
229
|
+
status: { code: Y(e, a.status) === "error" ? K : q }
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
var X = {
|
|
233
|
-
name:
|
|
233
|
+
name: g,
|
|
234
234
|
serialize(e) {
|
|
235
235
|
let t = C(e).map((e) => ({
|
|
236
|
-
resource: { attributes:
|
|
237
|
-
scopeSpans:
|
|
236
|
+
resource: { attributes: S(e.resource) },
|
|
237
|
+
scopeSpans: ne(e.records).map((e) => ({
|
|
238
238
|
scope: { name: e.name },
|
|
239
|
-
spans: e.records.map(
|
|
239
|
+
spans: e.records.map(ae)
|
|
240
240
|
}))
|
|
241
241
|
}));
|
|
242
242
|
return {
|
|
243
243
|
body: JSON.stringify({ resourceSpans: t }),
|
|
244
|
-
contentType:
|
|
244
|
+
contentType: h
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
248
|
// src/transport/serializers/select.ts
|
|
249
249
|
function Z(e) {
|
|
250
|
-
return e === "otlp" ?
|
|
250
|
+
return e === "otlp" ? re : e === "ecs" ? F : e;
|
|
251
251
|
}
|
|
252
252
|
function Q(e, t) {
|
|
253
|
-
let n = (t) => e.records.length > 0 && e.records.every((e) =>
|
|
253
|
+
let n = (t) => e.records.length > 0 && e.records.every((e) => x(e, "log.type") === t);
|
|
254
254
|
return t.metricsEndpoint !== null && n("metric") ? "metrics" : n("span") ? "traces" : "logs";
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function oe(e, t) {
|
|
257
257
|
return e === "metrics" ? t.metricsEndpoint : e === "traces" ? t.tracesEndpoint : t.endpoint;
|
|
258
258
|
}
|
|
259
|
-
var
|
|
260
|
-
metrics:
|
|
259
|
+
var se = {
|
|
260
|
+
metrics: W,
|
|
261
261
|
traces: X
|
|
262
262
|
};
|
|
263
|
-
function
|
|
263
|
+
function ce(e, t, n, r) {
|
|
264
264
|
try {
|
|
265
|
-
return (
|
|
265
|
+
return (se[Q(t, e)] ?? Z(e.serializer)).serialize(t.records);
|
|
266
266
|
} catch (e) {
|
|
267
267
|
n.report("transport.serialize_failed", r, { batchId: t.id }, e);
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
// src/transport/response-body.ts
|
|
272
|
-
var
|
|
272
|
+
var le = {
|
|
273
273
|
logs: "rejectedLogRecords",
|
|
274
274
|
metrics: "rejectedDataPoints",
|
|
275
275
|
traces: "rejectedSpans"
|
|
276
276
|
};
|
|
277
|
-
function
|
|
277
|
+
function $(e, t) {
|
|
278
278
|
return e !== "logs" || t === "otlp";
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function ue(e, t) {
|
|
281
281
|
if (e.status === 413) return !0;
|
|
282
282
|
let n = e.headers.get("Content-Type") ?? "";
|
|
283
283
|
return t && e.ok && n.includes("json");
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
return n.guardAsync("transport.http_error", "The library could not read the response body. It uses the status code alone.", () =>
|
|
285
|
+
function de(e, t, n) {
|
|
286
|
+
return n.guardAsync("transport.http_error", "The library could not read the response body. It uses the status code alone.", () => fe(e, t));
|
|
287
287
|
}
|
|
288
|
-
async function
|
|
288
|
+
async function fe(e, t) {
|
|
289
289
|
let n = e.body?.getReader();
|
|
290
290
|
if (!n) return "";
|
|
291
291
|
let r, i = new Promise((e, t) => {
|
|
@@ -309,23 +309,23 @@ async function ue(e, t) {
|
|
|
309
309
|
t.removeEventListener("abort", r);
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function pe(e) {
|
|
313
313
|
let t = JSON.parse(e), n = v(t) ? t.maxBytes : void 0;
|
|
314
314
|
return typeof n == "number" && Number.isSafeInteger(n) && n > 0 ? n : void 0;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function me(e, t) {
|
|
317
317
|
if (e.trim() === "") return;
|
|
318
318
|
let n = JSON.parse(e), r = v(n) ? n.partialSuccess : void 0;
|
|
319
319
|
if (!v(r)) return;
|
|
320
|
-
let i =
|
|
320
|
+
let i = he(r[le[t]]), a = typeof r.errorMessage == "string" ? b(r.errorMessage, 256) : "";
|
|
321
321
|
if (i !== 0 || a !== "") return {
|
|
322
322
|
rejected: i,
|
|
323
323
|
message: a
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function he(e) {
|
|
327
327
|
return typeof e == "string" && /^\d{1,15}$/.test(e) ? Number(e) : typeof e == "number" && Number.isSafeInteger(e) && e > 0 ? e : 0;
|
|
328
328
|
}
|
|
329
|
-
export {
|
|
329
|
+
export { de as a, ce as c, W as d, w as f, me as i, Z as l, pe as n, Q as o, T as p, ue as r, oe as s, $ as t, X as u };
|
|
330
330
|
|
|
331
|
-
//# sourceMappingURL=response-body-
|
|
331
|
+
//# sourceMappingURL=response-body-yi92Rpvo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-body-yi92Rpvo.js","names":["ECS_VERSION","CONTENT_TYPE_NDJSON","METRIC_KEYS","NANOS_PER_MILLI","MILLIS_PER_SECOND","SPAN_KEYS","ECS_LEVEL_NAMES","RESOURCE_SERVICE_VERSION","NANOS_PATTERN","ATTR_APP_NAMESPACE","RESOURCE_DEPLOYMENT_ENVIRONMENT","ATTR_LOG_TYPE","TELEMETRY_SDK_VERSION","RECORD_FIELD_KEYS","TELEMETRY_SDK_NAME","RESOURCE_BROWSER_USER_AGENT","RESOURCE_SERVICE_NAME","CONTENT_TYPE_JSON","SERIALIZER_NAME_OTLP","METRIC_FIELD_KEYS","isObject","_defineProperty","truncate","attributeOf","toKeyValues","groupByScope","otlpSerializer","groupByResource","TransportError","message","kind","status","retryAfterMs","maxBytes","cause","parseRetryAfter","header","seconds","date","ERROR_FIELDS","MAPPED_KEYS","toMillis","timeUnixNano","toLabelValue","value","pushLabel","existing","labels","key","flattenLabel","scalar","seen","item","name","entry","toLabels","source","errorOf","fields","field","attributes","unmapped","ecsSerializer","records","millis","record","logger","DELTA","LIBRARY_KEYS","numberOf","isNumbers","pointAttributes","keys","out","histogramOf","count","bounds","buckets","min","numberPointOf","pointOf","start","values","metricOf","points","data","point","otlpMetricsSerializer","resourceMetrics","entries","group","type","named","unit","found","SPAN_KIND","STATUS_ERROR","STATUS_UNSET","FIELD_KEYS","stringOf","spanOf","parent","linkTraceId","linkSpanId","otlpTracesSerializer","resourceSpans","scope","serializerFor","choice","batchKind","only","batch","config","endpointFor","SIGNAL_SERIALIZERS","serializeBatch","error","REJECTED_FIELDS","isOtlpBatch","serializer","needsBody","response","otlp","readOptionalBody","diagnostics","readBodyText","signal","reader","abort","aborted","readChunk","decoder","text","size","chunk","maxBytesOf","parsed","hint","partialSuccessOf","partial","rejected","countOf"],"sources":["../src/transport/errors.ts","../src/transport/serializers/ecs.ts","../src/transport/serializers/otlp-metrics.ts","../src/transport/serializers/otlp-traces.ts","../src/transport/serializers/select.ts","../src/transport/response-body.ts"],"sourcesContent":["// src/transport/errors.ts\n//\n// Classifies HTTP transport failures and parses the Retry-After header.\n\nimport { MILLIS_PER_SECOND } from \"../constants\";\n\n/**\n * The failure kind decides whether the engine retries, backs off or drops. Transient, offline\n * and timeout failures are retried with backoff. A throttled failure waits for the server's\n * delay, and a too_large failure splits the batch. A permanent failure is dropped, because the\n * server will never accept that batch.\n */\nexport type TransportFailureKind =\n \"transient\" | \"throttled\" | \"too_large\" | \"permanent\" | \"timeout\" | \"offline\";\n\n/** A failed transport attempt, with its failure kind and metadata. */\nexport class TransportError extends Error {\n /**\n * @param kind Failure classification.\n * @param message Error description.\n * @param status Optional HTTP response status code.\n * @param retryAfterMs Delay requested by the server in milliseconds.\n * @param maxBytes Maximum payload bytes suggested by a 413 response.\n * @param cause Error that caused this failure.\n */\n constructor(\n public readonly kind: TransportFailureKind,\n message: string,\n public readonly status?: number,\n public readonly retryAfterMs?: number,\n public readonly maxBytes?: number,\n cause?: unknown,\n ) {\n super(message);\n this.name = \"TransportError\";\n\n // Older browsers ignore the ES2022 (message, { cause }) option, so set the property the way\n // the native one does: own, writable and not enumerable.\n if (cause !== undefined) {\n Object.defineProperty(this, \"cause\", { value: cause, writable: true, configurable: true });\n }\n }\n}\n\n/**\n * Parses an HTTP Retry-After value into a delay in milliseconds. The value\n * can be a number of seconds or an HTTP date. A date in the past gives a negative delay,\n * which is clamped to zero.\n * @param header Raw Retry-After header string or null.\n * @returns Non-negative delay in milliseconds, or undefined if invalid or missing.\n */\nexport function parseRetryAfter(header: string | null): number | undefined {\n if (!header) {\n return undefined;\n }\n\n const seconds = Number(header);\n if (Number.isFinite(seconds)) {\n return Math.max(0, seconds * MILLIS_PER_SECOND);\n }\n\n const date = Date.parse(header);\n return Number.isNaN(date) ? undefined : Math.max(0, date - Date.now());\n}\n","// src/transport/serializers/ecs.ts\n//\n// Serializes log batches as Elastic Common Schema (ECS) newline-delimited JSON.\n\nimport {\n ATTR_APP_NAMESPACE,\n ATTR_LOG_TYPE,\n ATTR_PAGE_URL,\n ATTR_URL_FULL,\n CONTENT_TYPE_NDJSON,\n ECS_LEVEL_NAMES,\n ECS_VERSION,\n LOG_TYPE_METRIC,\n NANOS_PATTERN,\n NANOS_PER_MILLI,\n RESOURCE_BROWSER_USER_AGENT,\n RESOURCE_DEPLOYMENT_ENVIRONMENT,\n RESOURCE_SERVICE_NAME,\n RESOURCE_SERVICE_VERSION,\n SERIALIZER_NAME_ECS,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** The ECS field for each error attribute. */\nconst ERROR_FIELDS = {\n \"error.type\": \"type\",\n \"error.message\": \"message\",\n \"error.stack_trace\": \"stack_trace\",\n} as const;\n\n/** Attribute keys whose string value moves to an ECS field, and so leaves labels. */\nconst MAPPED_KEYS = new Set<string>([ATTR_APP_NAMESPACE, ...Object.keys(ERROR_FIELDS)]);\n\n/**\n * Converts a nanosecond epoch string to epoch milliseconds. A record from the bus has only\n * passed a shape check, and BigInt throws a SyntaxError on a non-numeric string. That error\n * would lose the whole batch, not just one record.\n * @param timeUnixNano Nanosecond epoch as decimal digits.\n * @returns Epoch milliseconds, or the current time when the input isn't numeric.\n */\nfunction toMillis(timeUnixNano: string): number {\n if (!NANOS_PATTERN.test(timeUnixNano)) {\n return Date.now();\n }\n\n return Number(BigInt(timeUnixNano) / NANOS_PER_MILLI);\n}\n\n/** Elasticsearch maps these value types under `labels` without a dynamic mapping conflict. */\ntype LabelValue = string | number | boolean;\n\n/**\n * Converts a value to its label form.\n * @param value Raw attribute or resource value.\n * @returns Scalar label value, or null when the value has no scalar form.\n */\nfunction toLabelValue(value: unknown): LabelValue | null {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n\n // JSON.stringify throws on a BigInt, and that error would lose the whole batch.\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n return null;\n}\n\n/**\n * Writes one label, folding a repeated key into an array. Elasticsearch reads\n * a repeated leaf as one multi-valued field, and an array of objects maps the same way.\n * @param labels Label map being built.\n * @param key Dotted label key.\n * @param value Scalar label value.\n */\nfunction pushLabel(labels: Record<string, unknown>, key: string, value: LabelValue): void {\n const existing = labels[key];\n\n if (existing === undefined) {\n labels[key] = value;\n return;\n }\n\n if (Array.isArray(existing)) {\n (existing as LabelValue[]).push(value);\n return;\n }\n\n labels[key] = [existing, value];\n}\n\n/**\n * Flattens one value into dotted label keys. ECS `labels` is a flat map, and a\n * nested object under it causes an Elasticsearch dynamic mapping conflict.\n * @param labels Label map being built.\n * @param key Dotted key for this value.\n * @param value Value to flatten.\n * @param seen Active ancestor objects. Stops infinite recursion on a cycle.\n */\nfunction flattenLabel(\n labels: Record<string, unknown>,\n key: string,\n value: unknown,\n seen: WeakSet<object>,\n): void {\n const scalar = toLabelValue(value);\n\n if (scalar !== null) {\n pushLabel(labels, key, scalar);\n return;\n }\n\n // A forwarded record has only passed a shape check, so its attributes can contain a cycle.\n if (typeof value !== \"object\" || value === null || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value as unknown[]) {\n flattenLabel(labels, key, item, seen);\n }\n } else {\n for (const [name, entry] of Object.entries(value)) {\n flattenLabel(labels, `${key}.${name}`, entry, seen);\n }\n }\n\n // Remove the object on unwind, otherwise a repeated sibling reads as a cycle.\n seen.delete(value);\n}\n\n/**\n * Flattens an attribute or resource map into ECS labels.\n * @param source Attribute or resource map.\n * @returns Flat label map keyed by dotted path.\n */\nfunction toLabels(source: Record<string, unknown>): Record<string, unknown> {\n // Use a null prototype, so an attribute named `__proto__` becomes a key and not a prototype.\n const labels: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n const seen = new WeakSet();\n\n for (const [key, value] of Object.entries(source)) {\n flattenLabel(labels, key, value, seen);\n }\n\n return labels;\n}\n\n/**\n * Builds the ECS error field from the error attributes.\n * @param attributes Record attributes.\n * @returns The field, or undefined for a record without a string error attribute.\n */\nfunction errorOf(attributes: Record<string, unknown>): Record<string, string> | undefined {\n const fields: [string, string][] = [];\n\n for (const [key, field] of Object.entries(ERROR_FIELDS)) {\n const value = attributes[key];\n if (typeof value === \"string\") {\n fields.push([field, value]);\n }\n }\n\n return fields.length > 0 ? Object.fromEntries(fields) : undefined;\n}\n\n/**\n * Removes the attributes that have an ECS field. A label copy of a stack trace would double\n * the size.\n * @param attributes Record attributes.\n * @returns The attributes that go to labels.\n */\nfunction unmapped(attributes: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(attributes).filter(\n ([key, value]) => !(MAPPED_KEYS.has(key) && typeof value === \"string\"),\n ),\n );\n}\n\n/** Writes log records as Elastic Common Schema (ECS) NDJSON documents. */\nexport const ecsSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_ECS,\n\n /**\n * Serializes log records into newline-delimited ECS JSON documents.\n * @param records Records to serialize.\n * @returns Serialized NDJSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const lines = records.map((record) => {\n const millis = toMillis(record.timeUnixNano);\n\n const { attributes } = record;\n const logger = attributes[ATTR_APP_NAMESPACE];\n\n // JSON.stringify leaves out an undefined field.\n return JSON.stringify({\n \"@timestamp\": new Date(millis).toISOString(),\n message: record.body,\n ecs: { version: ECS_VERSION },\n log: {\n level: ECS_LEVEL_NAMES[record.severityText] ?? record.severityText.toLowerCase(),\n logger: typeof logger === \"string\" ? logger : undefined,\n },\n event: { kind: attributes[ATTR_LOG_TYPE] === LOG_TYPE_METRIC ? \"metric\" : \"event\" },\n error: errorOf(attributes),\n trace: { id: record.traceId },\n span: { id: record.spanId },\n service: {\n name: record.resource[RESOURCE_SERVICE_NAME],\n version: record.resource[RESOURCE_SERVICE_VERSION],\n environment: record.resource[RESOURCE_DEPLOYMENT_ENVIRONMENT],\n },\n user_agent: { original: record.resource[RESOURCE_BROWSER_USER_AGENT] },\n // A captured network event's request URL takes precedence over the page URL.\n url: {\n full: attributes[ATTR_URL_FULL] ?? attributes[ATTR_PAGE_URL],\n },\n // Spread the attributes last, so a record attribute overrides a resource key with the\n // same name.\n labels: { ...toLabels(record.resource), ...toLabels(unmapped(attributes)) },\n });\n });\n\n return { body: `${lines.join(\"\\n\")}\\n`, contentType: CONTENT_TYPE_NDJSON };\n },\n};\n","// src/transport/serializers/otlp-metrics.ts\n//\n// Serializes metric records as an OTLP/JSON ExportMetricsServiceRequest. The transport only\n// uses it for a batch of metric records when metricsEndpoint is set.\n\nimport {\n CONTENT_TYPE_JSON,\n METRIC_FIELD_KEYS,\n METRIC_KEYS,\n RECORD_FIELD_KEYS,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n TELEMETRY_SDK_VERSION,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\nimport { groupByResource, toKeyValues } from \"./otlp\";\n\n/** OTLP AggregationTemporality DELTA. Each point holds the change since the previous point. */\nconst DELTA = 1;\n\n/** Keys that hold the library's own value, so a point never takes them as attributes. */\nconst LIBRARY_KEYS: ReadonlySet<string> = new Set([...METRIC_FIELD_KEYS, ...RECORD_FIELD_KEYS]);\n\n/** The OTLP field for each metric type. Anything that isn't a counter or a histogram is a gauge. */\ntype MetricField = \"sum\" | \"histogram\" | \"gauge\";\n\n/** One OTLP data point. */\ntype DataPoint = Record<string, unknown>;\n\n/** Data points of one metric name, type and unit. */\ninterface MetricEntry {\n /** Metric name. */\n name: string;\n /** Unit of the values. */\n unit: string;\n /** OTLP field of the type. */\n field: MetricField;\n /** Data points. */\n points: DataPoint[];\n}\n\n/**\n * Reads a finite number attribute.\n * @param record Metric record.\n * @param key Attribute key.\n * @returns The number, or undefined.\n */\nfunction numberOf(record: LogRecord, key: string): number | undefined {\n const value: unknown = record.attributes[key];\n return typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n}\n\n/**\n * Checks whether a value is a list of finite numbers.\n * @param value Attribute value.\n * @returns True for a list of finite numbers.\n */\nfunction isNumbers(value: unknown): value is number[] {\n return (\n Array.isArray(value) &&\n value.every((item: unknown) => typeof item === \"number\" && Number.isFinite(item))\n );\n}\n\n/**\n * Reads the point attributes that the app passed in its call. The record's context attributes\n * stay out, because a session id on every point would create a new series for every session.\n * @param record Metric record.\n * @returns The string, number and boolean attributes that `metric.attribute_keys` names.\n */\nfunction pointAttributes(record: LogRecord): Record<string, unknown> {\n const keys: unknown = record.attributes[METRIC_KEYS.attributeKeys];\n const out: Record<string, unknown> = {};\n\n if (!Array.isArray(keys)) {\n return out;\n }\n\n for (const key of keys as unknown[]) {\n // A caller's key, or a frame's key list, can name a field that holds the library's value.\n // Any other key, such as the web-vitals rating, is the caller's own.\n const named = typeof key === \"string\" && !LIBRARY_KEYS.has(key);\n const value: unknown = named ? record.attributes[key] : undefined;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n out[key as string] = value;\n }\n }\n\n return out;\n}\n\n/**\n * Builds a point's histogram fields.\n * @param record Metric record.\n * @returns The fields, or null for a point that a record limit cut short.\n */\nfunction histogramOf(record: LogRecord): DataPoint | null {\n const count = numberOf(record, METRIC_KEYS.count);\n\n // A single-value histogram record, for example a long frame, has one bucket and no boundaries.\n if (count === undefined) {\n const value = numberOf(record, \"metric.value\");\n return value === undefined\n ? null\n : {\n count: \"1\",\n sum: value < 0 ? undefined : value,\n min: value,\n max: value,\n bucketCounts: [\"1\"],\n explicitBounds: [],\n };\n }\n\n const bounds: unknown = record.attributes[METRIC_KEYS.bounds];\n const buckets: unknown = record.attributes[METRIC_KEYS.buckets];\n\n // The library always builds complete lists, but a record from elsewhere can have lists that\n // don't line up, and a point built from those would report bogus buckets.\n if (!isNumbers(bounds) || !isNumbers(buckets) || buckets.length !== bounds.length + 1) {\n return null;\n }\n\n // Per OTLP, a histogram with a negative value sets no sum, because a backend reads the sum\n // as a total.\n const min = numberOf(record, METRIC_KEYS.min);\n\n return {\n count: String(count),\n sum: min !== undefined && min < 0 ? undefined : numberOf(record, METRIC_KEYS.sum),\n min,\n max: numberOf(record, METRIC_KEYS.max),\n // OTLP JSON encodes an int64 as a decimal string.\n bucketCounts: buckets.map(String),\n explicitBounds: bounds,\n };\n}\n\n/**\n * Builds the value field of a sum or gauge point.\n * @param record Metric record.\n * @returns The field, or null for a record without a valid value.\n */\nfunction numberPointOf(record: LogRecord): DataPoint | null {\n const value = numberOf(record, \"metric.value\");\n return value === undefined ? null : { asDouble: value };\n}\n\n/**\n * Builds one OTLP data point.\n * @param record Metric record.\n * @param field OTLP field of the type.\n * @returns The point, or null for a record without a valid value.\n */\nfunction pointOf(record: LogRecord, field: MetricField): DataPoint | null {\n const start: unknown = record.attributes[METRIC_KEYS.start];\n const values = field === \"histogram\" ? histogramOf(record) : numberPointOf(record);\n\n if (values === null) {\n return null;\n }\n\n return {\n attributes: toKeyValues(pointAttributes(record)),\n // A single-value record has no interval, so its point starts and ends at its own time.\n startTimeUnixNano: typeof start === \"string\" ? start : record.timeUnixNano,\n timeUnixNano: record.timeUnixNano,\n ...values,\n };\n}\n\n/**\n * Builds the OTLP metric of an entry.\n * @param entry Data points of one name, type and unit.\n * @returns The OTLP metric.\n */\nfunction metricOf({ name, unit, field, points }: MetricEntry): Record<string, unknown> {\n if (field === \"gauge\") {\n return { name, unit, gauge: { dataPoints: points } };\n }\n\n const data: Record<string, unknown> = { aggregationTemporality: DELTA, dataPoints: points };\n\n // A counter record from another context can hold a negative value. A monotonic sum must not\n // decrease.\n if (field === \"sum\") {\n data.isMonotonic = points.every((point) => (point.asDouble as number) >= 0);\n }\n\n return { name, unit, [field]: data };\n}\n\n/** Writes metric records as an OTLP/JSON ExportMetricsServiceRequest. */\nexport const otlpMetricsSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups the records by resource, then by metric name, type and unit. Drops any record\n * without a valid value.\n * @param records Metric records to serialize.\n * @returns Serialized JSON payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceMetrics = groupByResource(records).map((group) => {\n const entries = new Map<string, MetricEntry>();\n\n for (const record of group.records) {\n const type: unknown = record.attributes[\"metric.type\"];\n const field: MetricField =\n type === \"counter\" ? \"sum\" : type === \"histogram\" ? \"histogram\" : \"gauge\";\n const point = pointOf(record, field);\n\n if (point === null) {\n continue;\n }\n\n const named: unknown = record.attributes[\"metric.name\"];\n const unit: unknown = record.attributes[\"metric.unit\"];\n const entry: MetricEntry = {\n name: typeof named === \"string\" ? named : record.body,\n unit: typeof unit === \"string\" ? unit : \"\",\n field,\n points: [],\n };\n const key = JSON.stringify([entry.field, entry.name, entry.unit]);\n const found = entries.get(key) ?? entry;\n\n found.points.push(point);\n entries.set(key, found);\n }\n\n return {\n resource: { attributes: toKeyValues(group.resource) },\n scopeMetrics: [\n {\n scope: { name: TELEMETRY_SDK_NAME, version: TELEMETRY_SDK_VERSION },\n metrics: [...entries.values()].map(metricOf),\n },\n ],\n };\n });\n\n return {\n body: JSON.stringify({ resourceMetrics }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n","// src/transport/serializers/otlp-traces.ts\n//\n// Serializes span records as an OTLP/JSON ExportTraceServiceRequest. The transport\n// uses it for a batch of span records.\n\nimport { ATTR_LOG_TYPE, CONTENT_TYPE_JSON, SERIALIZER_NAME_OTLP, SPAN_KEYS } from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\nimport { groupByResource, groupByScope, toKeyValues } from \"./otlp\";\n\n/** The OTLP SpanKind for each of the library's span kinds. */\nconst SPAN_KIND = { internal: 1, client: 3 } as const;\n\n/** OTLP StatusCode ERROR. */\nconst STATUS_ERROR = 2;\n\n/** OTLP StatusCode UNSET. */\nconst STATUS_UNSET = 0;\n\n/** Attribute keys that hold span fields, and so aren't span attributes. */\nconst FIELD_KEYS = new Set<string>([ATTR_LOG_TYPE, ...Object.values(SPAN_KEYS)]);\n\n/**\n * Reads a string attribute.\n * @param record Span record.\n * @param key Attribute key.\n * @returns The string, or undefined.\n */\nfunction stringOf(record: LogRecord, key: string): string | undefined {\n const value: unknown = record.attributes[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * Builds one OTLP span. A record that lost a time field starts and ends at its record time.\n * @param record Span record.\n * @returns The OTLP span.\n */\nfunction spanOf(record: LogRecord): Record<string, unknown> {\n const attributes = Object.fromEntries(\n Object.entries(record.attributes).filter(([key]) => !FIELD_KEYS.has(key)),\n );\n const parent = stringOf(record, SPAN_KEYS.parentId);\n const linkTraceId = stringOf(record, SPAN_KEYS.linkTraceId);\n const linkSpanId = stringOf(record, SPAN_KEYS.linkSpanId);\n\n return {\n traceId: record.traceId,\n spanId: record.spanId,\n // A root span has no parent, so leave the field out.\n ...(parent ? { parentSpanId: parent } : {}),\n ...(linkTraceId && linkSpanId\n ? {\n links: [{ traceId: linkTraceId, spanId: linkSpanId }],\n }\n : {}),\n name: record.body,\n kind: stringOf(record, SPAN_KEYS.kind) === \"client\" ? SPAN_KIND.client : SPAN_KIND.internal,\n startTimeUnixNano: stringOf(record, SPAN_KEYS.start) ?? record.timeUnixNano,\n endTimeUnixNano: stringOf(record, SPAN_KEYS.end) ?? record.timeUnixNano,\n attributes: toKeyValues(attributes),\n status: {\n code: stringOf(record, SPAN_KEYS.status) === \"error\" ? STATUS_ERROR : STATUS_UNSET,\n },\n };\n}\n\n/** Writes span records as an OTLP/JSON ExportTraceServiceRequest. */\nexport const otlpTracesSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups the records by resource.\n * @param records Span records to serialize.\n * @returns Serialized JSON payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceSpans = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeSpans: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n spans: scope.records.map(spanOf),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceSpans }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n","// src/transport/serializers/select.ts\n//\n// Maps the serializer option to an implementation. Only transport code imports this module,\n// and config.ts keeps just the name, so the main chunk contains no serializer.\n\nimport { ATTR_LOG_TYPE } from \"../../constants\";\nimport type { Diagnostics } from \"../../core/diagnostics\";\nimport { attributeOf, type LogBatch } from \"../../models/batch\";\nimport type { BatchKind, ResolvedConfig, SerializerChoice } from \"../../models/config\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\nimport { ecsSerializer } from \"./ecs\";\nimport { otlpSerializer } from \"./otlp\";\nimport { otlpMetricsSerializer } from \"./otlp-metrics\";\nimport { otlpTracesSerializer } from \"./otlp-traces\";\n\n/**\n * Returns the implementation for a resolved serializer option.\n * @param choice Serializer name, or a custom implementation.\n * @returns Serializer implementation.\n */\nexport function serializerFor(choice: SerializerChoice): LogSerializer {\n if (choice === \"otlp\") {\n return otlpSerializer;\n }\n\n if (choice === \"ecs\") {\n return ecsSerializer;\n }\n\n return choice;\n}\n\n/**\n * Returns the kind of a batch. Only a batch of metric records goes to metricsEndpoint. A batch\n * of span records is always \"traces\" and must not go to endpoint as log records. A stored\n * record can be corrupt, and then it is neither a metric nor a span.\n * @param batch Batch to test.\n * @param config Active configuration.\n * @returns \"metrics\" with metricsEndpoint set and only metric records, \"traces\" for only span\n * records, else \"logs\".\n */\nexport function batchKind(batch: LogBatch, config: ResolvedConfig): BatchKind {\n const only = (type: string): boolean =>\n batch.records.length > 0 &&\n batch.records.every((record) => attributeOf(record, ATTR_LOG_TYPE) === type);\n\n if (config.metricsEndpoint !== null && only(\"metric\")) {\n return \"metrics\";\n }\n\n return only(\"span\") ? \"traces\" : \"logs\";\n}\n\n/**\n * Returns the endpoint for a batch kind.\n * @param kind Kind of the batch.\n * @param config Active configuration.\n * @returns metricsEndpoint for a metrics batch, tracesEndpoint for a traces batch, else\n * endpoint. null or \"\" means the batch has no destination.\n */\nexport function endpointFor(kind: BatchKind, config: ResolvedConfig): string | null {\n if (kind === \"metrics\") {\n return config.metricsEndpoint;\n }\n\n return kind === \"traces\" ? config.tracesEndpoint : config.endpoint;\n}\n\n/** Serializers for the batch kinds that don't use the configured serializer. */\nconst SIGNAL_SERIALIZERS: Partial<Record<BatchKind, LogSerializer>> = {\n metrics: otlpMetricsSerializer,\n traces: otlpTracesSerializer,\n};\n\n/**\n * Serializes a batch. Reports a serializer that throws, and the caller then drops the batch.\n * A metrics batch gets the OTLP metrics format, and a traces batch the OTLP traces format.\n * @param config Active configuration.\n * @param batch Batch to serialize.\n * @param diagnostics Diagnostics reporter.\n * @param message ASD-STE100 sentence for the report.\n * @returns The serialized batch, or undefined if the serializer threw.\n */\nexport function serializeBatch(\n config: ResolvedConfig,\n batch: LogBatch,\n diagnostics: Diagnostics,\n message: string,\n): SerializedBatch | undefined {\n try {\n const serializer =\n SIGNAL_SERIALIZERS[batchKind(batch, config)] ?? serializerFor(config.serializer);\n return serializer.serialize(batch.records);\n } catch (error) {\n diagnostics.report(\"transport.serialize_failed\", message, { batchId: batch.id }, error);\n return undefined;\n }\n}\n","// src/transport/response-body.ts\n//\n// Reads the small JSON answer of an ingest server on the main thread and in the worker. The\n// read stops at the request's abort signal and at RESPONSE_BODY_LIMIT_BYTES, otherwise a server\n// that sends the headers and then stalls or streams forever holds the dispatch slot.\n\nimport {\n HEADER_CONTENT_TYPE,\n HTTP_PAYLOAD_TOO_LARGE,\n RESPONSE_BODY_LIMIT_BYTES,\n SERVER_MESSAGE_MAX_CHARS,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { BatchKind, SerializerChoice } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { truncate } from \"../utils/sanitize\";\n\n/** What an OTLP server rejected or warned about in a batch it accepted. */\nexport interface PartialSuccess {\n /** Number of records the server rejected. 0 means a warning only. */\n rejected: number;\n /** The server's errorMessage, cut to SERVER_MESSAGE_MAX_CHARS. Empty when it sent none. */\n message: string;\n}\n\n/** OTLP names the rejected count after the signal. */\nconst REJECTED_FIELDS: Record<BatchKind, string> = {\n logs: \"rejectedLogRecords\",\n metrics: \"rejectedDataPoints\",\n traces: \"rejectedSpans\",\n};\n\n/**\n * Checks whether a batch goes out in an OTLP format. Metrics and traces always do.\n * @param kind Kind of the batch.\n * @param serializer The log serializer option.\n * @returns True for an OTLP batch.\n */\nexport function isOtlpBatch(kind: BatchKind, serializer: SerializerChoice): boolean {\n return kind !== \"logs\" || serializer === \"otlp\";\n}\n\n/**\n * Checks whether the library reads a response's body. A 413 can carry a size hint, and an OTLP\n * answer in JSON can carry a partialSuccess.\n * @param response Response whose headers have arrived.\n * @param otlp True when the batch went out in an OTLP format.\n * @returns True when the body has something the library uses.\n */\nexport function needsBody(response: Response, otlp: boolean): boolean {\n if (response.status === HTTP_PAYLOAD_TOO_LARGE) {\n return true;\n }\n\n const type = response.headers.get(HEADER_CONTENT_TYPE) ?? \"\";\n return otlp && response.ok && type.includes(\"json\");\n}\n\n/**\n * Reads a body that only adds detail to the status. A body that fails or runs out of time gives\n * undefined, because the server has answered and a retry would send an accepted batch again.\n * @param response Response whose headers have arrived.\n * @param signal The request's abort signal. An abort ends the read.\n * @param diagnostics Reports a read that fails.\n * @returns The text, or undefined when the read fails or the body is larger than the limit.\n */\nexport function readOptionalBody(\n response: Response,\n signal: AbortSignal,\n diagnostics: Diagnostics,\n): Promise<string | undefined> {\n return diagnostics.guardAsync(\n \"transport.http_error\",\n \"The library could not read the response body. It uses the status code alone.\",\n () => readBodyText(response, signal),\n );\n}\n\n/**\n * Reads a response body as text, up to RESPONSE_BODY_LIMIT_BYTES.\n * @param response Response whose headers have arrived.\n * @param signal The request's abort signal. An abort ends the read.\n * @returns The text, or undefined when the body is larger than the limit.\n * @throws Error when the signal aborts or the body stream fails.\n */\nasync function readBodyText(response: Response, signal: AbortSignal): Promise<string | undefined> {\n const reader = response.body?.getReader();\n if (!reader) {\n return \"\";\n }\n\n // A browser's fetch abort also fails the stream, but a body that a service worker or a test\n // builds doesn't know the signal, so race each read against it too.\n let abort!: () => void;\n const aborted = new Promise<never>((_resolve, reject) => {\n abort = () => {\n reject(new Error(\"The request ended before its body arrived.\"));\n };\n });\n signal.addEventListener(\"abort\", abort, { once: true });\n if (signal.aborted) {\n abort();\n }\n\n const readChunk = () => Promise.race([reader.read(), aborted]);\n const decoder = new TextDecoder();\n let text = \"\";\n let size = 0;\n try {\n let chunk = await readChunk();\n while (!chunk.done) {\n size += chunk.value.byteLength;\n if (size > RESPONSE_BODY_LIMIT_BYTES) {\n // Release the connection instead of downloading the rest.\n await reader.cancel();\n return undefined;\n }\n\n text += decoder.decode(chunk.value, { stream: true });\n chunk = await readChunk();\n }\n\n return text + decoder.decode();\n } finally {\n signal.removeEventListener(\"abort\", abort);\n }\n}\n\n/**\n * Reads the optional size hint of a 413 body, for example {\"maxBytes\":65536}.\n * @param text The body text.\n * @returns The hint when it's a positive safe integer, otherwise undefined.\n * @throws SyntaxError when the text isn't JSON.\n */\nexport function maxBytesOf(text: string): number | undefined {\n const parsed: unknown = JSON.parse(text);\n const hint = isObject(parsed) ? parsed.maxBytes : undefined;\n\n return typeof hint === \"number\" && Number.isSafeInteger(hint) && hint > 0 ? hint : undefined;\n}\n\n/**\n * Reads the partialSuccess of an OTLP export answer, for example\n * {\"partialSuccess\":{\"rejectedLogRecords\":\"2\",\"errorMessage\":\"...\"}}.\n * @param text The answer's body text.\n * @param kind Kind of the batch, which names the count's field.\n * @returns What the server rejected or warned about, or undefined for a full success.\n * @throws SyntaxError when the text isn't JSON.\n */\nexport function partialSuccessOf(text: string, kind: BatchKind): PartialSuccess | undefined {\n // OTLP allows an empty body for a full success.\n if (text.trim() === \"\") {\n return undefined;\n }\n\n const parsed: unknown = JSON.parse(text);\n const partial = isObject(parsed) ? parsed.partialSuccess : undefined;\n if (!isObject(partial)) {\n return undefined;\n }\n\n const rejected = countOf(partial[REJECTED_FIELDS[kind]]);\n const message =\n typeof partial.errorMessage === \"string\"\n ? truncate(partial.errorMessage, SERVER_MESSAGE_MAX_CHARS)\n : \"\";\n if (rejected === 0 && message === \"\") {\n return undefined;\n }\n\n return { rejected, message };\n}\n\n/**\n * Reads an OTLP int64 count, which JSON gives as a digit string or as a number.\n * @param value The count field.\n * @returns The count, or 0 for anything that isn't a whole number above 0.\n */\nfunction countOf(value: unknown): number {\n // Up to 15 digits always fits in a safe integer.\n if (typeof value === \"string\" && /^\\d{1,15}$/.test(value)) {\n return Number(value);\n }\n\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0 ? value : 0;\n}\n"],"mappings":";;;;;;;AAgBA,IAAa4B,IAAb,cAAoC,MAAM;CASxC,YACE,GACA,GACA,GACA,GACA,GACA,GACA;EAMA,AALA,MAAMC,CAAO,GAPGR,EAAA,MAAA,QAAA,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KA,IAAQ,IAAIA,IAAQ;AACzF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fn as e, Pn as t } from "./constants-CEHN6KuY.js";
|
|
2
2
|
import { n } from "./guards-BlYGRK4l.js";
|
|
3
|
-
import { i as r } from "./identity-
|
|
4
|
-
import { a as i, i as a, n as o, r as s } from "./config-
|
|
5
|
-
import { clearStored as c, keepStored as l } from "./stored-context-
|
|
3
|
+
import { i as r } from "./identity-Byh3gCdT.js";
|
|
4
|
+
import { a as i, i as a, n as o, r as s } from "./config-DK1Zf7jn.js";
|
|
5
|
+
import { clearStored as c, keepStored as l } from "./stored-context-df1dEnht.js";
|
|
6
6
|
// src/core/rotation.ts
|
|
7
7
|
var u = [
|
|
8
8
|
"discard",
|
|
@@ -10,38 +10,38 @@ var u = [
|
|
|
10
10
|
"retain",
|
|
11
11
|
"carry"
|
|
12
12
|
], d = Symbol("refused");
|
|
13
|
-
function f(
|
|
14
|
-
return
|
|
15
|
-
let o = t
|
|
16
|
-
return o === void 0 ? !1 :
|
|
13
|
+
function f(e, n, r) {
|
|
14
|
+
return t.filter((t) => {
|
|
15
|
+
let o = e[t], s = n[t];
|
|
16
|
+
return o === void 0 ? !1 : t === "endpoint" ? i(o, d, r) !== s : t === "metricsEndpoint" || t === "tracesEndpoint" ? a(t, o, d, r) !== s : o === null ? s !== void 0 : s !== o;
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function p(n, r) {
|
|
20
|
-
let i = { ...
|
|
21
|
-
for (let
|
|
22
|
-
let
|
|
23
|
-
Object.assign(i, { [
|
|
24
|
-
} else r.diagnostics.report("config.invalid", `rotateSecurityContext() ignores routing.${
|
|
20
|
+
let i = { ...e };
|
|
21
|
+
for (let e of Object.keys(n)) if (t.includes(e)) {
|
|
22
|
+
let t = Reflect.get(n, e);
|
|
23
|
+
Object.assign(i, { [e]: t });
|
|
24
|
+
} else r.diagnostics.report("config.invalid", `rotateSecurityContext() ignores routing.${e}. A rotation changes only the routing settings.`);
|
|
25
25
|
return i;
|
|
26
26
|
}
|
|
27
27
|
function m(e, t, r) {
|
|
28
28
|
return n(e) && n(e.routing) && n(e.context ?? {}) && u.includes(t) && Number.isFinite(r) && r >= 0 && r <= 6e5 && (e.id === void 0 || typeof e.id == "string" && e.id.length > 0);
|
|
29
29
|
}
|
|
30
|
-
function h(
|
|
31
|
-
let { runtime: a } =
|
|
30
|
+
function h(t, n, i) {
|
|
31
|
+
let { runtime: a } = t, o = i.pending ?? "discard", c = i.timeoutMs ?? 5e3;
|
|
32
32
|
if (!m(n, o, c)) throw Error("Invalid security-context rotation options.");
|
|
33
33
|
let l = a.config.securityContext.id, u = n.id ?? r(a.diagnostics);
|
|
34
34
|
if (u === l) throw Error("A rotation requires a different security-context id.");
|
|
35
|
-
let d =
|
|
35
|
+
let d = t.allowed({
|
|
36
36
|
...p(n.routing, a),
|
|
37
37
|
securityContext: { id: u }
|
|
38
|
-
}), h =
|
|
38
|
+
}), h = {
|
|
39
39
|
...a.config,
|
|
40
|
-
...
|
|
41
|
-
});
|
|
42
|
-
if (f(d,
|
|
40
|
+
...e
|
|
41
|
+
}, g = s(d, a.diagnostics, h, a.config);
|
|
42
|
+
if (f(d, g, t.quiet).length > 0) throw Error("Invalid routing settings for the next security context.");
|
|
43
43
|
return {
|
|
44
|
-
next:
|
|
44
|
+
next: g,
|
|
45
45
|
context: n.context ? Object.fromEntries(Object.entries(n.context)) : void 0,
|
|
46
46
|
pending: o,
|
|
47
47
|
timeoutMs: c,
|
|
@@ -77,8 +77,8 @@ async function _(e, t, n, r) {
|
|
|
77
77
|
C !== "retain" && C !== "carry" && e.drop([...T, ...E.flatMap((e) => e.records)]);
|
|
78
78
|
let { diagnostics: D } = i;
|
|
79
79
|
if (!b && (C === "discard" || C === "flush")) {
|
|
80
|
-
let t = S.map((e) => e.id);
|
|
81
|
-
|
|
80
|
+
let t = S.map((e) => e.id), n = await D.guardAsync("storage.degraded", "The library could not remove the stored batches of the old context.", () => c(e.storeAccess(), "context", t));
|
|
81
|
+
e.drop((n ?? []).flatMap((e) => e.records));
|
|
82
82
|
}
|
|
83
83
|
if (C === "retain" && (y.length > 0 || S.length > 0) && await D.guardAsync("storage.degraded", "The library could not store the records of the old context.", () => l(e.storeAccess(), y, S)), i.isDestroyed()) throw Error("The runtime has stopped.");
|
|
84
84
|
if (u.lockConfiguration = a.lockConfiguration, o(a, u), e.advanceIdentity(), i.context.clear(), d && i.context.merge(d), i.breadcrumbs.clear(), i.newSession(), i.builder.invalidateResource(), await e.openDelivery(), i.isDestroyed()) throw C === "carry" && (e.drop(T), await e.adopt(E)), Error("The runtime has stopped.");
|
|
@@ -90,4 +90,4 @@ async function _(e, t, n, r) {
|
|
|
90
90
|
}
|
|
91
91
|
export { _ as rotateContext };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=rotation-
|
|
93
|
+
//# sourceMappingURL=rotation-ChBbNDE2.js.map
|