testplane 9.1.1 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/build/package.json +2 -2
  2. package/build/src/base-testplane.d.ts +17 -1
  3. package/build/src/base-testplane.js +43 -9
  4. package/build/src/base-testplane.js.map +1 -1
  5. package/build/src/browser/browser.d.ts +3 -0
  6. package/build/src/browser/browser.js +4 -2
  7. package/build/src/browser/browser.js.map +1 -1
  8. package/build/src/browser/cdp/selectivity/testplane-selectivity.js +19 -19
  9. package/build/src/browser/cdp/selectivity/testplane-selectivity.js.map +1 -1
  10. package/build/src/browser/client-scripts/screen-shooter/build/bundle.compat.js +2 -2
  11. package/build/src/browser/client-scripts/screen-shooter/build/bundle.native.js +2 -2
  12. package/build/src/browser/client-scripts/screen-shooter/tsc-out/client-scripts/screen-shooter/implementation.js +52 -84
  13. package/build/src/browser/client-scripts/screen-shooter/tsc-out/client-scripts/screen-shooter/operations.js +4 -1
  14. package/build/src/browser/commands/assert-view/index.js +25 -2
  15. package/build/src/browser/commands/assert-view/index.js.map +1 -1
  16. package/build/src/browser/existing-browser.js +8 -1
  17. package/build/src/browser/existing-browser.js.map +1 -1
  18. package/build/src/browser/history/index.d.ts +4 -2
  19. package/build/src/browser/history/index.js +146 -67
  20. package/build/src/browser/history/index.js.map +1 -1
  21. package/build/src/browser/new-browser.js +1 -1
  22. package/build/src/browser/new-browser.js.map +1 -1
  23. package/build/src/browser/screen-shooter/elements-screen-shooter.d.ts +5 -0
  24. package/build/src/browser/screen-shooter/elements-screen-shooter.js +102 -55
  25. package/build/src/browser/screen-shooter/elements-screen-shooter.js.map +1 -1
  26. package/build/src/browser/screen-shooter/viewport-screen-shooter.d.ts +4 -0
  27. package/build/src/browser/screen-shooter/viewport-screen-shooter.js +29 -7
  28. package/build/src/browser/screen-shooter/viewport-screen-shooter.js.map +1 -1
  29. package/build/src/browser-pool/basic-pool.d.ts +4 -3
  30. package/build/src/browser-pool/basic-pool.js +39 -7
  31. package/build/src/browser-pool/basic-pool.js.map +1 -1
  32. package/build/src/browser-pool/caching-pool.d.ts +3 -2
  33. package/build/src/browser-pool/caching-pool.js +19 -7
  34. package/build/src/browser-pool/caching-pool.js.map +1 -1
  35. package/build/src/browser-pool/index.d.ts +2 -1
  36. package/build/src/browser-pool/index.js +8 -4
  37. package/build/src/browser-pool/index.js.map +1 -1
  38. package/build/src/browser-pool/limited-pool.d.ts +5 -1
  39. package/build/src/browser-pool/limited-pool.js +42 -4
  40. package/build/src/browser-pool/limited-pool.js.map +1 -1
  41. package/build/src/browser-pool/per-browser-limited-pool.d.ts +2 -2
  42. package/build/src/browser-pool/per-browser-limited-pool.js +2 -1
  43. package/build/src/browser-pool/per-browser-limited-pool.js.map +1 -1
  44. package/build/src/browser-pool/types.d.ts +8 -0
  45. package/build/src/cli/commands/config/index.js +7 -3
  46. package/build/src/cli/commands/config/index.js.map +1 -1
  47. package/build/src/cli/commands/install-deps/index.js +46 -38
  48. package/build/src/cli/commands/install-deps/index.js.map +1 -1
  49. package/build/src/cli/commands/list-browsers/index.js +15 -11
  50. package/build/src/cli/commands/list-browsers/index.js.map +1 -1
  51. package/build/src/cli/commands/list-tests/index.js +25 -21
  52. package/build/src/cli/commands/list-tests/index.js.map +1 -1
  53. package/build/src/cli/commands/selectivity-merge-dumps/index.js +12 -5
  54. package/build/src/cli/commands/selectivity-merge-dumps/index.js.map +1 -1
  55. package/build/src/cli/index.js +10 -6
  56. package/build/src/cli/index.js.map +1 -1
  57. package/build/src/config/defaults.d.ts +5 -0
  58. package/build/src/config/defaults.js +4 -0
  59. package/build/src/config/defaults.js.map +1 -1
  60. package/build/src/config/index.d.ts +6 -4
  61. package/build/src/config/index.js +60 -19
  62. package/build/src/config/index.js.map +1 -1
  63. package/build/src/config/options.js +26 -0
  64. package/build/src/config/options.js.map +1 -1
  65. package/build/src/config/types.d.ts +19 -0
  66. package/build/src/constants/process-messages.d.ts +3 -0
  67. package/build/src/constants/process-messages.js +4 -1
  68. package/build/src/constants/process-messages.js.map +1 -1
  69. package/build/src/events/async-emitter/index.d.ts +38 -0
  70. package/build/src/events/async-emitter/index.js +248 -5
  71. package/build/src/events/async-emitter/index.js.map +1 -1
  72. package/build/src/events/index.d.ts +3 -0
  73. package/build/src/events/index.js +1 -0
  74. package/build/src/events/index.js.map +1 -1
  75. package/build/src/index.d.ts +2 -1
  76. package/build/src/profiler/analysis/aggregator.d.ts +19 -0
  77. package/build/src/profiler/analysis/aggregator.js +229 -0
  78. package/build/src/profiler/analysis/aggregator.js.map +1 -0
  79. package/build/src/profiler/analysis/analyzers.d.ts +10 -0
  80. package/build/src/profiler/analysis/analyzers.js +1228 -0
  81. package/build/src/profiler/analysis/analyzers.js.map +1 -0
  82. package/build/src/profiler/analysis/compact.d.ts +5 -0
  83. package/build/src/profiler/analysis/compact.js +46 -0
  84. package/build/src/profiler/analysis/compact.js.map +1 -0
  85. package/build/src/profiler/analysis/finding-order.d.ts +4 -0
  86. package/build/src/profiler/analysis/finding-order.js +28 -0
  87. package/build/src/profiler/analysis/finding-order.js.map +1 -0
  88. package/build/src/profiler/analysis/outliers.d.ts +6 -0
  89. package/build/src/profiler/analysis/outliers.js +49 -0
  90. package/build/src/profiler/analysis/outliers.js.map +1 -0
  91. package/build/src/profiler/analysis/policy-v1.d.ts +71 -0
  92. package/build/src/profiler/analysis/policy-v1.js +43 -0
  93. package/build/src/profiler/analysis/policy-v1.js.map +1 -0
  94. package/build/src/profiler/collectors/module-graph.d.ts +14 -0
  95. package/build/src/profiler/collectors/module-graph.js +99 -0
  96. package/build/src/profiler/collectors/module-graph.js.map +1 -0
  97. package/build/src/profiler/collectors/pool-observer.d.ts +9 -0
  98. package/build/src/profiler/collectors/pool-observer.js +40 -0
  99. package/build/src/profiler/collectors/pool-observer.js.map +1 -0
  100. package/build/src/profiler/manager.d.ts +55 -0
  101. package/build/src/profiler/manager.js +343 -0
  102. package/build/src/profiler/manager.js.map +1 -0
  103. package/build/src/profiler/output/console.d.ts +6 -0
  104. package/build/src/profiler/output/console.js +443 -0
  105. package/build/src/profiler/output/console.js.map +1 -0
  106. package/build/src/profiler/output/json.d.ts +2 -0
  107. package/build/src/profiler/output/json.js +24 -0
  108. package/build/src/profiler/output/json.js.map +1 -0
  109. package/build/src/profiler/retention/operation-store.d.ts +22 -0
  110. package/build/src/profiler/retention/operation-store.js +110 -0
  111. package/build/src/profiler/retention/operation-store.js.map +1 -0
  112. package/build/src/profiler/retention/policy-v1.d.ts +22 -0
  113. package/build/src/profiler/retention/policy-v1.js +49 -0
  114. package/build/src/profiler/retention/policy-v1.js.map +1 -0
  115. package/build/src/profiler/retention/result-budget.d.ts +2 -0
  116. package/build/src/profiler/retention/result-budget.js +117 -0
  117. package/build/src/profiler/retention/result-budget.js.map +1 -0
  118. package/build/src/profiler/retention/serialized-budget.d.ts +5 -0
  119. package/build/src/profiler/retention/serialized-budget.js +58 -0
  120. package/build/src/profiler/retention/serialized-budget.js.map +1 -0
  121. package/build/src/profiler/retention/streaming-statistics.d.ts +38 -0
  122. package/build/src/profiler/retention/streaming-statistics.js +191 -0
  123. package/build/src/profiler/retention/streaming-statistics.js.map +1 -0
  124. package/build/src/profiler/retention/top-k.d.ts +13 -0
  125. package/build/src/profiler/retention/top-k.js +57 -0
  126. package/build/src/profiler/retention/top-k.js.map +1 -0
  127. package/build/src/profiler/runtime/async-activity.d.ts +19 -0
  128. package/build/src/profiler/runtime/async-activity.js +113 -0
  129. package/build/src/profiler/runtime/async-activity.js.map +1 -0
  130. package/build/src/profiler/runtime/bootstrap-probe.d.ts +42 -0
  131. package/build/src/profiler/runtime/bootstrap-probe.js +91 -0
  132. package/build/src/profiler/runtime/bootstrap-probe.js.map +1 -0
  133. package/build/src/profiler/runtime/clock.d.ts +22 -0
  134. package/build/src/profiler/runtime/clock.js +15 -0
  135. package/build/src/profiler/runtime/clock.js.map +1 -0
  136. package/build/src/profiler/runtime/event-observer.d.ts +4 -0
  137. package/build/src/profiler/runtime/event-observer.js +142 -0
  138. package/build/src/profiler/runtime/event-observer.js.map +1 -0
  139. package/build/src/profiler/runtime/noop.d.ts +20 -0
  140. package/build/src/profiler/runtime/noop.js +37 -0
  141. package/build/src/profiler/runtime/noop.js.map +1 -0
  142. package/build/src/profiler/runtime/runtime.d.ts +95 -0
  143. package/build/src/profiler/runtime/runtime.js +1343 -0
  144. package/build/src/profiler/runtime/runtime.js.map +1 -0
  145. package/build/src/profiler/runtime/types.d.ts +88 -0
  146. package/build/src/profiler/runtime/types.js +3 -0
  147. package/build/src/profiler/runtime/types.js.map +1 -0
  148. package/build/src/profiler/sanitize.d.ts +15 -0
  149. package/build/src/profiler/sanitize.js +194 -0
  150. package/build/src/profiler/sanitize.js.map +1 -0
  151. package/build/src/profiler/schema/index.d.ts +1 -0
  152. package/build/src/profiler/schema/index.js +18 -0
  153. package/build/src/profiler/schema/index.js.map +1 -0
  154. package/build/src/profiler/schema/v1.d.ts +281 -0
  155. package/build/src/profiler/schema/v1.js +3 -0
  156. package/build/src/profiler/schema/v1.js.map +1 -0
  157. package/build/src/runner/browser-env/vite/browser-modules/mocha/index.js +30 -0
  158. package/build/src/runner/browser-env/vite/browser-modules/mocha/index.js.map +1 -1
  159. package/build/src/runner/browser-env/vite/browser-modules/tsconfig.tsbuildinfo +1 -1
  160. package/build/src/runner/browser-env/vite/browser-modules/types.d.ts +31 -6
  161. package/build/src/runner/browser-env/vite/browser-modules/types.js +8 -8
  162. package/build/src/runner/browser-env/vite/browser-modules/types.js.map +1 -1
  163. package/build/src/runner/browser-env/vite/plugins/generate-index-html.d.ts +7 -1
  164. package/build/src/runner/browser-env/vite/plugins/generate-index-html.js +28 -6
  165. package/build/src/runner/browser-env/vite/plugins/generate-index-html.js.map +1 -1
  166. package/build/src/runner/browser-env/vite/server.js +17 -1
  167. package/build/src/runner/browser-env/vite/server.js.map +1 -1
  168. package/build/src/runner/browser-env/vite/socket.js +4 -0
  169. package/build/src/runner/browser-env/vite/socket.js.map +1 -1
  170. package/build/src/runner/browser-env/vite/types.d.ts +9 -7
  171. package/build/src/runner/browser-env/vite/types.js +8 -8
  172. package/build/src/runner/browser-env/vite/types.js.map +1 -1
  173. package/build/src/runner/browser-env/vite/utils.js +9 -2
  174. package/build/src/runner/browser-env/vite/utils.js.map +1 -1
  175. package/build/src/runner/browser-runner.d.ts +3 -1
  176. package/build/src/runner/browser-runner.js +4 -2
  177. package/build/src/runner/browser-runner.js.map +1 -1
  178. package/build/src/runner/index.d.ts +3 -1
  179. package/build/src/runner/index.js +7 -4
  180. package/build/src/runner/index.js.map +1 -1
  181. package/build/src/runner/test-runner/index.d.ts +2 -1
  182. package/build/src/runner/test-runner/index.js +2 -2
  183. package/build/src/runner/test-runner/index.js.map +1 -1
  184. package/build/src/runner/test-runner/insistant-test-runner.d.ts +2 -1
  185. package/build/src/runner/test-runner/insistant-test-runner.js +3 -2
  186. package/build/src/runner/test-runner/insistant-test-runner.js.map +1 -1
  187. package/build/src/runner/test-runner/regular-test-runner.d.ts +9 -3
  188. package/build/src/runner/test-runner/regular-test-runner.js +77 -16
  189. package/build/src/runner/test-runner/regular-test-runner.js.map +1 -1
  190. package/build/src/signal-handler.js +14 -5
  191. package/build/src/signal-handler.js.map +1 -1
  192. package/build/src/test-reader/index.d.ts +2 -1
  193. package/build/src/test-reader/index.js +19 -10
  194. package/build/src/test-reader/index.js.map +1 -1
  195. package/build/src/test-reader/mocha-reader/index.d.ts +2 -1
  196. package/build/src/test-reader/mocha-reader/index.js +41 -24
  197. package/build/src/test-reader/mocha-reader/index.js.map +1 -1
  198. package/build/src/test-reader/mocha-reader/tree-builder-decorator.js +2 -2
  199. package/build/src/test-reader/mocha-reader/tree-builder-decorator.js.map +1 -1
  200. package/build/src/test-reader/mocha-reader/utils.d.ts +2 -0
  201. package/build/src/test-reader/mocha-reader/utils.js +18 -2
  202. package/build/src/test-reader/mocha-reader/utils.js.map +1 -1
  203. package/build/src/test-reader/test-object/hook.d.ts +4 -2
  204. package/build/src/test-reader/test-object/hook.js +3 -1
  205. package/build/src/test-reader/test-object/hook.js.map +1 -1
  206. package/build/src/test-reader/test-parser.d.ts +2 -1
  207. package/build/src/test-reader/test-parser.js +48 -4
  208. package/build/src/test-reader/test-parser.js.map +1 -1
  209. package/build/src/testplane.d.ts +6 -2
  210. package/build/src/testplane.js +82 -27
  211. package/build/src/testplane.js.map +1 -1
  212. package/build/src/types/index.d.ts +4 -1
  213. package/build/src/types/index.js.map +1 -1
  214. package/build/src/utils/exit-code.d.ts +1 -0
  215. package/build/src/utils/exit-code.js +28 -0
  216. package/build/src/utils/exit-code.js.map +1 -0
  217. package/build/src/utils/module-observer-registry.d.ts +43 -0
  218. package/build/src/utils/module-observer-registry.js +257 -0
  219. package/build/src/utils/module-observer-registry.js.map +1 -0
  220. package/build/src/utils/processor.js +1 -0
  221. package/build/src/utils/processor.js.map +1 -1
  222. package/build/src/utils/workers-registry.d.ts +48 -1
  223. package/build/src/utils/workers-registry.js +162 -4
  224. package/build/src/utils/workers-registry.js.map +1 -1
  225. package/build/src/worker/browser-env/runner/test-runner/execution-thread.js +15 -1
  226. package/build/src/worker/browser-env/runner/test-runner/execution-thread.js.map +1 -1
  227. package/build/src/worker/browser-env/runner/test-runner/index.js +20 -0
  228. package/build/src/worker/browser-env/runner/test-runner/index.js.map +1 -1
  229. package/build/src/worker/index.js +39 -1
  230. package/build/src/worker/index.js.map +1 -1
  231. package/build/src/worker/runner/browser-pool.d.ts +3 -2
  232. package/build/src/worker/runner/browser-pool.js +5 -3
  233. package/build/src/worker/runner/browser-pool.js.map +1 -1
  234. package/build/src/worker/runner/caching-test-parser.d.ts +6 -1
  235. package/build/src/worker/runner/caching-test-parser.js +40 -4
  236. package/build/src/worker/runner/caching-test-parser.js.map +1 -1
  237. package/build/src/worker/runner/index.d.ts +10 -9
  238. package/build/src/worker/runner/index.js +52 -6
  239. package/build/src/worker/runner/index.js.map +1 -1
  240. package/build/src/worker/runner/sequence-test-parser.d.ts +4 -1
  241. package/build/src/worker/runner/sequence-test-parser.js +17 -3
  242. package/build/src/worker/runner/sequence-test-parser.js.map +1 -1
  243. package/build/src/worker/runner/simple-test-parser.d.ts +3 -1
  244. package/build/src/worker/runner/simple-test-parser.js +4 -2
  245. package/build/src/worker/runner/simple-test-parser.js.map +1 -1
  246. package/build/src/worker/runner/test-runner/execution-thread.d.ts +20 -2
  247. package/build/src/worker/runner/test-runner/execution-thread.js +37 -2
  248. package/build/src/worker/runner/test-runner/execution-thread.js.map +1 -1
  249. package/build/src/worker/runner/test-runner/hook-runner.d.ts +1 -1
  250. package/build/src/worker/runner/test-runner/hook-runner.js +4 -4
  251. package/build/src/worker/runner/test-runner/hook-runner.js.map +1 -1
  252. package/build/src/worker/runner/test-runner/index.d.ts +8 -7
  253. package/build/src/worker/runner/test-runner/index.js +36 -25
  254. package/build/src/worker/runner/test-runner/index.js.map +1 -1
  255. package/build/src/worker/runner/test-runner/types.d.ts +8 -1
  256. package/build/src/worker/testplane-facade.js +63 -4
  257. package/build/src/worker/testplane-facade.js.map +1 -1
  258. package/build/src/worker/testplane.d.ts +6 -0
  259. package/build/src/worker/testplane.js +7 -1
  260. package/build/src/worker/testplane.js.map +1 -1
  261. package/package.json +2 -2
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncActivityTracker = void 0;
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
+ class AsyncActivityTracker {
6
+ constructor(_clock, _currentSpanId, onError) {
7
+ this._clock = _clock;
8
+ this._currentSpanId = _currentSpanId;
9
+ this._resourceSpans = new Map();
10
+ this._activeSegments = new Map();
11
+ this._activeMs = new Map();
12
+ this._activeSpans = new Set();
13
+ this._enabled = false;
14
+ const safe = (action) => {
15
+ try {
16
+ action();
17
+ }
18
+ catch (error) {
19
+ try {
20
+ onError(error);
21
+ }
22
+ catch {
23
+ // async_hooks callbacks must never throw.
24
+ }
25
+ }
26
+ };
27
+ this._hook = (0, node_async_hooks_1.createHook)({
28
+ init: asyncId => safe(() => {
29
+ const spanId = this._currentSpanId();
30
+ if (spanId && this._activeSpans.has(spanId)) {
31
+ this._resourceSpans.set(asyncId, spanId);
32
+ }
33
+ }),
34
+ before: asyncId => safe(() => {
35
+ const spanId = this._resourceSpans.get(asyncId);
36
+ if (spanId && this._activeSpans.has(spanId)) {
37
+ this._activeSegments.set(asyncId, { spanId, startedAt: this._clock.now() });
38
+ }
39
+ }),
40
+ after: asyncId => safe(() => this._finishSegment(asyncId)),
41
+ destroy: asyncId => safe(() => this._deleteResource(asyncId)),
42
+ promiseResolve: asyncId => safe(() => this._finishSegment(asyncId)),
43
+ });
44
+ }
45
+ startSpan(spanId) {
46
+ if (!this._activeSpans.size) {
47
+ this._hook.enable();
48
+ this._enabled = true;
49
+ }
50
+ this._activeSpans.add(spanId);
51
+ }
52
+ measureSynchronous(spanId, action) {
53
+ if (!spanId) {
54
+ return action();
55
+ }
56
+ const startedAt = this._clock.now();
57
+ try {
58
+ return action();
59
+ }
60
+ finally {
61
+ this._add(spanId, this._clock.now() - startedAt);
62
+ }
63
+ }
64
+ finishSpan(spanId) {
65
+ let activeMs = this._activeMs.get(spanId) ?? 0;
66
+ const current = this._activeSegments.get((0, node_async_hooks_1.executionAsyncId)());
67
+ if (current?.spanId === spanId) {
68
+ activeMs += Math.max(0, this._clock.now() - current.startedAt);
69
+ this._activeSegments.delete((0, node_async_hooks_1.executionAsyncId)());
70
+ }
71
+ this._activeMs.delete(spanId);
72
+ this._activeSpans.delete(spanId);
73
+ if (!this._activeSpans.size) {
74
+ this._hook.disable();
75
+ this._enabled = false;
76
+ this._resourceSpans.clear();
77
+ this._activeSegments.clear();
78
+ }
79
+ return activeMs;
80
+ }
81
+ disable() {
82
+ if (this._enabled) {
83
+ this._hook.disable();
84
+ this._enabled = false;
85
+ }
86
+ this._resourceSpans.clear();
87
+ this._activeSegments.clear();
88
+ this._activeMs.clear();
89
+ this._activeSpans.clear();
90
+ }
91
+ _finishSegment(asyncId) {
92
+ const segment = this._activeSegments.get(asyncId);
93
+ if (!segment) {
94
+ return;
95
+ }
96
+ this._activeSegments.delete(asyncId);
97
+ if (this._activeSpans.has(segment.spanId)) {
98
+ this._add(segment.spanId, this._clock.now() - segment.startedAt);
99
+ }
100
+ }
101
+ _deleteResource(asyncId) {
102
+ this._finishSegment(asyncId);
103
+ this._resourceSpans.delete(asyncId);
104
+ }
105
+ _add(spanId, durationMs) {
106
+ if (!this._activeSpans.has(spanId)) {
107
+ return;
108
+ }
109
+ this._activeMs.set(spanId, (this._activeMs.get(spanId) ?? 0) + Math.max(0, durationMs));
110
+ }
111
+ }
112
+ exports.AsyncActivityTracker = AsyncActivityTracker;
113
+ //# sourceMappingURL=async-activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-activity.js","sourceRoot":"","sources":["../../../../src/profiler/runtime/async-activity.ts"],"names":[],"mappings":";;;AAAA,uDAAgF;AAShF,MAAa,oBAAoB;IAQ7B,YACqB,MAAqB,EACrB,cAAwC,EACzD,OAAiC;QAFhB,WAAM,GAAN,MAAM,CAAe;QACrB,mBAAc,GAAd,cAAc,CAA0B;QAT5C,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,oBAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;QACnD,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QACtC,iBAAY,GAAG,IAAI,GAAG,EAAU,CAAC;QAE1C,aAAQ,GAAG,KAAK,CAAC;QAOrB,MAAM,IAAI,GAAG,CAAC,MAAkB,EAAQ,EAAE;YACtC,IAAI,CAAC;gBACD,MAAM,EAAE,CAAC;YACb,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,CAAC;oBACD,OAAO,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBAAC,MAAM,CAAC;oBACL,0CAA0C;gBAC9C,CAAC;YACL,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG,IA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CAAC,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5F,CAAC;CACJ;AArHD,oDAqHC"}
@@ -0,0 +1,42 @@
1
+ import { ProfilerClock } from "./clock";
2
+ interface BootstrapRecord {
3
+ id: number;
4
+ parentId?: number;
5
+ kind: string;
6
+ name: string;
7
+ /** Monotonic clock value when the startup phase began. */
8
+ startMs: number;
9
+ /** Monotonic clock value when the startup phase ended. */
10
+ endMs: number;
11
+ /** CPU time used by the process while this startup phase was open. */
12
+ processCpuMs: number;
13
+ status: "completed" | "failed" | "interrupted";
14
+ }
15
+ interface BootstrapPhase {
16
+ end(status?: BootstrapRecord["status"]): void;
17
+ }
18
+ /**
19
+ * Records the small part of startup that happens before profiler.level is known.
20
+ * It deliberately uses only a bounded array and clock/CPU snapshots.
21
+ */
22
+ export declare class BootstrapProbe {
23
+ /** ISO 8601 wall-clock time when the bootstrap probe started. */
24
+ readonly startedAt: string;
25
+ /** Unix wall-clock timestamp in milliseconds when the probe started. */
26
+ readonly startedAtEpochMs: number;
27
+ /** High-resolution monotonic clock value used as the local timing origin. */
28
+ readonly startedAtMonotonicMs: number;
29
+ private readonly _clock;
30
+ private readonly _records;
31
+ private readonly _open;
32
+ private readonly _stack;
33
+ private _sequence;
34
+ private _discarded;
35
+ constructor(clock?: ProfilerClock);
36
+ startPhase(kind: string, name?: string): BootstrapPhase;
37
+ withPhase<T>(kind: string, name: string, action: () => T | Promise<T>): Promise<T>;
38
+ takeRecords(): BootstrapRecord[];
39
+ discard(): void;
40
+ private _finishPhase;
41
+ }
42
+ export {};
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BootstrapProbe = void 0;
4
+ const clock_1 = require("./clock");
5
+ const NOOP_BOOTSTRAP_PHASE = Object.freeze({ end: () => undefined });
6
+ /**
7
+ * Records the small part of startup that happens before profiler.level is known.
8
+ * It deliberately uses only a bounded array and clock/CPU snapshots.
9
+ */
10
+ class BootstrapProbe {
11
+ constructor(clock = clock_1.systemClock) {
12
+ this._records = [];
13
+ this._open = new Set();
14
+ this._stack = [];
15
+ this._sequence = 0;
16
+ this._discarded = false;
17
+ this._clock = clock;
18
+ this.startedAtEpochMs = clock.epochNow();
19
+ this.startedAtMonotonicMs = clock.now();
20
+ this.startedAt = new Date(this.startedAtEpochMs).toISOString();
21
+ }
22
+ startPhase(kind, name = kind) {
23
+ if (this._discarded) {
24
+ return NOOP_BOOTSTRAP_PHASE;
25
+ }
26
+ const phase = {
27
+ id: ++this._sequence,
28
+ parentId: this._stack.at(-1)?.id,
29
+ kind,
30
+ name,
31
+ startMs: this._clock.now(),
32
+ cpu: this._clock.cpuUsage(),
33
+ ended: false,
34
+ };
35
+ this._open.add(phase);
36
+ this._stack.push(phase);
37
+ return {
38
+ end: (status = "completed") => this._finishPhase(phase, status),
39
+ };
40
+ }
41
+ async withPhase(kind, name, action) {
42
+ const phase = this.startPhase(kind, name);
43
+ try {
44
+ const result = await action();
45
+ phase.end();
46
+ return result;
47
+ }
48
+ catch (error) {
49
+ phase.end("failed");
50
+ throw error;
51
+ }
52
+ }
53
+ takeRecords() {
54
+ if (this._discarded) {
55
+ return [];
56
+ }
57
+ for (const phase of this._open) {
58
+ this._finishPhase(phase, "interrupted");
59
+ }
60
+ return this._records.splice(0);
61
+ }
62
+ discard() {
63
+ this._discarded = true;
64
+ this._records.length = 0;
65
+ this._open.clear();
66
+ this._stack.length = 0;
67
+ }
68
+ _finishPhase(phase, status) {
69
+ if (phase.ended || this._discarded) {
70
+ return;
71
+ }
72
+ phase.ended = true;
73
+ this._open.delete(phase);
74
+ const stackIndex = this._stack.lastIndexOf(phase);
75
+ if (stackIndex >= 0) {
76
+ this._stack.splice(stackIndex, 1);
77
+ }
78
+ this._records.push({
79
+ id: phase.id,
80
+ parentId: phase.parentId,
81
+ kind: phase.kind,
82
+ name: phase.name,
83
+ startMs: phase.startMs,
84
+ endMs: this._clock.now(),
85
+ processCpuMs: (0, clock_1.cpuUsageToMs)(this._clock.cpuUsage(phase.cpu)),
86
+ status,
87
+ });
88
+ }
89
+ }
90
+ exports.BootstrapProbe = BootstrapProbe;
91
+ //# sourceMappingURL=bootstrap-probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-probe.js","sourceRoot":"","sources":["../../../../src/profiler/runtime/bootstrap-probe.ts"],"names":[],"mappings":";;;AAAA,mCAAmE;AA+BnE,MAAM,oBAAoB,GAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAa,cAAc;IAevB,YAAY,QAAuB,mBAAW;QAN7B,aAAQ,GAAsB,EAAE,CAAC;QACjC,UAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QACtC,WAAM,GAAyB,EAAE,CAAC;QAC3C,cAAS,GAAG,CAAC,CAAC;QACd,eAAU,GAAG,KAAK,CAAC;QAGvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,OAAe,IAAI;QACxC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,OAAO,oBAAoB,CAAC;QAChC,CAAC;QAED,MAAM,KAAK,GAAuB;YAC9B,EAAE,EAAE,EAA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C,CAAC;IAED,OAAO;QACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEO,YAAY,CAAC,KAAyB,EAAE,MAAiC;QAC7E,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QAED,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YACxB,YAAY,EAAE,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3D,MAAM;SACT,CAAC,CAAC;IACP,CAAC;CACJ;AAlGD,wCAkGC"}
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="mocha" />
5
+ /// <reference types="expect-webdriverio" />
6
+ /// <reference types="node" />
7
+ /// <reference types="node" />
8
+ /// <reference types="node" />
9
+ /// <reference types="node" />
10
+ /// <reference types="node" />
11
+ export interface ProfilerClock {
12
+ /** High-resolution monotonic time in milliseconds. It is suitable for measuring elapsed time. */
13
+ now(): number;
14
+ /** Unix wall-clock timestamp in milliseconds. It is suitable for timestamps shared between processes. */
15
+ epochNow(): number;
16
+ /** Process CPU usage since startup, or since `previousValue` when it is supplied. */
17
+ cpuUsage(previousValue?: NodeJS.CpuUsage): NodeJS.CpuUsage;
18
+ /** Current-thread CPU usage since startup, or since `previousValue` when it is supplied. */
19
+ threadCpuUsage?(previousValue?: NodeJS.CpuUsage): NodeJS.CpuUsage;
20
+ }
21
+ export declare const systemClock: ProfilerClock;
22
+ export declare const cpuUsageToMs: (usage: NodeJS.CpuUsage) => number;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cpuUsageToMs = exports.systemClock = void 0;
4
+ const node_perf_hooks_1 = require("node:perf_hooks");
5
+ exports.systemClock = {
6
+ now: () => node_perf_hooks_1.performance.now(),
7
+ epochNow: () => Date.now(),
8
+ cpuUsage: (previousValue) => process.cpuUsage(previousValue),
9
+ threadCpuUsage: typeof process.threadCpuUsage === "function"
10
+ ? (previousValue) => process.threadCpuUsage(previousValue)
11
+ : undefined,
12
+ };
13
+ const cpuUsageToMs = (usage) => (usage.user + usage.system) / 1000;
14
+ exports.cpuUsageToMs = cpuUsageToMs;
15
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.js","sourceRoot":"","sources":["../../../../src/profiler/runtime/clock.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAajC,QAAA,WAAW,GAAkB;IACtC,GAAG,EAAE,GAAG,EAAE,CAAC,6BAAW,CAAC,GAAG,EAAE;IAC5B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IAC1B,QAAQ,EAAE,CAAC,aAAa,EAAmB,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAC7E,cAAc,EACV,OAAO,OAAO,CAAC,cAAc,KAAK,UAAU;QACxC,CAAC,CAAC,CAAC,aAAa,EAAmB,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC;QAC3E,CAAC,CAAC,SAAS;CACtB,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,KAAsB,EAAU,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAAtF,QAAA,YAAY,gBAA0E"}
@@ -0,0 +1,4 @@
1
+ import type { Config } from "../../config";
2
+ import type { EventObserver } from "../../events/async-emitter";
3
+ import type { ProfilerManager } from "../manager";
4
+ export declare function createProfilerEventObserver(manager: ProfilerManager, config: Config): EventObserver | undefined;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createProfilerEventObserver = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_url_1 = require("node:url");
10
+ const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
11
+ const sanitize_1 = require("../sanitize");
12
+ class ProfilerEventObserver {
13
+ constructor(_manager, config) {
14
+ this._manager = _manager;
15
+ this._sanitizer = new sanitize_1.ProfilerSanitizer();
16
+ this._plugins = buildPluginIndex(Object.keys(config.plugins ?? {}));
17
+ }
18
+ register({ event, listener }) {
19
+ const source = this._captureSource(listener.name);
20
+ return {
21
+ event: String(event),
22
+ functionName: listener.name || "<anonymous>",
23
+ origin: source?.internal ? "internal" : "user",
24
+ source: source?.ref,
25
+ };
26
+ }
27
+ observeSync(registration, action) {
28
+ return this._observe(registration, action);
29
+ }
30
+ async observeAsync(registration, action) {
31
+ return this._observe(registration, action);
32
+ }
33
+ observeSyncEmission(event, action) {
34
+ return this._manager.runtime.withSpan("event.emit", { minLevel: 2, name: String(event), attributes: { event: String(event), dispatch: "sync" } }, action);
35
+ }
36
+ observeAsyncEmission(event, action) {
37
+ return this._manager.runtime.withSpan("event.emit", { minLevel: 2, name: String(event), attributes: { event: String(event), dispatch: "async" } }, action);
38
+ }
39
+ error(stage, error) {
40
+ this._manager.runtime.recordError(stage, error);
41
+ }
42
+ _observe(registration, action) {
43
+ const { origin } = registration;
44
+ return this._manager.runtime.withSpan("event.listener", {
45
+ minLevel: 2,
46
+ name: `${origin === "internal" ? "internal:" : ""}${registration.event}:${registration.functionName}`,
47
+ source: registration.source,
48
+ attributes: {
49
+ event: registration.event,
50
+ function: registration.functionName,
51
+ plugin: registration.source?.plugin ?? null,
52
+ origin,
53
+ },
54
+ }, action);
55
+ }
56
+ _captureSource(functionName) {
57
+ try {
58
+ const frames = error_stack_parser_1.default.parse(new Error());
59
+ const frame = frames.find(candidate => {
60
+ const file = (candidate.fileName ?? "").replaceAll("\\", "/");
61
+ return (file &&
62
+ !file.includes("/src/profiler/") &&
63
+ !file.includes("/src/events/async-emitter/") &&
64
+ !file.startsWith("node:") &&
65
+ !file.includes("node:internal"));
66
+ });
67
+ if (!frame?.fileName) {
68
+ return { internal: false, ref: { functionName, confidence: "low" } };
69
+ }
70
+ const fileName = frame.fileName.startsWith("file:") ? (0, node_url_1.fileURLToPath)(frame.fileName) : frame.fileName;
71
+ const realFile = safeRealpath(fileName);
72
+ const plugin = this._plugins.find(candidate => isInside(realFile, candidate.root));
73
+ return {
74
+ internal: isTestplaneSource(realFile),
75
+ ref: {
76
+ file: this._sanitizer.path(realFile),
77
+ line: frame.lineNumber,
78
+ column: frame.columnNumber,
79
+ functionName,
80
+ plugin: plugin?.name,
81
+ confidence: plugin ? "high" : "medium",
82
+ },
83
+ };
84
+ }
85
+ catch (error) {
86
+ this.error("event.source", error);
87
+ return { internal: false, ref: { functionName, confidence: "low" } };
88
+ }
89
+ }
90
+ }
91
+ function buildPluginIndex(pluginNames) {
92
+ return pluginNames.flatMap(name => {
93
+ const entry = resolvePlugin(name) ?? resolvePlugin(`hermione-${name}`);
94
+ if (!entry) {
95
+ return [];
96
+ }
97
+ return [{ name, root: findPackageRoot(entry) }];
98
+ });
99
+ }
100
+ function resolvePlugin(name) {
101
+ try {
102
+ return require.resolve(name, { paths: [process.cwd()] });
103
+ }
104
+ catch {
105
+ return;
106
+ }
107
+ }
108
+ function findPackageRoot(entry) {
109
+ let current = node_path_1.default.dirname(entry);
110
+ while (current !== node_path_1.default.dirname(current)) {
111
+ if (node_fs_1.default.existsSync(node_path_1.default.join(current, "package.json"))) {
112
+ return current;
113
+ }
114
+ current = node_path_1.default.dirname(current);
115
+ }
116
+ return node_path_1.default.dirname(entry);
117
+ }
118
+ const testplaneRoot = findPackageRoot(__filename);
119
+ function isTestplaneSource(file) {
120
+ const relative = node_path_1.default.relative(testplaneRoot, file).split(node_path_1.default.sep).join("/");
121
+ return relative.startsWith("src/") || relative.startsWith("build/src/");
122
+ }
123
+ function safeRealpath(value) {
124
+ try {
125
+ return node_fs_1.default.realpathSync.native(value);
126
+ }
127
+ catch {
128
+ return node_path_1.default.resolve(value);
129
+ }
130
+ }
131
+ function isInside(file, directory) {
132
+ const relative = node_path_1.default.relative(directory, file);
133
+ return relative === "" || (!relative.startsWith("..") && !node_path_1.default.isAbsolute(relative));
134
+ }
135
+ function createProfilerEventObserver(manager, config) {
136
+ if (!manager.runtime.isEnabled(2)) {
137
+ return;
138
+ }
139
+ return new ProfilerEventObserver(manager, config);
140
+ }
141
+ exports.createProfilerEventObserver = createProfilerEventObserver;
142
+ //# sourceMappingURL=event-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-observer.js","sourceRoot":"","sources":["../../../../src/profiler/runtime/event-observer.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,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C"}
@@ -0,0 +1,20 @@
1
+ import type { CorrelationContext, EnabledProfilerLevel, ProfilerValue } from "../schema";
2
+ import type { ProfilerFragment, ProfilerRuntimeLike, RuntimeSnapshot, SpanHandle, SpanOptions } from "./types";
3
+ declare class NoopProfilerRuntime implements ProfilerRuntimeLike {
4
+ readonly level = 0;
5
+ isEnabled(_minLevel?: EnabledProfilerLevel): boolean;
6
+ startSpan(_kind: string, _options?: SpanOptions): SpanHandle;
7
+ withSpan<T>(_kind: string, _options: SpanOptions, action: () => T): T;
8
+ withContext<T>(_context: Partial<CorrelationContext>, action: () => T): T;
9
+ increment(_metric: string, _value?: number, _dimensions?: Record<string, ProfilerValue>): void;
10
+ sample(_metric: string, _value: number, _dimensions?: Record<string, ProfilerValue>): void;
11
+ recordError(_stage: string, _error: unknown): void;
12
+ recordMeasurement(_kind: string, _durationMs: number, _options?: SpanOptions, _status?: "completed" | "failed" | "interrupted"): void;
13
+ snapshot(): RuntimeSnapshot | null;
14
+ closeOpenSpans(): void;
15
+ stop(): void;
16
+ takeFragment(): ProfilerFragment | null;
17
+ ingestFragment(_fragment: unknown): void;
18
+ }
19
+ export declare const noopProfilerRuntime: Readonly<NoopProfilerRuntime>;
20
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noopProfilerRuntime = void 0;
4
+ /* eslint-disable @typescript-eslint/no-unused-vars -- method parameters document the no-op interface */
5
+ const NOOP_SPAN = Object.freeze({ end: () => undefined });
6
+ class NoopProfilerRuntime {
7
+ constructor() {
8
+ this.level = 0;
9
+ }
10
+ isEnabled(_minLevel = 1) {
11
+ return false;
12
+ }
13
+ startSpan(_kind, _options) {
14
+ return NOOP_SPAN;
15
+ }
16
+ withSpan(_kind, _options, action) {
17
+ return action();
18
+ }
19
+ withContext(_context, action) {
20
+ return action();
21
+ }
22
+ increment(_metric, _value, _dimensions) { }
23
+ sample(_metric, _value, _dimensions) { }
24
+ recordError(_stage, _error) { }
25
+ recordMeasurement(_kind, _durationMs, _options, _status) { }
26
+ snapshot() {
27
+ return null;
28
+ }
29
+ closeOpenSpans() { }
30
+ stop() { }
31
+ takeFragment() {
32
+ return null;
33
+ }
34
+ ingestFragment(_fragment) { }
35
+ }
36
+ exports.noopProfilerRuntime = Object.freeze(new NoopProfilerRuntime());
37
+ //# sourceMappingURL=noop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.js","sourceRoot":"","sources":["../../../../src/profiler/runtime/noop.ts"],"names":[],"mappings":";;;AAGA,wGAAwG;AAExG,MAAM,SAAS,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;AAEtE,MAAM,mBAAmB;IAAzB;QACa,UAAK,GAAG,CAAC,CAAC;IA4CvB,CAAC;IA1CG,SAAS,CAAC,YAAkC,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,QAAsB;QAC3C,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,QAAQ,CAAI,KAAa,EAAE,QAAqB,EAAE,MAAe;QAC7D,OAAO,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,WAAW,CAAI,QAAqC,EAAE,MAAe;QACjE,OAAO,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,SAAS,CAAC,OAAe,EAAE,MAAe,EAAE,WAA2C,IAAS,CAAC;IAEjG,MAAM,CAAC,OAAe,EAAE,MAAc,EAAE,WAA2C,IAAS,CAAC;IAE7F,WAAW,CAAC,MAAc,EAAE,MAAe,IAAS,CAAC;IAErD,iBAAiB,CACb,KAAa,EACb,WAAmB,EACnB,QAAsB,EACtB,OAAgD,IAC3C,CAAC;IAEV,QAAQ;QACJ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,KAAU,CAAC;IAEzB,IAAI,KAAU,CAAC;IAEf,YAAY;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,cAAc,CAAC,SAAkB,IAAS,CAAC;CAC9C;AAEY,QAAA,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import type { CorrelationContext, EnabledProfilerLevel, ProcessRef, ProfilerValue } from "../schema";
2
+ import type { BootstrapProbe } from "./bootstrap-probe";
3
+ import { ProfilerClock } from "./clock";
4
+ import type { ProfilerRuntimeLike, ProfilerFragment, RuntimeSnapshot, SpanHandle, SpanOptions } from "./types";
5
+ export declare class ProfilerRuntime implements ProfilerRuntimeLike {
6
+ readonly level: EnabledProfilerLevel;
7
+ readonly runId: string;
8
+ /** High-resolution monotonic clock value used as offset `0` for local elapsed-time measurements. */
9
+ readonly originMonotonicMs: number;
10
+ /** Unix timestamp in milliseconds that corresponds to `originMonotonicMs`. */
11
+ readonly originEpochMs: number;
12
+ private readonly _clock;
13
+ private readonly _process;
14
+ private readonly _operationIdPrefix;
15
+ private readonly _context;
16
+ private readonly _openSpans;
17
+ private readonly _operations;
18
+ private readonly _aggregates;
19
+ private readonly _fragmentAggregates;
20
+ private readonly _metrics;
21
+ private readonly _fragmentMetrics;
22
+ private readonly _errors;
23
+ private _idSequence;
24
+ private _stopped;
25
+ private _overheadMs;
26
+ private _sampler?;
27
+ private _lastElu?;
28
+ private readonly _transferredOperationIds;
29
+ private _transferredErrorCount;
30
+ private readonly _ingestedFragmentSequences;
31
+ /** Out-of-order fragments waiting for a contiguous predecessor (RPC vs IPC race). */
32
+ private readonly _pendingFragments;
33
+ private _pendingFragmentBytes;
34
+ private readonly _externalTruncation;
35
+ private readonly _asyncActivity?;
36
+ private _eventLoopDelay?;
37
+ private _lastHostCpu?;
38
+ private _maxClockUncertaintyMs;
39
+ private _unalignedFragments;
40
+ private _aggregateIdentitiesSeen;
41
+ private _aggregateIdentityOverflow;
42
+ private _metricIdentitiesSeen;
43
+ private _metricIdentityOverflow;
44
+ private _fragmentSequence;
45
+ private readonly _clockUncertaintyMs?;
46
+ constructor(options: {
47
+ runId: string;
48
+ level: EnabledProfilerLevel;
49
+ process?: ProcessRef;
50
+ clock?: ProfilerClock;
51
+ /** High-resolution monotonic clock value to use as offset `0`. */
52
+ originMonotonicMs?: number;
53
+ /** Unix timestamp in milliseconds that corresponds to `originMonotonicMs`. */
54
+ originEpochMs?: number;
55
+ /** Estimated maximum error when this runtime clock is aligned with another process. */
56
+ clockUncertaintyMs?: number;
57
+ });
58
+ isEnabled(minLevel?: EnabledProfilerLevel): boolean;
59
+ adoptBootstrapProbe(probe: BootstrapProbe): void;
60
+ startSpan(kind: string, options?: SpanOptions): SpanHandle;
61
+ withSpan<T>(kind: string, options: SpanOptions, action: () => T): T;
62
+ withContext<T>(context: Partial<CorrelationContext>, action: () => T): T;
63
+ increment(metric: string, value?: number, dimensions?: Record<string, ProfilerValue>): void;
64
+ sample(metric: string, value: number, dimensions?: Record<string, ProfilerValue>): void;
65
+ recordError(stage: string, error: unknown): void;
66
+ recordMeasurement(kind: string, durationMs: number, options?: SpanOptions, status?: "completed" | "failed" | "interrupted"): void;
67
+ closeOpenSpans(): void;
68
+ stop(): void;
69
+ snapshot(): RuntimeSnapshot;
70
+ takeFragment(): ProfilerFragment | null;
71
+ ingestFragment(fragment: unknown): void;
72
+ private _applyFragmentSafely;
73
+ private _hasMatchingFragmentLevel;
74
+ private _applyIngestedFragment;
75
+ private _drainPendingFragments;
76
+ private _reconcilePendingFragments;
77
+ /** Apply buffered fragments for a source, recording transport.gap for any holes. */
78
+ private _forceApplyPendingFragments;
79
+ private _takePendingFragment;
80
+ private _endSpan;
81
+ private _registerChildInterval;
82
+ private _completeChildInterval;
83
+ private _flushOpenChildIntervals;
84
+ private _mergeChildInterval;
85
+ private _recordOperation;
86
+ private _addLocalAggregate;
87
+ private _addAggregate;
88
+ private _mergeAggregate;
89
+ private _updateAggregate;
90
+ private _updateMetric;
91
+ private _startResourceSampler;
92
+ private _recordResourceSample;
93
+ private _snapshotAggregates;
94
+ private _nextId;
95
+ }