@tracepanel/js 0.3.4 → 0.4.1

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 (59) hide show
  1. package/README.md +50 -4
  2. package/dist/agent.d.ts +23 -1
  3. package/dist/agent.js +72 -22
  4. package/dist/agent.js.map +1 -1
  5. package/dist/body.d.ts +32 -0
  6. package/dist/body.js +314 -0
  7. package/dist/body.js.map +1 -0
  8. package/dist/bullmq.d.ts +76 -1
  9. package/dist/bullmq.js +215 -6
  10. package/dist/bullmq.js.map +1 -1
  11. package/dist/bun.js +81 -11
  12. package/dist/bun.js.map +1 -1
  13. package/dist/config.d.ts +20 -0
  14. package/dist/config.js +13 -0
  15. package/dist/config.js.map +1 -1
  16. package/dist/console.d.ts +5 -0
  17. package/dist/console.js +16 -0
  18. package/dist/console.js.map +1 -1
  19. package/dist/express.js +94 -23
  20. package/dist/express.js.map +1 -1
  21. package/dist/headers.js +54 -8
  22. package/dist/headers.js.map +1 -1
  23. package/dist/inspector.d.ts +9 -0
  24. package/dist/inspector.js +47 -0
  25. package/dist/inspector.js.map +1 -0
  26. package/dist/locals.d.ts +51 -0
  27. package/dist/locals.js +269 -0
  28. package/dist/locals.js.map +1 -0
  29. package/dist/loggers.d.ts +50 -0
  30. package/dist/loggers.js +201 -0
  31. package/dist/loggers.js.map +1 -0
  32. package/dist/model.d.ts +23 -2
  33. package/dist/model.js.map +1 -1
  34. package/dist/next.js +6 -0
  35. package/dist/next.js.map +1 -1
  36. package/dist/nuxt-plugin.d.ts +1 -0
  37. package/dist/nuxt-plugin.js +6 -0
  38. package/dist/nuxt-plugin.js.map +1 -1
  39. package/dist/processor.d.ts +23 -2
  40. package/dist/processor.js +61 -14
  41. package/dist/processor.js.map +1 -1
  42. package/dist/profile.d.ts +63 -0
  43. package/dist/profile.js +300 -0
  44. package/dist/profile.js.map +1 -0
  45. package/dist/request.d.ts +61 -0
  46. package/dist/request.js +244 -0
  47. package/dist/request.js.map +1 -0
  48. package/dist/session.d.ts +10 -0
  49. package/dist/session.js +45 -0
  50. package/dist/session.js.map +1 -0
  51. package/dist/setup.js +10 -1
  52. package/dist/setup.js.map +1 -1
  53. package/dist/stack.d.ts +27 -3
  54. package/dist/stack.js +106 -9
  55. package/dist/stack.js.map +1 -1
  56. package/dist/widget.d.ts +24 -0
  57. package/dist/widget.js +62 -1
  58. package/dist/widget.js.map +1 -1
  59. package/package.json +16 -4
package/README.md CHANGED
@@ -225,10 +225,35 @@ page's, such as a dev server's client.
225
225
 
226
226
  ## What it records
227
227
 
228
- - HTTP requests, with the route and the handler that served them.
228
+ - HTTP requests, with the route and the handler that served them, and what
229
+ each one carried: its headers, query and cookies, the body as far as the
230
+ app read it, and the response's headers. Values under names such as
231
+ `password`, `token`, `session` or `csrf` are masked, and they never leave
232
+ your machine. A body is what the app read, up to 16 KB: in Express and
233
+ Nest what a body parser read (`req.body`, an upload's files by name and
234
+ size); in Next.js, Nuxt and under `withTracepanel()` the bytes the app's
235
+ own reads took from the request's stream, a copy of their start kept as
236
+ they pass. JSON and forms have their secrets masked, text is cut at
237
+ 16 KB, and binary bodies are left out. A multipart form keeps its fields
238
+ and its files by name and size, never their contents, however large the
239
+ upload. JSON or a URL-encoded form past 16 KB is left out, since its
240
+ secrets can't be masked from a part of it. A body the app never reads is
241
+ not recorded, and Tracepanel never reads it or waits for it.
242
+ - The request's session as the handler left it: express-session's or
243
+ cookie-session's `req.session` in Express and Nest, and in Nuxt the
244
+ sessions h3's `useSession()` read (nuxt-auth-utils' among them). Each
245
+ value is text, masked under a sensitive name and below one, and
246
+ nuxt-auth-utils' `secure` data always is. Next.js and Bun have no
247
+ session of their own, and a sealed cookie (iron-session, Auth.js) takes
248
+ the app's secret to read, so none is recorded there: `setUser()` names
249
+ the signed-in user instead.
250
+ - A form's POST that redirects to another page: the panel on that page
251
+ lists the POST before it.
229
252
  - SQL from `pg` and `mysql2` (and so Drizzle, Knex, Sequelize, TypeORM and
230
253
  Prisma's driver adapters), with the line of your code that ran each
231
- statement. Prisma's operations show as steps.
254
+ statement. A statement no code of yours made, such as a session store's,
255
+ names the library code that asked for it, past the driver and the ORM;
256
+ so do Redis and MongoDB commands. Prisma's operations show as steps.
232
257
  - Transactions: BEGIN … COMMIT (or ROLLBACK) on a `pg` client or a `mysql2`
233
258
  connection, with its statements and the calls made inside it, and its
234
259
  savepoints.
@@ -237,8 +262,24 @@ page's, such as a dev server's client.
237
262
  - Outgoing HTTP calls: `fetch()`, and `node:http` clients such as axios, on
238
263
  Node and on Bun.
239
264
  - BullMQ: each job a worker runs is a task, each job the app adds a step.
240
- - `console` calls made during a request, and Nest's `Logger`.
241
- - Errors thrown in a handler, with your frames and their source.
265
+ While a job is in flight, the console's Tasks page lists it under Now:
266
+ queued, running in its worker, or waiting for its next attempt, and the
267
+ workers that run them.
268
+ - Logs made during a request: `console` calls, Nest's `Logger`, and pino's
269
+ and winston's loggers, with their fields and the error they carry.
270
+ - Errors thrown in a handler, with your frames, their source and their
271
+ local variables. Node's inspector reads the variables as the error is
272
+ thrown, in your own frames only, while a request runs; a value under a
273
+ name such as `password` or `token` is masked, and a long one is cut. A
274
+ caller waiting on an `await` has none. Each error read costs about a
275
+ millisecond, at most 50 a second; a process under a debugger
276
+ (`--inspect`) is left alone.
277
+ - Where a request's time goes in code, for the console's flame graph, when
278
+ it asks: the panel's Profile toggle, or an `X-Tracepanel-Profile: 1`
279
+ header. V8's profiler samples the whole process, and one event loop runs
280
+ every request at once, so a profile keeps the samples taken while its
281
+ request was the only one running, and counts the rest
282
+ (`tracepanel.dropped_samples`). Time spent waiting on I/O is not in it.
242
283
  - The caller's trace, when a request carries a W3C `traceparent`: the agent
243
284
  links the two.
244
285
 
@@ -289,6 +330,11 @@ Environment variables, as in the Python SDK:
289
330
  | `TRACEPANEL_LONG_TRANSACTION_MS` | `500` | a long transaction |
290
331
  | `TRACEPANEL_QUEUE_WAIT_MS` | `1000` | a task that waited long for a worker |
291
332
  | `TRACEPANEL_LARGE_RESULT_ROWS` | `1000` | a query without a LIMIT that read too many rows |
333
+ | `TRACEPANEL_CAPTURE_REQUEST` | on | `0` stops keeping each request's headers, query, cookies and body |
334
+ | `TRACEPANEL_CAPTURE_LOCALS` | on | `0` stops reading an error's local variables |
335
+ | `TRACEPANEL_PROFILE` | off | `1` profiles every trace, not only a request that asks |
336
+ | `TRACEPANEL_PROFILE_ENABLED` | on | `0` profiles nothing, and the console offers no Profile toggle |
337
+ | `TRACEPANEL_PROFILE_INTERVAL_MS` | `1` | how often a profiled trace is sampled |
292
338
 
293
339
  ## Command line
294
340
 
package/dist/agent.d.ts CHANGED
@@ -22,18 +22,40 @@ export declare class ConsoleUrl {
22
22
  /** `fresh`: read now, as a proxy to the console does for each request (a new agent listens on a new port). */
23
23
  get(fresh?: boolean): string;
24
24
  }
25
- /** Batches traces to the agent in the background; a full queue drops a trace rather than slow a request down. */
25
+ /**
26
+ * A task event: a job queued, started, retried or finished, or a worker's heartbeat, with what that step knows (see
27
+ * bullmq.ts). The console's Live list of tasks in flight is made of them, before a task's trace exists.
28
+ */
29
+ export type TaskEvent = Record<string, unknown>;
30
+ /** Say in the hello that this app sends `name` (`live_tasks`). */
31
+ export declare function sends(name: string): void;
32
+ /**
33
+ * The first line to the agent: it finds the issues with this project's limits. What the app offers the console, said
34
+ * here only: it can EXPLAIN a query on its database, its traces hold what each request carried while that is kept,
35
+ * and a request that asks is profiled while profiling is on (the console's Profile toggle shows then); and what it
36
+ * sends besides traces (`live_tasks`).
37
+ */
38
+ export declare function hello(config: Config): Record<string, unknown>;
39
+ /**
40
+ * Batches traces and task events to the agent in the background; a full queue drops one rather than slow a request
41
+ * down.
42
+ */
26
43
  export declare class Sender {
27
44
  private readonly config;
28
45
  private readonly starter;
29
46
  private queue;
47
+ private events;
30
48
  private timer;
31
49
  private socket;
32
50
  private connecting;
33
51
  private retryAt;
34
52
  private warned;
53
+ /** What the connection's hello said the app sends: a module that sends more loaded after it (bullmq) reconnects. */
54
+ private said;
35
55
  constructor(config: Config, starter: Starter);
36
56
  submit(trace: Trace): void;
57
+ /** A task event, sent with the next batch: not counted with the traces, and dropped while no agent answers. */
58
+ submitEvent(event: TaskEvent): void;
37
59
  private flushSoon;
38
60
  private flush;
39
61
  private connection;
package/dist/agent.js CHANGED
@@ -1,12 +1,14 @@
1
1
  // Traces go to the project's agent, which finds their issues, keeps them and serves the console. Its addresses are in
2
2
  // <store>/agent.addr and console.addr. The wire: a hello line, then frames of a 4-byte big-endian length and a JSON
3
- // array of traces. The agent starts on demand, as the other SDKs start it, and outlives the app's restarts.
3
+ // array of traces, or an object of task events (`{"tasks": [...]}`: a queue's jobs while they are in flight). The
4
+ // agent starts on demand, as the other SDKs start it, and outlives the app's restarts.
4
5
  import { spawn } from "node:child_process";
5
6
  import { closeSync, mkdirSync, openSync, readFileSync, rmSync } from "node:fs";
6
7
  import { createRequire } from "node:module";
7
8
  import { connect } from "node:net";
8
9
  import { join } from "node:path";
9
10
  import { explain } from "./explain.js";
11
+ import { available as canProfile } from "./profile.js";
10
12
  const PROTOCOL = 1;
11
13
  const QUEUE_SIZE = 1000;
12
14
  const BATCH_SIZE = 50;
@@ -123,16 +125,48 @@ export class ConsoleUrl {
123
125
  return this.url;
124
126
  }
125
127
  }
126
- /** Batches traces to the agent in the background; a full queue drops a trace rather than slow a request down. */
128
+ /** What the integrations send the agent beyond traces (`live_tasks`: BullMQ's task events), as they say on load. */
129
+ const SENDS = new Set();
130
+ /** Say in the hello that this app sends `name` (`live_tasks`). */
131
+ export function sends(name) {
132
+ SENDS.add(name);
133
+ }
134
+ /**
135
+ * The first line to the agent: it finds the issues with this project's limits. What the app offers the console, said
136
+ * here only: it can EXPLAIN a query on its database, its traces hold what each request carried while that is kept,
137
+ * and a request that asks is profiled while profiling is on (the console's Profile toggle shows then); and what it
138
+ * sends besides traces (`live_tasks`).
139
+ */
140
+ export function hello(config) {
141
+ return {
142
+ protocol: PROTOCOL,
143
+ max_traces: config.maxTraces,
144
+ thresholds: config.thresholds,
145
+ service: config.service,
146
+ capabilities: [
147
+ "explain",
148
+ ...(config.captureRequest ? ["request"] : []),
149
+ ...(config.profileEnabled && canProfile() ? ["profile"] : []),
150
+ ...[...SENDS].sort(),
151
+ ],
152
+ };
153
+ }
154
+ /**
155
+ * Batches traces and task events to the agent in the background; a full queue drops one rather than slow a request
156
+ * down.
157
+ */
127
158
  export class Sender {
128
159
  config;
129
160
  starter;
130
161
  queue = [];
162
+ events = [];
131
163
  timer;
132
164
  socket;
133
165
  connecting;
134
166
  retryAt = 0;
135
167
  warned = false;
168
+ /** What the connection's hello said the app sends: a module that sends more loaded after it (bullmq) reconnects. */
169
+ said = "";
136
170
  constructor(config, starter) {
137
171
  this.config = config;
138
172
  this.starter = starter;
@@ -146,6 +180,16 @@ export class Sender {
146
180
  else
147
181
  this.flushSoon(BATCH_WAIT_MS);
148
182
  }
183
+ /** A task event, sent with the next batch: not counted with the traces, and dropped while no agent answers. */
184
+ submitEvent(event) {
185
+ if (this.events.length >= QUEUE_SIZE)
186
+ return;
187
+ this.events.push(event);
188
+ if (this.events.length >= BATCH_SIZE)
189
+ this.flushSoon(0);
190
+ else
191
+ this.flushSoon(BATCH_WAIT_MS);
192
+ }
149
193
  flushSoon(delay) {
150
194
  if (this.timer && delay > 0)
151
195
  return;
@@ -158,19 +202,25 @@ export class Sender {
158
202
  }
159
203
  async flush() {
160
204
  const batch = this.queue.splice(0, BATCH_SIZE);
161
- if (batch.length === 0)
205
+ const events = this.events.splice(0, BATCH_SIZE);
206
+ if (batch.length === 0 && events.length === 0)
162
207
  return;
163
208
  const socket = await this.connection();
164
209
  if (!socket)
165
210
  return;
166
- const data = Buffer.from(JSON.stringify(batch));
167
- const length = Buffer.alloc(4);
168
- length.writeUInt32BE(data.length);
169
- socket.write(Buffer.concat([length, data]));
170
- if (this.queue.length > 0)
211
+ if (batch.length > 0)
212
+ writeFrame(socket, batch);
213
+ if (events.length > 0)
214
+ writeFrame(socket, { tasks: events });
215
+ if (this.queue.length > 0 || this.events.length > 0)
171
216
  this.flushSoon(0);
172
217
  }
173
218
  async connection() {
219
+ if (this.socket && !this.socket.destroyed && this.said !== saying(this.config)) {
220
+ // The hello is the one place the app says what it sends: a new connection says it again.
221
+ this.socket.destroy();
222
+ this.socket = undefined;
223
+ }
174
224
  if (this.socket && !this.socket.destroyed)
175
225
  return this.socket;
176
226
  if (Date.now() < this.retryAt)
@@ -221,16 +271,8 @@ export class Sender {
221
271
  socket.setTimeout(500, fail);
222
272
  socket.once("error", fail);
223
273
  socket.once("connect", () => {
224
- // The agent finds the issues with this project's limits.
225
- // It can EXPLAIN a query on the app's database for the console.
226
- const hello = {
227
- protocol: PROTOCOL,
228
- max_traces: this.config.maxTraces,
229
- thresholds: this.config.thresholds,
230
- service: this.config.service,
231
- capabilities: ["explain"],
232
- };
233
- socket.write(`${JSON.stringify(hello)}\n`);
274
+ this.said = saying(this.config);
275
+ socket.write(`${JSON.stringify(hello(this.config))}\n`);
234
276
  });
235
277
  let received = Buffer.alloc(0);
236
278
  socket.on("data", function onData(chunk) {
@@ -256,6 +298,17 @@ export class Sender {
256
298
  });
257
299
  }
258
300
  }
301
+ /** What a hello says the app sends, to tell when it says more. */
302
+ function saying(config) {
303
+ return JSON.stringify(hello(config).capabilities);
304
+ }
305
+ /** One frame: a 4-byte big-endian length, then the JSON. */
306
+ function writeFrame(socket, payload) {
307
+ const data = Buffer.from(JSON.stringify(payload));
308
+ const length = Buffer.alloc(4);
309
+ length.writeUInt32BE(data.length);
310
+ socket.write(Buffer.concat([length, data]));
311
+ }
259
312
  function hostPort(value) {
260
313
  const at = value.lastIndexOf(":");
261
314
  return { host: value.slice(0, at).replace(/^\[|\]$/g, ""), port: Number(value.slice(at + 1)) };
@@ -290,10 +343,7 @@ async function answer(socket, request) {
290
343
  catch (error) {
291
344
  reply = { answer: request.id, error: error instanceof Error ? error.message : String(error) };
292
345
  }
293
- const data = Buffer.from(JSON.stringify(reply));
294
- const length = Buffer.alloc(4);
295
- length.writeUInt32BE(data.length);
296
346
  if (!socket.destroyed)
297
- socket.write(Buffer.concat([length, data]));
347
+ writeFrame(socket, reply);
298
348
  }
299
349
  //# sourceMappingURL=agent.js.map
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,oHAAoH;AACpH,4GAA4G;AAE5G,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAuB,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,mHAAmH;AACnH,mDAAmD;AACnD,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,wHAAwH;AACxH,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,KAAK,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AAC,CAAC,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC9D,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;YACvC,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAiB,CAAC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACP,gEAAgE;YAClE,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC;AAED,0FAA0F;AAC1F,KAAK,UAAU,MAAM,CAAC,MAAc,EAAE,OAAqB;IACzD,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO;IAC7B,IAAI,KAA8B,CAAC;IACnC,IAAI,CAAC;QACH,KAAK,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAChG,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC"}
package/dist/body.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { IncomingMessage } from "node:http";
2
+ import type { Attrs } from "./model.js";
3
+ /** What the app read of a request's body, kept as it passed: its start, its size, and whether it read it all. */
4
+ export declare class BodyTap {
5
+ private readonly contentType;
6
+ private readonly kept;
7
+ private size;
8
+ private ended;
9
+ private readonly form;
10
+ constructor(contentType: string);
11
+ /** A piece of the body on its way to the app. */
12
+ feed(chunk: unknown): void;
13
+ /** The app read the body to its end. */
14
+ end(): void;
15
+ /** http.request.body, as far as the app read it. */
16
+ attrs(): Attrs;
17
+ }
18
+ /**
19
+ * A Node request whose body pieces pass the tap on their way to the app: every reader of a stream (a `data`
20
+ * listener, `read()`, async iteration, `pipe()`) gets them through its `emit("data")`. The tap is the request's from
21
+ * then on (`tapOf`). A framework that puts another stream's `emit` on the request (Next.js does, for a body a
22
+ * middleware read too) gets it tapped as well.
23
+ */
24
+ export declare function tapIncoming(req: IncomingMessage): BodyTap;
25
+ /** The tap on a Node request's body, if it has one. */
26
+ export declare function tapOf(req: IncomingMessage | undefined): BodyTap | undefined;
27
+ /**
28
+ * A fetch Request whose body passes the tap on its way to the handler: `request.body` and its readers (`text()`,
29
+ * `json()`, `formData()`, ...) read through it, piece by piece as the handler pulls them. The request stays the one
30
+ * the server made (Bun's `params` and `cookies` with it); `clone()` is its own, untapped.
31
+ */
32
+ export declare function tapRequest(request: Request): BodyTap | undefined;