fboxrec 0.1.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/README.md +86 -0
- package/dist/chunk-HCJF2ASP.mjs +2194 -0
- package/dist/chunk-HCJF2ASP.mjs.map +1 -0
- package/dist/cli/main.cjs +723 -0
- package/dist/index.cjs +2231 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +106 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +1 -0
- package/dist/register.cjs +2189 -0
- package/dist/register.cjs.map +1 -0
- package/dist/register.d.mts +2 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.mjs +7 -0
- package/dist/register.mjs.map +1 -0
- package/package.json +58 -0
- package/viewer-dist/assets/__vite-browser-external-BIHI7g3E.js +1 -0
- package/viewer-dist/assets/index-C8nZrN2-.js +40 -0
- package/viewer-dist/assets/index-CbAgeaEr.css +1 -0
- package/viewer-dist/index.html +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# fboxrec — Flightbox
|
|
2
|
+
|
|
3
|
+
Flight recorder for Node.js servers. Records the last N seconds of your
|
|
4
|
+
server's activity — HTTP in/out, `pg`, `console.*`, vitals (the full list
|
|
5
|
+
below) — into a preallocated in-memory ring buffer; keeps it only when
|
|
6
|
+
something breaks.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install fboxrec
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
// One line at the top of your entrypoint:
|
|
14
|
+
require('fboxrec').start();
|
|
15
|
+
|
|
16
|
+
// Or zero code changes:
|
|
17
|
+
// node -r fboxrec/register server.js (CJS)
|
|
18
|
+
// node --import fboxrec/register server.js (ESM)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What gets recorded
|
|
22
|
+
|
|
23
|
+
- HTTP server requests (method, path, status, duration) — Express, Fastify,
|
|
24
|
+
Koa, bare `node:http`
|
|
25
|
+
- Outbound HTTP calls, correlated to the request that made them
|
|
26
|
+
- `pg` queries (text truncated at 2KB, parameter *shapes* — never values)
|
|
27
|
+
and pool wait times
|
|
28
|
+
- `console.*` output, event-loop lag and memory vitals
|
|
29
|
+
- Custom events: `flightbox.addEvent('cache.miss', { key })`
|
|
30
|
+
|
|
31
|
+
Everything is correlated by request via AsyncLocalStorage, timestamped with
|
|
32
|
+
the monotonic clock, and held in a fixed 64MB ring (configurable) — the
|
|
33
|
+
recorded window is a consequence of memory and traffic, not a setting.
|
|
34
|
+
|
|
35
|
+
## When something breaks
|
|
36
|
+
|
|
37
|
+
Triggers snapshot the ring into a gzipped `.fbox` incident file:
|
|
38
|
+
|
|
39
|
+
- **slow request** — measured at request end, plus an in-flight watchdog
|
|
40
|
+
that catches requests that will never finish
|
|
41
|
+
- **uncaught exception / unhandled rejection**, with an OOM panic path that
|
|
42
|
+
survives heap exhaustion
|
|
43
|
+
- **heap pressure** and **event-loop stall** thresholds
|
|
44
|
+
- **manual** — `flightbox.trigger('reason')`
|
|
45
|
+
|
|
46
|
+
One storm = one file (60s cooldown). Incidents are staged crash-safely on
|
|
47
|
+
local disk first, then delivered to your sinks (S3/R2/MinIO via built-in
|
|
48
|
+
SigV4 — no AWS SDK; or disk/http). Your data never touches anyone else's
|
|
49
|
+
servers.
|
|
50
|
+
|
|
51
|
+
Staging is quota-bound (default 500MB, FIFO eviction), oversized dumps are
|
|
52
|
+
refused outright, and a disk-space floor disables the agent before it can
|
|
53
|
+
push a disk to full. Note the quota is **per process**: in a cluster of N
|
|
54
|
+
workers the local ceiling is roughly N × the quota (each worker stages into
|
|
55
|
+
its own dir), plus the `delivered/` retention bucket. Size the quota with
|
|
56
|
+
your worker count in mind — a single process cannot fill the disk, but the
|
|
57
|
+
guarantee is per-process, not host-wide (a host-wide coordinator is
|
|
58
|
+
post-v0.1, ADR 014).
|
|
59
|
+
|
|
60
|
+
## Viewing an incident
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx fboxrec open incident.fbox # bundled offline viewer on localhost
|
|
64
|
+
npx fboxrec open s3://bucket/key # downloads with YOUR credentials
|
|
65
|
+
npx fboxrec doctor # verifies config, creds, connectivity
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
require('fboxrec').start({
|
|
72
|
+
service: 'checkout-api',
|
|
73
|
+
bufferMb: 64,
|
|
74
|
+
dir: '.flightbox',
|
|
75
|
+
triggers: { slowRequestMs: 5000, cooldownMs: 60000 },
|
|
76
|
+
sinks: [{ type: 's3', bucket: 'acme-incidents', prefix: 'prod/' }]
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or env vars only: `FLIGHTBOX_BUFFER_MB`, `FLIGHTBOX_DIR`,
|
|
81
|
+
`FLIGHTBOX_SERVICE`, `FLIGHTBOX_TRIGGER_SLOW_MS`, `FLIGHTBOX_MAX_STAGE_MB`,
|
|
82
|
+
`FLIGHTBOX_S3_BUCKET` (+ `FLIGHTBOX_S3_REGION` / `FLIGHTBOX_S3_ENDPOINT`).
|
|
83
|
+
|
|
84
|
+
Requires Node >= 18. One runtime dependency (msgpackr).
|
|
85
|
+
|
|
86
|
+
MIT
|