@utk09/ui-observability 0.12.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +420 -0
- package/README.md +72 -839
- package/dist/{batch-BjQUwjA6.js → batch-CXmPmTse.js} +4 -4
- package/dist/{batch-BjQUwjA6.js.map → batch-CXmPmTse.js.map} +1 -1
- package/dist/{batch-D5LlU4Q9.cjs → batch-mmPigCpi.cjs} +2 -2
- package/dist/{batch-D5LlU4Q9.cjs.map → batch-mmPigCpi.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +331 -0
- package/dist/bus/bus.d.ts +60 -10
- package/dist/bus/links.d.cts +132 -0
- package/dist/bus/links.d.ts +18 -3
- package/dist/bus/validation.d.cts +16 -0
- package/dist/bus/validation.d.ts +10 -1
- package/dist/{bus-ecxUNTja.js → bus-C39wspFV.js} +308 -193
- package/dist/bus-C39wspFV.js.map +1 -0
- package/dist/bus-_EaOVPGq.cjs +2 -0
- package/dist/bus-_EaOVPGq.cjs.map +1 -0
- package/dist/capture/console.d.cts +37 -0
- package/dist/capture/console.d.ts +1 -1
- package/dist/capture/errors.d.cts +32 -0
- package/dist/capture/errors.d.ts +1 -1
- package/dist/capture/interactions.d.cts +48 -0
- package/dist/capture/interactions.d.ts +1 -1
- package/dist/capture/lifecycle.d.cts +20 -0
- package/dist/capture/lifecycle.d.ts +1 -1
- package/dist/capture/long-frames.d.cts +31 -0
- package/dist/capture/long-frames.d.ts +1 -1
- package/dist/capture/network.d.cts +57 -0
- package/dist/capture/network.d.ts +1 -1
- package/dist/capture/profiler-frames.d.cts +44 -0
- package/dist/capture/profiler-frames.d.ts +1 -1
- package/dist/capture/replay-buffer.d.cts +45 -0
- package/dist/capture/replay-buffer.d.ts +9 -10
- package/dist/capture/replay-upload.d.cts +79 -0
- package/dist/capture/replay-upload.d.ts +7 -2
- package/dist/capture/replay.d.cts +114 -0
- package/dist/capture/replay.d.ts +1 -1
- package/dist/capture/reports.d.cts +17 -0
- package/dist/capture/reports.d.ts +1 -1
- package/dist/capture/resource-timing.d.cts +14 -0
- package/dist/capture/resource-timing.d.ts +1 -1
- package/dist/capture/server-timing.d.cts +19 -0
- package/dist/capture/storm.d.cts +13 -0
- package/dist/capture/storm.d.ts +5 -5
- package/dist/capture/types.d.cts +128 -0
- package/dist/capture/types.d.ts +10 -9
- package/dist/capture/unclean-exit.d.cts +31 -0
- package/dist/capture/unclean-exit.d.ts +1 -1
- package/dist/capture/user-timing.d.cts +22 -0
- package/dist/capture/user-timing.d.ts +2 -2
- package/dist/capture/web-socket.d.cts +40 -0
- package/dist/capture/web-socket.d.ts +3 -3
- package/dist/capture/web-vitals.d.cts +40 -0
- package/dist/capture/web-vitals.d.ts +1 -1
- package/dist/{compression-lD9abCcO.cjs → compression-CvED_Jel.cjs} +2 -2
- package/dist/{compression-lD9abCcO.cjs.map → compression-CvED_Jel.cjs.map} +1 -1
- package/dist/{compression-AJJCMBOa.js → compression-tVtXwVjX.js} +2 -2
- package/dist/{compression-AJJCMBOa.js.map → compression-tVtXwVjX.js.map} +1 -1
- package/dist/config-DUs7uHHt.cjs +2 -0
- package/dist/config-DUs7uHHt.cjs.map +1 -0
- package/dist/config-SgQcCP1_.js +560 -0
- package/dist/config-SgQcCP1_.js.map +1 -0
- package/dist/console-BGgGnjSi.js +81 -0
- package/dist/console-BGgGnjSi.js.map +1 -0
- package/dist/console-CSZ5_Vx5.cjs +2 -0
- package/dist/console-CSZ5_Vx5.cjs.map +1 -0
- package/dist/constants-CUyd9cTZ.js +357 -0
- package/dist/constants-CUyd9cTZ.js.map +1 -0
- package/dist/constants-CqdJhTxH.cjs +2 -0
- package/dist/constants-CqdJhTxH.cjs.map +1 -0
- package/dist/constants.d.cts +751 -0
- package/dist/constants.d.ts +88 -20
- package/dist/core/breadcrumbs.d.cts +54 -0
- package/dist/core/breadcrumbs.d.ts +5 -0
- package/dist/core/config.d.cts +45 -0
- package/dist/core/config.d.ts +30 -2
- package/dist/core/context.d.cts +24 -0
- package/dist/core/context.d.ts +3 -8
- package/dist/core/debug-buffer.d.cts +34 -0
- package/dist/core/debug-buffer.d.ts +3 -3
- package/dist/core/debug-bundle.d.cts +12 -0
- package/dist/core/debug-bundle.d.ts +3 -3
- package/dist/core/deferred.d.cts +7 -0
- package/dist/core/deferred.d.ts +2 -2
- package/dist/core/diagnostics.d.cts +86 -0
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/drops.d.cts +39 -0
- package/dist/core/drops.d.ts +16 -6
- package/dist/core/hold-buffer.d.cts +36 -0
- package/dist/core/hold-buffer.d.ts +16 -7
- package/dist/core/journey.d.cts +148 -0
- package/dist/core/journey.d.ts +7 -7
- package/dist/core/logger.d.cts +141 -0
- package/dist/core/logger.d.ts +23 -30
- package/dist/core/measure.d.cts +30 -0
- package/dist/core/measure.d.ts +14 -3
- package/dist/core/meter.d.cts +78 -0
- package/dist/core/meter.d.ts +14 -8
- package/dist/core/pipeline.d.cts +227 -0
- package/dist/core/pipeline.d.ts +73 -10
- package/dist/core/profile-buckets.d.cts +31 -0
- package/dist/core/profiler.d.cts +218 -0
- package/dist/core/profiler.d.ts +2 -2
- package/dist/core/record.d.cts +190 -0
- package/dist/core/record.d.ts +44 -12
- package/dist/core/remote-rules.d.cts +17 -0
- package/dist/core/remote-rules.d.ts +3 -3
- package/dist/core/remote-sampling.d.cts +74 -0
- package/dist/core/remote-sampling.d.ts +3 -3
- package/dist/core/rotation.d.cts +75 -0
- package/dist/core/rotation.d.ts +75 -0
- package/dist/core/runtime.d.cts +765 -0
- package/dist/core/runtime.d.ts +245 -70
- package/dist/core/sampling.d.cts +86 -0
- package/dist/core/sampling.d.ts +5 -5
- package/dist/core/sender.d.cts +161 -0
- package/dist/core/sender.d.ts +59 -15
- package/dist/core/spans.d.cts +39 -0
- package/dist/core/spans.d.ts +1 -1
- package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
- package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
- package/dist/debug-bundle-CRpYV_ui.js +35 -0
- package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
- package/dist/defineProperty-X1c4tIPD.cjs +1 -0
- package/dist/defineProperty-s2S8BXUc.js +35 -0
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.cjs.map +1 -1
- package/dist/doctor.d.cts +36 -0
- package/dist/doctor.d.ts +5 -2
- package/dist/doctor.js +121 -89
- package/dist/doctor.js.map +1 -1
- package/dist/errors-BE_EZV7Q.js +86 -0
- package/dist/errors-BE_EZV7Q.js.map +1 -0
- package/dist/errors-CNPbesMs.cjs +3 -0
- package/dist/errors-CNPbesMs.cjs.map +1 -0
- package/dist/factory-CTi0Is3F.js +404 -0
- package/dist/factory-CTi0Is3F.js.map +1 -0
- package/dist/factory-hRrH32v5.cjs +2 -0
- package/dist/factory-hRrH32v5.cjs.map +1 -0
- package/dist/guards-BlYGRK4l.js +10 -0
- package/dist/guards-BlYGRK4l.js.map +1 -0
- package/dist/guards-EjG3ahFp.cjs +2 -0
- package/dist/guards-EjG3ahFp.cjs.map +1 -0
- package/dist/{identity-BrQp_5J5.js → identity-DdhKgrpk.js} +20 -24
- package/dist/identity-DdhKgrpk.js.map +1 -0
- package/dist/identity-DlWRIuwy.cjs +2 -0
- package/dist/identity-DlWRIuwy.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +300 -0
- package/dist/index.d.ts +89 -98
- package/dist/index.js +1173 -1506
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
- package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
- package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-GHdl0t8A.js} +51 -47
- package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
- package/dist/interactions-CUkzK8sR.cjs +2 -0
- package/dist/interactions-CUkzK8sR.cjs.map +1 -0
- package/dist/{interactions-B6z2I4tU.js → interactions-DiFvCosX.js} +41 -49
- package/dist/interactions-DiFvCosX.js.map +1 -0
- package/dist/journey-B4Adltjm.cjs +2 -0
- package/dist/journey-B4Adltjm.cjs.map +1 -0
- package/dist/{journey-35yCMNFo.js → journey-D2_sia57.js} +45 -48
- package/dist/journey-D2_sia57.js.map +1 -0
- package/dist/{library-console-Dl_Ly6DQ.js → library-console-Btrzt814.js} +2 -2
- package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-Btrzt814.js.map} +1 -1
- package/dist/{library-console-BFWEuQsl.cjs → library-console-CPW6bvZH.cjs} +2 -2
- package/dist/{library-console-BFWEuQsl.cjs.map → library-console-CPW6bvZH.cjs.map} +1 -1
- package/dist/{library-request-nI6pvI6I.js → library-request-BJ9PLRaD.js} +2 -2
- package/dist/{library-request-nI6pvI6I.js.map → library-request-BJ9PLRaD.js.map} +1 -1
- package/dist/{library-request-Da-CHKzT.cjs → library-request-D7OvTxZV.cjs} +2 -2
- package/dist/{library-request-Da-CHKzT.cjs.map → library-request-D7OvTxZV.cjs.map} +1 -1
- package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-22CUCrc9.js} +21 -29
- package/dist/lifecycle-22CUCrc9.js.map +1 -0
- package/dist/lifecycle-IaAm1mOC.cjs +2 -0
- package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
- package/dist/{log-record-DIA6McNr.js → log-record-BNiLfqtL.js} +8 -7
- package/dist/log-record-BNiLfqtL.js.map +1 -0
- package/dist/log-record-CkivuiEl.cjs +2 -0
- package/dist/log-record-CkivuiEl.cjs.map +1 -0
- package/dist/long-frames-BUUbXd-B.cjs +2 -0
- package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
- package/dist/{long-frames-430_85Da.js → long-frames-DNFaRnC3.js} +18 -22
- package/dist/long-frames-DNFaRnC3.js.map +1 -0
- package/dist/models/batch.d.cts +57 -0
- package/dist/models/batch.d.ts +2 -2
- package/dist/models/bus.d.cts +158 -0
- package/dist/models/bus.d.ts +22 -2
- package/dist/models/config.d.cts +1540 -0
- package/dist/models/config.d.ts +360 -259
- package/dist/models/drop.d.cts +54 -0
- package/dist/models/drop.d.ts +16 -3
- package/dist/models/health.d.cts +148 -0
- package/dist/models/health.d.ts +108 -12
- package/dist/models/log-record.d.cts +61 -0
- package/dist/models/metric.d.cts +139 -0
- package/dist/models/metric.d.ts +13 -2
- package/dist/models/plugin.d.cts +47 -0
- package/dist/models/plugin.d.ts +3 -3
- package/dist/models/replay.d.cts +60 -0
- package/dist/models/serializer.d.cts +23 -0
- package/dist/models/serializer.d.ts +1 -1
- package/dist/models/storage.d.cts +95 -0
- package/dist/models/storage.d.ts +7 -5
- package/dist/network-CGMLQ-mA.cjs +2 -0
- package/dist/network-CGMLQ-mA.cjs.map +1 -0
- package/dist/{network-C7SkLf4v.js → network-on2zZT6H.js} +51 -51
- package/dist/network-on2zZT6H.js.map +1 -0
- package/dist/{otlp-2MCrC3kd.cjs → otlp-BENHf3g9.cjs} +2 -2
- package/dist/{otlp-2MCrC3kd.cjs.map → otlp-BENHf3g9.cjs.map} +1 -1
- package/dist/{otlp-COq033e3.js → otlp-DimfrRor.js} +12 -12
- package/dist/{otlp-COq033e3.js.map → otlp-DimfrRor.js.map} +1 -1
- package/dist/{platform-CVewe4wQ.js → platform-BaaFIPCU.js} +10 -10
- package/dist/{platform-CVewe4wQ.js.map → platform-BaaFIPCU.js.map} +1 -1
- package/dist/{platform-12uR7kBQ.cjs → platform-CfA3-7sJ.cjs} +2 -2
- package/dist/{platform-12uR7kBQ.cjs.map → platform-CfA3-7sJ.cjs.map} +1 -1
- package/dist/{profiler-BVWIOgnq.js → profiler-BAZoh7A4.js} +89 -107
- package/dist/profiler-BAZoh7A4.js.map +1 -0
- package/dist/profiler-D4tJpDRc.cjs +2 -0
- package/dist/profiler-D4tJpDRc.cjs.map +1 -0
- package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
- package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
- package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-cJMx9wNM.js} +29 -37
- package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
- package/dist/remote-rules-Dz9MRAsB.js +95 -0
- package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
- package/dist/remote-rules-_tY0zj5o.cjs +2 -0
- package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
- package/dist/replay-B3gFXIZd.cjs +2 -0
- package/dist/replay-B3gFXIZd.cjs.map +1 -0
- package/dist/replay-Ds-ANH34.js +310 -0
- package/dist/replay-Ds-ANH34.js.map +1 -0
- package/dist/reports-BDSe4dFH.cjs +2 -0
- package/dist/reports-BDSe4dFH.cjs.map +1 -0
- package/dist/{reports-BuXekPOS.js → reports-C-thq-bk.js} +25 -30
- package/dist/reports-C-thq-bk.js.map +1 -0
- package/dist/resource-timing-C576gFIQ.cjs +2 -0
- package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
- package/dist/{resource-timing-CXGHwFRD.js → resource-timing-eUl2dNgC.js} +20 -23
- package/dist/resource-timing-eUl2dNgC.js.map +1 -0
- package/dist/response-body-YdNl-HkR.cjs +3 -0
- package/dist/response-body-YdNl-HkR.cjs.map +1 -0
- package/dist/response-body-eoSQpLiH.js +331 -0
- package/dist/response-body-eoSQpLiH.js.map +1 -0
- package/dist/rotation-Cwct4ckk.js +94 -0
- package/dist/rotation-Cwct4ckk.js.map +1 -0
- package/dist/rotation-D4qUAHAu.cjs +2 -0
- package/dist/rotation-D4qUAHAu.cjs.map +1 -0
- package/dist/sampling-BlrI8jor.js +63 -0
- package/dist/sampling-BlrI8jor.js.map +1 -0
- package/dist/sampling-mXt4dstx.cjs +2 -0
- package/dist/sampling-mXt4dstx.cjs.map +1 -0
- package/dist/{sanitize-CNmsD9r3.js → sanitize-Ba0KqU06.js} +2 -2
- package/dist/sanitize-Ba0KqU06.js.map +1 -0
- package/dist/{sanitize-ChLn97Ch.cjs → sanitize-DQyiI_KY.cjs} +2 -2
- package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
- package/dist/sender-BdRuNVhF.cjs +2 -0
- package/dist/sender-BdRuNVhF.cjs.map +1 -0
- package/dist/sender-Dv8rAmpV.js +979 -0
- package/dist/sender-Dv8rAmpV.js.map +1 -0
- package/dist/storage/context-storage.d.cts +90 -0
- package/dist/storage/context-storage.d.ts +5 -5
- package/dist/storage/emergency-queue.d.cts +27 -0
- package/dist/storage/emergency-queue.d.ts +4 -4
- package/dist/storage/eviction.d.cts +40 -0
- package/dist/storage/eviction.d.ts +1 -1
- package/dist/storage/factory.d.cts +21 -0
- package/dist/storage/factory.d.ts +3 -3
- package/dist/storage/gap.d.cts +20 -0
- package/dist/storage/gap.d.ts +3 -3
- package/dist/storage/idb-driver.d.cts +93 -0
- package/dist/storage/idb-driver.d.ts +1 -1
- package/dist/storage/indexeddb-storage.d.cts +97 -0
- package/dist/storage/indexeddb-storage.d.ts +12 -4
- package/dist/storage/keys.d.cts +17 -0
- package/dist/storage/keys.d.ts +2 -2
- package/dist/storage/local-storage.d.cts +139 -0
- package/dist/storage/local-storage.d.ts +11 -4
- package/dist/storage/memory-storage.d.cts +73 -0
- package/dist/storage/memory-storage.d.ts +4 -3
- package/dist/storage/persistence.d.cts +8 -0
- package/dist/storage/persistence.d.ts +2 -2
- package/dist/storage/stored-context.d.cts +34 -0
- package/dist/storage/stored-context.d.ts +34 -0
- package/dist/stored-context-B2EzVuYm.js +51 -0
- package/dist/stored-context-B2EzVuYm.js.map +1 -0
- package/dist/stored-context-CXt7eHZL.cjs +2 -0
- package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
- package/dist/storm-C-zYSdDX.cjs +2 -0
- package/dist/storm-C-zYSdDX.cjs.map +1 -0
- package/dist/storm-DjKetLKZ.js +9 -0
- package/dist/storm-DjKetLKZ.js.map +1 -0
- package/dist/transport/compression.d.cts +7 -0
- package/dist/transport/custom-transport.d.cts +22 -0
- package/dist/transport/custom-transport.d.ts +6 -5
- package/dist/transport/errors.d.cts +31 -0
- package/dist/transport/exit-flush.d.cts +135 -0
- package/dist/transport/exit-flush.d.ts +30 -13
- package/dist/transport/headers.d.cts +8 -0
- package/dist/transport/headers.d.ts +2 -2
- package/dist/transport/http-transport.d.cts +116 -0
- package/dist/transport/http-transport.d.ts +20 -8
- package/dist/transport/memory-transport.d.cts +30 -0
- package/dist/transport/memory-transport.d.ts +2 -2
- package/dist/transport/response-body.d.cts +49 -0
- package/dist/transport/response-body.d.ts +49 -0
- package/dist/transport/retry-engine.d.cts +129 -0
- package/dist/transport/retry-engine.d.ts +27 -9
- package/dist/transport/serializers/ecs.d.cts +3 -0
- package/dist/transport/serializers/ecs.d.ts +1 -1
- package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
- package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
- package/dist/transport/serializers/otlp-traces.d.cts +3 -0
- package/dist/transport/serializers/otlp-traces.d.ts +1 -1
- package/dist/transport/serializers/otlp.d.cts +47 -0
- package/dist/transport/serializers/otlp.d.ts +2 -2
- package/dist/transport/serializers/select.d.cts +38 -0
- package/dist/transport/serializers/select.d.ts +5 -5
- package/dist/transport/status-transport.d.cts +129 -0
- package/dist/transport/status-transport.d.ts +25 -8
- package/dist/transport/worker-client.d.cts +23 -0
- package/dist/transport/worker-client.d.ts +12 -3
- package/dist/transport/worker-entry.d.cts +5 -0
- package/dist/transport/worker-entry.d.ts +1 -1
- package/dist/transport/worker-protocol.d.cts +38 -0
- package/dist/transport/worker-protocol.d.ts +4 -2
- package/dist/transport/worker-server.d.cts +3 -0
- package/dist/transport/worker-server.d.ts +1 -1
- package/dist/transport/worker-transport.d.cts +10 -0
- package/dist/transport/worker-transport.d.ts +5 -4
- package/dist/types-BAerHgCq.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-DQD1cT7c.js} +23 -30
- package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
- package/dist/unclean-exit-py99ApzT.cjs +2 -0
- package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
- package/dist/{user-timing-DgHubxCI.js → user-timing-BePqb1uN.js} +15 -17
- package/dist/user-timing-BePqb1uN.js.map +1 -0
- package/dist/user-timing-D6XTmpuM.cjs +2 -0
- package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
- package/dist/utils/console.d.cts +36 -0
- package/dist/utils/console.d.ts +4 -4
- package/dist/utils/deadline.d.cts +14 -0
- package/dist/utils/error-like.d.cts +25 -0
- package/dist/utils/fixed-window.d.cts +25 -0
- package/dist/utils/global-scope.d.cts +20 -0
- package/dist/utils/guards.d.cts +14 -0
- package/dist/utils/guards.d.ts +8 -0
- package/dist/utils/identity.d.cts +109 -0
- package/dist/utils/identity.d.ts +3 -4
- package/dist/utils/library-console.d.cts +11 -0
- package/dist/utils/library-request.d.cts +24 -0
- package/dist/utils/lock.d.cts +24 -0
- package/dist/utils/lock.d.ts +1 -1
- package/dist/utils/openfin.d.cts +48 -0
- package/dist/utils/patch.d.cts +9 -0
- package/dist/utils/platform.d.cts +62 -0
- package/dist/utils/platform.d.ts +2 -2
- package/dist/utils/sanitize.d.cts +52 -0
- package/dist/utils/sanitize.d.ts +1 -1
- package/dist/utils/sequence.d.cts +10 -0
- package/dist/utils/tracing.d.cts +158 -0
- package/dist/utils/tracing.d.ts +11 -4
- package/dist/utils/unref.d.cts +9 -0
- package/dist/web-socket-CoIUBM3C.cjs +2 -0
- package/dist/{web-socket-DthJuSAg.js.map → web-socket-CoIUBM3C.cjs.map} +1 -1
- package/dist/{web-socket-DthJuSAg.js → web-socket-DSHgDiZ6.js} +23 -28
- package/dist/web-socket-DSHgDiZ6.js.map +1 -0
- package/dist/{web-vitals-CsGCWnUr.js → web-vitals-4pWACwaR.js} +15 -21
- package/dist/web-vitals-4pWACwaR.js.map +1 -0
- package/dist/web-vitals-__X7t4pj.cjs +2 -0
- package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
- package/dist/worker-protocol-QbvqNazn.cjs +2 -0
- package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
- package/dist/{worker-protocol-B0_8rWy5.js → worker-protocol-x074Rpet.js} +14 -11
- package/dist/worker-protocol-x074Rpet.js.map +1 -0
- package/dist/worker-server-CFe4nvos.cjs +2 -0
- package/dist/worker-server-CFe4nvos.cjs.map +1 -0
- package/dist/worker-server-iUVSjH8L.js +94 -0
- package/dist/worker-server-iUVSjH8L.js.map +1 -0
- package/dist/worker-transport-CRAX-09c.cjs +2 -0
- package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
- package/dist/worker-transport-Dy1KMA7t.js +190 -0
- package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
- package/llms.txt +397 -0
- package/package.json +54 -46
- package/dist/bus-D_7pd7RN.cjs +0 -2
- package/dist/bus-D_7pd7RN.cjs.map +0 -1
- package/dist/bus-ecxUNTja.js.map +0 -1
- package/dist/console-CLz_PvFn.cjs +0 -2
- package/dist/console-CLz_PvFn.cjs.map +0 -1
- package/dist/console-cwgHKXvM.js +0 -82
- package/dist/console-cwgHKXvM.js.map +0 -1
- package/dist/constants-Bwl_YtQi.js +0 -349
- package/dist/constants-Bwl_YtQi.js.map +0 -1
- package/dist/constants-DakMxVB2.cjs +0 -2
- package/dist/constants-DakMxVB2.cjs.map +0 -1
- package/dist/context-storage-BjzeBSxH.cjs +0 -2
- package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
- package/dist/context-storage-BzkoHzkQ.js +0 -51
- package/dist/context-storage-BzkoHzkQ.js.map +0 -1
- package/dist/debug-bundle-BOdYmCeV.js +0 -32
- package/dist/debug-bundle-BOdYmCeV.js.map +0 -1
- package/dist/debug-bundle-Ex4L_LSP.cjs +0 -2
- package/dist/debug-bundle-Ex4L_LSP.cjs.map +0 -1
- package/dist/emergency-queue-B9WZxanZ.js +0 -67
- package/dist/emergency-queue-B9WZxanZ.js.map +0 -1
- package/dist/emergency-queue-HBpL5r3V.cjs +0 -2
- package/dist/emergency-queue-HBpL5r3V.cjs.map +0 -1
- package/dist/errors-D6bwgJtO.js +0 -92
- package/dist/errors-D6bwgJtO.js.map +0 -1
- package/dist/errors-DCOCRdSi.cjs +0 -3
- package/dist/errors-DCOCRdSi.cjs.map +0 -1
- package/dist/factory-DLFDjdLv.cjs +0 -2
- package/dist/factory-DLFDjdLv.cjs.map +0 -1
- package/dist/factory-e9Qo3K0z.js +0 -276
- package/dist/factory-e9Qo3K0z.js.map +0 -1
- package/dist/guards-Cidk71ME.js +0 -7
- package/dist/guards-Cidk71ME.js.map +0 -1
- package/dist/guards-nJ70syPt.cjs +0 -2
- package/dist/guards-nJ70syPt.cjs.map +0 -1
- package/dist/identity-BlvlgjrU.cjs +0 -2
- package/dist/identity-BlvlgjrU.cjs.map +0 -1
- package/dist/identity-BrQp_5J5.js.map +0 -1
- package/dist/indexeddb-storage-CtLvZH1r.cjs +0 -2
- package/dist/indexeddb-storage-CtLvZH1r.cjs.map +0 -1
- package/dist/indexeddb-storage-DLXQzAGh.js.map +0 -1
- package/dist/interactions-B6z2I4tU.js.map +0 -1
- package/dist/interactions-P6pz08Jn.cjs +0 -2
- package/dist/interactions-P6pz08Jn.cjs.map +0 -1
- package/dist/journey-35yCMNFo.js.map +0 -1
- package/dist/journey-DAGh5h9k.cjs +0 -2
- package/dist/journey-DAGh5h9k.cjs.map +0 -1
- package/dist/keys-BHhw_0Wh.cjs +0 -2
- package/dist/keys-BHhw_0Wh.cjs.map +0 -1
- package/dist/keys-BU9j5YqW.js +0 -16
- package/dist/keys-BU9j5YqW.js.map +0 -1
- package/dist/lifecycle-BGGOcN4N.cjs +0 -2
- package/dist/lifecycle-BGGOcN4N.cjs.map +0 -1
- package/dist/lifecycle-CZ6RRXc6.js.map +0 -1
- package/dist/log-record-D7bA1RPb.cjs +0 -2
- package/dist/log-record-D7bA1RPb.cjs.map +0 -1
- package/dist/log-record-DIA6McNr.js.map +0 -1
- package/dist/long-frames-430_85Da.js.map +0 -1
- package/dist/long-frames-Dd8tsi2U.cjs +0 -2
- package/dist/long-frames-Dd8tsi2U.cjs.map +0 -1
- package/dist/models/stats.d.ts +0 -11
- package/dist/network-C7SkLf4v.js.map +0 -1
- package/dist/network-pEX3PAJv.cjs +0 -2
- package/dist/network-pEX3PAJv.cjs.map +0 -1
- package/dist/profiler-BVWIOgnq.js.map +0 -1
- package/dist/profiler-eVCknCzS.cjs +0 -2
- package/dist/profiler-eVCknCzS.cjs.map +0 -1
- package/dist/profiler-frames-CLXlT_xL.js.map +0 -1
- package/dist/profiler-frames-Dg2OebB2.cjs +0 -2
- package/dist/profiler-frames-Dg2OebB2.cjs.map +0 -1
- package/dist/remote-rules-BJGDJGwA.js +0 -98
- package/dist/remote-rules-BJGDJGwA.js.map +0 -1
- package/dist/remote-rules-CJD3ToVk.cjs +0 -2
- package/dist/remote-rules-CJD3ToVk.cjs.map +0 -1
- package/dist/replay-0zAJv9T3.js +0 -338
- package/dist/replay-0zAJv9T3.js.map +0 -1
- package/dist/replay-DomJpXqW.cjs +0 -2
- package/dist/replay-DomJpXqW.cjs.map +0 -1
- package/dist/reports-BsbqmP8h.cjs +0 -2
- package/dist/reports-BsbqmP8h.cjs.map +0 -1
- package/dist/reports-BuXekPOS.js.map +0 -1
- package/dist/resource-timing-CXGHwFRD.js.map +0 -1
- package/dist/resource-timing-DkycFGDa.cjs +0 -2
- package/dist/resource-timing-DkycFGDa.cjs.map +0 -1
- package/dist/sampling-Dd0wllyq.cjs +0 -2
- package/dist/sampling-Dd0wllyq.cjs.map +0 -1
- package/dist/sampling-UUDbi3K0.js +0 -60
- package/dist/sampling-UUDbi3K0.js.map +0 -1
- package/dist/sanitize-CNmsD9r3.js.map +0 -1
- package/dist/sanitize-ChLn97Ch.cjs.map +0 -1
- package/dist/select-CTk-K5mG.cjs +0 -3
- package/dist/select-CTk-K5mG.cjs.map +0 -1
- package/dist/select-DPv_j6wq.js +0 -270
- package/dist/select-DPv_j6wq.js.map +0 -1
- package/dist/sender-15zEsZpr.js +0 -857
- package/dist/sender-15zEsZpr.js.map +0 -1
- package/dist/sender-Bfpv9tad.cjs +0 -2
- package/dist/sender-Bfpv9tad.cjs.map +0 -1
- package/dist/storage-BA9RqRO-.cjs +0 -2
- package/dist/storage-BA9RqRO-.cjs.map +0 -1
- package/dist/storage-DZwed89z.js +0 -16
- package/dist/storage-DZwed89z.js.map +0 -1
- package/dist/storm-BTSNTIWI.js +0 -9
- package/dist/storm-BTSNTIWI.js.map +0 -1
- package/dist/storm-D0_qZOEg.cjs +0 -2
- package/dist/storm-D0_qZOEg.cjs.map +0 -1
- package/dist/unclean-exit-ClGzrc2A.cjs +0 -2
- package/dist/unclean-exit-ClGzrc2A.cjs.map +0 -1
- package/dist/unclean-exit-Cob_jyTv.js.map +0 -1
- package/dist/user-timing-CdYqx3PF.cjs +0 -2
- package/dist/user-timing-CdYqx3PF.cjs.map +0 -1
- package/dist/user-timing-DgHubxCI.js.map +0 -1
- package/dist/utils/timer.d.ts +0 -19
- package/dist/web-socket-BTuvYoJI.cjs +0 -2
- package/dist/web-socket-BTuvYoJI.cjs.map +0 -1
- package/dist/web-vitals-Ch5BpDmo.cjs +0 -2
- package/dist/web-vitals-Ch5BpDmo.cjs.map +0 -1
- package/dist/web-vitals-CsGCWnUr.js.map +0 -1
- package/dist/worker-protocol-B0_8rWy5.js.map +0 -1
- package/dist/worker-protocol-BjzFORfq.cjs +0 -2
- package/dist/worker-protocol-BjzFORfq.cjs.map +0 -1
- package/dist/worker-server-4en-Lt-3.cjs +0 -2
- package/dist/worker-server-4en-Lt-3.cjs.map +0 -1
- package/dist/worker-server-Cne9MX9I.js +0 -83
- package/dist/worker-server-Cne9MX9I.js.map +0 -1
- package/dist/worker-transport-B-GF4Aqn.cjs +0 -2
- package/dist/worker-transport-B-GF4Aqn.cjs.map +0 -1
- package/dist/worker-transport-C3SjJAEC.js +0 -200
- package/dist/worker-transport-C3SjJAEC.js.map +0 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $t as e, Jt as t, Xt as n, Yt as r, en as i, er as a, tn as o, zt as s } from "./constants-CUyd9cTZ.js";
|
|
2
2
|
import { t as c } from "./unref-DgHPQeWv.js";
|
|
3
|
+
import { t as l } from "./defineProperty-s2S8BXUc.js";
|
|
3
4
|
// src/core/profile-buckets.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let t = Math.min(e,
|
|
7
|
-
if (t <
|
|
5
|
+
var u = 16, d = u - 1;
|
|
6
|
+
function f(e) {
|
|
7
|
+
let t = Math.min(e, i);
|
|
8
|
+
if (t < u) return t;
|
|
8
9
|
let n = 31 - Math.clz32(t) - 4;
|
|
9
|
-
return n + 1 << 4 | t >>> n &
|
|
10
|
+
return n + 1 << 4 | t >>> n & d;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
if (e <
|
|
12
|
+
function p(e) {
|
|
13
|
+
if (e < u) return e;
|
|
13
14
|
let t = (e >>> 4) - 1;
|
|
14
|
-
return (
|
|
15
|
+
return (u + (e & d) << t) + (1 << t) - 1;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function m(e, t, n, r) {
|
|
17
18
|
let i = Math.max(1, Math.ceil(r * n)), a = 0;
|
|
18
|
-
for (let n = 0; n < 368; n++) if (a += e[t + n], a >= i) return
|
|
19
|
-
return
|
|
19
|
+
for (let n = 0; n < 368; n++) if (a += e[t + n], a >= i) return p(n);
|
|
20
|
+
return p(367);
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function h(e, t) {
|
|
22
23
|
let n = 0;
|
|
23
24
|
for (; n < 368 && e[t + n] === 0;) n++;
|
|
24
25
|
if (n === 368) return {
|
|
@@ -32,45 +33,26 @@ function m(e, t) {
|
|
|
32
33
|
let a = n >> i, o = r >> i, s = Array.from({ length: o - a + 1 }, () => 0);
|
|
33
34
|
for (let o = n; o <= r; o++) s[(o >> i) - a] += e[t + o];
|
|
34
35
|
return {
|
|
35
|
-
bounds: Array.from({ length: o - a }, (e, t) =>
|
|
36
|
+
bounds: Array.from({ length: o - a }, (e, t) => p((a + t + 1 << i) - 1) / 1e3),
|
|
36
37
|
counts: s
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
// src/core/profiler.ts
|
|
40
|
-
var
|
|
41
|
+
var g = 4, _ = 0, v = 1, y = 2, b = 3, x = 2, S = 2 ** 31 - 1, C = 3, w = 3, T = Symbol.for(`${r}@${a}`), E = {
|
|
41
42
|
begin: () => -1,
|
|
42
43
|
end: () => void 0,
|
|
43
44
|
endAfterPaint: () => void 0,
|
|
44
45
|
record: () => void 0
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
stack = new Float64Array(32 * S);
|
|
52
|
-
depth = 0;
|
|
53
|
-
ring = /* @__PURE__ */ new Float64Array();
|
|
54
|
-
ringAt = 0;
|
|
55
|
-
linkMs = Infinity;
|
|
56
|
-
painted = [];
|
|
57
|
-
channel;
|
|
58
|
-
sampling = /* @__PURE__ */ new Int32Array();
|
|
59
|
-
floor = -1;
|
|
60
|
-
timer = null;
|
|
61
|
-
startedAt = 0;
|
|
62
|
-
badTokens = 0;
|
|
63
|
-
overhead = void 0;
|
|
64
|
-
calibrated = !1;
|
|
65
|
-
sink = null;
|
|
66
|
-
reported = !1;
|
|
67
|
-
limitDue = !1;
|
|
68
|
-
probe(e, n, r) {
|
|
69
|
-
if (typeof e != "string" || e === "") return r?.report("config.invalid", "The probe name must be a string that is not empty. The probe does nothing."), T;
|
|
46
|
+
}, D = class {
|
|
47
|
+
constructor() {
|
|
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
|
+
}
|
|
50
|
+
probe(e, t, r) {
|
|
51
|
+
if (typeof e != "string" || e === "") return r?.report("config.invalid", "The probe name must be a string that is not empty. The probe does nothing."), E;
|
|
70
52
|
let i = this.registry.get(e);
|
|
71
53
|
if (i) return i.probe;
|
|
72
|
-
if (this.registry.size >= 1024) return r?.report("config.invalid", `The profiler keeps at most ${String(
|
|
73
|
-
let a = this.rulesOf(e,
|
|
54
|
+
if (this.registry.size >= 1024) return r?.report("config.invalid", `The profiler keeps at most ${String(n)} probe names. The probe ${e} does nothing.`), E;
|
|
55
|
+
let a = this.rulesOf(e, t, r), { period: o } = a;
|
|
74
56
|
if (this.registry.has(e) || this.registry.size >= 1024) return this.probe(e, void 0, r);
|
|
75
57
|
let s = this.registry.size + 1, c = this.makeProbe(e, s, a), { probe: l } = c;
|
|
76
58
|
return this.registry.set(e, c), s < this.limit ? this.prime(s, o) : this.limit > 0 && !this.reported && (this.reported = !0, this.sink?.diagnostics.report("config.invalid", `The probe ${e} is above the profiler.maxProbes limit of ${String(this.limit - 1)}. The probe does nothing.`) === !1 && (this.limitDue = !0)), l;
|
|
@@ -99,16 +81,16 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
99
81
|
}
|
|
100
82
|
}
|
|
101
83
|
link(e) {
|
|
102
|
-
this.linkMs = e, e < Infinity && this.ring.length === 0 && (this.ring = new Float64Array(256 *
|
|
84
|
+
this.linkMs = e, e < Infinity && this.ring.length === 0 && (this.ring = new Float64Array(256 * w));
|
|
103
85
|
}
|
|
104
86
|
linked(e, t) {
|
|
105
87
|
let { ring: n } = this, r = [...this.registry.keys()], i = /* @__PURE__ */ new Set();
|
|
106
|
-
for (let a = 0; a < n.length; a +=
|
|
88
|
+
for (let a = 0; a < n.length; a += w) n[a] > 0 && n[a + 1] < t && n[a + 2] > e && i.add(r[n[a] - 1]);
|
|
107
89
|
return [...i];
|
|
108
90
|
}
|
|
109
91
|
attach(e) {
|
|
110
92
|
let t = e.capacity + 1;
|
|
111
|
-
this.sink = e, this.stats.length !== t *
|
|
93
|
+
this.sink = e, this.stats.length !== t * g && (this.stats = new Float64Array(t * g), this.hist = new Uint32Array(t * 368), this.selfHist = new Uint32Array(t * 368), this.sampling = new Int32Array(t * x)), this.limit = t, this.reported = !1, this.limitDue = !1, this.prime(0, 1);
|
|
112
94
|
for (let e of this.registry.values()) e.slot < t && this.prime(e.slot, e.period);
|
|
113
95
|
this.registry.size > e.capacity && (this.reported = !0, this.reportLimit(e));
|
|
114
96
|
}
|
|
@@ -120,7 +102,7 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
120
102
|
if (!t?.ready()) return;
|
|
121
103
|
this.limitDue && this.reportLimit(t), this.clearTimer(), e && !this.calibrated && this.hasData() && this.calibrate();
|
|
122
104
|
let n = `${String(this.startedAt)}000000`;
|
|
123
|
-
for (let [e, r] of this.registry) r.slot < this.limit && this.stats[r.slot *
|
|
105
|
+
for (let [e, r] of this.registry) r.slot < this.limit && this.stats[r.slot * g + _] > 0 && this.emitSlot(t, e, r, n);
|
|
124
106
|
this.badTokens > 0 && (t.diagnostics.count("record.dropped_malformed", this.badTokens), this.badTokens = 0);
|
|
125
107
|
}
|
|
126
108
|
reset() {
|
|
@@ -140,47 +122,47 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
140
122
|
} catch (t) {
|
|
141
123
|
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;
|
|
142
124
|
}
|
|
143
|
-
return typeof i == "number" && Number.isInteger(i) && i >= 1 && i <=
|
|
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;
|
|
144
126
|
}
|
|
145
|
-
makeProbe(
|
|
146
|
-
let { period: i, threshold: a, loose: o } = r, s = (
|
|
147
|
-
this.add(
|
|
148
|
-
}, c = (e,
|
|
149
|
-
|
|
127
|
+
makeProbe(t, n, r) {
|
|
128
|
+
let { period: i, threshold: a, loose: o } = r, s = (e) => {
|
|
129
|
+
this.add(n, e), e > a && this.sink?.outlier(t, e);
|
|
130
|
+
}, c = (e, t) => {
|
|
131
|
+
n < this.limit && e > this.floor && s(t - e);
|
|
150
132
|
}, l = (e) => {
|
|
151
|
-
o || this.pop(
|
|
133
|
+
o || this.pop(n, e, performance.now());
|
|
152
134
|
}, u = (e) => {
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
155
|
-
e !== -1 &&
|
|
135
|
+
let t = typeof e == "number" && e >= 0 ? performance.now() : -1;
|
|
136
|
+
if (t < 0) {
|
|
137
|
+
e !== -1 && n < this.limit && this.badTokens++;
|
|
156
138
|
return;
|
|
157
139
|
}
|
|
158
140
|
if (o) {
|
|
159
|
-
c(e,
|
|
141
|
+
c(e, t);
|
|
160
142
|
return;
|
|
161
143
|
}
|
|
162
|
-
if (
|
|
163
|
-
let r = this.pop(
|
|
164
|
-
s(
|
|
144
|
+
if (n >= this.limit || e <= this.floor) return;
|
|
145
|
+
let r = this.pop(n, e, t);
|
|
146
|
+
s(t - e), r >= 0 && this.selfHist[n * 368 + f(Math.ceil(r * 1e3))]++;
|
|
165
147
|
};
|
|
166
148
|
return {
|
|
167
149
|
probe: {
|
|
168
150
|
begin: () => {
|
|
169
|
-
if (
|
|
151
|
+
if (n >= this.limit || !this.sampled(n)) return -1;
|
|
170
152
|
let e = performance.now();
|
|
171
|
-
return o || this.push(
|
|
153
|
+
return o || this.push(n, e), e;
|
|
172
154
|
},
|
|
173
155
|
end: u,
|
|
174
156
|
endAfterPaint: (e) => {
|
|
175
|
-
typeof e == "number" && e >= 0 &&
|
|
157
|
+
typeof e == "number" && e >= 0 && n < this.limit && this.afterPaint((t) => {
|
|
176
158
|
c(e, t);
|
|
177
159
|
}) ? l(e) : u(e);
|
|
178
160
|
},
|
|
179
161
|
record: (r) => {
|
|
180
|
-
|
|
162
|
+
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.probe]: t }) : this.sampled(n) && s(r));
|
|
181
163
|
}
|
|
182
164
|
},
|
|
183
|
-
slot:
|
|
165
|
+
slot: n,
|
|
184
166
|
period: i,
|
|
185
167
|
settle: c,
|
|
186
168
|
leave: l
|
|
@@ -189,15 +171,15 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
189
171
|
push(e, t) {
|
|
190
172
|
let { stack: n } = this;
|
|
191
173
|
this.depth === 32 && (this.depth = 0);
|
|
192
|
-
let r = this.depth++ *
|
|
174
|
+
let r = this.depth++ * C;
|
|
193
175
|
n[r] = t, n[r + 1] = 0, n[r + 2] = e;
|
|
194
176
|
}
|
|
195
177
|
pop(e, t, n) {
|
|
196
178
|
let { stack: r } = this, i = n - t, a = 0;
|
|
197
|
-
for (let o = (this.depth - 1) *
|
|
198
|
-
if (this.depth = o /
|
|
179
|
+
for (let o = (this.depth - 1) * C; o >= 0; o -= C) if (a += r[o + 1], r[o] === t && r[o + 2] === e) {
|
|
180
|
+
if (this.depth = o / C, o > 0 && (r[o - C + 1] += i), i >= this.linkMs) {
|
|
199
181
|
let { ring: r, ringAt: i } = this;
|
|
200
|
-
r[i] = e, r[i + 1] = t, r[i + 2] = n, this.ringAt = (i +
|
|
182
|
+
r[i] = e, r[i + 1] = t, r[i + 2] = n, this.ringAt = (i + w) % r.length;
|
|
201
183
|
}
|
|
202
184
|
return Math.max(i - a, 0);
|
|
203
185
|
}
|
|
@@ -221,11 +203,11 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
221
203
|
}), !0;
|
|
222
204
|
}
|
|
223
205
|
prime(e, t) {
|
|
224
|
-
let n = e *
|
|
206
|
+
let n = e * x;
|
|
225
207
|
this.sampling[n] = 1, this.sampling[n + 1] = t;
|
|
226
208
|
}
|
|
227
209
|
sampled(e) {
|
|
228
|
-
let t = e *
|
|
210
|
+
let t = e * x, n = this.sampling[t] - 1;
|
|
229
211
|
return n > 0 ? (this.sampling[t] = n, !1) : (this.sampling[t] = this.sampling[t + 1], !0);
|
|
230
212
|
}
|
|
231
213
|
add(e, t) {
|
|
@@ -233,8 +215,8 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
233
215
|
this.badTokens++;
|
|
234
216
|
return;
|
|
235
217
|
}
|
|
236
|
-
let { stats: n } = this, r = e *
|
|
237
|
-
n[r +
|
|
218
|
+
let { stats: n } = this, r = e * g, i = n[r + _];
|
|
219
|
+
n[r + _] = i + 1, n[r + v] += t, (i === 0 || t < n[r + y]) && (n[r + y] = t), (i === 0 || t > n[r + b]) && (n[r + b] = t), this.hist[e * 368 + f(Math.ceil(t * 1e3))]++, this.timer === null && e > 0 && this.sink !== null && (this.startedAt = Date.now(), this.wait(this.sink));
|
|
238
220
|
}
|
|
239
221
|
wait(e) {
|
|
240
222
|
this.timer = setTimeout(() => {
|
|
@@ -252,35 +234,35 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
252
234
|
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);
|
|
253
235
|
}
|
|
254
236
|
hasData() {
|
|
255
|
-
for (let e = 1; e < this.limit; e++) if (this.stats[e *
|
|
237
|
+
for (let e = 1; e < this.limit; e++) if (this.stats[e * g + _] > 0) return !0;
|
|
256
238
|
return !1;
|
|
257
239
|
}
|
|
258
|
-
emitSlot(
|
|
259
|
-
let { stats:
|
|
260
|
-
[
|
|
261
|
-
[
|
|
262
|
-
[
|
|
263
|
-
[
|
|
264
|
-
[
|
|
240
|
+
emitSlot(t, n, r, i) {
|
|
241
|
+
let { stats: a, hist: c } = this, l = r.slot * g, u = r.slot * 368, d = a[l + _], f = a[l + y], p = a[l + b], x = (e) => Math.min(Math.max(m(c, u, d, e) / 1e3, f), p), S = {
|
|
242
|
+
[e.probe]: n,
|
|
243
|
+
[e.sampleEvery]: r.period,
|
|
244
|
+
[e.p50]: x(.5),
|
|
245
|
+
[e.p90]: x(.9),
|
|
246
|
+
[e.p99]: x(.99)
|
|
265
247
|
};
|
|
266
|
-
this.overhead !== void 0 && (S[
|
|
248
|
+
this.overhead !== void 0 && (S[e.overhead] = this.overhead);
|
|
267
249
|
let { selfHist: C } = this, w = 0;
|
|
268
250
|
for (let e = u; e < u + 368; e++) w += C[e];
|
|
269
|
-
w > 0 && (S[
|
|
270
|
-
let { bounds: T, counts: E } =
|
|
251
|
+
w > 0 && (S[e.selfP99] = Math.min(m(C, u, w, .99) / 1e3, p));
|
|
252
|
+
let { bounds: T, counts: E } = h(c, u), D = {
|
|
271
253
|
"metric.name": o,
|
|
272
254
|
"metric.unit": "ms",
|
|
273
255
|
"metric.type": "histogram",
|
|
274
|
-
[
|
|
275
|
-
[
|
|
276
|
-
[
|
|
277
|
-
[
|
|
278
|
-
[
|
|
279
|
-
[
|
|
280
|
-
[
|
|
281
|
-
[
|
|
256
|
+
[s.start]: i,
|
|
257
|
+
[s.attributeKeys]: [e.probe, e.sampleEvery],
|
|
258
|
+
[s.count]: d,
|
|
259
|
+
[s.sum]: a[l + v],
|
|
260
|
+
[s.min]: f,
|
|
261
|
+
[s.max]: p,
|
|
262
|
+
[s.bounds]: T,
|
|
263
|
+
[s.buckets]: E
|
|
282
264
|
};
|
|
283
|
-
|
|
265
|
+
a.fill(0, l, l + g), c.fill(0, u, u + 368), C.fill(0, u, u + 368), t.emit(o, S, D);
|
|
284
266
|
}
|
|
285
267
|
calibrate() {
|
|
286
268
|
this.calibrated = !0;
|
|
@@ -288,23 +270,23 @@ var h = 4, g = 0, _ = 1, v = 2, y = 3, b = 2, x = 2 ** 31 - 1, S = 3, C = 3, w =
|
|
|
288
270
|
period: 1,
|
|
289
271
|
threshold: Infinity,
|
|
290
272
|
loose: !1
|
|
291
|
-
}),
|
|
292
|
-
for (let e = 0; e < 1e5 &&
|
|
293
|
-
if (
|
|
294
|
-
let
|
|
295
|
-
for (let
|
|
296
|
-
let
|
|
297
|
-
if (e.end(
|
|
273
|
+
}), n = performance.now(), r = n;
|
|
274
|
+
for (let e = 0; e < 1e5 && r === n; e++) r = performance.now();
|
|
275
|
+
if (r === n) return;
|
|
276
|
+
let i = r + 2, a = r, o = 0;
|
|
277
|
+
for (let n = 0; n < t; n++) {
|
|
278
|
+
let t = e.begin();
|
|
279
|
+
if (e.end(t), t !== a && (a = t, o = n, t >= i)) break;
|
|
298
280
|
}
|
|
299
|
-
o > 0 && (this.overhead = Math.round((a -
|
|
281
|
+
o > 0 && (this.overhead = Math.round((a - r) * 1e6 / o));
|
|
300
282
|
}
|
|
301
283
|
};
|
|
302
|
-
function
|
|
303
|
-
let e = globalThis, t = e[
|
|
284
|
+
function O() {
|
|
285
|
+
let e = globalThis, t = e[T];
|
|
304
286
|
if (t) return t;
|
|
305
|
-
let n = new
|
|
306
|
-
return e[
|
|
287
|
+
let n = new D();
|
|
288
|
+
return e[T] = n, n;
|
|
307
289
|
}
|
|
308
|
-
export {
|
|
290
|
+
export { O as t };
|
|
309
291
|
|
|
310
|
-
//# sourceMappingURL=profiler-
|
|
292
|
+
//# sourceMappingURL=profiler-BAZoh7A4.js.map
|
|
@@ -0,0 +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,KAAqB,KAGnC,IAFA,KAAOC,EAAQC,IAAOF,IAElBD,KAAOH,GACT,OAAOH,EAAQO,CAAC;CAKpB,OAAOP,EAAA,GAA2B;AACpC;AAQA,SAAgBU,EACd,GACA,GACwC;CACxC,IAAIC,IAAQ;CACZ,OAAOA,IAAA,OAA2BH,EAAQC,IAAOE,OAAW,IAC1D;CAGF,IAAIA,MAAA,KACF,OAAO;EAAE,QAAQ,CAAC;EAAG,QAAQ,CAAC,CAAC;CAAE;CAInC,IAAIC,IAAA;CACJ,OAAOJ,EAAQC,IAAOG,OAAU,IAC9B;CAKF,IAAIC,IAAQ;CACZ,QAAQD,KAAQC,MAAUF,KAASE,KAAS,IAAA,MAC1C;CAGF,IAAMC,IAAMH,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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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-CqdJhTxH.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.en);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.Yt}@${e.er}`),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.Xt)} 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.$t.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.$t.probe]:n,[e.$t.sampleEvery]:r.period,[e.$t.p50]:y(.5),[e.$t.p90]:y(.9),[e.$t.p99]:y(.99)};this.overhead!==void 0&&(b[e.$t.overhead]=this.overhead);let{selfHist:x}=this,S=0;for(let e=h;e<h+368;e++)S+=x[e];S>0&&(b[e.$t.selfP99]=Math.min(s(x,h,S,.99)/1e3,v));let{bounds:C,counts:w}=c(o,h),T={"metric.name":e.tn,"metric.unit":`ms`,"metric.type":`histogram`,[e.zt.start]:i,[e.zt.attributeKeys]:[e.$t.probe,e.$t.sampleEvery],[e.zt.count]:g,[e.zt.sum]:a[m+d],[e.zt.min]:_,[e.zt.max]:v,[e.zt.bounds]:C,[e.zt.buckets]:w};a.fill(0,m,m+l),o.fill(0,h,h+368),x.fill(0,h,h+368),t.emit(e.tn,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.Jt;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-D4tJpDRc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-D4tJpDRc.cjs","names":["PROFILE_MAX_US","PROFILER_GLOBAL_KEY","TELEMETRY_SDK_VERSION","PROFILER_PROBE_LIMIT","PROFILE_KEYS","PROFILE_METRIC_NAME","METRIC_KEYS","PROFILER_CALIBRATION_PAIRS","require_constants","require_unref","require_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":"A,yHAaA,IAAMW,EAAY,GAGZC,EAAWD,EAAY,EAO7B,SAAgBE,EAAS,EAAoB,CAG3C,IAAMC,EAAQ,KAAK,IAAIC,EAAIf,EAAAA,EAAc,EAEzC,GAAIc,EAAQH,EACV,OAAOG,EAKT,IAAME,EAAQ,GAAK,KAAK,MAAMF,CAAK,EAAA,EACnC,OAASE,EAAQ,GAAA,EAA4BF,IAAUE,EAASJ,CAClE,CAOA,SAAgBK,EAAQ,EAAuB,CAC7C,GAAIC,EAAQP,EACV,OAAOO,EAIT,IAAMF,GAASE,IAAA,GAA8B,EAC7C,OAASP,GAAaO,EAAQN,IAAcI,IAAU,GAAKA,GAAS,CACtE,CAUA,SAAgBG,EAAa,EAAsB,EAAc,EAAe,EAAmB,CAEjG,IAAMC,EAAO,KAAK,IAAI,EAAG,KAAK,KAAKC,EAAIC,CAAK,CAAC,EACzCC,EAAM,EAGV,IAAK,IAAIC,EAAI,EAAGA,EAAA,IAAqB,IAGnC,GAFA,GAAOC,EAAQC,EAAOF,GAElBD,GAAOH,EACT,OAAOH,EAAQO,CAAC,EAKpB,OAAOP,EAAA,GAA2B,CACpC,CAQA,SAAgBU,EACd,EACA,EACwC,CACxC,IAAIC,EAAQ,EACZ,KAAOA,EAAA,KAA2BH,EAAQC,EAAOE,KAAW,GAC1D,IAGF,GAAIA,IAAA,IACF,MAAO,C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3E,EAAO,IACxE,EAAO,YAAY,IAAI,EAKzB,GAAI2E,IAAS3E,EACX,OAIF,IAAM6E,EAAQF,EAAA,EACVG,EAAOH,EACPI,EAAc,EAClB,IAAK,IAAIC,EAAQ,EAAGA,EAAQrG,EAAAA,GAA4B,IAAS,CAC/D,IAAMiD,EAAQD,EAAM,MAAM,EAG1B,GAFAA,EAAM,IAAIC,CAAK,EAEXA,IAAUkD,IACZ,EAAOlD,EACP,EAAcoD,EAEVpD,GAASiD,GACX,KAGN,CAGIE,EAAc,IAChB,KAAK,SAAW,KAAK,OAAQD,EAAOH,GAAQ,IAAOI,CAAW,EAElE,CACF,EAMA,SAAgBE,GAA6B,CAE3C,IAAMC,EAAQ,WACRC,EAASD,EAAMlE,GACrB,GAAImE,EACF,OAAOA,EAGT,IAAMC,EAAO,IAAIlE,EAEjB,MADA,GAAMF,GAAYoE,EACXA,CACT,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-CqdJhTxH.cjs"),t=require("./profiler-D4tJpDRc.cjs"),n=require("./storm-C-zYSdDX.cjs"),r=require("./defineProperty-X1c4tIPD.cjs");var i=`long-animation-frame`,a=class{constructor(e){r.t(this,`ctx`,void 0),r.t(this,`name`,`frame-phases`),r.t(this,`observer`,void 0),r.t(this,`window`,{start:0,count:0}),this.ctx=e}install(){if(!this.observer){if((typeof PerformanceObserver>`u`?void 0:PerformanceObserver.supportedEntryTypes)?.includes(i))t.t().link(1),this.observer=new PerformanceObserver(e=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a long animation frame of the profiler.`,()=>{for(let t of e.getEntries())this.record(t)})}),this.observer.observe({type:i});else{let{once:e}=this.ctx;e.framePhases||(e.framePhases=!0,this.ctx.diagnostics.report(`capture.install_failed`,`The browser does not report long animation frames. profiler.framePhases is off.`))}}}uninstall(){this.observer&&(this.observer.disconnect(),this.observer=void 0,t.t().link(1/0))}record(r){let i=r.startTime,a=i+r.duration,o=t.t().linked(i,a);if(o.length===0)return;let{captureLimits:s}=this.ctx.config;if(!n.t(this.window,s.longFramesPerWindow,this.ctx.diagnostics,`profiler frames`,s.windowMs))return;let c=(e=0)=>e>0?e:a,l=c(r.renderStart),u=c(r.styleAndLayoutStart),d=0;for(let e of r.scripts??[])d+=e.forcedStyleAndLayoutDuration??0;let f=[[`script`,l-i],[`render`,u-l],[`style_layout`,a-u],[`forced_layout`,d]];for(let t of o)for(let[n,r]of f)this.ctx.logger.logMetric(e.Zt,r,`ms`,`histogram`,{[e.$t.probe]:t,[e.$t.framePhase]:n})}},o=class{constructor(e){r.t(this,`ctx`,void 0),r.t(this,`name`,`frame-pacing`),r.t(this,`handle`,void 0),r.t(this,`last`,-1),r.t(this,`onVisibility`,()=>{this.last=-1}),this.ctx=e}install(){let n=globalThis,{requestAnimationFrame:r}=n;if(this.handle!==void 0)return;if(typeof r!=`function`){let{once:e}=this.ctx;e.framePacing||(e.framePacing=!0,this.ctx.diagnostics.report(`capture.install_failed`,`This context has no frame callback. The frame pacing of the profiler is off.`));return}let i=t.t().probe(e.Qt,void 0,this.ctx.diagnostics),a=e=>{try{this.last>=0&&i.record(e-this.last)}catch(e){this.ctx.diagnostics.report(`capture.record_failed`,`The library could not record a frame interval of the profiler.`,void 0,e)}this.last=e,this.handle=r(a)};n.document?.addEventListener(`visibilitychange`,this.onVisibility),this.handle=r(a)}uninstall(){let e=globalThis;this.handle!==void 0&&(e.cancelAnimationFrame?.(this.handle),e.document?.removeEventListener(`visibilitychange`,this.onVisibility),this.handle=void 0,this.last=-1)}};exports.FramePacingCapture=o,exports.FramePhasesCapture=a;
|
|
2
|
+
//# sourceMappingURL=profiler-frames-C4xr7KfH.cjs.map
|