@tracepanel/js 0.9.2 → 0.11.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 +49 -2
- package/dist/api.d.ts +10 -0
- package/dist/api.js +12 -0
- package/dist/api.js.map +1 -1
- package/dist/browser.js +21 -3
- package/dist/browser.js.map +1 -1
- package/dist/bullmq.d.ts +7 -0
- package/dist/bullmq.js +35 -3
- package/dist/bullmq.js.map +1 -1
- package/dist/bun.js +3 -3
- package/dist/bun.js.map +1 -1
- package/dist/calls.js +10 -4
- package/dist/calls.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.js +30 -2
- package/dist/config.js.map +1 -1
- package/dist/console.d.ts +3 -1
- package/dist/console.js +47 -15
- package/dist/console.js.map +1 -1
- package/dist/dumps.d.ts +52 -0
- package/dist/dumps.js +520 -0
- package/dist/dumps.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/locals.d.ts +2 -1
- package/dist/locals.js +8 -6
- package/dist/locals.js.map +1 -1
- package/dist/loggers.js +2 -2
- package/dist/loggers.js.map +1 -1
- package/dist/masking.d.ts +16 -0
- package/dist/masking.js +148 -0
- package/dist/masking.js.map +1 -0
- package/dist/next.js +6 -4
- package/dist/next.js.map +1 -1
- package/dist/nuxt-plugin.js +1 -1
- package/dist/nuxt-plugin.js.map +1 -1
- package/dist/processor.d.ts +7 -1
- package/dist/processor.js +37 -5
- package/dist/processor.js.map +1 -1
- package/dist/profile.d.ts +27 -1
- package/dist/profile.js +43 -7
- package/dist/profile.js.map +1 -1
- package/dist/request.d.ts +3 -2
- package/dist/request.js +6 -6
- package/dist/request.js.map +1 -1
- package/dist/setup.js +6 -4
- package/dist/setup.js.map +1 -1
- package/dist/stack.d.ts +41 -5
- package/dist/stack.js +392 -47
- package/dist/stack.js.map +1 -1
- package/package.json +3 -2
package/dist/config.js
CHANGED
|
@@ -9,11 +9,38 @@ const THRESHOLDS = {
|
|
|
9
9
|
queue_wait_ms: ["TRACEPANEL_QUEUE_WAIT_MS", 1000],
|
|
10
10
|
large_result_rows: ["TRACEPANEL_LARGE_RESULT_ROWS", 1000],
|
|
11
11
|
};
|
|
12
|
+
/** The limits that may be set per database too, and the field of their map. */
|
|
13
|
+
const BY_DB = {
|
|
14
|
+
slow_sql_ms: "slow_sql_ms_by_db",
|
|
15
|
+
long_transaction_ms: "long_transaction_ms_by_db",
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The limits from the environment, the agent's defaults for the rest. TRACEPANEL_SLOW_SQL_MS and
|
|
19
|
+
* TRACEPANEL_LONG_TRANSACTION_MS take one per database too, by its `db.system`: `100,snowflake=3000` holds every
|
|
20
|
+
* database to 100 ms but Snowflake, to 3 s. A part that isn't a number is left out.
|
|
21
|
+
*/
|
|
12
22
|
function thresholds(env) {
|
|
13
23
|
const found = {};
|
|
14
24
|
for (const [name, [variable, fallback]] of Object.entries(THRESHOLDS)) {
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
found[name] = fallback;
|
|
26
|
+
for (const part of (env[variable] ?? "").split(",")) {
|
|
27
|
+
const [left, right] = part.split("=", 2).map((piece) => piece.trim());
|
|
28
|
+
const value = right === undefined ? left : right;
|
|
29
|
+
if (value === undefined || value === "")
|
|
30
|
+
continue;
|
|
31
|
+
const number = Number(value);
|
|
32
|
+
if (!Number.isFinite(number) || number < 0)
|
|
33
|
+
continue;
|
|
34
|
+
if (right === undefined) {
|
|
35
|
+
found[name] = number;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const field = BY_DB[name];
|
|
39
|
+
const system = left?.toLowerCase();
|
|
40
|
+
if (field === undefined || !system)
|
|
41
|
+
continue;
|
|
42
|
+
found[field] = { ...found[field], [system]: number };
|
|
43
|
+
}
|
|
17
44
|
}
|
|
18
45
|
return found;
|
|
19
46
|
}
|
|
@@ -54,6 +81,7 @@ export function loadConfig(env = process.env) {
|
|
|
54
81
|
captureRequest: on(env.TRACEPANEL_CAPTURE_REQUEST),
|
|
55
82
|
captureLocals: on(env.TRACEPANEL_CAPTURE_LOCALS),
|
|
56
83
|
widget: on(env.TRACEPANEL_WIDGET),
|
|
84
|
+
dumps: on(env.TRACEPANEL_DUMPS),
|
|
57
85
|
profile: onlyIf(env.TRACEPANEL_PROFILE),
|
|
58
86
|
profileMemory: onlyIf(env.TRACEPANEL_PROFILE_MEMORY),
|
|
59
87
|
profileEnabled: on(env.TRACEPANEL_PROFILE_ENABLED),
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyEpD,MAAM,UAAU,GAAoC;IAClD,UAAU,EAAE,CAAC,iCAAiC,EAAE,CAAC,CAAC;IAClD,iBAAiB,EAAE,CAAC,8BAA8B,EAAE,CAAC,CAAC;IACtD,WAAW,EAAE,CAAC,wBAAwB,EAAE,GAAG,CAAC;IAC5C,YAAY,EAAE,CAAC,yBAAyB,EAAE,GAAG,CAAC;IAC9C,mBAAmB,EAAE,CAAC,gCAAgC,EAAE,GAAG,CAAC;IAC5D,aAAa,EAAE,CAAC,0BAA0B,EAAE,IAAI,CAAC;IACjD,iBAAiB,EAAE,CAAC,8BAA8B,EAAE,IAAI,CAAC;CAC1D,CAAC;AAEF,+EAA+E;AAC/E,MAAM,KAAK,GAA8E;IACvF,WAAW,EAAE,mBAAmB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
1
2
|
import type { TracepanelProcessor } from "./processor.js";
|
|
2
3
|
/**
|
|
3
4
|
* Runs a logger's own write (pino's, winston's): it recorded the log already, so what it prints through console is
|
|
@@ -7,5 +8,6 @@ export declare function quietly<T>(write: () => T): T;
|
|
|
7
8
|
/**
|
|
8
9
|
* Each of console's methods becomes a property whose value records the call, then runs the method as it is now:
|
|
9
10
|
* something that replaces it later (Nuxt's dev server puts its own logger there) replaces what runs, not the record.
|
|
11
|
+
* A later capture (Nuxt's plugin) only changes where the calls go.
|
|
10
12
|
*/
|
|
11
|
-
export declare function captureConsole(processor: TracepanelProcessor): void;
|
|
13
|
+
export declare function captureConsole(processor: TracepanelProcessor, config?: Pick<Config, "root" | "dumps">): void;
|
package/dist/console.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
// console.* calls made during a request go to its trace, then on to the terminal as before.
|
|
1
|
+
// console.* calls made during a request go to its trace, then on to the terminal as before. A developer's own debug
|
|
2
|
+
// output (console.dir(), a console.log() of an object) goes there as a dump (dumps.ts).
|
|
2
3
|
import { format } from "node:util";
|
|
4
|
+
import { DUMPING, dump, isDump } from "./dumps.js";
|
|
5
|
+
import { captured } from "./stack.js";
|
|
3
6
|
const LEVELS = {
|
|
4
7
|
debug: "debug",
|
|
5
8
|
log: "info",
|
|
@@ -8,6 +11,8 @@ const LEVELS = {
|
|
|
8
11
|
error: "error",
|
|
9
12
|
};
|
|
10
13
|
const CAPTURED = Symbol.for("tracepanel.console");
|
|
14
|
+
// How deep the stack at a dump is read: console's wrappers (a dev overlay's) above the app's frame.
|
|
15
|
+
const DUMP_DEPTH = 20;
|
|
11
16
|
let quiet = 0;
|
|
12
17
|
/**
|
|
13
18
|
* Runs a logger's own write (pino's, winston's): it recorded the log already, so what it prints through console is
|
|
@@ -25,27 +30,44 @@ export function quietly(write) {
|
|
|
25
30
|
/**
|
|
26
31
|
* Each of console's methods becomes a property whose value records the call, then runs the method as it is now:
|
|
27
32
|
* something that replaces it later (Nuxt's dev server puts its own logger there) replaces what runs, not the record.
|
|
33
|
+
* A later capture (Nuxt's plugin) only changes where the calls go.
|
|
28
34
|
*/
|
|
29
|
-
export function captureConsole(processor) {
|
|
35
|
+
export function captureConsole(processor, config) {
|
|
30
36
|
const target = console;
|
|
31
|
-
|
|
37
|
+
const captured = target[CAPTURED];
|
|
38
|
+
if (captured) {
|
|
39
|
+
captured.processor = processor;
|
|
40
|
+
captured.config = config ?? captured.config;
|
|
32
41
|
return;
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
}
|
|
43
|
+
const capture = { processor, config };
|
|
44
|
+
target[CAPTURED] = capture;
|
|
45
|
+
for (const method of new Set([...Object.keys(LEVELS), ...DUMPING])) {
|
|
46
|
+
const level = LEVELS[method];
|
|
35
47
|
let current = target[method];
|
|
36
48
|
const recorded = (...args) => {
|
|
37
49
|
if (quiet > 0)
|
|
38
50
|
return current.apply(console, args);
|
|
39
|
-
const
|
|
40
|
-
processor.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const { processor, config } = capture;
|
|
52
|
+
if (config?.dumps && isDump(method, args) && processor.current()) {
|
|
53
|
+
const found = dumpOf(method, args, config.root);
|
|
54
|
+
if (found) {
|
|
55
|
+
processor.addLog(found);
|
|
56
|
+
return current.apply(console, args);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (level) {
|
|
60
|
+
const error = args.find((arg) => arg instanceof Error);
|
|
61
|
+
processor.addLog({
|
|
62
|
+
time: Date.now() * 1000,
|
|
63
|
+
level,
|
|
64
|
+
logger: "console",
|
|
65
|
+
message: format(...args),
|
|
66
|
+
exception: error?.stack ?? null,
|
|
67
|
+
attrs: {},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return current.apply(console, args);
|
|
49
71
|
};
|
|
50
72
|
Object.defineProperty(console, method, {
|
|
51
73
|
configurable: true,
|
|
@@ -57,4 +79,14 @@ export function captureConsole(processor) {
|
|
|
57
79
|
});
|
|
58
80
|
}
|
|
59
81
|
}
|
|
82
|
+
/** The dump of a console call, or null: not the app's own call, or anything gone wrong (the call goes on). */
|
|
83
|
+
function dumpOf(method, args, root) {
|
|
84
|
+
try {
|
|
85
|
+
const { stack, sites } = captured(DUMP_DEPTH);
|
|
86
|
+
return dump(method, args, stack, root, sites);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
60
92
|
//# sourceMappingURL=console.js.map
|
package/dist/console.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,wFAAwF;AAExF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,GAAiC;IAC3C,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAClD,oGAAoG;AACpG,MAAM,UAAU,GAAG,EAAE,CAAC;AAQtB,IAAI,KAAK,GAAG,CAAC,CAAC;AAEd;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAI,KAAc;IACvC,KAAK,EAAE,CAAC;IACR,IAAI,CAAC;QACH,OAAO,KAAK,EAAE,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,KAAK,EAAE,CAAC;IACV,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"./model.js";
|
|
2
|
+
import { type StackFrame } from "./stack.js";
|
|
3
|
+
/** How long an argument's text is at most, "… (truncated)" included. */
|
|
4
|
+
export declare const MAX_REPR = 16384;
|
|
5
|
+
/** The console methods whose calls can be dumps. dir() and table() always are. */
|
|
6
|
+
export declare const DUMPING: Set<string>;
|
|
7
|
+
export interface DumpArg {
|
|
8
|
+
/** The argument's source text, or null: a literal, or a call whose source couldn't be read. */
|
|
9
|
+
expr: string | null;
|
|
10
|
+
repr: string;
|
|
11
|
+
type: string;
|
|
12
|
+
len: number | null;
|
|
13
|
+
}
|
|
14
|
+
/** Whether a call to a console method is a dump: dir(), table(), or a log of a value that isn't a primitive. */
|
|
15
|
+
export declare function isDump(method: string, args: readonly unknown[]): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The dump of a console call, or null when the call isn't the app's own. `stack`: the stack at the call, the frames
|
|
18
|
+
* of console's wrappers (this package's, a dev overlay's) above the app's.
|
|
19
|
+
*/
|
|
20
|
+
export declare function dump(method: string, args: readonly unknown[], stack: string | undefined, root: string, sites?: readonly (StackFrame | undefined)[]): Omit<Log, "span_id"> | null;
|
|
21
|
+
/** What a dump shows of a value: a copy with its secrets masked, or the value; `byText`: its text is to be masked. */
|
|
22
|
+
export interface Shown {
|
|
23
|
+
value: unknown;
|
|
24
|
+
byText: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A value as inspect() is to show it, a secret's value masked: a copy where an object's key, a class's field or a
|
|
28
|
+
* Map's key names a secret (`password`, `apiToken`), with the same prototypes (inspect() names the class) and
|
|
29
|
+
* cycles; the value itself when nothing in it does. The app's value is never changed, and no getter is called. A
|
|
30
|
+
* proxy isn't looked into (its traps could run anything): inspect() shows its target without them, and that text is
|
|
31
|
+
* masked (maskText()).
|
|
32
|
+
*/
|
|
33
|
+
export declare function masked(value: unknown): Shown;
|
|
34
|
+
/** A value as Node's console prints it, cut at MAX_REPR. */
|
|
35
|
+
export declare function reprOf(value: unknown): string;
|
|
36
|
+
/**
|
|
37
|
+
* A text inspect() made with every value under a key that names a secret masked: a quoted string (over several
|
|
38
|
+
* lines too), an object or array to its closing bracket, `[Getter]`, a number; and `name=value` pairs. What is masked
|
|
39
|
+
* reads `'********'`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function maskText(text: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* The source text of each argument of the call at a frame, read from its source (through its bundle's source map,
|
|
44
|
+
* see stack.ts); null when the source can't be read or the call's arguments can't be told apart (a spread, a call
|
|
45
|
+
* split oddly).
|
|
46
|
+
*/
|
|
47
|
+
export declare function expressions(site: StackFrame, count: number): (string | null)[] | null;
|
|
48
|
+
/**
|
|
49
|
+
* The arguments of the call whose parenthesis is at `open`, as source text without comments: strings, templates and
|
|
50
|
+
* brackets kept whole.
|
|
51
|
+
*/
|
|
52
|
+
export declare function argumentsAt(text: string, open: number): string[] | null;
|