@goliapkg/sentori-react-native 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/capture.d.ts +6 -1
- package/lib/capture.d.ts.map +1 -1
- package/lib/capture.js +49 -2
- package/lib/capture.js.map +1 -1
- package/lib/compat/sentry.d.ts +14 -0
- package/lib/compat/sentry.d.ts.map +1 -1
- package/lib/compat/sentry.js +6 -0
- package/lib/compat/sentry.js.map +1 -1
- package/lib/config.d.ts +12 -18
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/handlers/network.d.ts.map +1 -1
- package/lib/handlers/network.js +7 -0
- package/lib/handlers/network.js.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts +17 -0
- package/lib/init.d.ts.map +1 -1
- package/lib/init.js +37 -0
- package/lib/init.js.map +1 -1
- package/lib/navigation.d.ts.map +1 -1
- package/lib/navigation.js +14 -1
- package/lib/navigation.js.map +1 -1
- package/lib/runtime-metrics-fps.d.ts +19 -0
- package/lib/runtime-metrics-fps.d.ts.map +1 -0
- package/lib/runtime-metrics-fps.js +128 -0
- package/lib/runtime-metrics-fps.js.map +1 -0
- package/lib/runtime-metrics-heap.d.ts +13 -0
- package/lib/runtime-metrics-heap.d.ts.map +1 -0
- package/lib/runtime-metrics-heap.js +67 -0
- package/lib/runtime-metrics-heap.js.map +1 -0
- package/lib/runtime-metrics-network.d.ts +23 -0
- package/lib/runtime-metrics-network.d.ts.map +1 -0
- package/lib/runtime-metrics-network.js +99 -0
- package/lib/runtime-metrics-network.js.map +1 -0
- package/lib/runtime-metrics.d.ts +43 -0
- package/lib/runtime-metrics.d.ts.map +1 -0
- package/lib/runtime-metrics.js +115 -0
- package/lib/runtime-metrics.js.map +1 -0
- package/lib/transport.d.ts +18 -0
- package/lib/transport.d.ts.map +1 -1
- package/lib/transport.js +31 -0
- package/lib/transport.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/before-send.test.ts +72 -0
- package/src/__tests__/compat-sentry.test.ts +121 -0
- package/src/__tests__/runtime-metrics-instruments.test.ts +109 -0
- package/src/__tests__/runtime-metrics-network.test.ts +78 -0
- package/src/capture.ts +48 -2
- package/src/compat/sentry.ts +8 -0
- package/src/config.ts +12 -15
- package/src/handlers/network.ts +11 -0
- package/src/index.ts +14 -0
- package/src/init.ts +58 -0
- package/src/navigation.ts +14 -1
- package/src/runtime-metrics-fps.ts +137 -0
- package/src/runtime-metrics-heap.ts +78 -0
- package/src/runtime-metrics-network.ts +103 -0
- package/src/runtime-metrics.ts +122 -0
- package/src/transport.ts +39 -0
package/lib/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAkB,SAAS,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC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CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;aACxD;SACF,CAAC;QACF,IAAI,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,gEAAgE;AAChE,sDAAsD;AACtD,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
package/lib/navigation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAiCA;;kDAEkD;AAClD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAClE,eAAe,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACrD,CAAC;AASF,wBAAgB,YAAY,IAAI,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,iBAAiB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAiCA;;kDAEkD;AAClD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAClE,eAAe,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACrD,CAAC;AASF,wBAAgB,YAAY,IAAI,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAsHzE"}
|
package/lib/navigation.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// a request parented to the current screen, pass it explicitly:
|
|
21
21
|
// `startSpan(op, { parent: activeSpan() })`.
|
|
22
22
|
import { useEffect, useRef } from 'react';
|
|
23
|
-
import { setActiveSpan, startSpan } from '@goliapkg/sentori-core';
|
|
23
|
+
import { emitMetric, setActiveSpan, startSpan } from '@goliapkg/sentori-core';
|
|
24
24
|
import { getNativeFrameCounters, resetNativeFrameCounters, } from './native';
|
|
25
25
|
import { track } from './track';
|
|
26
26
|
import { captureStep } from './trail';
|
|
@@ -138,6 +138,19 @@ export function useTraceNavigation(navigationRef) {
|
|
|
138
138
|
if (next === null || next === prev)
|
|
139
139
|
return;
|
|
140
140
|
const dwellMs = finishOpenSpanWithDwell();
|
|
141
|
+
// v2.1 W2 — emit dwell as a runtime metric so the BI panel
|
|
142
|
+
// can rank screens by how long users sat on them. Tagged
|
|
143
|
+
// with `from` + `to` so a release-over-release diff can spot
|
|
144
|
+
// a 2x dwell regression on Onboarding etc. emit is cheap +
|
|
145
|
+
// bounded by the core ring cap; if `capture.runtimeMetrics:
|
|
146
|
+
// false` the flush is off but the ring still records up to
|
|
147
|
+
// the cap before dropping oldest.
|
|
148
|
+
if (typeof dwellMs === 'number' && dwellMs >= 0) {
|
|
149
|
+
emitMetric('runtime.route_nav_ms', dwellMs, {
|
|
150
|
+
from: prev ?? '',
|
|
151
|
+
to: next ?? '',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
141
154
|
openScreenSpan(prev, next, dwellMs);
|
|
142
155
|
});
|
|
143
156
|
return () => {
|
package/lib/navigation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oEAAoE;AACpE,0DAA0D;AAC1D,qEAAqE;AACrE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AAI,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,WAAW,EAAE,CAAC;YACd,uBAAuB,EAAE,CAAC;YAC1B,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;YAC3B,qBAAqB,CAAC,OAAO,GAAG,IAAI,CAAC;YACrC,aAAa,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Idempotent start. Safe to call multiple times; only the first
|
|
2
|
+
* call kicks off the rAF loop. */
|
|
3
|
+
export declare function startFpsInstrument(): void;
|
|
4
|
+
/** Stop the loop. Used by tests + by hosts that want to opt out
|
|
5
|
+
* mid-session. */
|
|
6
|
+
export declare function stopFpsInstrument(): void;
|
|
7
|
+
/** Test-only state inspection. */
|
|
8
|
+
export declare function __peekFpsInstrumentState(): {
|
|
9
|
+
count: number;
|
|
10
|
+
running: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Test-only force-emit (skips the every-300-frames gate). */
|
|
13
|
+
export declare function __forceEmitFpsForTests(): void;
|
|
14
|
+
/** Test-only sample injection so we can assert without spinning
|
|
15
|
+
* rAF in the test runner. */
|
|
16
|
+
export declare function __pushSampleForTests(dt: number): void;
|
|
17
|
+
/** Test-only reset between runs. */
|
|
18
|
+
export declare function __resetFpsInstrumentForTests(): void;
|
|
19
|
+
//# sourceMappingURL=runtime-metrics-fps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-fps.d.ts","sourceRoot":"","sources":["../src/runtime-metrics-fps.ts"],"names":[],"mappings":"AAwFA;mCACmC;AACnC,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC;AAED;mBACmB;AACnB,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,kCAAkC;AAClC,wBAAgB,wBAAwB,IAAI;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAEA;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAED;8BAC8B;AAC9B,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAIrD;AAED,oCAAoC;AACpC,wBAAgB,4BAA4B,IAAI,IAAI,CAMnD"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// v2.1 W2 part 3 — FPS auto-instrument.
|
|
2
|
+
//
|
|
3
|
+
// Rolling 5 s window of inter-frame Δt measured via rAF; emit
|
|
4
|
+
// runtime.fps.p50 + runtime.fps.p95 every 5 s.
|
|
5
|
+
//
|
|
6
|
+
// Perf bedrock (.claude/CLAUDE.md):
|
|
7
|
+
// • per-tick cost must be < 0.5 ms on a Pixel-5-equivalent
|
|
8
|
+
// bench → stop-ship gate in W2 part 4 CI
|
|
9
|
+
// • main-thread sustained < 1 %
|
|
10
|
+
// • no allocation inside the rAF callback hot path
|
|
11
|
+
//
|
|
12
|
+
// Implementation choices:
|
|
13
|
+
// • single-frame Δt = perf.now() - prev — cheap, no allocation
|
|
14
|
+
// • rolling window stored in a fixed-size Float32Array (no
|
|
15
|
+
// splice / shift — circular buffer write index)
|
|
16
|
+
// • percentile computed by copying-and-sorting only at emit
|
|
17
|
+
// time (every 5 s, ~300 floats) — no per-tick sort
|
|
18
|
+
//
|
|
19
|
+
// Bail-outs:
|
|
20
|
+
// • if requestAnimationFrame isn't available (rare RN host),
|
|
21
|
+
// never start the loop
|
|
22
|
+
// • if perf.now() is missing (older RN engines), fall back to
|
|
23
|
+
// Date.now() — coarser but better than crashing
|
|
24
|
+
import { emitMetric } from '@goliapkg/sentori-core';
|
|
25
|
+
const TICK_FRAMES_BEFORE_EMIT = 300; // ~5 s at 60 fps
|
|
26
|
+
const SAMPLE_CAP = 600; // safety: 10 s at 60 fps caps memory
|
|
27
|
+
let _running = false;
|
|
28
|
+
let _samples = new Float32Array(SAMPLE_CAP);
|
|
29
|
+
let _write = 0;
|
|
30
|
+
let _count = 0;
|
|
31
|
+
let _prev = 0;
|
|
32
|
+
function now() {
|
|
33
|
+
// Engines without perf.now() (very old RN runtimes / minimal
|
|
34
|
+
// JSCore builds) fall back to wall-clock. Date.now() has 1 ms
|
|
35
|
+
// resolution so FPS readings cap at 1000; good enough.
|
|
36
|
+
const p = globalThis.performance;
|
|
37
|
+
return p?.now ? p.now() : Date.now();
|
|
38
|
+
}
|
|
39
|
+
function rafTick(t) {
|
|
40
|
+
if (!_running)
|
|
41
|
+
return;
|
|
42
|
+
if (_prev !== 0) {
|
|
43
|
+
const dt = t - _prev;
|
|
44
|
+
if (dt > 0 && dt < 1000) {
|
|
45
|
+
_samples[_write] = dt;
|
|
46
|
+
_write = (_write + 1) % SAMPLE_CAP;
|
|
47
|
+
_count += 1;
|
|
48
|
+
if (_count >= TICK_FRAMES_BEFORE_EMIT) {
|
|
49
|
+
emitWindow();
|
|
50
|
+
_count = 0;
|
|
51
|
+
_write = 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_prev = t;
|
|
56
|
+
requestAnimationFrame(rafTick);
|
|
57
|
+
}
|
|
58
|
+
function emitWindow() {
|
|
59
|
+
// Copy + sort. ~300 floats, well under 1 ms even on a slow phone.
|
|
60
|
+
// Allocation lives outside the per-tick hot path — only at emit.
|
|
61
|
+
const n = _count;
|
|
62
|
+
if (n === 0)
|
|
63
|
+
return;
|
|
64
|
+
const slice = new Float32Array(n);
|
|
65
|
+
for (let i = 0; i < n; i++)
|
|
66
|
+
slice[i] = _samples[i];
|
|
67
|
+
slice.sort();
|
|
68
|
+
const p50dt = percentile(slice, 0.5);
|
|
69
|
+
const p95dt = percentile(slice, 0.95);
|
|
70
|
+
// FPS = 1000 ms / per-frame Δt.
|
|
71
|
+
const fpsP50 = p50dt > 0 ? Math.round(1000 / p50dt) : 0;
|
|
72
|
+
// p95 of Δt is the *slowest* 95 % — i.e. when frames are bad.
|
|
73
|
+
// p95 FPS conventionally means "5 % worst frames as fps".
|
|
74
|
+
const fpsP5Slow = p95dt > 0 ? Math.round(1000 / p95dt) : 0;
|
|
75
|
+
emitMetric('runtime.fps.p50', fpsP50);
|
|
76
|
+
emitMetric('runtime.fps.p95', fpsP5Slow);
|
|
77
|
+
}
|
|
78
|
+
function percentile(sorted, q) {
|
|
79
|
+
if (sorted.length === 0)
|
|
80
|
+
return 0;
|
|
81
|
+
// Discrete percentile — index = ceil(q * n) - 1, clamped.
|
|
82
|
+
const idx = Math.min(sorted.length - 1, Math.max(0, Math.ceil(q * sorted.length) - 1));
|
|
83
|
+
return sorted[idx];
|
|
84
|
+
}
|
|
85
|
+
/** Idempotent start. Safe to call multiple times; only the first
|
|
86
|
+
* call kicks off the rAF loop. */
|
|
87
|
+
export function startFpsInstrument() {
|
|
88
|
+
if (_running)
|
|
89
|
+
return;
|
|
90
|
+
if (typeof requestAnimationFrame !== 'function')
|
|
91
|
+
return;
|
|
92
|
+
_running = true;
|
|
93
|
+
_prev = 0;
|
|
94
|
+
_count = 0;
|
|
95
|
+
_write = 0;
|
|
96
|
+
requestAnimationFrame(rafTick);
|
|
97
|
+
}
|
|
98
|
+
/** Stop the loop. Used by tests + by hosts that want to opt out
|
|
99
|
+
* mid-session. */
|
|
100
|
+
export function stopFpsInstrument() {
|
|
101
|
+
_running = false;
|
|
102
|
+
}
|
|
103
|
+
/** Test-only state inspection. */
|
|
104
|
+
export function __peekFpsInstrumentState() {
|
|
105
|
+
return { count: _count, running: _running };
|
|
106
|
+
}
|
|
107
|
+
/** Test-only force-emit (skips the every-300-frames gate). */
|
|
108
|
+
export function __forceEmitFpsForTests() {
|
|
109
|
+
emitWindow();
|
|
110
|
+
_count = 0;
|
|
111
|
+
_write = 0;
|
|
112
|
+
}
|
|
113
|
+
/** Test-only sample injection so we can assert without spinning
|
|
114
|
+
* rAF in the test runner. */
|
|
115
|
+
export function __pushSampleForTests(dt) {
|
|
116
|
+
_samples[_write] = dt;
|
|
117
|
+
_write = (_write + 1) % SAMPLE_CAP;
|
|
118
|
+
_count += 1;
|
|
119
|
+
}
|
|
120
|
+
/** Test-only reset between runs. */
|
|
121
|
+
export function __resetFpsInstrumentForTests() {
|
|
122
|
+
_running = false;
|
|
123
|
+
_samples = new Float32Array(SAMPLE_CAP);
|
|
124
|
+
_write = 0;
|
|
125
|
+
_count = 0;
|
|
126
|
+
_prev = 0;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=runtime-metrics-fps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-fps.js","sourceRoot":"","sources":["../src/runtime-metrics-fps.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,8DAA8D;AAC9D,+CAA+C;AAC/C,EAAE;AACF,oCAAoC;AACpC,6DAA6D;AAC7D,6CAA6C;AAC7C,kCAAkC;AAClC,qDAAqD;AACrD,EAAE;AACF,0BAA0B;AAC1B,iEAAiE;AACjE,6DAA6D;AAC7D,oDAAoD;AACpD,8DAA8D;AAC9D,uDAAuD;AACvD,EAAE;AACF,aAAa;AACb,+DAA+D;AAC/D,2BAA2B;AAC3B,gEAAgE;AAChE,oDAAoD;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,uBAAuB,GAAG,GAAG,CAAC,CAAC,iBAAiB;AACtD,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,qCAAqC;AAE7D,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,QAAQ,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;AAC5C,IAAI,MAAM,GAAG,CAAC,CAAC;AACf,IAAI,MAAM,GAAG,CAAC,CAAC;AACf,IAAI,KAAK,GAAG,CAAC,CAAC;AAEd,SAAS,GAAG;IACV,6DAA6D;IAC7D,8DAA8D;IAC9D,uDAAuD;IACvD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CAAC;AACnB,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,wBAAwB;IAItC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,sBAAsB;IACpC,UAAU,EAAE,CAAC;IACb,MAAM,GAAG,CAAC,CAAC;IACX,MAAM,GAAG,CAAC,CAAC;AACb,CAAC;AAED;8BAC8B;AAC9B,MAAM,UAAU,oBAAoB,CAAC,EAAU;IAC7C,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACtB,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IACnC,MAAM,IAAI,CAAC,CAAC;AACd,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,4BAA4B;IAC1C,QAAQ,GAAG,KAAK,CAAC;IACjB,QAAQ,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,GAAG,CAAC,CAAC;IACX,MAAM,GAAG,CAAC,CAAC;IACX,KAAK,GAAG,CAAC,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Idempotent start. No-op on hosts that don't expose
|
|
2
|
+
* performance.memory — checked once at start so we don't pay
|
|
3
|
+
* for the detect on every tick. */
|
|
4
|
+
export declare function startHeapInstrument(): void;
|
|
5
|
+
/** Stop. Idempotent. */
|
|
6
|
+
export declare function stopHeapInstrument(): void;
|
|
7
|
+
/** Test-only force tick (skips the 30 s wait). */
|
|
8
|
+
export declare function __forceHeapTickForTests(): void;
|
|
9
|
+
/** Test-only state. */
|
|
10
|
+
export declare function __peekHeapInstrumentState(): {
|
|
11
|
+
running: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=runtime-metrics-heap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-heap.d.ts","sourceRoot":"","sources":["../src/runtime-metrics-heap.ts"],"names":[],"mappings":"AAgDA;;oCAEoC;AACpC,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED,wBAAwB;AACxB,wBAAgB,kBAAkB,IAAI,IAAI,CAKzC;AAED,kDAAkD;AAClD,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,uBAAuB;AACvB,wBAAgB,yBAAyB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAEhE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// v2.1 W2 part 3 — JS heap auto-instrument.
|
|
2
|
+
//
|
|
3
|
+
// Polls `performance.memory.usedJSHeapSize` every 30 s, emits
|
|
4
|
+
// runtime.heap.used_bytes. Web-only metric, RN best-effort —
|
|
5
|
+
// the V8/Hermes value depends on which engine RN is wired to:
|
|
6
|
+
// • Hermes (RN ≥ 0.70 default): exposes a per-isolate count
|
|
7
|
+
// when memoryReporter is enabled (Hermes 0.12+)
|
|
8
|
+
// • JSC (legacy / explicit opt-in): no native equivalent
|
|
9
|
+
// • Web (sdk-javascript wires this same module): Chromium
|
|
10
|
+
// gates it behind a high-resolution-timer flag in some
|
|
11
|
+
// contexts; treat missing field as a silent no-op
|
|
12
|
+
//
|
|
13
|
+
// Cost: one number read + one emit every 30 s. Negligible.
|
|
14
|
+
// The timer .unref()s so Node tests / CLI hosts exit cleanly.
|
|
15
|
+
import { emitMetric } from '@goliapkg/sentori-core';
|
|
16
|
+
const TICK_MS = 30_000;
|
|
17
|
+
let _timer = null;
|
|
18
|
+
function readHeap() {
|
|
19
|
+
const perf = globalThis.performance;
|
|
20
|
+
return perf?.memory ?? null;
|
|
21
|
+
}
|
|
22
|
+
function tickOnce() {
|
|
23
|
+
const m = readHeap();
|
|
24
|
+
if (!m)
|
|
25
|
+
return;
|
|
26
|
+
if (typeof m.usedJSHeapSize === 'number' && Number.isFinite(m.usedJSHeapSize)) {
|
|
27
|
+
emitMetric('runtime.heap.used_bytes', m.usedJSHeapSize);
|
|
28
|
+
}
|
|
29
|
+
// Total + limit help capacity-plan but cost an extra ~16 B
|
|
30
|
+
// per row downstream — keep them only when present.
|
|
31
|
+
if (typeof m.totalJSHeapSize === 'number' && Number.isFinite(m.totalJSHeapSize)) {
|
|
32
|
+
emitMetric('runtime.heap.total_bytes', m.totalJSHeapSize);
|
|
33
|
+
}
|
|
34
|
+
if (typeof m.jsHeapSizeLimit === 'number' && Number.isFinite(m.jsHeapSizeLimit)) {
|
|
35
|
+
emitMetric('runtime.heap.limit_bytes', m.jsHeapSizeLimit);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Idempotent start. No-op on hosts that don't expose
|
|
39
|
+
* performance.memory — checked once at start so we don't pay
|
|
40
|
+
* for the detect on every tick. */
|
|
41
|
+
export function startHeapInstrument() {
|
|
42
|
+
if (_timer !== null)
|
|
43
|
+
return;
|
|
44
|
+
if (!readHeap())
|
|
45
|
+
return;
|
|
46
|
+
// One immediate sample at start so the first dashboard render
|
|
47
|
+
// doesn't sit empty for 30 s.
|
|
48
|
+
tickOnce();
|
|
49
|
+
_timer = setInterval(tickOnce, TICK_MS);
|
|
50
|
+
_timer.unref?.();
|
|
51
|
+
}
|
|
52
|
+
/** Stop. Idempotent. */
|
|
53
|
+
export function stopHeapInstrument() {
|
|
54
|
+
if (_timer !== null) {
|
|
55
|
+
clearInterval(_timer);
|
|
56
|
+
_timer = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Test-only force tick (skips the 30 s wait). */
|
|
60
|
+
export function __forceHeapTickForTests() {
|
|
61
|
+
tickOnce();
|
|
62
|
+
}
|
|
63
|
+
/** Test-only state. */
|
|
64
|
+
export function __peekHeapInstrumentState() {
|
|
65
|
+
return { running: _timer !== null };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=runtime-metrics-heap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-heap.js","sourceRoot":"","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pC,MAAM,UAAU,mBAAmB;IACjC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO;IAC5B,IAAI,CAAC,QAAQ,EAAE;QAAE,OAAO;IACxB,8DAA8D;IAC9D,8BAA8B;IAC9B,QAAQ,EAAE,CAAC;IACX,MAAM,GAAG,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,MAA4C,CAAC,KAAK,EAAE,EAAE,CAAC;AAC1D,CAAC;AAED,wBAAwB;AACxB,MAAM,UAAU,kBAAkB;IAChC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,uBAAuB;IACrC,QAAQ,EAAE,CAAC;AACb,CAAC;AAED,uBAAuB;AACvB,MAAM,UAAU,yBAAyB;IACvC,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Called from handlers/network.ts on every outbound request.
|
|
2
|
+
* Cheap — two adds, no allocation. */
|
|
3
|
+
export declare function recordNetworkBytes(sent: number, received: number): void;
|
|
4
|
+
/** Estimate request bytes from a fetch init. Used by the fetch
|
|
5
|
+
* patch in handlers/network.ts. */
|
|
6
|
+
export declare function estimateRequestBytes(init?: RequestInit): number;
|
|
7
|
+
/** Read response bytes from the Content-Length header. Returns
|
|
8
|
+
* 0 if missing or unparseable — undercount-safe. */
|
|
9
|
+
export declare function estimateResponseBytes(headers: Headers | undefined | null): number;
|
|
10
|
+
/** Idempotent start — second call is a no-op. */
|
|
11
|
+
export declare function startNetworkBytesInstrument(): void;
|
|
12
|
+
/** Stop the periodic emit. Idempotent. */
|
|
13
|
+
export declare function stopNetworkBytesInstrument(): void;
|
|
14
|
+
/** Test-only: force one emit tick + reset counters. */
|
|
15
|
+
export declare function __forceNetworkEmitForTests(): void;
|
|
16
|
+
/** Test-only: peek raw counter state without resetting. */
|
|
17
|
+
export declare function __peekNetworkCountersForTests(): {
|
|
18
|
+
sent: number;
|
|
19
|
+
received: number;
|
|
20
|
+
};
|
|
21
|
+
/** Test-only: reset for clean test runs. */
|
|
22
|
+
export declare function __resetNetworkBytesForTests(): void;
|
|
23
|
+
//# sourceMappingURL=runtime-metrics-network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-network.d.ts","sourceRoot":"","sources":["../src/runtime-metrics-network.ts"],"names":[],"mappings":"AA4BA;uCACuC;AACvC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAGvE;AAYD;oCACoC;AACpC,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAE/D;AAED;qDACqD;AACrD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAMjF;AAaD,iDAAiD;AACjD,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD;AAED,0CAA0C;AAC1C,wBAAgB,0BAA0B,IAAI,IAAI,CAKjD;AAED,uDAAuD;AACvD,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,2DAA2D;AAC3D,wBAAgB,6BAA6B,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAElF;AAED,4CAA4C;AAC5C,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// v2.1 W2 part 4 — network bytes auto-instrument.
|
|
2
|
+
//
|
|
3
|
+
// Two counters (sent / received bytes) incremented by the existing
|
|
4
|
+
// fetch patch on every request/response, drained every 30 s as
|
|
5
|
+
// runtime.network.bytes_sent + runtime.network.bytes_received.
|
|
6
|
+
//
|
|
7
|
+
// Best-effort: not every Response exposes `content-length`
|
|
8
|
+
// (chunked encoding, server stripped it, gzipped without a
|
|
9
|
+
// pre-decode header). For those we report 0 — undercounts vs.
|
|
10
|
+
// over-attributing arbitrary numbers. Request body size is
|
|
11
|
+
// estimated only when init.body is a string or has `.byteLength`;
|
|
12
|
+
// FormData / Blob / ReadableStream are not measured.
|
|
13
|
+
//
|
|
14
|
+
// XHR is NOT instrumented here — the existing patchXhr() in
|
|
15
|
+
// handlers/network.ts does the trace span work, and XHR usage in
|
|
16
|
+
// 2026-era RN apps is rare enough that the engineering cost of
|
|
17
|
+
// a second patch isn't justified by the missing data. If a host
|
|
18
|
+
// app shows up with significant XHR traffic we add it in a patch
|
|
19
|
+
// release.
|
|
20
|
+
import { emitMetric } from '@goliapkg/sentori-core';
|
|
21
|
+
const TICK_MS = 30_000;
|
|
22
|
+
let _bytesSent = 0;
|
|
23
|
+
let _bytesReceived = 0;
|
|
24
|
+
let _timer = null;
|
|
25
|
+
/** Called from handlers/network.ts on every outbound request.
|
|
26
|
+
* Cheap — two adds, no allocation. */
|
|
27
|
+
export function recordNetworkBytes(sent, received) {
|
|
28
|
+
if (sent > 0)
|
|
29
|
+
_bytesSent += sent;
|
|
30
|
+
if (received > 0)
|
|
31
|
+
_bytesReceived += received;
|
|
32
|
+
}
|
|
33
|
+
function estimateBodyBytes(body) {
|
|
34
|
+
if (body == null)
|
|
35
|
+
return 0;
|
|
36
|
+
if (typeof body === 'string')
|
|
37
|
+
return body.length;
|
|
38
|
+
// ArrayBuffer / Uint8Array / ArrayBufferView all carry byteLength.
|
|
39
|
+
const maybe = body;
|
|
40
|
+
if (typeof maybe.byteLength === 'number')
|
|
41
|
+
return maybe.byteLength;
|
|
42
|
+
// FormData / Blob / ReadableStream — not measured.
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
/** Estimate request bytes from a fetch init. Used by the fetch
|
|
46
|
+
* patch in handlers/network.ts. */
|
|
47
|
+
export function estimateRequestBytes(init) {
|
|
48
|
+
return estimateBodyBytes(init?.body);
|
|
49
|
+
}
|
|
50
|
+
/** Read response bytes from the Content-Length header. Returns
|
|
51
|
+
* 0 if missing or unparseable — undercount-safe. */
|
|
52
|
+
export function estimateResponseBytes(headers) {
|
|
53
|
+
if (!headers)
|
|
54
|
+
return 0;
|
|
55
|
+
const v = headers.get?.('content-length');
|
|
56
|
+
if (!v)
|
|
57
|
+
return 0;
|
|
58
|
+
const n = parseInt(v, 10);
|
|
59
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
60
|
+
}
|
|
61
|
+
function emit() {
|
|
62
|
+
if (_bytesSent > 0) {
|
|
63
|
+
emitMetric('runtime.network.bytes_sent', _bytesSent);
|
|
64
|
+
_bytesSent = 0;
|
|
65
|
+
}
|
|
66
|
+
if (_bytesReceived > 0) {
|
|
67
|
+
emitMetric('runtime.network.bytes_received', _bytesReceived);
|
|
68
|
+
_bytesReceived = 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Idempotent start — second call is a no-op. */
|
|
72
|
+
export function startNetworkBytesInstrument() {
|
|
73
|
+
if (_timer !== null)
|
|
74
|
+
return;
|
|
75
|
+
_timer = setInterval(emit, TICK_MS);
|
|
76
|
+
_timer.unref?.();
|
|
77
|
+
}
|
|
78
|
+
/** Stop the periodic emit. Idempotent. */
|
|
79
|
+
export function stopNetworkBytesInstrument() {
|
|
80
|
+
if (_timer !== null) {
|
|
81
|
+
clearInterval(_timer);
|
|
82
|
+
_timer = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Test-only: force one emit tick + reset counters. */
|
|
86
|
+
export function __forceNetworkEmitForTests() {
|
|
87
|
+
emit();
|
|
88
|
+
}
|
|
89
|
+
/** Test-only: peek raw counter state without resetting. */
|
|
90
|
+
export function __peekNetworkCountersForTests() {
|
|
91
|
+
return { sent: _bytesSent, received: _bytesReceived };
|
|
92
|
+
}
|
|
93
|
+
/** Test-only: reset for clean test runs. */
|
|
94
|
+
export function __resetNetworkBytesForTests() {
|
|
95
|
+
stopNetworkBytesInstrument();
|
|
96
|
+
_bytesSent = 0;
|
|
97
|
+
_bytesReceived = 0;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=runtime-metrics-network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics-network.js","sourceRoot":"","sources":["../src/runtime-metrics-network.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,mEAAmE;AACnE,+DAA+D;AAC/D,+DAA+D;AAC/D,EAAE;AACF,2DAA2D;AAC3D,2DAA2D;AAC3D,8DAA8D;AAC9D,2DAA2D;AAC3D,kEAAkE;AAClE,qDAAqD;AACrD,EAAE;AACF,4DAA4D;AAC5D,iEAAiE;AACjE,+DAA+D;AAC/D,gEAAgE;AAChE,iEAAiE;AACjE,WAAW;AAEX,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,IAAI,cAAc,GAAG,CAAC,CAAC;AACvB,IAAI,MAAM,GAA0C,IAAI,CAAC;AAEzD;uCACuC;AACvC,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,QAAgB;IAC/D,IAAI,IAAI,GAAG,CAAC;QAAE,UAAU,IAAI,IAAI,CAAC;IACjC,IAAI,QAAQ,GAAG,CAAC;QAAE,cAAc,IAAI,QAAQ,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAiC;IAC1D,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,CAAC,CAAC;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IACjD,mEAAmE;IACnE,MAAM,KAAK,GAAG,IAA+B,CAAC;IAC9C,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,K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C,CAAC;QACtB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,0BAA0B;IACxC,IAAI,EAAE,CAAC;AACT,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,6BAA6B;IAC3C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AACxD,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,2BAA2B;IACzC,0BAA0B,EAAE,CAAC;IAC7B,UAAU,GAAG,CAAC,CAAC;IACf,cAAc,GAAG,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drain core's runtime-metrics ring and POST to
|
|
3
|
+
* /v1/runtime-metrics:batch. Rebuffers on failure so the next
|
|
4
|
+
* tick retries; sustained outages spill into the ring's drop
|
|
5
|
+
* counter which reports to the SDK self-report channel.
|
|
6
|
+
*
|
|
7
|
+
* Returns when the round-trip settles (success or failure). Per
|
|
8
|
+
* the NEVER rule, never throws — failure is logged + rebuffered,
|
|
9
|
+
* the resolved promise's value is undefined.
|
|
10
|
+
*/
|
|
11
|
+
export declare function flushRuntimeMetrics(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Start the 30 s flush timer. Called once from `init()`. Idempotent
|
|
14
|
+
* — repeated calls are a no-op so users that call
|
|
15
|
+
* `Sentori.init({ metrics: true })` more than once (HMR, fast
|
|
16
|
+
* refresh) don't get multiple timers.
|
|
17
|
+
*/
|
|
18
|
+
export declare function startRuntimeMetricsTimer(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Capture the wall-clock at `init()` so cold-start instrumentation
|
|
21
|
+
* has a t0. Called from init() before any other auto-instrument
|
|
22
|
+
* fires. Returns the captured t0 in millis (callers that want to
|
|
23
|
+
* stash + use it later can hold the value).
|
|
24
|
+
*/
|
|
25
|
+
export declare function markColdStartT0(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Emit one `runtime.cold_start_ms` metric point. Idempotent per
|
|
28
|
+
* session — the second + later calls are a no-op so route-nav
|
|
29
|
+
* instrument (W2 part 3) can call this safely without worrying
|
|
30
|
+
* about double-counting.
|
|
31
|
+
*
|
|
32
|
+
* Hosts that want a more interactive-pixel-perfect cold-start
|
|
33
|
+
* boundary (TTI vs. raw init→render) can call
|
|
34
|
+
* `markTimeToFullDisplay()` and we emit that separately as
|
|
35
|
+
* `runtime.time_to_full_display_ms` (existing v1 instrument).
|
|
36
|
+
*/
|
|
37
|
+
export declare function emitColdStart(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Test-only escape hatch: stop the timer + reset cold-start state
|
|
40
|
+
* so vitest / bun:test teardown doesn't leak intervals across runs.
|
|
41
|
+
*/
|
|
42
|
+
export declare function __resetRuntimeMetricsRnForTests(): void;
|
|
43
|
+
//# sourceMappingURL=runtime-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics.d.ts","sourceRoot":"","sources":["../src/runtime-metrics.ts"],"names":[],"mappings":"AAiCA;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWzD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAS/C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAKxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAWpC;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAOtD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// v2.1 W2 part 2 — RN runtime metrics flusher + cold-start
|
|
2
|
+
// instrument.
|
|
3
|
+
//
|
|
4
|
+
// The buffer + emit primitives live in @goliapkg/sentori-core
|
|
5
|
+
// (runtime-metrics.ts). This module owns:
|
|
6
|
+
// • the periodic flush timer (30 s, coalesced w/ event flush)
|
|
7
|
+
// • the rebuffer-on-failure recovery path
|
|
8
|
+
// • the cold-start auto-instrument (one-shot at init)
|
|
9
|
+
//
|
|
10
|
+
// Other auto-instrument modules (FPS / heap / route-nav / network
|
|
11
|
+
// bytes) ship in the W2 part 3+ chunks; each is its own file with
|
|
12
|
+
// its own per-tick perf budget test gated as stop-ship in CI.
|
|
13
|
+
//
|
|
14
|
+
// NEVER rule: every public surface here is wrapped in safeFn
|
|
15
|
+
// boundaries by the SDK init layer; the flush timer itself
|
|
16
|
+
// catches all rejections + reports via the circuit breaker.
|
|
17
|
+
import { drainRuntimeMetricsForFlush, emitMetric, rebufferRuntimeMetrics, reportInternal, } from '@goliapkg/sentori-core';
|
|
18
|
+
import { getConfig, isInitialized } from './config';
|
|
19
|
+
import { sendRuntimeMetricsBatch } from './transport';
|
|
20
|
+
const FLUSH_INTERVAL_MS = 30_000;
|
|
21
|
+
let _timer = null;
|
|
22
|
+
let _coldStartT0 = null;
|
|
23
|
+
let _coldStartEmitted = false;
|
|
24
|
+
/**
|
|
25
|
+
* Drain core's runtime-metrics ring and POST to
|
|
26
|
+
* /v1/runtime-metrics:batch. Rebuffers on failure so the next
|
|
27
|
+
* tick retries; sustained outages spill into the ring's drop
|
|
28
|
+
* counter which reports to the SDK self-report channel.
|
|
29
|
+
*
|
|
30
|
+
* Returns when the round-trip settles (success or failure). Per
|
|
31
|
+
* the NEVER rule, never throws — failure is logged + rebuffered,
|
|
32
|
+
* the resolved promise's value is undefined.
|
|
33
|
+
*/
|
|
34
|
+
export async function flushRuntimeMetrics() {
|
|
35
|
+
if (!isInitialized())
|
|
36
|
+
return;
|
|
37
|
+
const config = getConfig();
|
|
38
|
+
if (!config)
|
|
39
|
+
return;
|
|
40
|
+
const batch = drainRuntimeMetricsForFlush();
|
|
41
|
+
if (batch.length === 0)
|
|
42
|
+
return;
|
|
43
|
+
const ok = await sendRuntimeMetricsBatch(config.ingestUrl, config.token, batch);
|
|
44
|
+
if (!ok) {
|
|
45
|
+
rebufferRuntimeMetrics(batch);
|
|
46
|
+
reportInternal('runtime-metrics.flush', new Error('runtime-metrics POST failed'));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Start the 30 s flush timer. Called once from `init()`. Idempotent
|
|
51
|
+
* — repeated calls are a no-op so users that call
|
|
52
|
+
* `Sentori.init({ metrics: true })` more than once (HMR, fast
|
|
53
|
+
* refresh) don't get multiple timers.
|
|
54
|
+
*/
|
|
55
|
+
export function startRuntimeMetricsTimer() {
|
|
56
|
+
if (_timer !== null)
|
|
57
|
+
return;
|
|
58
|
+
_timer = setInterval(() => {
|
|
59
|
+
void flushRuntimeMetrics();
|
|
60
|
+
}, FLUSH_INTERVAL_MS);
|
|
61
|
+
// Don't keep Node alive solely for this timer. RN's setInterval
|
|
62
|
+
// is a NoopRef so this is harmless there; Node + CLI tests
|
|
63
|
+
// benefit so the process can exit cleanly.
|
|
64
|
+
_timer.unref?.();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Capture the wall-clock at `init()` so cold-start instrumentation
|
|
68
|
+
* has a t0. Called from init() before any other auto-instrument
|
|
69
|
+
* fires. Returns the captured t0 in millis (callers that want to
|
|
70
|
+
* stash + use it later can hold the value).
|
|
71
|
+
*/
|
|
72
|
+
export function markColdStartT0() {
|
|
73
|
+
if (_coldStartT0 === null) {
|
|
74
|
+
_coldStartT0 = Date.now();
|
|
75
|
+
}
|
|
76
|
+
return _coldStartT0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Emit one `runtime.cold_start_ms` metric point. Idempotent per
|
|
80
|
+
* session — the second + later calls are a no-op so route-nav
|
|
81
|
+
* instrument (W2 part 3) can call this safely without worrying
|
|
82
|
+
* about double-counting.
|
|
83
|
+
*
|
|
84
|
+
* Hosts that want a more interactive-pixel-perfect cold-start
|
|
85
|
+
* boundary (TTI vs. raw init→render) can call
|
|
86
|
+
* `markTimeToFullDisplay()` and we emit that separately as
|
|
87
|
+
* `runtime.time_to_full_display_ms` (existing v1 instrument).
|
|
88
|
+
*/
|
|
89
|
+
export function emitColdStart() {
|
|
90
|
+
if (_coldStartEmitted)
|
|
91
|
+
return;
|
|
92
|
+
if (_coldStartT0 === null)
|
|
93
|
+
return;
|
|
94
|
+
const ms = Date.now() - _coldStartT0;
|
|
95
|
+
if (ms <= 0 || ms > 60_000) {
|
|
96
|
+
// Implausible — likely the host called emit before init or
|
|
97
|
+
// we got into a freeze-then-resume situation. Drop silently.
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
emitMetric('runtime.cold_start_ms', ms);
|
|
101
|
+
_coldStartEmitted = true;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Test-only escape hatch: stop the timer + reset cold-start state
|
|
105
|
+
* so vitest / bun:test teardown doesn't leak intervals across runs.
|
|
106
|
+
*/
|
|
107
|
+
export function __resetRuntimeMetricsRnForTests() {
|
|
108
|
+
if (_timer !== null) {
|
|
109
|
+
clearInterval(_timer);
|
|
110
|
+
_timer = null;
|
|
111
|
+
}
|
|
112
|
+
_coldStartT0 = null;
|
|
113
|
+
_coldStartEmitted = false;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=runtime-metrics.js.map
|