@utk09/ui-observability 1.0.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 +111 -219
- package/README.md +24 -26
- package/dist/{batch-CXmPmTse.js → batch-120Kc9jr.js} +3 -3
- package/dist/{batch-CXmPmTse.js.map → batch-120Kc9jr.js.map} +1 -1
- package/dist/{batch-mmPigCpi.cjs → batch-C3uNp5kU.cjs} +2 -2
- package/dist/{batch-mmPigCpi.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +31 -2
- package/dist/bus/bus.d.ts +31 -2
- package/dist/bus-Dj8IEVcC.cjs +2 -0
- package/dist/bus-Dj8IEVcC.cjs.map +1 -0
- package/dist/{bus-C39wspFV.js → bus-DyNafxZN.js} +127 -104
- 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/interactions.d.cts +35 -3
- package/dist/capture/interactions.d.ts +35 -3
- package/dist/capture/observed-windows.d.cts +51 -0
- package/dist/capture/observed-windows.d.ts +51 -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-tVtXwVjX.js → compression-BWkDWY3v.js} +2 -2
- package/dist/{compression-tVtXwVjX.js.map → compression-BWkDWY3v.js.map} +1 -1
- package/dist/{compression-CvED_Jel.cjs → compression-CEVe7NPX.cjs} +2 -2
- package/dist/{compression-CvED_Jel.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-DK1Zf7jn.js +556 -0
- package/dist/config-DK1Zf7jn.js.map +1 -0
- package/dist/{console-BGgGnjSi.js → console-CAyCQOpm.js} +5 -5
- package/dist/{console-BGgGnjSi.js.map → console-CAyCQOpm.js.map} +1 -1
- package/dist/{console-CSZ5_Vx5.cjs → console-Dk6GH4yj.cjs} +2 -2
- package/dist/{console-CSZ5_Vx5.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
- package/dist/{constants-CUyd9cTZ.js → constants-CEHN6KuY.js} +46 -25
- 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 +23 -0
- package/dist/constants.d.ts +23 -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/rotation.d.cts +26 -2
- package/dist/core/rotation.d.ts +26 -2
- package/dist/core/runtime.d.cts +9 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/sender.d.cts +3 -2
- package/dist/core/sender.d.ts +3 -2
- package/dist/{debug-bundle-BXIlwDKM.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
- package/dist/{debug-bundle-BXIlwDKM.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
- package/dist/{debug-bundle-CRpYV_ui.js → debug-bundle-w78W46zr.js} +4 -4
- package/dist/{debug-bundle-CRpYV_ui.js.map → debug-bundle-w78W46zr.js.map} +1 -1
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.js +36 -36
- 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-BE_EZV7Q.js → errors-C-LYbqyB.js} +27 -24
- package/dist/errors-C-LYbqyB.js.map +1 -0
- package/dist/{factory-CTi0Is3F.js → factory-BHYrcSaU.js} +39 -28
- 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-DdhKgrpk.js → identity-Byh3gCdT.js} +35 -24
- package/dist/identity-Byh3gCdT.js.map +1 -0
- package/dist/identity-BzAzdQyv.cjs +2 -0
- package/dist/identity-BzAzdQyv.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +453 -417
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-GHdl0t8A.js → indexeddb-storage-BYywz-v6.js} +17 -17
- package/dist/{indexeddb-storage-GHdl0t8A.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
- package/dist/{indexeddb-storage-CL9uqBCy.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
- package/dist/{indexeddb-storage-CL9uqBCy.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
- package/dist/interactions-BXzEel4F.cjs +2 -0
- package/dist/interactions-BXzEel4F.cjs.map +1 -0
- package/dist/interactions-DdKPMWIN.js +207 -0
- package/dist/interactions-DdKPMWIN.js.map +1 -0
- package/dist/{journey-B4Adltjm.cjs → journey-BUmsrgaw.cjs} +2 -2
- package/dist/{journey-B4Adltjm.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
- package/dist/{journey-D2_sia57.js → journey-Nu655gEO.js} +14 -14
- package/dist/{journey-D2_sia57.js.map → journey-Nu655gEO.js.map} +1 -1
- package/dist/{library-console-CPW6bvZH.cjs → library-console-DdIlzzph.cjs} +2 -2
- package/dist/{library-console-CPW6bvZH.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
- package/dist/{library-console-Btrzt814.js → library-console-amePMnP8.js} +2 -2
- package/dist/{library-console-Btrzt814.js.map → library-console-amePMnP8.js.map} +1 -1
- package/dist/{library-request-BJ9PLRaD.js → library-request-Cv7C05jf.js} +2 -2
- package/dist/{library-request-BJ9PLRaD.js.map → library-request-Cv7C05jf.js.map} +1 -1
- package/dist/{library-request-D7OvTxZV.cjs → library-request-DO3Ec7KE.cjs} +2 -2
- package/dist/{library-request-D7OvTxZV.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
- package/dist/{lifecycle-IaAm1mOC.cjs → lifecycle-B5yfH5is.cjs} +2 -2
- package/dist/{lifecycle-IaAm1mOC.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
- package/dist/{lifecycle-22CUCrc9.js → lifecycle-CMHz2Zbs.js} +2 -2
- package/dist/{lifecycle-22CUCrc9.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
- package/dist/{log-record-BNiLfqtL.js → log-record-B_nSqxoe.js} +2 -2
- package/dist/{log-record-BNiLfqtL.js.map → log-record-B_nSqxoe.js.map} +1 -1
- package/dist/{log-record-CkivuiEl.cjs → log-record-Bdywwg0k.cjs} +2 -2
- package/dist/{log-record-CkivuiEl.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
- package/dist/{long-frames-DNFaRnC3.js → long-frames-6NGl1-uN.js} +3 -3
- package/dist/{long-frames-DNFaRnC3.js.map → long-frames-6NGl1-uN.js.map} +1 -1
- package/dist/{long-frames-BUUbXd-B.cjs → long-frames-D9DfSWqv.cjs} +2 -2
- package/dist/{long-frames-BUUbXd-B.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
- package/dist/models/bus.d.cts +6 -1
- package/dist/models/bus.d.ts +6 -1
- package/dist/models/config.d.cts +27 -11
- package/dist/models/config.d.ts +27 -11
- package/dist/models/serializer.d.cts +3 -1
- package/dist/models/serializer.d.ts +3 -1
- package/dist/{network-CGMLQ-mA.cjs → network-BNHBI0Fc.cjs} +2 -2
- package/dist/{network-CGMLQ-mA.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
- package/dist/{network-on2zZT6H.js → network-Cc3tSB7e.js} +5 -5
- package/dist/{network-on2zZT6H.js.map → network-Cc3tSB7e.js.map} +1 -1
- package/dist/observed-windows-8JtCsIr1.js +64 -0
- package/dist/observed-windows-8JtCsIr1.js.map +1 -0
- package/dist/observed-windows-BlE25nrn.cjs +2 -0
- package/dist/observed-windows-BlE25nrn.cjs.map +1 -0
- package/dist/openfin-Bxelt0yg.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/{otlp-DimfrRor.js → otlp-Btix3EBa.js} +7 -7
- package/dist/{otlp-DimfrRor.js.map → otlp-Btix3EBa.js.map} +1 -1
- package/dist/{otlp-BENHf3g9.cjs → otlp-CFSW-Dno.cjs} +2 -2
- package/dist/{otlp-BENHf3g9.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-Dba6R3Hp.js +75 -0
- package/dist/platform-Dba6R3Hp.js.map +1 -0
- package/dist/{profiler-BAZoh7A4.js → profiler-DNKcqu09.js} +60 -60
- package/dist/{profiler-BAZoh7A4.js.map → profiler-DNKcqu09.js.map} +1 -1
- package/dist/{profiler-D4tJpDRc.cjs → profiler-DpoPi1hH.cjs} +2 -2
- package/dist/{profiler-D4tJpDRc.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
- package/dist/{profiler-frames-C4xr7KfH.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
- package/dist/{profiler-frames-C4xr7KfH.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
- package/dist/{profiler-frames-cJMx9wNM.js → profiler-frames-CGXZeZ_3.js} +16 -16
- package/dist/{profiler-frames-cJMx9wNM.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
- package/dist/{remote-rules-Dz9MRAsB.js → remote-rules-DNK96vLa.js} +25 -25
- package/dist/{remote-rules-Dz9MRAsB.js.map → remote-rules-DNK96vLa.js.map} +1 -1
- package/dist/{remote-rules-_tY0zj5o.cjs → remote-rules-DuMFRlit.cjs} +2 -2
- package/dist/{remote-rules-_tY0zj5o.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-Ds-ANH34.js → replay-Dy6OiaOZ.js} +104 -77
- package/dist/replay-Dy6OiaOZ.js.map +1 -0
- package/dist/{reports-BDSe4dFH.cjs → reports-CGK9YQch.cjs} +2 -2
- package/dist/{reports-BDSe4dFH.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
- package/dist/{reports-C-thq-bk.js → reports-CX57-S9s.js} +3 -3
- package/dist/{reports-C-thq-bk.js.map → reports-CX57-S9s.js.map} +1 -1
- package/dist/{resource-timing-eUl2dNgC.js → resource-timing-CWVDCbrY.js} +4 -4
- package/dist/{resource-timing-eUl2dNgC.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
- package/dist/{resource-timing-C576gFIQ.cjs → resource-timing-DalulXiR.cjs} +2 -2
- package/dist/{resource-timing-C576gFIQ.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-eoSQpLiH.js → response-body-yi92Rpvo.js} +109 -109
- package/dist/response-body-yi92Rpvo.js.map +1 -0
- package/dist/{rotation-Cwct4ckk.js → rotation-ChBbNDE2.js} +27 -28
- 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-BlrI8jor.js → sampling-DZTOD28D.js} +16 -16
- package/dist/{sampling-BlrI8jor.js.map → sampling-DZTOD28D.js.map} +1 -1
- package/dist/{sampling-mXt4dstx.cjs → sampling-wAVJIZXp.cjs} +2 -2
- package/dist/{sampling-mXt4dstx.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
- package/dist/{sanitize-Ba0KqU06.js → sanitize-B2GKlSFp.js} +2 -2
- package/dist/{sanitize-Ba0KqU06.js.map → sanitize-B2GKlSFp.js.map} +1 -1
- package/dist/{sanitize-DQyiI_KY.cjs → sanitize-BZdhoghq.cjs} +2 -2
- package/dist/{sanitize-DQyiI_KY.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
- package/dist/{sender-Dv8rAmpV.js → sender-BRSpc7R8.js} +192 -178
- 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-B2EzVuYm.js → stored-context-df1dEnht.js} +12 -10
- package/dist/stored-context-df1dEnht.js.map +1 -0
- package/dist/{storm-DjKetLKZ.js → storm-U3_ek1nA.js} +2 -2
- package/dist/{storm-DjKetLKZ.js.map → storm-U3_ek1nA.js.map} +1 -1
- package/dist/{storm-C-zYSdDX.cjs → storm-qiE_AMC7.cjs} +2 -2
- package/dist/{storm-C-zYSdDX.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-DQD1cT7c.js → unclean-exit-Bj6gYHeL.js} +2 -2
- package/dist/{unclean-exit-DQD1cT7c.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
- package/dist/{unclean-exit-py99ApzT.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
- package/dist/{unclean-exit-py99ApzT.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
- package/dist/{user-timing-D6XTmpuM.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
- package/dist/{user-timing-D6XTmpuM.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
- package/dist/{user-timing-BePqb1uN.js → user-timing-Duz0d-OA.js} +2 -2
- package/dist/{user-timing-BePqb1uN.js.map → user-timing-Duz0d-OA.js.map} +1 -1
- package/dist/utils/identity.d.cts +5 -0
- package/dist/utils/identity.d.ts +5 -0
- 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-DSHgDiZ6.js → web-socket-CE_9Q22z.js} +5 -5
- package/dist/{web-socket-DSHgDiZ6.js.map → web-socket-CE_9Q22z.js.map} +1 -1
- package/dist/{web-socket-CoIUBM3C.cjs → web-socket-sm3rD-A_.cjs} +2 -2
- package/dist/{web-socket-CoIUBM3C.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-QbvqNazn.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
- package/dist/{worker-protocol-QbvqNazn.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
- package/dist/{worker-protocol-x074Rpet.js → worker-protocol-h4-tRWqy.js} +6 -6
- package/dist/{worker-protocol-x074Rpet.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
- package/dist/{worker-server-CFe4nvos.cjs → worker-server-CF1yatXq.cjs} +2 -2
- package/dist/{worker-server-CFe4nvos.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
- package/dist/worker-server-FYfKHQhJ.js +94 -0
- package/dist/{worker-server-iUVSjH8L.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
- package/dist/worker-transport-COgY4RX8.cjs +2 -0
- package/dist/worker-transport-COgY4RX8.cjs.map +1 -0
- package/dist/{worker-transport-Dy1KMA7t.js → worker-transport-jzX1IusG.js} +49 -45
- package/dist/worker-transport-jzX1IusG.js.map +1 -0
- package/llms.txt +14 -12
- package/package.json +13 -5
- package/dist/bus-C39wspFV.js.map +0 -1
- package/dist/bus-_EaOVPGq.cjs +0 -2
- package/dist/bus-_EaOVPGq.cjs.map +0 -1
- package/dist/config-DUs7uHHt.cjs +0 -2
- package/dist/config-DUs7uHHt.cjs.map +0 -1
- package/dist/config-SgQcCP1_.js +0 -560
- package/dist/config-SgQcCP1_.js.map +0 -1
- package/dist/constants-CUyd9cTZ.js.map +0 -1
- package/dist/constants-CqdJhTxH.cjs +0 -2
- package/dist/constants-CqdJhTxH.cjs.map +0 -1
- package/dist/errors-BE_EZV7Q.js.map +0 -1
- package/dist/errors-CNPbesMs.cjs +0 -3
- package/dist/errors-CNPbesMs.cjs.map +0 -1
- package/dist/factory-CTi0Is3F.js.map +0 -1
- package/dist/factory-hRrH32v5.cjs +0 -2
- package/dist/factory-hRrH32v5.cjs.map +0 -1
- package/dist/identity-DdhKgrpk.js.map +0 -1
- package/dist/identity-DlWRIuwy.cjs +0 -2
- package/dist/identity-DlWRIuwy.cjs.map +0 -1
- package/dist/interactions-CUkzK8sR.cjs +0 -2
- package/dist/interactions-CUkzK8sR.cjs.map +0 -1
- package/dist/interactions-DiFvCosX.js +0 -111
- package/dist/interactions-DiFvCosX.js.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-BaaFIPCU.js +0 -62
- package/dist/platform-BaaFIPCU.js.map +0 -1
- package/dist/platform-CfA3-7sJ.cjs +0 -2
- package/dist/platform-CfA3-7sJ.cjs.map +0 -1
- package/dist/replay-B3gFXIZd.cjs +0 -2
- package/dist/replay-B3gFXIZd.cjs.map +0 -1
- package/dist/replay-Ds-ANH34.js.map +0 -1
- package/dist/response-body-YdNl-HkR.cjs +0 -3
- package/dist/response-body-YdNl-HkR.cjs.map +0 -1
- package/dist/response-body-eoSQpLiH.js.map +0 -1
- package/dist/rotation-Cwct4ckk.js.map +0 -1
- package/dist/rotation-D4qUAHAu.cjs +0 -2
- package/dist/rotation-D4qUAHAu.cjs.map +0 -1
- package/dist/sender-BdRuNVhF.cjs +0 -2
- package/dist/sender-BdRuNVhF.cjs.map +0 -1
- package/dist/sender-Dv8rAmpV.js.map +0 -1
- package/dist/stored-context-B2EzVuYm.js.map +0 -1
- package/dist/stored-context-CXt7eHZL.cjs +0 -2
- package/dist/stored-context-CXt7eHZL.cjs.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-iUVSjH8L.js +0 -94
- package/dist/worker-transport-CRAX-09c.cjs +0 -2
- package/dist/worker-transport-CRAX-09c.cjs.map +0 -1
- package/dist/worker-transport-Dy1KMA7t.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Ct as e, Lt as t, Ut as n, Xt as r, i } from "./constants-CEHN6KuY.js";
|
|
2
|
+
import { t as a } from "./openfin-Bxelt0yg.js";
|
|
3
|
+
// src/utils/platform.ts
|
|
4
|
+
var o = null;
|
|
5
|
+
function s(e, t) {
|
|
6
|
+
let n = e[t];
|
|
7
|
+
return n !== void 0 && e instanceof n;
|
|
8
|
+
}
|
|
9
|
+
function c(e) {
|
|
10
|
+
if (o) return o;
|
|
11
|
+
let t = globalThis, n = t.navigator?.userAgent ?? "", i = "browser", c, d, f = !1, p = a()?.me;
|
|
12
|
+
return s(t, "ServiceWorkerGlobalScope") ? (i = "service_worker", f = !0) : s(t, "SharedWorkerGlobalScope") ? (i = "shared_worker", f = !0) : s(t, "WorkerGlobalScope") ? (i = "web_worker", f = !0) : p === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? i = "ionic" : t.cordova !== void 0 || l(n) ? i = "mobile_webview" : typeof document > "u" && typeof process < "u" && (i = "node") : (i = r.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "The library could not read fin.me.identity.", () => {
|
|
13
|
+
let e = p.identity;
|
|
14
|
+
c = e?.uuid, d = e?.name;
|
|
15
|
+
})), o = {
|
|
16
|
+
platform: i,
|
|
17
|
+
openfinUuid: c,
|
|
18
|
+
openfinName: d,
|
|
19
|
+
userAgent: n,
|
|
20
|
+
isWorker: f,
|
|
21
|
+
isTopLevelDocument: u(e)
|
|
22
|
+
}, o;
|
|
23
|
+
}
|
|
24
|
+
function l(r) {
|
|
25
|
+
return i.test(r) ? !0 : (e.test(r) || t.test(r) && n.test(r)) && r.includes("AppleWebKit") && !r.includes("Safari/");
|
|
26
|
+
}
|
|
27
|
+
function u(e) {
|
|
28
|
+
if (typeof window > "u") return !1;
|
|
29
|
+
try {
|
|
30
|
+
return window.self === window.top;
|
|
31
|
+
} catch {
|
|
32
|
+
return e.count("platform.api_blocked"), !1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function d(e) {
|
|
36
|
+
try {
|
|
37
|
+
return typeof location < "u" ? location.href : "";
|
|
38
|
+
} catch {
|
|
39
|
+
return e.count("platform.api_blocked"), "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var f = /^(\s*(?:[a-z][a-z\d+.-]*:[/\\]+|[/\\]{2,}))(?![/\\])[^/?#\s]*@/i, p = /[\t\n\r]/g;
|
|
43
|
+
function m() {
|
|
44
|
+
return typeof document < "u" ? document.baseURI : typeof location > "u" ? void 0 : location.href;
|
|
45
|
+
}
|
|
46
|
+
function h(e) {
|
|
47
|
+
if (!e.includes("@")) return e;
|
|
48
|
+
let t;
|
|
49
|
+
try {
|
|
50
|
+
t = new URL(e, m());
|
|
51
|
+
} catch {
|
|
52
|
+
return e.replace(p, "").replace(f, "$1");
|
|
53
|
+
}
|
|
54
|
+
return t.username === "" && t.password === "" ? e : (t.username = "", t.password = "", t.href);
|
|
55
|
+
}
|
|
56
|
+
function g(e, t, n, r) {
|
|
57
|
+
if (n) try {
|
|
58
|
+
let t = n(e);
|
|
59
|
+
return typeof t == "string" ? t : "";
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return r?.report("capture.record_failed", "capture.urlTransform threw an error. The library records an empty URL.", void 0, e), "";
|
|
62
|
+
}
|
|
63
|
+
let i = h(e);
|
|
64
|
+
return t ? i : _(i);
|
|
65
|
+
}
|
|
66
|
+
function _(e) {
|
|
67
|
+
let t = e.search(/[?#]/);
|
|
68
|
+
return t === -1 ? e : e.slice(0, t);
|
|
69
|
+
}
|
|
70
|
+
function v() {
|
|
71
|
+
return globalThis.navigator?.onLine !== !1;
|
|
72
|
+
}
|
|
73
|
+
export { g as a, m as i, c as n, v as r, d as t };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=platform-Dba6R3Hp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-Dba6R3Hp.js","names":["IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","OPENFIN_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","ANDROID_WEBVIEW_UA_PATTERN","currentUrl","USER_INFO_PATTERN","URL_DROPPED","pageBase","withoutUserInfo","url","parsed","recordedUrl","transform","value","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/**\n * Matches the user info after a URL's slashes or backslashes, with or without a scheme. A space\n * ends it (\"// step @ 3\" isn't a URL), and the lookahead keeps the match linear.\n */\nconst USER_INFO_PATTERN = /^(\\s*(?:[a-z][a-z\\d+.-]*:[/\\\\]+|[/\\\\]{2,}))(?![/\\\\])[^/?#\\s]*@/i;\n\n/** A browser drops these characters from a URL before it reads it. */\nconst URL_DROPPED = /[\\t\\n\\r]/g;\n\n/**\n * Returns the URL that a relative URL resolves against. A worker has no document, so it uses\n * its own location.\n * @returns The base URL, or undefined when the scope has neither.\n */\nexport function pageBase(): string | undefined {\n if (typeof document !== \"undefined\") {\n return document.baseURI;\n }\n\n return typeof location === \"undefined\" ? undefined : location.href;\n}\n\n/**\n * Removes the user name and the password from a URL. A browser also finds them in a URL with\n * no scheme, with backslashes or with a leading space, so the URL parser reads them.\n * @param url Absolute or relative URL.\n * @returns The URL without user info, or the URL as given when it has none.\n */\nfunction withoutUserInfo(url: string): string {\n // User info always ends in \"@\", so most URLs skip the parse, which runs on the log path.\n if (!url.includes(\"@\")) {\n return url;\n }\n\n let parsed: URL;\n try {\n parsed = new URL(url, pageBase());\n } catch {\n // The parser rejects the URL, or a blob: or about:blank base can't resolve it, so the\n // fallback is the pattern.\n return url.replace(URL_DROPPED, \"\").replace(USER_INFO_PATTERN, \"$1\");\n }\n\n if (parsed.username === \"\" && parsed.password === \"\") {\n return url;\n }\n\n parsed.username = \"\";\n parsed.password = \"\";\n return parsed.href;\n}\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = withoutUserInfo(url);\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":";;;AAkDA,IAAIK,IAAkC;AAWtC,SAASC,EAAc,GAAW,GAAuB;CACvD,IAAMC,IAAQC,EAAEC;CAIhB,OAHIF,MAAU,KAAA,KAGPC,aAAcD;AACvB;AAOA,SAAgBG,EAAe,GAA4C;CACzE,IAAIL,GACF,OAAOA;CAET,IAAMG,IAAI,YAEJG,IAAMH,EAAE,WAAqC,aAAa,IAC5DI,IAAyB,WACzBC,GACAC,GACAC,IAAW,IAETC,IAAQZ,EAAO,CAAC,EAAE;CAkCxB,OAhCIE,EAAcE,GAAG,0BAA0B,KAC7C,IAAW,kBACX,IAAW,MACFF,EAAcE,GAAG,yBAAyB,KACnD,IAAW,iBACX,IAAW,MACFF,EAAcE,GAAG,mBAAmB,KAC7C,IAAW,cACX,IAAW,MACFQ,MAAU,KAAA,IAOVR,EAAE,cAAc,KAAA,KAAaA,EAAE,UAAU,KAAA,IAClD,IAAW,UACFA,EAAE,YAAY,KAAA,KAAaS,EAAUN,CAAE,IAChD,IAAW,mBACF,OAAO,WAAa,OAAe,OAAO,UAAY,QAC/D,IAAW,WAXX,IAAWR,EAAmB,KAAKQ,CAAE,IAAI,YAAY,eACrDO,EAAY,MAAM,uBAAuB,qDAAqD;EAC5F,IAAMC,IAAWH,EAAM;EAEvB,AADA,IAAcG,GAAU,MACxB,IAAcA,GAAU;CAC1B,CAAC,IASH,IAAS;EACP;EACA;EACA;EACA,WAAWR;EACX;EACA,oBAAoBS,EAAWF,CAAW;CAC5C,GACOb;AACT;AAOA,SAASY,EAAU,GAAqB;CAMtC,OALII,EAA2B,KAAKV,CAAE,IAC7B,MAGPX,EAAsB,KAAKW,CAAE,KAAMV,EAA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ACjD,IAAMC,IAAMT,EAAI,OAAO,MAAM;CAE7B,OAAOS,MAAQ,KAAKT,IAAMA,EAAI,MAAM,GAAGS,CAAG;AAC5C;AAOA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $t as e,
|
|
1
|
+
import { $t as e, Bt as t, Qt as n, Zt as r, in as i, ir as a, nn as o, rn as s } from "./constants-CEHN6KuY.js";
|
|
2
2
|
import { t as c } from "./unref-DgHPQeWv.js";
|
|
3
3
|
import { t as l } from "./defineProperty-s2S8BXUc.js";
|
|
4
4
|
// src/core/profile-buckets.ts
|
|
5
5
|
var u = 16, d = u - 1;
|
|
6
6
|
function f(e) {
|
|
7
|
-
let t = Math.min(e,
|
|
7
|
+
let t = Math.min(e, s);
|
|
8
8
|
if (t < u) return t;
|
|
9
9
|
let n = 31 - Math.clz32(t) - 4;
|
|
10
10
|
return n + 1 << 4 | t >>> n & d;
|
|
@@ -38,7 +38,7 @@ function h(e, t) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
// src/core/profiler.ts
|
|
41
|
-
var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T = Symbol.for(`${
|
|
41
|
+
var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T = Symbol.for(`${n}@${a}`), E = {
|
|
42
42
|
begin: () => -1,
|
|
43
43
|
end: () => void 0,
|
|
44
44
|
endAfterPaint: () => void 0,
|
|
@@ -47,15 +47,15 @@ var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T =
|
|
|
47
47
|
constructor() {
|
|
48
48
|
l(this, "registry", /* @__PURE__ */ new Map()), l(this, "limit", 0), l(this, "stats", /* @__PURE__ */ new Float64Array()), l(this, "hist", /* @__PURE__ */ new Uint32Array()), l(this, "selfHist", /* @__PURE__ */ new Uint32Array()), l(this, "stack", new Float64Array(32 * C)), l(this, "depth", 0), l(this, "ring", /* @__PURE__ */ new Float64Array()), l(this, "ringAt", 0), l(this, "linkMs", Infinity), l(this, "painted", []), l(this, "channel", void 0), l(this, "sampling", /* @__PURE__ */ new Int32Array()), l(this, "floor", -1), l(this, "timer", null), l(this, "startedAt", 0), l(this, "badTokens", 0), l(this, "overhead", void 0), l(this, "calibrated", !1), l(this, "sink", null), l(this, "reported", !1), l(this, "limitDue", !1);
|
|
49
49
|
}
|
|
50
|
-
probe(
|
|
51
|
-
if (typeof
|
|
52
|
-
let i = this.registry.get(
|
|
50
|
+
probe(t, n, r) {
|
|
51
|
+
if (typeof t != "string" || t === "") return r?.report("config.invalid", "The probe name must be a string that is not empty. The probe does nothing."), E;
|
|
52
|
+
let i = this.registry.get(t);
|
|
53
53
|
if (i) return i.probe;
|
|
54
|
-
if (this.registry.size >= 1024) return r?.report("config.invalid", `The profiler keeps at most ${String(
|
|
55
|
-
let a = this.rulesOf(
|
|
56
|
-
if (this.registry.has(
|
|
57
|
-
let s = this.registry.size + 1, c = this.makeProbe(
|
|
58
|
-
return this.registry.set(
|
|
54
|
+
if (this.registry.size >= 1024) return r?.report("config.invalid", `The profiler keeps at most ${String(e)} probe names. The probe ${t} does nothing.`), E;
|
|
55
|
+
let a = this.rulesOf(t, n, r), { period: o } = a;
|
|
56
|
+
if (this.registry.has(t) || this.registry.size >= 1024) return this.probe(t, void 0, r);
|
|
57
|
+
let s = this.registry.size + 1, c = this.makeProbe(t, s, a), { probe: l } = c;
|
|
58
|
+
return this.registry.set(t, c), s < this.limit ? this.prime(s, o) : this.limit > 0 && !this.reported && (this.reported = !0, this.sink?.diagnostics.report("config.invalid", `The probe ${t} is above the profiler.maxProbes limit of ${String(this.limit - 1)}. The probe does nothing.`) === !1 && (this.limitDue = !0)), l;
|
|
59
59
|
}
|
|
60
60
|
time(e, t, n) {
|
|
61
61
|
this.probe(e, void 0, n);
|
|
@@ -124,46 +124,46 @@ var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T =
|
|
|
124
124
|
}
|
|
125
125
|
return typeof i == "number" && Number.isInteger(i) && i >= 1 && i <= S ? r.period = i : i !== void 0 && n?.report("config.invalid", `The sampleEvery option of the probe ${e} must be an integer from 1 to ${String(S)}. The library uses 1.`), typeof a == "number" && a >= 0 && a < Infinity ? r.threshold = a : a !== void 0 && n?.report("config.invalid", `The slowMs option of the probe ${e} must be a finite number, 0 or larger. The probe adds no breadcrumb.`), typeof o == "boolean" ? r.loose = o : o !== void 0 && n?.report("config.invalid", `The async option of the probe ${e} must be a boolean. The library uses false.`), r;
|
|
126
126
|
}
|
|
127
|
-
makeProbe(t, n
|
|
128
|
-
let { period:
|
|
129
|
-
this.add(
|
|
130
|
-
}, c = (e,
|
|
131
|
-
|
|
127
|
+
makeProbe(e, t, n) {
|
|
128
|
+
let { period: r, threshold: i, loose: a } = n, s = (n) => {
|
|
129
|
+
this.add(t, n), n > i && this.sink?.outlier(e, n);
|
|
130
|
+
}, c = (e, n) => {
|
|
131
|
+
t < this.limit && e > this.floor && s(n - e);
|
|
132
132
|
}, l = (e) => {
|
|
133
|
-
|
|
133
|
+
a || this.pop(t, e, performance.now());
|
|
134
134
|
}, u = (e) => {
|
|
135
|
-
let
|
|
136
|
-
if (
|
|
137
|
-
e !== -1 &&
|
|
135
|
+
let n = typeof e == "number" && e >= 0 ? performance.now() : -1;
|
|
136
|
+
if (n < 0) {
|
|
137
|
+
e !== -1 && t < this.limit && this.badTokens++;
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
if (
|
|
141
|
-
c(e,
|
|
140
|
+
if (a) {
|
|
141
|
+
c(e, n);
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
if (
|
|
145
|
-
let r = this.pop(
|
|
146
|
-
s(
|
|
144
|
+
if (t >= this.limit || e <= this.floor) return;
|
|
145
|
+
let r = this.pop(t, e, n);
|
|
146
|
+
s(n - e), r >= 0 && this.selfHist[t * 368 + f(Math.ceil(r * 1e3))]++;
|
|
147
147
|
};
|
|
148
148
|
return {
|
|
149
149
|
probe: {
|
|
150
150
|
begin: () => {
|
|
151
|
-
if (
|
|
151
|
+
if (t >= this.limit || !this.sampled(t)) return -1;
|
|
152
152
|
let e = performance.now();
|
|
153
|
-
return
|
|
153
|
+
return a || this.push(t, e), e;
|
|
154
154
|
},
|
|
155
155
|
end: u,
|
|
156
156
|
endAfterPaint: (e) => {
|
|
157
|
-
typeof e == "number" && e >= 0 &&
|
|
157
|
+
typeof e == "number" && e >= 0 && t < this.limit && this.afterPaint((t) => {
|
|
158
158
|
c(e, t);
|
|
159
159
|
}) ? l(e) : u(e);
|
|
160
160
|
},
|
|
161
|
-
record: (
|
|
162
|
-
|
|
161
|
+
record: (n) => {
|
|
162
|
+
t >= this.limit || (typeof n != "number" || !Number.isFinite(n) || n < 0 ? this.sink?.diagnostics.report("record.dropped_malformed", `The duration of the probe ${e} is not valid. The library dropped it.`, { [o.probe]: e }) : this.sampled(t) && s(n));
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
|
-
slot:
|
|
166
|
-
period:
|
|
165
|
+
slot: t,
|
|
166
|
+
period: r,
|
|
167
167
|
settle: c,
|
|
168
168
|
leave: l
|
|
169
169
|
};
|
|
@@ -237,32 +237,32 @@ var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T =
|
|
|
237
237
|
for (let e = 1; e < this.limit; e++) if (this.stats[e * g + _] > 0) return !0;
|
|
238
238
|
return !1;
|
|
239
239
|
}
|
|
240
|
-
emitSlot(
|
|
241
|
-
let { stats:
|
|
242
|
-
[
|
|
243
|
-
[
|
|
244
|
-
[
|
|
245
|
-
[
|
|
246
|
-
[
|
|
240
|
+
emitSlot(e, n, r, a) {
|
|
241
|
+
let { stats: s, hist: c } = this, l = r.slot * g, u = r.slot * 368, d = s[l + _], f = s[l + y], p = s[l + b], x = (e) => Math.min(Math.max(m(c, u, d, e) / 1e3, f), p), S = {
|
|
242
|
+
[o.probe]: n,
|
|
243
|
+
[o.sampleEvery]: r.period,
|
|
244
|
+
[o.p50]: x(.5),
|
|
245
|
+
[o.p90]: x(.9),
|
|
246
|
+
[o.p99]: x(.99)
|
|
247
247
|
};
|
|
248
|
-
this.overhead !== void 0 && (S[
|
|
248
|
+
this.overhead !== void 0 && (S[o.overhead] = this.overhead);
|
|
249
249
|
let { selfHist: C } = this, w = 0;
|
|
250
250
|
for (let e = u; e < u + 368; e++) w += C[e];
|
|
251
|
-
w > 0 && (S[
|
|
251
|
+
w > 0 && (S[o.selfP99] = Math.min(m(C, u, w, .99) / 1e3, p));
|
|
252
252
|
let { bounds: T, counts: E } = h(c, u), D = {
|
|
253
|
-
"metric.name":
|
|
253
|
+
"metric.name": i,
|
|
254
254
|
"metric.unit": "ms",
|
|
255
255
|
"metric.type": "histogram",
|
|
256
|
-
[
|
|
257
|
-
[
|
|
258
|
-
[
|
|
259
|
-
[
|
|
260
|
-
[
|
|
261
|
-
[
|
|
262
|
-
[
|
|
263
|
-
[
|
|
256
|
+
[t.start]: a,
|
|
257
|
+
[t.attributeKeys]: [o.probe, o.sampleEvery],
|
|
258
|
+
[t.count]: d,
|
|
259
|
+
[t.sum]: s[l + v],
|
|
260
|
+
[t.min]: f,
|
|
261
|
+
[t.max]: p,
|
|
262
|
+
[t.bounds]: T,
|
|
263
|
+
[t.buckets]: E
|
|
264
264
|
};
|
|
265
|
-
|
|
265
|
+
s.fill(0, l, l + g), c.fill(0, u, u + 368), C.fill(0, u, u + 368), e.emit(i, S, D);
|
|
266
266
|
}
|
|
267
267
|
calibrate() {
|
|
268
268
|
this.calibrated = !0;
|
|
@@ -270,15 +270,15 @@ var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T =
|
|
|
270
270
|
period: 1,
|
|
271
271
|
threshold: Infinity,
|
|
272
272
|
loose: !1
|
|
273
|
-
}),
|
|
274
|
-
for (let e = 0; e < 1e5 &&
|
|
275
|
-
if (
|
|
276
|
-
let i =
|
|
277
|
-
for (let
|
|
278
|
-
let
|
|
279
|
-
if (e.end(
|
|
273
|
+
}), t = performance.now(), n = t;
|
|
274
|
+
for (let e = 0; e < 1e5 && n === t; e++) n = performance.now();
|
|
275
|
+
if (n === t) return;
|
|
276
|
+
let i = n + 2, a = n, o = 0;
|
|
277
|
+
for (let t = 0; t < r; t++) {
|
|
278
|
+
let n = e.begin();
|
|
279
|
+
if (e.end(n), n !== a && (a = n, o = t, n >= i)) break;
|
|
280
280
|
}
|
|
281
|
-
o > 0 && (this.overhead = Math.round((a -
|
|
281
|
+
o > 0 && (this.overhead = Math.round((a - n) * 1e6 / o));
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
284
|
function O() {
|
|
@@ -289,4 +289,4 @@ function O() {
|
|
|
289
289
|
}
|
|
290
290
|
export { O as t };
|
|
291
291
|
|
|
292
|
-
//# sourceMappingURL=profiler-
|
|
292
|
+
//# sourceMappingURL=profiler-DNKcqu09.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiler-BAZoh7A4.js","names":["PROFILE_KEYS","PROFILER_CALIBRATION_PAIRS","PROFILER_PROBE_LIMIT","PROFILER_GLOBAL_KEY","PROFILE_MAX_US","TELEMETRY_SDK_VERSION","PROFILE_METRIC_NAME","METRIC_KEYS","unrefTimer","_defineProperty","SUB_COUNT","SUB_MASK","bucketOf","value","us","shift","upperOf","index","percentileOf","rank","q","count","sum","i","buckets","base","pointBuckets","first","last","merge","low","high","counts","k","STATS_WIDTH","COUNT","SUM","MIN","MAX","SAMPLING_WIDTH","MAX_PERIOD","FRAME_WIDTH","SPAN_WIDTH","CORE_KEY","NOOP_PROBE","ProfilerCore","name","diagnostics","known","rules","options","slot","entry","period","probe","token","waits","result","fn","then","done","error","minMs","names","found","at","ring","to","from","limit","sink","timed","start","threshold","loose","put","ms","settle","now","leave","end","self","durationMs","child","stack","ringAt","frame","page","drain","waiting","left","row","stats","min","max","quantile","hist","attributes","selfCount","selfHist","fields","bounds","edge","reads","until","tick","pairsAtTick","pairs","profilerCore","store","pinned","core"],"sources":["../src/core/profile-buckets.ts","../src/core/profiler.ts"],"sourcesContent":["// src/core/profile-buckets.ts\n//\n// Maps a duration in microseconds to a bucket of the profiler's log-linear histogram. Also\n// reads percentiles and builds the explicit bounds for a summary record.\n\nimport {\n PROFILE_BUCKETS,\n PROFILE_MAX_US,\n PROFILE_POINT_BUCKETS,\n PROFILE_SUB_BITS,\n} from \"../constants\";\n\n/** Sub-buckets per power of two. Values below this each get a bucket of their own. */\nconst SUB_COUNT = 1 << PROFILE_SUB_BITS;\n\n/** Masks the sub-bucket bits of a bucket index. */\nconst SUB_MASK = SUB_COUNT - 1;\n\n/**\n * Returns the bucket for a duration. Runs on the hot path, once per value.\n * @param us Duration in microseconds, a non-negative integer.\n * @returns The bucket index, 0 to 367. Anything above PROFILE_MAX_US lands in 367.\n */\nexport function bucketOf(us: number): number {\n // Clamp before the bit math: Math.clz32 and >>> only look at 32 bits, so a value of 2^32 or\n // more would land in the wrong bucket.\n const value = Math.min(us, PROFILE_MAX_US);\n\n if (value < SUB_COUNT) {\n return value;\n }\n\n // Math.clz32 gives us the exponent without a loop (up to 26 steps) or float math.\n // `shift` is how many low bits sit below the sub-bucket bits.\n const shift = 31 - Math.clz32(value) - PROFILE_SUB_BITS;\n return ((shift + 1) << PROFILE_SUB_BITS) | ((value >>> shift) & SUB_MASK);\n}\n\n/**\n * Returns the largest duration that still falls into a bucket.\n * @param index Bucket index, 0 to 367.\n * @returns The inclusive upper bound, in microseconds.\n */\nexport function upperOf(index: number): number {\n if (index < SUB_COUNT) {\n return index;\n }\n\n // Set all the low bits bucketOf dropped. Without them we'd return the bucket's smallest value.\n const shift = (index >>> PROFILE_SUB_BITS) - 1;\n return ((SUB_COUNT + (index & SUB_MASK)) << shift) + (1 << shift) - 1;\n}\n\n/**\n * Reads a percentile from one probe's histogram. Allocates nothing.\n * @param buckets Bucket counts for all probes.\n * @param base Index of the probe's first bucket.\n * @param count Sum of the probe's buckets. Must be above 0.\n * @param q Percentile as a fraction, e.g. 0.99.\n * @returns The upper bound of the bucket that holds the rank, in microseconds.\n */\nexport function percentileOf(buckets: Uint32Array, base: number, count: number, q: number): number {\n // A rank of 0 would match the first bucket even when it is empty.\n const rank = Math.max(1, Math.ceil(q * count));\n let sum = 0;\n\n // Walk the counts in place. Copying or sorting would make garbage on every flush.\n for (let i = 0; i < PROFILE_BUCKETS; i++) {\n sum += buckets[base + i];\n\n if (sum >= rank) {\n return upperOf(i);\n }\n }\n\n // Only reachable if the caller passed a wrong count.\n return upperOf(PROFILE_BUCKETS - 1);\n}\n\n/**\n * Builds the explicit-bounds histogram for a summary record.\n * @param buckets Bucket counts for all probes.\n * @param base Index of the probe's first bucket.\n * @returns Bounds in ms and the count per group. There is one more count than there are bounds.\n */\nexport function pointBuckets(\n buckets: Uint32Array,\n base: number,\n): { bounds: number[]; counts: number[] } {\n let first = 0;\n while (first < PROFILE_BUCKETS && buckets[base + first] === 0) {\n first++;\n }\n\n if (first === PROFILE_BUCKETS) {\n return { bounds: [], counts: [0] };\n }\n\n // The bucket at `first` isn't empty, so this loop stops there at the latest.\n let last = PROFILE_BUCKETS - 1;\n while (buckets[base + last] === 0) {\n last--;\n }\n\n // Groups start at multiples of 2^merge. That puts every bound on a fixed grid for the merge\n // level, whatever the record's first bucket happens to be.\n let merge = 0;\n while ((last >> merge) - (first >> merge) + 1 > PROFILE_POINT_BUCKETS) {\n merge++;\n }\n\n const low = first >> merge;\n const high = last >> merge;\n\n // Plain arrays, because the OTLP metrics serializer drops typed arrays.\n const counts = Array.from({ length: high - low + 1 }, () => 0);\n for (let i = first; i <= last; i++) {\n counts[(i >> merge) - low] += buckets[base + i];\n }\n\n // A group's bound is the bound of its last bucket. Dividing by 1000 gives ms.\n const bounds = Array.from(\n { length: high - low },\n (_unused, k) => upperOf(((low + k + 1) << merge) - 1) / 1000,\n );\n\n return { bounds, counts };\n}\n","// src/core/profiler.ts\n//\n// Times spans of app code with probes. Durations accumulate in typed arrays, and once per\n// interval every probe that saw data is flushed as one histogram summary record.\n\nimport {\n METRIC_KEYS,\n PROFILE_BUCKETS,\n PROFILE_KEYS,\n PROFILE_METRIC_NAME,\n PROFILER_CALIBRATION_MS,\n PROFILER_CALIBRATION_PAIRS,\n PROFILER_GLOBAL_KEY,\n PROFILER_PROBE_LIMIT,\n PROFILER_RING_SPANS,\n PROFILER_STACK_DEPTH,\n TELEMETRY_SDK_VERSION,\n} from \"../constants\";\nimport type { MetricAttributes, Probe, ProbeOptions, Profiler } from \"../models/metric\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\nimport { bucketOf, percentileOf, pointBuckets } from \"./profile-buckets\";\n\n/** One stats row is [count, sum, min, max]. Sum, min and max are in ms. */\nconst STATS_WIDTH = 4;\nconst COUNT = 0;\nconst SUM = 1;\nconst MIN = 2;\nconst MAX = 3;\n\n/** One sampling row is [countdown, period]. */\nconst SAMPLING_WIDTH = 2;\n\n/** The period lives in an Int32Array, so this is as large as it gets. */\nconst MAX_PERIOD = 2 ** 31 - 1;\n\n/** One span-stack frame is [start, child time, slot]. */\nconst FRAME_WIDTH = 3;\n\n/** One entry in the recent-span ring is [slot, start, end]. */\nconst SPAN_WIDTH = 3;\n\n/** Global key for the core, one per library version. */\nconst CORE_KEY = Symbol.for(`${PROFILER_GLOBAL_KEY}@${TELEMETRY_SDK_VERSION}`);\n\n/** Handed out for names we reject. Never reads the clock. */\nconst NOOP_PROBE: Probe = {\n begin: () => -1,\n end: () => undefined,\n endAfterPaint: () => undefined,\n record: () => undefined,\n};\n\n/** Ends a span that was waiting on a paint or a promise. */\ntype Settle = (token: number, now: number) => void;\n\n/** The page globals the paint wait needs. Workers and Node.js have none of them. */\ninterface PaintScope {\n requestAnimationFrame?: (callback: () => void) => unknown;\n document?: {\n /** \"hidden\" while the page isn't painting. */\n visibilityState?: string;\n addEventListener: (type: string, listener: () => void) => void;\n };\n}\n\n/** What the runtime hands the core on attach. */\nexport interface ProfilerSink {\n /** Max number of probes (profiler.maxProbes). */\n capacity: number;\n /** Interval length in ms. */\n intervalMs(): number;\n /**\n * Builds and sends the record for one point.\n * @param name Metric name.\n * @param attributes Record attributes for the point.\n * @param fields Metric fields for the point.\n */\n emit(name: string, attributes: MetricAttributes, fields: Record<string, unknown>): void;\n /** The runtime's diagnostics reporter. */\n diagnostics: Diagnostics;\n /** False while the runtime can't accept records. */\n ready(): boolean;\n /**\n * Leaves a breadcrumb for a span that ran longer than its probe's threshold.\n * @param name Probe name.\n * @param ms Span duration in ms.\n */\n outlier(name: string, ms: number): void;\n}\n\n/** Probe options after validation. */\ninterface ProbeRules {\n /** Measure one span in every `period`. */\n period: number;\n /** Spans longer than this (ms) leave a breadcrumb. Infinity means never. */\n threshold: number;\n /** True for async probes, whose spans stay off the span stack. */\n loose: boolean;\n}\n\n/** A registered probe. */\ninterface ProbeEntry {\n /** The handle. Every probe() call with the same name returns this one. */\n probe: Probe;\n /** The probe's row in the typed arrays: registration index + 1. */\n slot: number;\n /** Sampling period, from the options passed the first time the name was seen. */\n period: number;\n /** Ends one of this probe's spans that isn't on the span stack. */\n settle: Settle;\n /** Pops a span off the stack without ending it. It ends later. */\n leave: (token: number) => void;\n}\n\n/** Holds the probe names and all their timings. There is one core per library version. */\nexport class ProfilerCore implements Profiler {\n /** Probes by name. Names are never removed, so insertion order is slot order. */\n private readonly registry = new Map<string, ProbeEntry>();\n\n /** Rows in use. 0 while detached, so one compare covers both \"off\" and \"over the limit\". */\n private limit = 0;\n\n // The typed arrays start empty rather than null. Hypothesis (not measured): a single field\n // type keeps V8's inline caches on the hot path monomorphic.\n\n /**\n * Count, sum, min and max per slot. A row's four values sit in 32 adjacent bytes, so an add\n * should touch a single cache line (hypothesis, not measured).\n */\n private stats = new Float64Array(0);\n\n /** Bucket counts, PROFILE_BUCKETS per slot. */\n private hist = new Uint32Array(0);\n\n /** Self-time bucket counts per slot. Spans without a stack frame don't add to it. */\n private selfHist = new Uint32Array(0);\n\n /** Frames for the open, nested spans. Each frame adds up the time of the spans inside it. */\n private readonly stack = new Float64Array(PROFILER_STACK_DEPTH * FRAME_WIDTH);\n\n /** Number of frames in use. */\n private depth = 0;\n\n /** Recent spans, for linking to long animation frames. Empty until link() turns it on. */\n private ring = new Float64Array(0);\n\n /** Next write offset in the ring. */\n private ringAt = 0;\n\n /** Shortest span (ms) that goes into the ring. Infinity keeps the ring off. */\n private linkMs = Infinity;\n\n /** Spans waiting for the next paint. */\n private painted: ((now: number) => void)[] = [];\n\n /** Gets us a task right after the paint. Created on the first wait. */\n private channel: MessageChannel | undefined;\n\n /** Countdown and period per slot. */\n private sampling = new Int32Array(0);\n\n /**\n * Clock value at the last detach() or reset(). Spans that started at or before it are dropped.\n * \"At\" matters: on a coarse clock, a span started in the reset's tick reads the same value.\n */\n private floor = -1;\n\n /** Timer for the current interval. It only runs while there is data waiting. */\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n /** When the interval's first value arrived, in epoch ms. */\n private startedAt = 0;\n\n /** Invalid tokens seen while on, since the last collect(). end() itself reports nothing. */\n private badTokens = 0;\n\n /** Cost of one sampled begin()/end() pair, in ns. */\n private overhead: number | undefined = undefined;\n\n /** Set once calibration has run, so a too-coarse clock only blocks us once. */\n private calibrated = false;\n\n /** The runtime's sink. Null while detached. */\n private sink: ProfilerSink | null = null;\n\n /** True once this attach has reported a probe over the limit. */\n private reported = false;\n\n /** True while a limit report the throttle dropped is waiting for the next collect. */\n private limitDue = false;\n\n /**\n * Returns the probe for a name. Never throws into the app.\n * @param name Probe name. A JavaScript caller can pass anything.\n * @param options Probe options. Only the options from the first call for a name count.\n * @param diagnostics The current runtime's diagnostics. Without a runtime, nothing is reported.\n * @returns The probe, or a no-op probe if the name is rejected.\n */\n probe(name: string, options?: ProbeOptions, diagnostics?: Diagnostics): Probe {\n // Only look at the type. String(name) would run a hostile toString().\n if (typeof name !== \"string\" || name === \"\") {\n diagnostics?.report(\n \"config.invalid\",\n \"The probe name must be a string that is not empty. The probe does nothing.\",\n );\n return NOOP_PROBE;\n }\n\n const known = this.registry.get(name);\n if (known) {\n return known.probe;\n }\n\n if (this.registry.size >= PROFILER_PROBE_LIMIT) {\n diagnostics?.report(\n \"config.invalid\",\n `The profiler keeps at most ${String(PROFILER_PROBE_LIMIT)} probe names. The probe ${name} does nothing.`,\n );\n return NOOP_PROBE;\n }\n\n const rules = this.rulesOf(name, options, diagnostics);\n const { period } = rules;\n\n // An options getter can register probes behind our back. Re-check, or two names share a slot.\n if (this.registry.has(name) || this.registry.size >= PROFILER_PROBE_LIMIT) {\n return this.probe(name, undefined, diagnostics);\n }\n\n const slot = this.registry.size + 1;\n const entry = this.makeProbe(name, slot, rules);\n const { probe } = entry;\n this.registry.set(name, entry);\n\n if (slot < this.limit) {\n this.prime(slot, period);\n } else if (this.limit > 0 && !this.reported) {\n this.reported = true;\n // The limit belongs to the attached runtime, so report through it even when the caller\n // passed no diagnostics.\n const sent = this.sink?.diagnostics.report(\n \"config.invalid\",\n `The probe ${name} is above the profiler.maxProbes limit of ${String(this.limit - 1)}. The probe does nothing.`,\n );\n\n if (sent === false) {\n this.limitDue = true;\n }\n }\n\n return probe;\n }\n\n /**\n * Calls a function and times it. If the result is a thenable, the span ends when it settles.\n * The caller only ever sees errors from its own function.\n * @param name Probe name.\n * @param fn The app's function.\n * @param diagnostics The current runtime's diagnostics, if there is one.\n * @returns Whatever fn returned, or the result of its then() call.\n */\n time<T>(name: string, fn: () => T, diagnostics?: Diagnostics): T {\n this.probe(name, undefined, diagnostics);\n\n // A rejected name has no entry. Just run the function without a span.\n const entry = this.registry.get(name);\n const token = entry ? entry.probe.begin() : -1;\n let waits = false;\n\n try {\n const result = fn();\n\n if (entry && token >= 0) {\n try {\n const then = (result as { then?: unknown } | null | undefined)?.then;\n\n if (typeof then === \"function\") {\n const done = (): void => {\n entry.settle(token, performance.now());\n };\n\n waits = true;\n entry.leave(token);\n\n // Hand back the chained result, so a rejection has exactly one owner: the caller.\n return (then as PromiseLike<unknown>[\"then\"]).call(\n result,\n (value) => {\n done();\n return value;\n },\n (error: unknown) => {\n done();\n throw error;\n },\n ) as T;\n }\n } catch (error) {\n waits = false;\n diagnostics?.report(\n \"capture.record_failed\",\n `The library could not read what the function of the probe ${name} returned. The span ends now.`,\n undefined,\n error,\n );\n }\n }\n\n return result;\n } finally {\n if (!waits) {\n entry?.probe.end(token);\n }\n }\n }\n\n /**\n * Turns the recent-span ring on or off. The frame phases capture reads from it.\n * @param minMs Shortest span (ms) to keep. Infinity turns the ring off.\n */\n link(minMs: number): void {\n this.linkMs = minMs;\n\n if (minMs < Infinity && this.ring.length === 0) {\n this.ring = new Float64Array(PROFILER_RING_SPANS * SPAN_WIDTH);\n }\n }\n\n /**\n * Finds the probes that had a recent span inside a time range.\n * @param from Range start, as a performance.now() value.\n * @param to Range end.\n * @returns The probe names, without duplicates.\n */\n linked(from: number, to: number): string[] {\n const { ring } = this;\n const names = [...this.registry.keys()];\n const found = new Set<string>();\n\n for (let at = 0; at < ring.length; at += SPAN_WIDTH) {\n // Slot 0 means an empty row or a calibration span.\n if (ring[at] > 0 && ring[at + 1] < to && ring[at + 2] > from) {\n found.add(names[ring[at] - 1]);\n }\n }\n\n return [...found];\n }\n\n /**\n * Turns the profiler on with a runtime's sink. Calling it again swaps the sink.\n * @param sink The runtime's sink.\n */\n attach(sink: ProfilerSink): void {\n const limit = sink.capacity + 1;\n this.sink = sink;\n\n // Re-attaching with the same capacity keeps the data.\n if (this.stats.length !== limit * STATS_WIDTH) {\n this.stats = new Float64Array(limit * STATS_WIDTH);\n this.hist = new Uint32Array(limit * PROFILE_BUCKETS);\n this.selfHist = new Uint32Array(limit * PROFILE_BUCKETS);\n this.sampling = new Int32Array(limit * SAMPLING_WIDTH);\n }\n\n this.limit = limit;\n this.reported = false;\n this.limitDue = false;\n this.prime(0, 1);\n for (const entry of this.registry.values()) {\n if (entry.slot < limit) {\n this.prime(entry.slot, entry.period);\n }\n }\n\n if (this.registry.size > sink.capacity) {\n this.reported = true;\n this.reportLimit(sink);\n }\n }\n\n /** Turns the profiler off and drops the data. The runtime calls collect(false) first. */\n detach(): void {\n this.limit = 0;\n this.sink = null;\n this.clearTimer();\n this.clear();\n }\n\n /**\n * Sends one summary record per probe that has data, then starts a new interval. Does nothing\n * while the sink isn't ready.\n * @param timed True when called from the interval timer. Only a timed collect calibrates.\n */\n collect(timed: boolean): void {\n const { sink } = this;\n\n // A runtime that isn't ready would refuse the records, so keep the data and the timer for a\n // later collect. Zeroing the slots here would lose those points.\n if (!sink?.ready()) {\n return;\n }\n\n // The diagnostics throttle swallowed this attach's limit report. Try again, otherwise the\n // app never hears that some of its probes do nothing.\n if (this.limitDue) {\n this.reportLimit(sink);\n }\n\n this.clearTimer();\n\n // Calibration blocks the thread for 2-3 ms (longer on a too-coarse clock), so flush() and\n // the exit path skip it.\n if (timed && !this.calibrated && this.hasData()) {\n this.calibrate();\n }\n\n const start = `${String(this.startedAt)}000000`;\n for (const [name, entry] of this.registry) {\n // Probes over the limit have no row. After a detach() from inside an emit, none do.\n if (entry.slot < this.limit && this.stats[entry.slot * STATS_WIDTH + COUNT] > 0) {\n this.emitSlot(sink, name, entry, start);\n }\n }\n\n if (this.badTokens > 0) {\n sink.diagnostics.count(\"record.dropped_malformed\", this.badTokens);\n this.badTokens = 0;\n }\n }\n\n /** Drops the interval's data. The profiler stays on. */\n reset(): void {\n this.clearTimer();\n this.badTokens = 0;\n this.clear();\n }\n\n /** Drops the data and any open spans. Spans started at or before this call add nothing. */\n private clear(): void {\n this.floor = performance.now();\n this.depth = 0;\n this.stats.fill(0);\n this.hist.fill(0);\n this.selfHist.fill(0);\n this.ring.fill(0);\n }\n\n /**\n * Reads the options for a new probe. Never throws into the app.\n * @param name Probe name.\n * @param options Options from the app.\n * @param diagnostics The current runtime's diagnostics, if there is one.\n * @returns The rules. Any invalid option falls back to its default.\n */\n private rulesOf(\n name: string,\n options: ProbeOptions | undefined,\n diagnostics: Diagnostics | undefined,\n ): ProbeRules {\n const rules: ProbeRules = { period: 1, threshold: Infinity, loose: false };\n let period: unknown;\n let threshold: unknown;\n let loose: unknown;\n\n // A getter or a Proxy trap on the options can throw.\n try {\n period = options?.sampleEvery;\n threshold = options?.slowMs;\n loose = options?.async;\n } catch (error) {\n diagnostics?.report(\n \"config.invalid\",\n `The library could not read the options of the probe ${name}. The library uses the defaults.`,\n undefined,\n error,\n );\n return rules;\n }\n\n if (\n typeof period === \"number\" &&\n Number.isInteger(period) &&\n period >= 1 &&\n period <= MAX_PERIOD\n ) {\n rules.period = period;\n } else if (period !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The sampleEvery option of the probe ${name} must be an integer from 1 to ${String(MAX_PERIOD)}. The library uses 1.`,\n );\n }\n\n if (typeof threshold === \"number\" && threshold >= 0 && threshold < Infinity) {\n rules.threshold = threshold;\n } else if (threshold !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The slowMs option of the probe ${name} must be a finite number, 0 or larger. The probe adds no breadcrumb.`,\n );\n }\n\n if (typeof loose === \"boolean\") {\n rules.loose = loose;\n } else if (loose !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The async option of the probe ${name} must be a boolean. The library uses false.`,\n );\n }\n\n return rules;\n }\n\n /**\n * Builds a probe's closures, once per probe, so destructured members still work.\n * @param name Probe name.\n * @param slot The probe's row.\n * @param rules Validated probe options.\n * @returns The registry entry, including the probe.\n */\n private makeProbe(name: string, slot: number, rules: ProbeRules): ProbeEntry {\n const { period, threshold, loose } = rules;\n\n // Records one duration, plus a breadcrumb if it is over the probe's threshold.\n const put = (ms: number): void => {\n this.add(slot, ms);\n\n if (ms > threshold) {\n this.sink?.outlier(name, ms);\n }\n };\n\n // Drop the span if we're off, or if it started at or before a detach() or reset().\n const settle: Settle = (token, now) => {\n if (slot < this.limit && token > this.floor) {\n put(now - token);\n }\n };\n\n const leave = (token: number): void => {\n if (!loose) {\n this.pop(slot, token, performance.now());\n }\n };\n\n const end = (token: number): void => {\n // Type check first, so the compare can never run a hostile valueOf().\n const now = typeof token === \"number\" && token >= 0 ? performance.now() : -1;\n if (now < 0) {\n // -1 means begin() didn't measure this span. Other bad tokens only count while we're on.\n if (token !== -1 && slot < this.limit) {\n this.badTokens++;\n }\n return;\n }\n\n if (loose) {\n settle(token, now);\n return;\n }\n\n // Drop the span if we're off, or if it started at or before a detach() or reset().\n if (slot >= this.limit || token <= this.floor) {\n return;\n }\n\n const self = this.pop(slot, token, now);\n put(now - token);\n\n // No frame means no self time: the frame was lost to a reset or to a full stack.\n if (self >= 0) {\n this.selfHist[slot * PROFILE_BUCKETS + bucketOf(Math.ceil(self * 1000))]++;\n }\n };\n\n const probe: Probe = {\n begin: () => {\n // Off, over the limit or sampled out: don't even read the clock.\n if (slot >= this.limit || !this.sampled(slot)) {\n return -1;\n }\n\n const now = performance.now();\n if (!loose) {\n this.push(slot, now);\n }\n\n return now;\n },\n end,\n endAfterPaint: (token) => {\n const waits =\n typeof token === \"number\" &&\n token >= 0 &&\n slot < this.limit &&\n this.afterPaint((now) => {\n settle(token, now);\n });\n\n // Bad token, probe off, or a page that isn't painting: end right away.\n if (!waits) {\n end(token);\n return;\n }\n\n leave(token);\n },\n record: (durationMs) => {\n if (slot >= this.limit) {\n return;\n }\n\n if (typeof durationMs !== \"number\" || !Number.isFinite(durationMs) || durationMs < 0) {\n this.sink?.diagnostics.report(\n \"record.dropped_malformed\",\n `The duration of the probe ${name} is not valid. The library dropped it.`,\n { [PROFILE_KEYS.probe]: name },\n );\n return;\n }\n\n if (this.sampled(slot)) {\n put(durationMs);\n }\n },\n };\n\n return { probe, slot, period, settle, leave };\n }\n\n /**\n * Pushes a frame for a new span.\n * @param slot The probe's row.\n * @param now Span start.\n */\n private push(slot: number, now: number): void {\n const { stack } = this;\n\n // A full stack is full of frames whose spans never got an end(). Drop them, or no later\n // span gets a self time.\n if (this.depth === PROFILER_STACK_DEPTH) {\n this.depth = 0;\n }\n\n const at = this.depth++ * FRAME_WIDTH;\n stack[at] = now;\n stack[at + 1] = 0;\n stack[at + 2] = slot;\n }\n\n /**\n * Pops a span's frame, along with any frames above it, and adds the span's duration to the\n * child time of the frame below.\n * @param slot The probe's row.\n * @param token Span start.\n * @param now Span end, or the time the span leaves the stack.\n * @returns Self time in ms, or -1 if the span had no frame.\n */\n private pop(slot: number, token: number, now: number): number {\n const { stack } = this;\n const ms = now - token;\n let child = 0;\n\n for (let at = (this.depth - 1) * FRAME_WIDTH; at >= 0; at -= FRAME_WIDTH) {\n // Any frame above ours is a span that never got an end(). Its child time is ours.\n child += stack[at + 1];\n\n if (stack[at] === token && stack[at + 2] === slot) {\n this.depth = at / FRAME_WIDTH;\n\n if (at > 0) {\n stack[at - FRAME_WIDTH + 1] += ms;\n }\n\n if (ms >= this.linkMs) {\n const { ring, ringAt } = this;\n ring[ringAt] = slot;\n ring[ringAt + 1] = token;\n ring[ringAt + 2] = now;\n this.ringAt = (ringAt + SPAN_WIDTH) % ring.length;\n }\n\n return Math.max(ms - child, 0);\n }\n }\n\n return -1;\n }\n\n /**\n * Runs a function in the first task after the next paint.\n * @param done Called with the time after the paint.\n * @returns False where there is no frame callback, or when the page is hidden.\n */\n private afterPaint(done: (now: number) => void): boolean {\n const { requestAnimationFrame: frame, document: page } = globalThis as PaintScope;\n\n if (\n typeof frame !== \"function\" ||\n typeof MessageChannel === \"undefined\" ||\n page?.visibilityState === \"hidden\"\n ) {\n return false;\n }\n\n if (!this.channel) {\n const drain = (): void => {\n const now = performance.now();\n const waiting = this.painted;\n this.painted = [];\n\n for (const end of waiting) {\n end(now);\n }\n };\n\n this.channel = new MessageChannel();\n this.channel.port1.onmessage = drain;\n\n // A hidden page gets no frame callbacks. End the spans now, or they include the hidden time.\n page?.addEventListener(\"visibilitychange\", () => {\n if (page.visibilityState === \"hidden\") {\n drain();\n }\n });\n }\n\n // rAF callbacks run before the paint. A task posted from one runs after it.\n if (this.painted.push(done) === 1) {\n frame(() => {\n this.channel?.port2.postMessage(0);\n });\n }\n\n return true;\n }\n\n /**\n * Writes a slot's sampling row so the next span gets measured.\n * @param slot The probe's row.\n * @param period Sampling period.\n */\n private prime(slot: number, period: number): void {\n const at = slot * SAMPLING_WIDTH;\n this.sampling[at] = 1;\n this.sampling[at + 1] = period;\n }\n\n /**\n * Counts down a slot's sampling. A countdown gives an exact rate, which Math.random() wouldn't.\n * @param slot The probe's row.\n * @returns True if this span should be measured.\n */\n private sampled(slot: number): boolean {\n const at = slot * SAMPLING_WIDTH;\n const left = this.sampling[at] - 1;\n\n if (left > 0) {\n this.sampling[at] = left;\n return false;\n }\n\n this.sampling[at] = this.sampling[at + 1];\n return true;\n }\n\n /**\n * Adds one duration to a slot. This is the hot path: no Map lookup, no try.\n * @param slot The probe's row.\n * @param ms Duration in ms.\n */\n private add(slot: number, ms: number): void {\n // A forged token gives a negative duration. A broken clock gives NaN or Infinity.\n if (!(ms >= 0) || ms === Infinity) {\n this.badTokens++;\n return;\n }\n\n const { stats } = this;\n const row = slot * STATS_WIDTH;\n const count = stats[row + COUNT];\n stats[row + COUNT] = count + 1;\n stats[row + SUM] += ms;\n\n if (count === 0 || ms < stats[row + MIN]) {\n stats[row + MIN] = ms;\n }\n\n if (count === 0 || ms > stats[row + MAX]) {\n stats[row + MAX] = ms;\n }\n\n // Buckets include their upper bound, so round up or the value lands one bucket too low.\n this.hist[slot * PROFILE_BUCKETS + bucketOf(Math.ceil(ms * 1000))]++;\n\n // Slot 0 is the calibration slot, and calibration must not start an interval.\n if (this.timer === null && slot > 0 && this.sink !== null) {\n this.startedAt = Date.now();\n this.wait(this.sink);\n }\n }\n\n /**\n * Starts the interval timer, unref'd so a pending timer doesn't keep Node.js alive.\n * @param sink The runtime's sink.\n */\n private wait(sink: ProfilerSink): void {\n this.timer = setTimeout(() => {\n this.tick();\n }, sink.intervalMs());\n unrefTimer(this.timer);\n }\n\n /** Collects at the end of an interval, or waits another one if the runtime isn't ready. */\n private tick(): void {\n const { sink } = this;\n\n if (sink !== null && !sink.ready()) {\n this.wait(sink);\n return;\n }\n\n this.collect(true);\n }\n\n /** Stops the interval timer. */\n private clearTimer(): void {\n if (this.timer !== null) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n /**\n * Reports that there are more probes than the limit allows. If the throttle drops the report,\n * the next collect tries again.\n * @param sink The runtime's sink.\n */\n private reportLimit(sink: ProfilerSink): void {\n // Clear the flag first, so a handler that collects can't kick off a second report.\n this.limitDue = false;\n const sent = sink.diagnostics.report(\n \"config.invalid\",\n `The app registered ${String(this.registry.size)} probes. The profiler.maxProbes limit is ${String(sink.capacity)}. The probes above the limit do nothing.`,\n );\n\n if (!sent) {\n this.limitDue = true;\n }\n }\n\n /**\n * Checks whether any probe recorded a value in this interval.\n * @returns True if a slot above 0 has a non-zero count.\n */\n private hasData(): boolean {\n for (let slot = 1; slot < this.limit; slot++) {\n if (this.stats[slot * STATS_WIDTH + COUNT] > 0) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sends one slot's summary record and zeroes the slot. The sampling countdown is left alone.\n * @param sink The runtime's sink.\n * @param name Probe name.\n * @param entry The probe's registry entry.\n * @param start Interval start, in Unix nanoseconds.\n */\n private emitSlot(sink: ProfilerSink, name: string, entry: ProbeEntry, start: string): void {\n const { stats, hist } = this;\n const row = entry.slot * STATS_WIDTH;\n const base = entry.slot * PROFILE_BUCKETS;\n const count = stats[row + COUNT];\n const min = stats[row + MIN];\n const max = stats[row + MAX];\n\n // A bucket bound can be higher than the exact max, so clamp every percentile to [min, max].\n const quantile = (q: number): number =>\n Math.min(Math.max(percentileOf(hist, base, count, q) / 1000, min), max);\n\n const attributes: MetricAttributes = {\n [PROFILE_KEYS.probe]: name,\n [PROFILE_KEYS.sampleEvery]: entry.period,\n [PROFILE_KEYS.p50]: quantile(0.5),\n [PROFILE_KEYS.p90]: quantile(0.9),\n [PROFILE_KEYS.p99]: quantile(0.99),\n };\n if (this.overhead !== undefined) {\n attributes[PROFILE_KEYS.overhead] = this.overhead;\n }\n\n // Count the self times here, at collect, so the hot path has no second counter to write.\n const { selfHist } = this;\n let selfCount = 0;\n for (let at = base; at < base + PROFILE_BUCKETS; at++) {\n selfCount += selfHist[at];\n }\n\n if (selfCount > 0) {\n attributes[PROFILE_KEYS.selfP99] = Math.min(\n percentileOf(selfHist, base, selfCount, 0.99) / 1000,\n max,\n );\n }\n\n const { bounds, counts } = pointBuckets(hist, base);\n const fields: Record<string, unknown> = {\n \"metric.name\": PROFILE_METRIC_NAME,\n \"metric.unit\": \"ms\",\n \"metric.type\": \"histogram\",\n [METRIC_KEYS.start]: start,\n [METRIC_KEYS.attributeKeys]: [PROFILE_KEYS.probe, PROFILE_KEYS.sampleEvery],\n [METRIC_KEYS.count]: count,\n [METRIC_KEYS.sum]: stats[row + SUM],\n [METRIC_KEYS.min]: min,\n [METRIC_KEYS.max]: max,\n [METRIC_KEYS.bounds]: bounds,\n [METRIC_KEYS.buckets]: counts,\n };\n\n // Zero before emitting: an app processor can call end() from inside the emit.\n stats.fill(0, row, row + STATS_WIDTH);\n hist.fill(0, base, base + PROFILE_BUCKETS);\n selfHist.fill(0, base, base + PROFILE_BUCKETS);\n sink.emit(PROFILE_METRIC_NAME, attributes, fields);\n }\n\n /**\n * Measures what one sampled begin()/end() pair costs, on slot 0. Runs once. If the clock never\n * shows an edge or never ticks, no value is set.\n */\n private calibrate(): void {\n this.calibrated = true;\n const { probe } = this.makeProbe(\"\", 0, { period: 1, threshold: Infinity, loose: false });\n\n // Browsers round performance.now() to 5 us, 100 us or 1 ms. Measure from clock edge to clock\n // edge: a window that isn't aligned to an edge can be off by up to one tick.\n const first = performance.now();\n let edge = first;\n for (let reads = 0; reads < PROFILER_CALIBRATION_PAIRS && edge === first; reads++) {\n edge = performance.now();\n }\n\n // No edge within the read limit, so the clock is frozen or too coarse. Without a start edge\n // the result would come out too large.\n if (edge === first) {\n return;\n }\n\n // begin()'s token is the clock reading, so the loop doesn't need a third clock read.\n const until = edge + PROFILER_CALIBRATION_MS;\n let tick = edge;\n let pairsAtTick = 0;\n for (let pairs = 0; pairs < PROFILER_CALIBRATION_PAIRS; pairs++) {\n const token = probe.begin();\n probe.end(token);\n\n if (token !== tick) {\n tick = token;\n pairsAtTick = pairs;\n\n if (token >= until) {\n break;\n }\n }\n }\n\n // Whole nanoseconds. Hypothesis: the noise in a single 2 ms run is more than 1 ns anyway.\n if (pairsAtTick > 0) {\n this.overhead = Math.round(((tick - edge) * 1e6) / pairsAtTick);\n }\n }\n}\n\n/**\n * Returns the profiler core for this library version. Two copies of the same version share it.\n * @returns The core.\n */\nexport function profilerCore(): ProfilerCore {\n // Each copy has its own class, so instanceof fails across copies. Cast structurally instead.\n const store = globalThis as Record<symbol, unknown>;\n const pinned = store[CORE_KEY] as ProfilerCore | undefined;\n if (pinned) {\n return pinned;\n }\n\n const core = new ProfilerCore();\n store[CORE_KEY] = core;\n return core;\n}\n"],"mappings":";;;;AAaA,IAAMU,IAAY,IAGZC,IAAWD,IAAY;AAO7B,SAAgBE,EAAS,GAAoB;CAG3C,IAAMC,IAAQ,KAAK,IAAIC,GAAIV,CAAc;CAEzC,IAAIS,IAAQH,GACV,OAAOG;CAKT,IAAME,IAAQ,KAAK,KAAK,MAAMF,CAAK,IAAA;CACnC,OAASE,IAAQ,KAAA,IAA4BF,MAAUE,IAASJ;AAClE;AAOA,SAAgBK,EAAQ,GAAuB;CAC7C,IAAIC,IAAQP,GACV,OAAOO;CAIT,IAAMF,KAASE,MAAA,KAA8B;CAC7C,QAASP,KAAaO,IAAQN,MAAcI,MAAU,KAAKA,KAAS;AACtE;AAUA,SAAgBG,EAAa,GAAsB,GAAc,GAAe,GAAmB;CAEjG,IAAMC,IAAO,KAAK,IAAI,GAAG,KAAK,KAAKC,IAAIC,CAAK,CAAC,GACzCC,IAAM;CAGV,KAAK,IAAIC,IAAI,GAAGA,IAAA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M;CACnD;CAMA,YAA0B;EACxB,KAAK,aAAa;EAClB,IAAM,EAAE,aAAU,KAAK,UAAU,IAAI,GAAG;GAAE,QAAQ;GAAG,WAAW;GAAU,OAAO;EAAM,CAAC,GAIlFzE,IAAQ,YAAY,IAAI,GAC1B2E,IAAO3E;EACX,KAAK,IAAI4E,IAAQ,GAAGA,IAAA,OAAsCD,MAAS3E,GAAO,KACxE,IAAO,YAAY,IAAI;EAKzB,IAAI2E,MAAS3E,GACX;EAIF,IAAM6E,IAAQF,IAAA,GACVG,IAAOH,GACPI,IAAc;EAClB,KAAK,IAAIC,IAAQ,GAAGA,IAAQ1G,GAA4B,KAAS;GAC/D,IAAMsD,IAAQD,EAAM,MAAM;GAG1B,IAFAA,EAAM,IAAIC,CAAK,GAEXA,MAAUkD,MACZ,IAAOlD,GACP,IAAcoD,GAEVpD,KAASiD,IACX;EAGN;EAGA,AAAIE,IAAc,MAChB,KAAK,WAAW,KAAK,OAAQD,IAAOH,KAAQ,MAAOI,CAAW;CAElE;AACF;AAMA,SAAgBE,IAA6B;CAE3C,IAAMC,IAAQ,YACRC,IAASD,EAAMlE;CACrB,IAAImE,GACF,OAAOA;CAGT,IAAMC,IAAO,IAAIlE,EAAa;CAE9B,OADA,EAAMF,KAAYoE,GACXA;AACT"}
|
|
1
|
+
{"version":3,"file":"profiler-DNKcqu09.js","names":["PROFILER_PROBE_LIMIT","METRIC_KEYS","PROFILER_GLOBAL_KEY","PROFILER_CALIBRATION_PAIRS","PROFILE_METRIC_NAME","TELEMETRY_SDK_VERSION","PROFILE_KEYS","PROFILE_MAX_US","unrefTimer","_defineProperty","SUB_COUNT","SUB_MASK","bucketOf","value","us","shift","upperOf","index","percentileOf","rank","q","count","sum","i","buckets","base","pointBuckets","first","last","merge","low","high","counts","k","STATS_WIDTH","COUNT","SUM","MIN","MAX","SAMPLING_WIDTH","MAX_PERIOD","FRAME_WIDTH","SPAN_WIDTH","CORE_KEY","NOOP_PROBE","ProfilerCore","name","diagnostics","known","rules","options","slot","entry","period","probe","token","waits","result","fn","then","done","error","minMs","names","found","at","ring","to","from","limit","sink","timed","start","threshold","loose","put","ms","settle","now","leave","end","self","durationMs","child","stack","ringAt","frame","page","drain","waiting","left","row","stats","min","max","quantile","hist","attributes","selfCount","selfHist","fields","bounds","edge","reads","until","tick","pairsAtTick","pairs","profilerCore","store","pinned","core"],"sources":["../src/core/profile-buckets.ts","../src/core/profiler.ts"],"sourcesContent":["// src/core/profile-buckets.ts\n//\n// Maps a duration in microseconds to a bucket of the profiler's log-linear histogram. Also\n// reads percentiles and builds the explicit bounds for a summary record.\n\nimport {\n PROFILE_BUCKETS,\n PROFILE_MAX_US,\n PROFILE_POINT_BUCKETS,\n PROFILE_SUB_BITS,\n} from \"../constants\";\n\n/** Sub-buckets per power of two. Values below this each get a bucket of their own. */\nconst SUB_COUNT = 1 << PROFILE_SUB_BITS;\n\n/** Masks the sub-bucket bits of a bucket index. */\nconst SUB_MASK = SUB_COUNT - 1;\n\n/**\n * Returns the bucket for a duration. Runs on the hot path, once per value.\n * @param us Duration in microseconds, a non-negative integer.\n * @returns The bucket index, 0 to 367. Anything above PROFILE_MAX_US lands in 367.\n */\nexport function bucketOf(us: number): number {\n // Clamp before the bit math: Math.clz32 and >>> only look at 32 bits, so a value of 2^32 or\n // more would land in the wrong bucket.\n const value = Math.min(us, PROFILE_MAX_US);\n\n if (value < SUB_COUNT) {\n return value;\n }\n\n // Math.clz32 gives us the exponent without a loop (up to 26 steps) or float math.\n // `shift` is how many low bits sit below the sub-bucket bits.\n const shift = 31 - Math.clz32(value) - PROFILE_SUB_BITS;\n return ((shift + 1) << PROFILE_SUB_BITS) | ((value >>> shift) & SUB_MASK);\n}\n\n/**\n * Returns the largest duration that still falls into a bucket.\n * @param index Bucket index, 0 to 367.\n * @returns The inclusive upper bound, in microseconds.\n */\nexport function upperOf(index: number): number {\n if (index < SUB_COUNT) {\n return index;\n }\n\n // Set all the low bits bucketOf dropped. Without them we'd return the bucket's smallest value.\n const shift = (index >>> PROFILE_SUB_BITS) - 1;\n return ((SUB_COUNT + (index & SUB_MASK)) << shift) + (1 << shift) - 1;\n}\n\n/**\n * Reads a percentile from one probe's histogram. Allocates nothing.\n * @param buckets Bucket counts for all probes.\n * @param base Index of the probe's first bucket.\n * @param count Sum of the probe's buckets. Must be above 0.\n * @param q Percentile as a fraction, e.g. 0.99.\n * @returns The upper bound of the bucket that holds the rank, in microseconds.\n */\nexport function percentileOf(buckets: Uint32Array, base: number, count: number, q: number): number {\n // A rank of 0 would match the first bucket even when it is empty.\n const rank = Math.max(1, Math.ceil(q * count));\n let sum = 0;\n\n // Walk the counts in place. Copying or sorting would make garbage on every flush.\n for (let i = 0; i < PROFILE_BUCKETS; i++) {\n sum += buckets[base + i];\n\n if (sum >= rank) {\n return upperOf(i);\n }\n }\n\n // Only reachable if the caller passed a wrong count.\n return upperOf(PROFILE_BUCKETS - 1);\n}\n\n/**\n * Builds the explicit-bounds histogram for a summary record.\n * @param buckets Bucket counts for all probes.\n * @param base Index of the probe's first bucket.\n * @returns Bounds in ms and the count per group. There is one more count than there are bounds.\n */\nexport function pointBuckets(\n buckets: Uint32Array,\n base: number,\n): { bounds: number[]; counts: number[] } {\n let first = 0;\n while (first < PROFILE_BUCKETS && buckets[base + first] === 0) {\n first++;\n }\n\n if (first === PROFILE_BUCKETS) {\n return { bounds: [], counts: [0] };\n }\n\n // The bucket at `first` isn't empty, so this loop stops there at the latest.\n let last = PROFILE_BUCKETS - 1;\n while (buckets[base + last] === 0) {\n last--;\n }\n\n // Groups start at multiples of 2^merge. That puts every bound on a fixed grid for the merge\n // level, whatever the record's first bucket happens to be.\n let merge = 0;\n while ((last >> merge) - (first >> merge) + 1 > PROFILE_POINT_BUCKETS) {\n merge++;\n }\n\n const low = first >> merge;\n const high = last >> merge;\n\n // Plain arrays, because the OTLP metrics serializer drops typed arrays.\n const counts = Array.from({ length: high - low + 1 }, () => 0);\n for (let i = first; i <= last; i++) {\n counts[(i >> merge) - low] += buckets[base + i];\n }\n\n // A group's bound is the bound of its last bucket. Dividing by 1000 gives ms.\n const bounds = Array.from(\n { length: high - low },\n (_unused, k) => upperOf(((low + k + 1) << merge) - 1) / 1000,\n );\n\n return { bounds, counts };\n}\n","// src/core/profiler.ts\n//\n// Times spans of app code with probes. Durations accumulate in typed arrays, and once per\n// interval every probe that saw data is flushed as one histogram summary record.\n\nimport {\n METRIC_KEYS,\n PROFILE_BUCKETS,\n PROFILE_KEYS,\n PROFILE_METRIC_NAME,\n PROFILER_CALIBRATION_MS,\n PROFILER_CALIBRATION_PAIRS,\n PROFILER_GLOBAL_KEY,\n PROFILER_PROBE_LIMIT,\n PROFILER_RING_SPANS,\n PROFILER_STACK_DEPTH,\n TELEMETRY_SDK_VERSION,\n} from \"../constants\";\nimport type { MetricAttributes, Probe, ProbeOptions, Profiler } from \"../models/metric\";\nimport { unrefTimer } from \"../utils/unref\";\nimport type { Diagnostics } from \"./diagnostics\";\nimport { bucketOf, percentileOf, pointBuckets } from \"./profile-buckets\";\n\n/** One stats row is [count, sum, min, max]. Sum, min and max are in ms. */\nconst STATS_WIDTH = 4;\nconst COUNT = 0;\nconst SUM = 1;\nconst MIN = 2;\nconst MAX = 3;\n\n/** One sampling row is [countdown, period]. */\nconst SAMPLING_WIDTH = 2;\n\n/** The period lives in an Int32Array, so this is as large as it gets. */\nconst MAX_PERIOD = 2 ** 31 - 1;\n\n/** One span-stack frame is [start, child time, slot]. */\nconst FRAME_WIDTH = 3;\n\n/** One entry in the recent-span ring is [slot, start, end]. */\nconst SPAN_WIDTH = 3;\n\n/** Global key for the core, one per library version. */\nconst CORE_KEY = Symbol.for(`${PROFILER_GLOBAL_KEY}@${TELEMETRY_SDK_VERSION}`);\n\n/** Handed out for names we reject. Never reads the clock. */\nconst NOOP_PROBE: Probe = {\n begin: () => -1,\n end: () => undefined,\n endAfterPaint: () => undefined,\n record: () => undefined,\n};\n\n/** Ends a span that was waiting on a paint or a promise. */\ntype Settle = (token: number, now: number) => void;\n\n/** The page globals the paint wait needs. Workers and Node.js have none of them. */\ninterface PaintScope {\n requestAnimationFrame?: (callback: () => void) => unknown;\n document?: {\n /** \"hidden\" while the page isn't painting. */\n visibilityState?: string;\n addEventListener: (type: string, listener: () => void) => void;\n };\n}\n\n/** What the runtime hands the core on attach. */\nexport interface ProfilerSink {\n /** Max number of probes (profiler.maxProbes). */\n capacity: number;\n /** Interval length in ms. */\n intervalMs(): number;\n /**\n * Builds and sends the record for one point.\n * @param name Metric name.\n * @param attributes Record attributes for the point.\n * @param fields Metric fields for the point.\n */\n emit(name: string, attributes: MetricAttributes, fields: Record<string, unknown>): void;\n /** The runtime's diagnostics reporter. */\n diagnostics: Diagnostics;\n /** False while the runtime can't accept records. */\n ready(): boolean;\n /**\n * Leaves a breadcrumb for a span that ran longer than its probe's threshold.\n * @param name Probe name.\n * @param ms Span duration in ms.\n */\n outlier(name: string, ms: number): void;\n}\n\n/** Probe options after validation. */\ninterface ProbeRules {\n /** Measure one span in every `period`. */\n period: number;\n /** Spans longer than this (ms) leave a breadcrumb. Infinity means never. */\n threshold: number;\n /** True for async probes, whose spans stay off the span stack. */\n loose: boolean;\n}\n\n/** A registered probe. */\ninterface ProbeEntry {\n /** The handle. Every probe() call with the same name returns this one. */\n probe: Probe;\n /** The probe's row in the typed arrays: registration index + 1. */\n slot: number;\n /** Sampling period, from the options passed the first time the name was seen. */\n period: number;\n /** Ends one of this probe's spans that isn't on the span stack. */\n settle: Settle;\n /** Pops a span off the stack without ending it. It ends later. */\n leave: (token: number) => void;\n}\n\n/** Holds the probe names and all their timings. There is one core per library version. */\nexport class ProfilerCore implements Profiler {\n /** Probes by name. Names are never removed, so insertion order is slot order. */\n private readonly registry = new Map<string, ProbeEntry>();\n\n /** Rows in use. 0 while detached, so one compare covers both \"off\" and \"over the limit\". */\n private limit = 0;\n\n // The typed arrays start empty rather than null. Hypothesis (not measured): a single field\n // type keeps V8's inline caches on the hot path monomorphic.\n\n /**\n * Count, sum, min and max per slot. A row's four values sit in 32 adjacent bytes, so an add\n * should touch a single cache line (hypothesis, not measured).\n */\n private stats = new Float64Array(0);\n\n /** Bucket counts, PROFILE_BUCKETS per slot. */\n private hist = new Uint32Array(0);\n\n /** Self-time bucket counts per slot. Spans without a stack frame don't add to it. */\n private selfHist = new Uint32Array(0);\n\n /** Frames for the open, nested spans. Each frame adds up the time of the spans inside it. */\n private readonly stack = new Float64Array(PROFILER_STACK_DEPTH * FRAME_WIDTH);\n\n /** Number of frames in use. */\n private depth = 0;\n\n /** Recent spans, for linking to long animation frames. Empty until link() turns it on. */\n private ring = new Float64Array(0);\n\n /** Next write offset in the ring. */\n private ringAt = 0;\n\n /** Shortest span (ms) that goes into the ring. Infinity keeps the ring off. */\n private linkMs = Infinity;\n\n /** Spans waiting for the next paint. */\n private painted: ((now: number) => void)[] = [];\n\n /** Gets us a task right after the paint. Created on the first wait. */\n private channel: MessageChannel | undefined;\n\n /** Countdown and period per slot. */\n private sampling = new Int32Array(0);\n\n /**\n * Clock value at the last detach() or reset(). Spans that started at or before it are dropped.\n * \"At\" matters: on a coarse clock, a span started in the reset's tick reads the same value.\n */\n private floor = -1;\n\n /** Timer for the current interval. It only runs while there is data waiting. */\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n /** When the interval's first value arrived, in epoch ms. */\n private startedAt = 0;\n\n /** Invalid tokens seen while on, since the last collect(). end() itself reports nothing. */\n private badTokens = 0;\n\n /** Cost of one sampled begin()/end() pair, in ns. */\n private overhead: number | undefined = undefined;\n\n /** Set once calibration has run, so a too-coarse clock only blocks us once. */\n private calibrated = false;\n\n /** The runtime's sink. Null while detached. */\n private sink: ProfilerSink | null = null;\n\n /** True once this attach has reported a probe over the limit. */\n private reported = false;\n\n /** True while a limit report the throttle dropped is waiting for the next collect. */\n private limitDue = false;\n\n /**\n * Returns the probe for a name. Never throws into the app.\n * @param name Probe name. A JavaScript caller can pass anything.\n * @param options Probe options. Only the options from the first call for a name count.\n * @param diagnostics The current runtime's diagnostics. Without a runtime, nothing is reported.\n * @returns The probe, or a no-op probe if the name is rejected.\n */\n probe(name: string, options?: ProbeOptions, diagnostics?: Diagnostics): Probe {\n // Only look at the type. String(name) would run a hostile toString().\n if (typeof name !== \"string\" || name === \"\") {\n diagnostics?.report(\n \"config.invalid\",\n \"The probe name must be a string that is not empty. The probe does nothing.\",\n );\n return NOOP_PROBE;\n }\n\n const known = this.registry.get(name);\n if (known) {\n return known.probe;\n }\n\n if (this.registry.size >= PROFILER_PROBE_LIMIT) {\n diagnostics?.report(\n \"config.invalid\",\n `The profiler keeps at most ${String(PROFILER_PROBE_LIMIT)} probe names. The probe ${name} does nothing.`,\n );\n return NOOP_PROBE;\n }\n\n const rules = this.rulesOf(name, options, diagnostics);\n const { period } = rules;\n\n // An options getter can register probes behind our back. Re-check, or two names share a slot.\n if (this.registry.has(name) || this.registry.size >= PROFILER_PROBE_LIMIT) {\n return this.probe(name, undefined, diagnostics);\n }\n\n const slot = this.registry.size + 1;\n const entry = this.makeProbe(name, slot, rules);\n const { probe } = entry;\n this.registry.set(name, entry);\n\n if (slot < this.limit) {\n this.prime(slot, period);\n } else if (this.limit > 0 && !this.reported) {\n this.reported = true;\n // The limit belongs to the attached runtime, so report through it even when the caller\n // passed no diagnostics.\n const sent = this.sink?.diagnostics.report(\n \"config.invalid\",\n `The probe ${name} is above the profiler.maxProbes limit of ${String(this.limit - 1)}. The probe does nothing.`,\n );\n\n if (sent === false) {\n this.limitDue = true;\n }\n }\n\n return probe;\n }\n\n /**\n * Calls a function and times it. If the result is a thenable, the span ends when it settles.\n * The caller only ever sees errors from its own function.\n * @param name Probe name.\n * @param fn The app's function.\n * @param diagnostics The current runtime's diagnostics, if there is one.\n * @returns Whatever fn returned, or the result of its then() call.\n */\n time<T>(name: string, fn: () => T, diagnostics?: Diagnostics): T {\n this.probe(name, undefined, diagnostics);\n\n // A rejected name has no entry. Just run the function without a span.\n const entry = this.registry.get(name);\n const token = entry ? entry.probe.begin() : -1;\n let waits = false;\n\n try {\n const result = fn();\n\n if (entry && token >= 0) {\n try {\n const then = (result as { then?: unknown } | null | undefined)?.then;\n\n if (typeof then === \"function\") {\n const done = (): void => {\n entry.settle(token, performance.now());\n };\n\n waits = true;\n entry.leave(token);\n\n // Hand back the chained result, so a rejection has exactly one owner: the caller.\n return (then as PromiseLike<unknown>[\"then\"]).call(\n result,\n (value) => {\n done();\n return value;\n },\n (error: unknown) => {\n done();\n throw error;\n },\n ) as T;\n }\n } catch (error) {\n waits = false;\n diagnostics?.report(\n \"capture.record_failed\",\n `The library could not read what the function of the probe ${name} returned. The span ends now.`,\n undefined,\n error,\n );\n }\n }\n\n return result;\n } finally {\n if (!waits) {\n entry?.probe.end(token);\n }\n }\n }\n\n /**\n * Turns the recent-span ring on or off. The frame phases capture reads from it.\n * @param minMs Shortest span (ms) to keep. Infinity turns the ring off.\n */\n link(minMs: number): void {\n this.linkMs = minMs;\n\n if (minMs < Infinity && this.ring.length === 0) {\n this.ring = new Float64Array(PROFILER_RING_SPANS * SPAN_WIDTH);\n }\n }\n\n /**\n * Finds the probes that had a recent span inside a time range.\n * @param from Range start, as a performance.now() value.\n * @param to Range end.\n * @returns The probe names, without duplicates.\n */\n linked(from: number, to: number): string[] {\n const { ring } = this;\n const names = [...this.registry.keys()];\n const found = new Set<string>();\n\n for (let at = 0; at < ring.length; at += SPAN_WIDTH) {\n // Slot 0 means an empty row or a calibration span.\n if (ring[at] > 0 && ring[at + 1] < to && ring[at + 2] > from) {\n found.add(names[ring[at] - 1]);\n }\n }\n\n return [...found];\n }\n\n /**\n * Turns the profiler on with a runtime's sink. Calling it again swaps the sink.\n * @param sink The runtime's sink.\n */\n attach(sink: ProfilerSink): void {\n const limit = sink.capacity + 1;\n this.sink = sink;\n\n // Re-attaching with the same capacity keeps the data.\n if (this.stats.length !== limit * STATS_WIDTH) {\n this.stats = new Float64Array(limit * STATS_WIDTH);\n this.hist = new Uint32Array(limit * PROFILE_BUCKETS);\n this.selfHist = new Uint32Array(limit * PROFILE_BUCKETS);\n this.sampling = new Int32Array(limit * SAMPLING_WIDTH);\n }\n\n this.limit = limit;\n this.reported = false;\n this.limitDue = false;\n this.prime(0, 1);\n for (const entry of this.registry.values()) {\n if (entry.slot < limit) {\n this.prime(entry.slot, entry.period);\n }\n }\n\n if (this.registry.size > sink.capacity) {\n this.reported = true;\n this.reportLimit(sink);\n }\n }\n\n /** Turns the profiler off and drops the data. The runtime calls collect(false) first. */\n detach(): void {\n this.limit = 0;\n this.sink = null;\n this.clearTimer();\n this.clear();\n }\n\n /**\n * Sends one summary record per probe that has data, then starts a new interval. Does nothing\n * while the sink isn't ready.\n * @param timed True when called from the interval timer. Only a timed collect calibrates.\n */\n collect(timed: boolean): void {\n const { sink } = this;\n\n // A runtime that isn't ready would refuse the records, so keep the data and the timer for a\n // later collect. Zeroing the slots here would lose those points.\n if (!sink?.ready()) {\n return;\n }\n\n // The diagnostics throttle swallowed this attach's limit report. Try again, otherwise the\n // app never hears that some of its probes do nothing.\n if (this.limitDue) {\n this.reportLimit(sink);\n }\n\n this.clearTimer();\n\n // Calibration blocks the thread for 2-3 ms (longer on a too-coarse clock), so flush() and\n // the exit path skip it.\n if (timed && !this.calibrated && this.hasData()) {\n this.calibrate();\n }\n\n const start = `${String(this.startedAt)}000000`;\n for (const [name, entry] of this.registry) {\n // Probes over the limit have no row. After a detach() from inside an emit, none do.\n if (entry.slot < this.limit && this.stats[entry.slot * STATS_WIDTH + COUNT] > 0) {\n this.emitSlot(sink, name, entry, start);\n }\n }\n\n if (this.badTokens > 0) {\n sink.diagnostics.count(\"record.dropped_malformed\", this.badTokens);\n this.badTokens = 0;\n }\n }\n\n /** Drops the interval's data. The profiler stays on. */\n reset(): void {\n this.clearTimer();\n this.badTokens = 0;\n this.clear();\n }\n\n /** Drops the data and any open spans. Spans started at or before this call add nothing. */\n private clear(): void {\n this.floor = performance.now();\n this.depth = 0;\n this.stats.fill(0);\n this.hist.fill(0);\n this.selfHist.fill(0);\n this.ring.fill(0);\n }\n\n /**\n * Reads the options for a new probe. Never throws into the app.\n * @param name Probe name.\n * @param options Options from the app.\n * @param diagnostics The current runtime's diagnostics, if there is one.\n * @returns The rules. Any invalid option falls back to its default.\n */\n private rulesOf(\n name: string,\n options: ProbeOptions | undefined,\n diagnostics: Diagnostics | undefined,\n ): ProbeRules {\n const rules: ProbeRules = { period: 1, threshold: Infinity, loose: false };\n let period: unknown;\n let threshold: unknown;\n let loose: unknown;\n\n // A getter or a Proxy trap on the options can throw.\n try {\n period = options?.sampleEvery;\n threshold = options?.slowMs;\n loose = options?.async;\n } catch (error) {\n diagnostics?.report(\n \"config.invalid\",\n `The library could not read the options of the probe ${name}. The library uses the defaults.`,\n undefined,\n error,\n );\n return rules;\n }\n\n if (\n typeof period === \"number\" &&\n Number.isInteger(period) &&\n period >= 1 &&\n period <= MAX_PERIOD\n ) {\n rules.period = period;\n } else if (period !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The sampleEvery option of the probe ${name} must be an integer from 1 to ${String(MAX_PERIOD)}. The library uses 1.`,\n );\n }\n\n if (typeof threshold === \"number\" && threshold >= 0 && threshold < Infinity) {\n rules.threshold = threshold;\n } else if (threshold !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The slowMs option of the probe ${name} must be a finite number, 0 or larger. The probe adds no breadcrumb.`,\n );\n }\n\n if (typeof loose === \"boolean\") {\n rules.loose = loose;\n } else if (loose !== undefined) {\n diagnostics?.report(\n \"config.invalid\",\n `The async option of the probe ${name} must be a boolean. The library uses false.`,\n );\n }\n\n return rules;\n }\n\n /**\n * Builds a probe's closures, once per probe, so destructured members still work.\n * @param name Probe name.\n * @param slot The probe's row.\n * @param rules Validated probe options.\n * @returns The registry entry, including the probe.\n */\n private makeProbe(name: string, slot: number, rules: ProbeRules): ProbeEntry {\n const { period, threshold, loose } = rules;\n\n // Records one duration, plus a breadcrumb if it is over the probe's threshold.\n const put = (ms: number): void => {\n this.add(slot, ms);\n\n if (ms > threshold) {\n this.sink?.outlier(name, ms);\n }\n };\n\n // Drop the span if we're off, or if it started at or before a detach() or reset().\n const settle: Settle = (token, now) => {\n if (slot < this.limit && token > this.floor) {\n put(now - token);\n }\n };\n\n const leave = (token: number): void => {\n if (!loose) {\n this.pop(slot, token, performance.now());\n }\n };\n\n const end = (token: number): void => {\n // Type check first, so the compare can never run a hostile valueOf().\n const now = typeof token === \"number\" && token >= 0 ? performance.now() : -1;\n if (now < 0) {\n // -1 means begin() didn't measure this span. Other bad tokens only count while we're on.\n if (token !== -1 && slot < this.limit) {\n this.badTokens++;\n }\n return;\n }\n\n if (loose) {\n settle(token, now);\n return;\n }\n\n // Drop the span if we're off, or if it started at or before a detach() or reset().\n if (slot >= this.limit || token <= this.floor) {\n return;\n }\n\n const self = this.pop(slot, token, now);\n put(now - token);\n\n // No frame means no self time: the frame was lost to a reset or to a full stack.\n if (self >= 0) {\n this.selfHist[slot * PROFILE_BUCKETS + bucketOf(Math.ceil(self * 1000))]++;\n }\n };\n\n const probe: Probe = {\n begin: () => {\n // Off, over the limit or sampled out: don't even read the clock.\n if (slot >= this.limit || !this.sampled(slot)) {\n return -1;\n }\n\n const now = performance.now();\n if (!loose) {\n this.push(slot, now);\n }\n\n return now;\n },\n end,\n endAfterPaint: (token) => {\n const waits =\n typeof token === \"number\" &&\n token >= 0 &&\n slot < this.limit &&\n this.afterPaint((now) => {\n settle(token, now);\n });\n\n // Bad token, probe off, or a page that isn't painting: end right away.\n if (!waits) {\n end(token);\n return;\n }\n\n leave(token);\n },\n record: (durationMs) => {\n if (slot >= this.limit) {\n return;\n }\n\n if (typeof durationMs !== \"number\" || !Number.isFinite(durationMs) || durationMs < 0) {\n this.sink?.diagnostics.report(\n \"record.dropped_malformed\",\n `The duration of the probe ${name} is not valid. The library dropped it.`,\n { [PROFILE_KEYS.probe]: name },\n );\n return;\n }\n\n if (this.sampled(slot)) {\n put(durationMs);\n }\n },\n };\n\n return { probe, slot, period, settle, leave };\n }\n\n /**\n * Pushes a frame for a new span.\n * @param slot The probe's row.\n * @param now Span start.\n */\n private push(slot: number, now: number): void {\n const { stack } = this;\n\n // A full stack is full of frames whose spans never got an end(). Drop them, or no later\n // span gets a self time.\n if (this.depth === PROFILER_STACK_DEPTH) {\n this.depth = 0;\n }\n\n const at = this.depth++ * FRAME_WIDTH;\n stack[at] = now;\n stack[at + 1] = 0;\n stack[at + 2] = slot;\n }\n\n /**\n * Pops a span's frame, along with any frames above it, and adds the span's duration to the\n * child time of the frame below.\n * @param slot The probe's row.\n * @param token Span start.\n * @param now Span end, or the time the span leaves the stack.\n * @returns Self time in ms, or -1 if the span had no frame.\n */\n private pop(slot: number, token: number, now: number): number {\n const { stack } = this;\n const ms = now - token;\n let child = 0;\n\n for (let at = (this.depth - 1) * FRAME_WIDTH; at >= 0; at -= FRAME_WIDTH) {\n // Any frame above ours is a span that never got an end(). Its child time is ours.\n child += stack[at + 1];\n\n if (stack[at] === token && stack[at + 2] === slot) {\n this.depth = at / FRAME_WIDTH;\n\n if (at > 0) {\n stack[at - FRAME_WIDTH + 1] += ms;\n }\n\n if (ms >= this.linkMs) {\n const { ring, ringAt } = this;\n ring[ringAt] = slot;\n ring[ringAt + 1] = token;\n ring[ringAt + 2] = now;\n this.ringAt = (ringAt + SPAN_WIDTH) % ring.length;\n }\n\n return Math.max(ms - child, 0);\n }\n }\n\n return -1;\n }\n\n /**\n * Runs a function in the first task after the next paint.\n * @param done Called with the time after the paint.\n * @returns False where there is no frame callback, or when the page is hidden.\n */\n private afterPaint(done: (now: number) => void): boolean {\n const { requestAnimationFrame: frame, document: page } = globalThis as PaintScope;\n\n if (\n typeof frame !== \"function\" ||\n typeof MessageChannel === \"undefined\" ||\n page?.visibilityState === \"hidden\"\n ) {\n return false;\n }\n\n if (!this.channel) {\n const drain = (): void => {\n const now = performance.now();\n const waiting = this.painted;\n this.painted = [];\n\n for (const end of waiting) {\n end(now);\n }\n };\n\n this.channel = new MessageChannel();\n this.channel.port1.onmessage = drain;\n\n // A hidden page gets no frame callbacks. End the spans now, or they include the hidden time.\n page?.addEventListener(\"visibilitychange\", () => {\n if (page.visibilityState === \"hidden\") {\n drain();\n }\n });\n }\n\n // rAF callbacks run before the paint. A task posted from one runs after it.\n if (this.painted.push(done) === 1) {\n frame(() => {\n this.channel?.port2.postMessage(0);\n });\n }\n\n return true;\n }\n\n /**\n * Writes a slot's sampling row so the next span gets measured.\n * @param slot The probe's row.\n * @param period Sampling period.\n */\n private prime(slot: number, period: number): void {\n const at = slot * SAMPLING_WIDTH;\n this.sampling[at] = 1;\n this.sampling[at + 1] = period;\n }\n\n /**\n * Counts down a slot's sampling. A countdown gives an exact rate, which Math.random() wouldn't.\n * @param slot The probe's row.\n * @returns True if this span should be measured.\n */\n private sampled(slot: number): boolean {\n const at = slot * SAMPLING_WIDTH;\n const left = this.sampling[at] - 1;\n\n if (left > 0) {\n this.sampling[at] = left;\n return false;\n }\n\n this.sampling[at] = this.sampling[at + 1];\n return true;\n }\n\n /**\n * Adds one duration to a slot. This is the hot path: no Map lookup, no try.\n * @param slot The probe's row.\n * @param ms Duration in ms.\n */\n private add(slot: number, ms: number): void {\n // A forged token gives a negative duration. A broken clock gives NaN or Infinity.\n if (!(ms >= 0) || ms === Infinity) {\n this.badTokens++;\n return;\n }\n\n const { stats } = this;\n const row = slot * STATS_WIDTH;\n const count = stats[row + COUNT];\n stats[row + COUNT] = count + 1;\n stats[row + SUM] += ms;\n\n if (count === 0 || ms < stats[row + MIN]) {\n stats[row + MIN] = ms;\n }\n\n if (count === 0 || ms > stats[row + MAX]) {\n stats[row + MAX] = ms;\n }\n\n // Buckets include their upper bound, so round up or the value lands one bucket too low.\n this.hist[slot * PROFILE_BUCKETS + bucketOf(Math.ceil(ms * 1000))]++;\n\n // Slot 0 is the calibration slot, and calibration must not start an interval.\n if (this.timer === null && slot > 0 && this.sink !== null) {\n this.startedAt = Date.now();\n this.wait(this.sink);\n }\n }\n\n /**\n * Starts the interval timer, unref'd so a pending timer doesn't keep Node.js alive.\n * @param sink The runtime's sink.\n */\n private wait(sink: ProfilerSink): void {\n this.timer = setTimeout(() => {\n this.tick();\n }, sink.intervalMs());\n unrefTimer(this.timer);\n }\n\n /** Collects at the end of an interval, or waits another one if the runtime isn't ready. */\n private tick(): void {\n const { sink } = this;\n\n if (sink !== null && !sink.ready()) {\n this.wait(sink);\n return;\n }\n\n this.collect(true);\n }\n\n /** Stops the interval timer. */\n private clearTimer(): void {\n if (this.timer !== null) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n /**\n * Reports that there are more probes than the limit allows. If the throttle drops the report,\n * the next collect tries again.\n * @param sink The runtime's sink.\n */\n private reportLimit(sink: ProfilerSink): void {\n // Clear the flag first, so a handler that collects can't kick off a second report.\n this.limitDue = false;\n const sent = sink.diagnostics.report(\n \"config.invalid\",\n `The app registered ${String(this.registry.size)} probes. The profiler.maxProbes limit is ${String(sink.capacity)}. The probes above the limit do nothing.`,\n );\n\n if (!sent) {\n this.limitDue = true;\n }\n }\n\n /**\n * Checks whether any probe recorded a value in this interval.\n * @returns True if a slot above 0 has a non-zero count.\n */\n private hasData(): boolean {\n for (let slot = 1; slot < this.limit; slot++) {\n if (this.stats[slot * STATS_WIDTH + COUNT] > 0) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sends one slot's summary record and zeroes the slot. The sampling countdown is left alone.\n * @param sink The runtime's sink.\n * @param name Probe name.\n * @param entry The probe's registry entry.\n * @param start Interval start, in Unix nanoseconds.\n */\n private emitSlot(sink: ProfilerSink, name: string, entry: ProbeEntry, start: string): void {\n const { stats, hist } = this;\n const row = entry.slot * STATS_WIDTH;\n const base = entry.slot * PROFILE_BUCKETS;\n const count = stats[row + COUNT];\n const min = stats[row + MIN];\n const max = stats[row + MAX];\n\n // A bucket bound can be higher than the exact max, so clamp every percentile to [min, max].\n const quantile = (q: number): number =>\n Math.min(Math.max(percentileOf(hist, base, count, q) / 1000, min), max);\n\n const attributes: MetricAttributes = {\n [PROFILE_KEYS.probe]: name,\n [PROFILE_KEYS.sampleEvery]: entry.period,\n [PROFILE_KEYS.p50]: quantile(0.5),\n [PROFILE_KEYS.p90]: quantile(0.9),\n [PROFILE_KEYS.p99]: quantile(0.99),\n };\n if (this.overhead !== undefined) {\n attributes[PROFILE_KEYS.overhead] = this.overhead;\n }\n\n // Count the self times here, at collect, so the hot path has no second counter to write.\n const { selfHist } = this;\n let selfCount = 0;\n for (let at = base; at < base + PROFILE_BUCKETS; at++) {\n selfCount += selfHist[at];\n }\n\n if (selfCount > 0) {\n attributes[PROFILE_KEYS.selfP99] = Math.min(\n percentileOf(selfHist, base, selfCount, 0.99) / 1000,\n max,\n );\n }\n\n const { bounds, counts } = pointBuckets(hist, base);\n const fields: Record<string, unknown> = {\n \"metric.name\": PROFILE_METRIC_NAME,\n \"metric.unit\": \"ms\",\n \"metric.type\": \"histogram\",\n [METRIC_KEYS.start]: start,\n [METRIC_KEYS.attributeKeys]: [PROFILE_KEYS.probe, PROFILE_KEYS.sampleEvery],\n [METRIC_KEYS.count]: count,\n [METRIC_KEYS.sum]: stats[row + SUM],\n [METRIC_KEYS.min]: min,\n [METRIC_KEYS.max]: max,\n [METRIC_KEYS.bounds]: bounds,\n [METRIC_KEYS.buckets]: counts,\n };\n\n // Zero before emitting: an app processor can call end() from inside the emit.\n stats.fill(0, row, row + STATS_WIDTH);\n hist.fill(0, base, base + PROFILE_BUCKETS);\n selfHist.fill(0, base, base + PROFILE_BUCKETS);\n sink.emit(PROFILE_METRIC_NAME, attributes, fields);\n }\n\n /**\n * Measures what one sampled begin()/end() pair costs, on slot 0. Runs once. If the clock never\n * shows an edge or never ticks, no value is set.\n */\n private calibrate(): void {\n this.calibrated = true;\n const { probe } = this.makeProbe(\"\", 0, { period: 1, threshold: Infinity, loose: false });\n\n // Browsers round performance.now() to 5 us, 100 us or 1 ms. Measure from clock edge to clock\n // edge: a window that isn't aligned to an edge can be off by up to one tick.\n const first = performance.now();\n let edge = first;\n for (let reads = 0; reads < PROFILER_CALIBRATION_PAIRS && edge === first; reads++) {\n edge = performance.now();\n }\n\n // No edge within the read limit, so the clock is frozen or too coarse. Without a start edge\n // the result would come out too large.\n if (edge === first) {\n return;\n }\n\n // begin()'s token is the clock reading, so the loop doesn't need a third clock read.\n const until = edge + PROFILER_CALIBRATION_MS;\n let tick = edge;\n let pairsAtTick = 0;\n for (let pairs = 0; pairs < PROFILER_CALIBRATION_PAIRS; pairs++) {\n const token = probe.begin();\n probe.end(token);\n\n if (token !== tick) {\n tick = token;\n pairsAtTick = pairs;\n\n if (token >= until) {\n break;\n }\n }\n }\n\n // Whole nanoseconds. Hypothesis: the noise in a single 2 ms run is more than 1 ns anyway.\n if (pairsAtTick > 0) {\n this.overhead = Math.round(((tick - edge) * 1e6) / pairsAtTick);\n }\n }\n}\n\n/**\n * Returns the profiler core for this library version. Two copies of the same version share it.\n * @returns The core.\n */\nexport function profilerCore(): ProfilerCore {\n // Each copy has its own class, so instanceof fails across copies. Cast structurally instead.\n const store = globalThis as Record<symbol, unknown>;\n const pinned = store[CORE_KEY] as ProfilerCore | undefined;\n if (pinned) {\n return pinned;\n }\n\n const core = new ProfilerCore();\n store[CORE_KEY] = core;\n return core;\n}\n"],"mappings":";;;;AAaA,IAAMU,IAAY,IAGZC,IAAWD,IAAY;AAO7B,SAAgBE,EAAS,GAAoB;CAG3C,IAAMC,IAAQ,KAAK,IAAIC,GAAIP,CAAc;CAEzC,IAAIM,IAAQH,GACV,OAAOG;CAKT,IAAME,IAAQ,KAAK,KAAK,MAAMF,CAAK,IAAA;CACnC,OAASE,IAAQ,KAAA,IAA4BF,MAAUE,IAASJ;AAClE;AAOA,SAAgBK,EAAQ,GAAuB;CAC7C,IAAIC,IAAQP,GACV,OAAOO;CAIT,IAAMF,KAASE,MAAA,KAA8B;CAC7C,QAASP,KAAaO,IAAQN,MAAcI,MAAU,KAAKA,KAAS;AACtE;AAUA,SAAgBG,EAAa,GAAsB,GAAc,GAAe,GAAmB;CAEjG,IAAMC,IAAO,KAAK,IAAI,GAAG,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KAAK,GAAG1E,GAAMA,IAAA,GAAsB,GAC7C6C,EAAK,KAAKlE,GAAqB6F,GAAYG,CAAM;CACnD;CAMA,YAA0B;EACxB,KAAK,aAAa;EAClB,IAAM,EAAE,aAAU,KAAK,UAAU,IAAI,GAAG;GAAE,QAAQ;GAAG,WAAW;GAAU,OAAO;EAAM,CAAC,GAIlFzE,IAAQ,YAAY,IAAI,GAC1B2E,IAAO3E;EACX,KAAK,IAAI4E,IAAQ,GAAGA,IAAA,OAAsCD,MAAS3E,GAAO,KACxE,IAAO,YAAY,IAAI;EAKzB,IAAI2E,MAAS3E,GACX;EAIF,IAAM6E,IAAQF,IAAA,GACVG,IAAOH,GACPI,IAAc;EAClB,KAAK,IAAIC,IAAQ,GAAGA,IAAQxG,GAA4B,KAAS;GAC/D,IAAMoD,IAAQD,EAAM,MAAM;GAG1B,IAFAA,EAAM,IAAIC,CAAK,GAEXA,MAAUkD,MACZ,IAAOlD,GACP,IAAcoD,GAEVpD,KAASiD,IACX;EAGN;EAGA,AAAIE,IAAc,MAChB,KAAK,WAAW,KAAK,OAAQD,IAAOH,KAAQ,MAAOI,CAAW;CAElE;AACF;AAMA,SAAgBE,IAA6B;CAE3C,IAAMC,IAAQ,YACRC,IAASD,EAAMlE;CACrB,IAAImE,GACF,OAAOA;CAGT,IAAMC,IAAO,IAAIlE,EAAa;CAE9B,OADA,EAAMF,KAAYoE,GACXA;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=profiler-
|
|
1
|
+
const e=require("./constants-NtiQDWL_.cjs"),t=require("./unref-CU9Nyz_9.cjs"),n=require("./defineProperty-X1c4tIPD.cjs");var r=16,i=r-1;function a(t){let n=Math.min(t,e.rn);if(n<r)return n;let a=31-Math.clz32(n)-4;return a+1<<4|n>>>a&i}function o(e){if(e<r)return e;let t=(e>>>4)-1;return(r+(e&i)<<t)+(1<<t)-1}function s(e,t,n,r){let i=Math.max(1,Math.ceil(r*n)),a=0;for(let n=0;n<368;n++)if(a+=e[t+n],a>=i)return o(n);return o(367)}function c(e,t){let n=0;for(;n<368&&e[t+n]===0;)n++;if(n===368)return{bounds:[],counts:[0]};let r=367;for(;e[t+r]===0;)r--;let i=0;for(;(r>>i)-(n>>i)+1>100;)i++;let a=n>>i,s=r>>i,c=Array.from({length:s-a+1},()=>0);for(let o=n;o<=r;o++)c[(o>>i)-a]+=e[t+o];return{bounds:Array.from({length:s-a},(e,t)=>o((a+t+1<<i)-1)/1e3),counts:c}}var l=4,u=0,d=1,f=2,p=3,m=2,h=2**31-1,g=3,_=3,v=Symbol.for(`${e.Qt}@${e.ir}`),y={begin:()=>-1,end:()=>void 0,endAfterPaint:()=>void 0,record:()=>void 0},b=class{constructor(){n.t(this,`registry`,new Map),n.t(this,`limit`,0),n.t(this,`stats`,new Float64Array),n.t(this,`hist`,new Uint32Array),n.t(this,`selfHist`,new Uint32Array),n.t(this,`stack`,new Float64Array(32*g)),n.t(this,`depth`,0),n.t(this,`ring`,new Float64Array),n.t(this,`ringAt`,0),n.t(this,`linkMs`,1/0),n.t(this,`painted`,[]),n.t(this,`channel`,void 0),n.t(this,`sampling`,new Int32Array),n.t(this,`floor`,-1),n.t(this,`timer`,null),n.t(this,`startedAt`,0),n.t(this,`badTokens`,0),n.t(this,`overhead`,void 0),n.t(this,`calibrated`,!1),n.t(this,`sink`,null),n.t(this,`reported`,!1),n.t(this,`limitDue`,!1)}probe(t,n,r){if(typeof t!=`string`||t===``)return r?.report(`config.invalid`,`The probe name must be a string that is not empty. The probe does nothing.`),y;let i=this.registry.get(t);if(i)return i.probe;if(this.registry.size>=1024)return r?.report(`config.invalid`,`The profiler keeps at most ${String(e.$t)} probe names. The probe ${t} does nothing.`),y;let a=this.rulesOf(t,n,r),{period:o}=a;if(this.registry.has(t)||this.registry.size>=1024)return this.probe(t,void 0,r);let s=this.registry.size+1,c=this.makeProbe(t,s,a),{probe:l}=c;return this.registry.set(t,c),s<this.limit?this.prime(s,o):this.limit>0&&!this.reported&&(this.reported=!0,this.sink?.diagnostics.report(`config.invalid`,`The probe ${t} is above the profiler.maxProbes limit of ${String(this.limit-1)}. The probe does nothing.`)===!1&&(this.limitDue=!0)),l}time(e,t,n){this.probe(e,void 0,n);let r=this.registry.get(e),i=r?r.probe.begin():-1,a=!1;try{let o=t();if(r&&i>=0)try{let e=o?.then;if(typeof e==`function`){let t=()=>{r.settle(i,performance.now())};return a=!0,r.leave(i),e.call(o,e=>(t(),e),e=>{throw t(),e})}}catch(t){a=!1,n?.report(`capture.record_failed`,`The library could not read what the function of the probe ${e} returned. The span ends now.`,void 0,t)}return o}finally{a||r?.probe.end(i)}}link(e){this.linkMs=e,e<1/0&&this.ring.length===0&&(this.ring=new Float64Array(256*_))}linked(e,t){let{ring:n}=this,r=[...this.registry.keys()],i=new Set;for(let a=0;a<n.length;a+=_)n[a]>0&&n[a+1]<t&&n[a+2]>e&&i.add(r[n[a]-1]);return[...i]}attach(e){let t=e.capacity+1;this.sink=e,this.stats.length!==t*l&&(this.stats=new Float64Array(t*l),this.hist=new Uint32Array(t*368),this.selfHist=new Uint32Array(t*368),this.sampling=new Int32Array(t*m)),this.limit=t,this.reported=!1,this.limitDue=!1,this.prime(0,1);for(let e of this.registry.values())e.slot<t&&this.prime(e.slot,e.period);this.registry.size>e.capacity&&(this.reported=!0,this.reportLimit(e))}detach(){this.limit=0,this.sink=null,this.clearTimer(),this.clear()}collect(e){let{sink:t}=this;if(!t?.ready())return;this.limitDue&&this.reportLimit(t),this.clearTimer(),e&&!this.calibrated&&this.hasData()&&this.calibrate();let n=`${String(this.startedAt)}000000`;for(let[e,r]of this.registry)r.slot<this.limit&&this.stats[r.slot*l+u]>0&&this.emitSlot(t,e,r,n);this.badTokens>0&&(t.diagnostics.count(`record.dropped_malformed`,this.badTokens),this.badTokens=0)}reset(){this.clearTimer(),this.badTokens=0,this.clear()}clear(){this.floor=performance.now(),this.depth=0,this.stats.fill(0),this.hist.fill(0),this.selfHist.fill(0),this.ring.fill(0)}rulesOf(e,t,n){let r={period:1,threshold:1/0,loose:!1},i,a,o;try{i=t?.sampleEvery,a=t?.slowMs,o=t?.async}catch(t){return n?.report(`config.invalid`,`The library could not read the options of the probe ${e}. The library uses the defaults.`,void 0,t),r}return typeof i==`number`&&Number.isInteger(i)&&i>=1&&i<=h?r.period=i:i!==void 0&&n?.report(`config.invalid`,`The sampleEvery option of the probe ${e} must be an integer from 1 to ${String(h)}. The library uses 1.`),typeof a==`number`&&a>=0&&a<1/0?r.threshold=a:a!==void 0&&n?.report(`config.invalid`,`The slowMs option of the probe ${e} must be a finite number, 0 or larger. The probe adds no breadcrumb.`),typeof o==`boolean`?r.loose=o:o!==void 0&&n?.report(`config.invalid`,`The async option of the probe ${e} must be a boolean. The library uses false.`),r}makeProbe(t,n,r){let{period:i,threshold:o,loose:s}=r,c=e=>{this.add(n,e),e>o&&this.sink?.outlier(t,e)},l=(e,t)=>{n<this.limit&&e>this.floor&&c(t-e)},u=e=>{s||this.pop(n,e,performance.now())},d=e=>{let t=typeof e==`number`&&e>=0?performance.now():-1;if(t<0){e!==-1&&n<this.limit&&this.badTokens++;return}if(s){l(e,t);return}if(n>=this.limit||e<=this.floor)return;let r=this.pop(n,e,t);c(t-e),r>=0&&this.selfHist[n*368+a(Math.ceil(r*1e3))]++};return{probe:{begin:()=>{if(n>=this.limit||!this.sampled(n))return-1;let e=performance.now();return s||this.push(n,e),e},end:d,endAfterPaint:e=>{typeof e==`number`&&e>=0&&n<this.limit&&this.afterPaint(t=>{l(e,t)})?u(e):d(e)},record:r=>{n>=this.limit||(typeof r!=`number`||!Number.isFinite(r)||r<0?this.sink?.diagnostics.report(`record.dropped_malformed`,`The duration of the probe ${t} is not valid. The library dropped it.`,{[e.nn.probe]:t}):this.sampled(n)&&c(r))}},slot:n,period:i,settle:l,leave:u}}push(e,t){let{stack:n}=this;this.depth===32&&(this.depth=0);let r=this.depth++*g;n[r]=t,n[r+1]=0,n[r+2]=e}pop(e,t,n){let{stack:r}=this,i=n-t,a=0;for(let o=(this.depth-1)*g;o>=0;o-=g)if(a+=r[o+1],r[o]===t&&r[o+2]===e){if(this.depth=o/g,o>0&&(r[o-g+1]+=i),i>=this.linkMs){let{ring:r,ringAt:i}=this;r[i]=e,r[i+1]=t,r[i+2]=n,this.ringAt=(i+_)%r.length}return Math.max(i-a,0)}return-1}afterPaint(e){let{requestAnimationFrame:t,document:n}=globalThis;if(typeof t!=`function`||typeof MessageChannel>`u`||n?.visibilityState===`hidden`)return!1;if(!this.channel){let e=()=>{let e=performance.now(),t=this.painted;this.painted=[];for(let n of t)n(e)};this.channel=new MessageChannel,this.channel.port1.onmessage=e,n?.addEventListener(`visibilitychange`,()=>{n.visibilityState===`hidden`&&e()})}return this.painted.push(e)===1&&t(()=>{this.channel?.port2.postMessage(0)}),!0}prime(e,t){let n=e*m;this.sampling[n]=1,this.sampling[n+1]=t}sampled(e){let t=e*m,n=this.sampling[t]-1;return n>0?(this.sampling[t]=n,!1):(this.sampling[t]=this.sampling[t+1],!0)}add(e,t){if(!(t>=0)||t===1/0){this.badTokens++;return}let{stats:n}=this,r=e*l,i=n[r+u];n[r+u]=i+1,n[r+d]+=t,(i===0||t<n[r+f])&&(n[r+f]=t),(i===0||t>n[r+p])&&(n[r+p]=t),this.hist[e*368+a(Math.ceil(t*1e3))]++,this.timer===null&&e>0&&this.sink!==null&&(this.startedAt=Date.now(),this.wait(this.sink))}wait(e){this.timer=setTimeout(()=>{this.tick()},e.intervalMs()),t.t(this.timer)}tick(){let{sink:e}=this;e!==null&&!e.ready()?this.wait(e):this.collect(!0)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}reportLimit(e){this.limitDue=!1,e.diagnostics.report(`config.invalid`,`The app registered ${String(this.registry.size)} probes. The profiler.maxProbes limit is ${String(e.capacity)}. The probes above the limit do nothing.`)||(this.limitDue=!0)}hasData(){for(let e=1;e<this.limit;e++)if(this.stats[e*l+u]>0)return!0;return!1}emitSlot(t,n,r,i){let{stats:a,hist:o}=this,m=r.slot*l,h=r.slot*368,g=a[m+u],_=a[m+f],v=a[m+p],y=e=>Math.min(Math.max(s(o,h,g,e)/1e3,_),v),b={[e.nn.probe]:n,[e.nn.sampleEvery]:r.period,[e.nn.p50]:y(.5),[e.nn.p90]:y(.9),[e.nn.p99]:y(.99)};this.overhead!==void 0&&(b[e.nn.overhead]=this.overhead);let{selfHist:x}=this,S=0;for(let e=h;e<h+368;e++)S+=x[e];S>0&&(b[e.nn.selfP99]=Math.min(s(x,h,S,.99)/1e3,v));let{bounds:C,counts:w}=c(o,h),T={"metric.name":e.in,"metric.unit":`ms`,"metric.type":`histogram`,[e.Bt.start]:i,[e.Bt.attributeKeys]:[e.nn.probe,e.nn.sampleEvery],[e.Bt.count]:g,[e.Bt.sum]:a[m+d],[e.Bt.min]:_,[e.Bt.max]:v,[e.Bt.bounds]:C,[e.Bt.buckets]:w};a.fill(0,m,m+l),o.fill(0,h,h+368),x.fill(0,h,h+368),t.emit(e.in,b,T)}calibrate(){this.calibrated=!0;let{probe:t}=this.makeProbe(``,0,{period:1,threshold:1/0,loose:!1}),n=performance.now(),r=n;for(let e=0;e<1e5&&r===n;e++)r=performance.now();if(r===n)return;let i=r+2,a=r,o=0;for(let n=0;n<e.Zt;n++){let e=t.begin();if(t.end(e),e!==a&&(a=e,o=n,e>=i))break}o>0&&(this.overhead=Math.round((a-r)*1e6/o))}};function x(){let e=globalThis,t=e[v];if(t)return t;let n=new b;return e[v]=n,n}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
|
|
2
|
+
//# sourceMappingURL=profiler-DpoPi1hH.cjs.map
|