@gantfdt/fp-runtime-core
v0.4.0
Published
Framework-agnostic event/trace runtime core for frontend performance engineering
Maintainers
Keywords
Readme
@gantfdt/fp-runtime-core
框架无关的事件 / trace 运行时内核——整个体系的地基。无 React、无浏览器 API 依赖,可独立运行在 Node 环境。
提供什么
- 事件契约:
RuntimeEvent(id/type/timestamp,traceId用于跨系统关联);事件类型枚举RUNTIME_EVENT_TYPES。 - 运行时:
createRuntime()创建 runtime,注册RuntimePlugin,事件经EventBus进入 O(1) 环形EventBuffer。 - trace 组装:
createTraceBuilder()把平铺事件流按 root 事件(navigation/interaction/custom)组装成Trace,支持在途超龄强制收尾(truncated标记)。 - 采样:
createSampler()(session 闸门 → trace 闸门,routes 规则可覆盖;采样率优先一切,无重要 trace 豁免);isImportantTrace()仅作 trace:endimportant信息标记。 - 传输:
createTransport()批量冲刷调度(Transport)。 - 可测试性内建:
Clock/IdGenerator全部注入(systemClock、createIdGenerator/createSequentialIds),禁止绕开注入直接Date.now()/Math.random()。
硬约束
- fail-open:一切失败路径经
onInternalError上报,绝不向宿主抛异常; - 公共契约(
RuntimeEvent/Runtime/RuntimePlugin/RuntimeContext)变更视为 schema 变更,需同步全部消费者。
谁依赖它
runtime-browser(浏览器采集)、runtime-react(React 采集)、sdk(门面组装)。本包不包含任何采集逻辑。
