@warlock.js/devtools 5.55.0 → 5.56.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/CHANGELOG.md +29 -0
- package/README.md +26 -13
- package/cjs/ai-source-DTpxumMA.cjs +381 -0
- package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
- package/cjs/auth-DzU0gHDG.cjs +1655 -0
- package/cjs/auth-DzU0gHDG.cjs.map +1 -0
- package/cjs/boot-BQi0Etor.cjs +138 -0
- package/cjs/boot-BQi0Etor.cjs.map +1 -0
- package/cjs/capture-CqIiaznN.cjs +1342 -0
- package/cjs/capture-CqIiaznN.cjs.map +1 -0
- package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
- package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
- package/cjs/collector-CJbQbzzK.cjs +271 -0
- package/cjs/collector-CJbQbzzK.cjs.map +1 -0
- package/cjs/contracts-CVmplkNb.cjs +112 -0
- package/cjs/contracts-CVmplkNb.cjs.map +1 -0
- package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
- package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
- package/cjs/errors-CyZp5yS-.cjs +177 -0
- package/cjs/errors-CyZp5yS-.cjs.map +1 -0
- package/cjs/histogram-BaI-PnCv.cjs +102 -0
- package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
- package/cjs/http-CabcUwBx.cjs +870 -0
- package/cjs/http-CabcUwBx.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/insights-BKtqxdnP.cjs +811 -0
- package/cjs/insights-BKtqxdnP.cjs.map +1 -0
- package/cjs/ip-DbNhPOzi.cjs +153 -0
- package/cjs/ip-DbNhPOzi.cjs.map +1 -0
- package/cjs/migrations-w7GMsrQw.cjs +297 -0
- package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
- package/cjs/openapi-CC7OAUc6.cjs +52 -0
- package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
- package/cjs/options-CWqFC5__.cjs +181 -0
- package/cjs/options-CWqFC5__.cjs.map +1 -0
- package/cjs/panels-B0dAfGbJ.cjs +298 -0
- package/cjs/panels-B0dAfGbJ.cjs.map +1 -0
- package/cjs/process-panel-DEOnLxoT.cjs +48 -0
- package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
- package/cjs/production/index.cjs +238 -0
- package/cjs/production/index.cjs.map +1 -0
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
- package/cjs/server-B6xdeKS8.cjs +184 -0
- package/cjs/server-B6xdeKS8.cjs.map +1 -0
- package/cjs/{src-Xwm3Eel9.cjs → src-Ce-3Lniv.cjs} +163 -295
- package/cjs/src-Ce-3Lniv.cjs.map +1 -0
- package/cjs/store-aq207T8v.cjs +9 -0
- package/cjs/stream-route-BGJa-zQu.cjs +875 -0
- package/cjs/stream-route-BGJa-zQu.cjs.map +1 -0
- package/esm/devtools-connector.d.mts +16 -13
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +127 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/options.mjs +2 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panels.mjs +50 -5
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/common-passwords.mjs +303 -0
- package/esm/production/auth/common-passwords.mjs.map +1 -0
- package/esm/production/auth/default-crypto.mjs +19 -0
- package/esm/production/auth/default-crypto.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +77 -0
- package/esm/production/auth/helpers.mjs.map +1 -0
- package/esm/production/auth/index.mjs +6 -0
- package/esm/production/auth/passkeys.mjs +96 -0
- package/esm/production/auth/passkeys.mjs.map +1 -0
- package/esm/production/auth/service.mjs +1166 -0
- package/esm/production/auth/service.mjs.map +1 -0
- package/esm/production/boot.mjs +138 -0
- package/esm/production/boot.mjs.map +1 -0
- package/esm/production/capture/dev-stats.mjs +83 -0
- package/esm/production/capture/dev-stats.mjs.map +1 -0
- package/esm/production/capture/engine.mjs +442 -0
- package/esm/production/capture/engine.mjs.map +1 -0
- package/esm/production/capture/explain.mjs +271 -0
- package/esm/production/capture/explain.mjs.map +1 -0
- package/esm/production/capture/filter.mjs +24 -0
- package/esm/production/capture/filter.mjs.map +1 -0
- package/esm/production/capture/index.mjs +7 -0
- package/esm/production/capture/production-capture.mjs +134 -0
- package/esm/production/capture/production-capture.mjs.map +1 -0
- package/esm/production/capture/redact.mjs +109 -0
- package/esm/production/capture/redact.mjs.map +1 -0
- package/esm/production/capture/stats-stores.mjs +300 -0
- package/esm/production/capture/stats-stores.mjs.map +1 -0
- package/esm/production/cli/actions.mjs +151 -0
- package/esm/production/cli/actions.mjs.map +1 -0
- package/esm/production/cli/index.d.mts +17 -0
- package/esm/production/cli/index.d.mts.map +1 -0
- package/esm/production/cli/index.mjs +86 -0
- package/esm/production/cli/index.mjs.map +1 -0
- package/esm/production/contracts.d.mts +592 -0
- package/esm/production/contracts.d.mts.map +1 -0
- package/esm/production/contracts.mjs +95 -0
- package/esm/production/contracts.mjs.map +1 -0
- package/esm/production/errors.d.mts +31 -0
- package/esm/production/errors.d.mts.map +1 -0
- package/esm/production/errors.mjs +142 -0
- package/esm/production/errors.mjs.map +1 -0
- package/esm/production/http/access.mjs +124 -0
- package/esm/production/http/access.mjs.map +1 -0
- package/esm/production/http/auth-routes.mjs +280 -0
- package/esm/production/http/auth-routes.mjs.map +1 -0
- package/esm/production/http/client.mjs +57 -0
- package/esm/production/http/client.mjs.map +1 -0
- package/esm/production/http/constants.mjs +11 -0
- package/esm/production/http/constants.mjs.map +1 -0
- package/esm/production/http/context.mjs +14 -0
- package/esm/production/http/context.mjs.map +1 -0
- package/esm/production/http/cookie.mjs +39 -0
- package/esm/production/http/cookie.mjs.map +1 -0
- package/esm/production/http/headers.mjs +25 -0
- package/esm/production/http/headers.mjs.map +1 -0
- package/esm/production/http/index.mjs +10 -0
- package/esm/production/http/ip.mjs +130 -0
- package/esm/production/http/ip.mjs.map +1 -0
- package/esm/production/http/mount.mjs +300 -0
- package/esm/production/http/mount.mjs.map +1 -0
- package/esm/production/http/state.mjs +54 -0
- package/esm/production/http/state.mjs.map +1 -0
- package/esm/production/index.d.mts +6 -0
- package/esm/production/index.mjs +5 -0
- package/esm/production/insights/cap-report.mjs +67 -0
- package/esm/production/insights/cap-report.mjs.map +1 -0
- package/esm/production/insights/health.mjs +88 -0
- package/esm/production/insights/health.mjs.map +1 -0
- package/esm/production/insights/index.mjs +10 -0
- package/esm/production/insights/insights.mjs +167 -0
- package/esm/production/insights/insights.mjs.map +1 -0
- package/esm/production/insights/instance.mjs +24 -0
- package/esm/production/insights/instance.mjs.map +1 -0
- package/esm/production/insights/jobs.mjs +100 -0
- package/esm/production/insights/jobs.mjs.map +1 -0
- package/esm/production/insights/reporter.mjs +59 -0
- package/esm/production/insights/reporter.mjs.map +1 -0
- package/esm/production/insights/resources.mjs +139 -0
- package/esm/production/insights/resources.mjs.map +1 -0
- package/esm/production/insights/writer.mjs +72 -0
- package/esm/production/insights/writer.mjs.map +1 -0
- package/esm/production/openapi.mjs +52 -0
- package/esm/production/openapi.mjs.map +1 -0
- package/esm/production/options.d.mts +60 -0
- package/esm/production/options.d.mts.map +1 -0
- package/esm/production/options.mjs +170 -0
- package/esm/production/options.mjs.map +1 -0
- package/esm/production/stats/histogram.mjs +67 -0
- package/esm/production/stats/histogram.mjs.map +1 -0
- package/esm/production/stats/merge.mjs +106 -0
- package/esm/production/stats/merge.mjs.map +1 -0
- package/esm/production/store/cascade-store.mjs +322 -0
- package/esm/production/store/cascade-store.mjs.map +1 -0
- package/esm/production/store/index.mjs +5 -0
- package/esm/production/store/mapping.mjs +258 -0
- package/esm/production/store/mapping.mjs.map +1 -0
- package/esm/production/store/memory-store.mjs +291 -0
- package/esm/production/store/memory-store.mjs.map +1 -0
- package/esm/production/store/migrations.d.mts +11 -0
- package/esm/production/store/migrations.d.mts.map +1 -0
- package/esm/production/store/migrations.mjs +29 -0
- package/esm/production/store/migrations.mjs.map +1 -0
- package/esm/production/store/models/account.migration.mjs +34 -0
- package/esm/production/store/models/account.migration.mjs.map +1 -0
- package/esm/production/store/models/account.model.mjs +13 -0
- package/esm/production/store/models/account.model.mjs.map +1 -0
- package/esm/production/store/models/audit.migration.mjs +30 -0
- package/esm/production/store/models/audit.migration.mjs.map +1 -0
- package/esm/production/store/models/audit.model.mjs +13 -0
- package/esm/production/store/models/audit.model.mjs.map +1 -0
- package/esm/production/store/models/base.mjs +27 -0
- package/esm/production/store/models/base.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +17 -0
- package/esm/production/store/models/invite.migration.mjs +26 -0
- package/esm/production/store/models/invite.migration.mjs.map +1 -0
- package/esm/production/store/models/invite.model.mjs +13 -0
- package/esm/production/store/models/invite.model.mjs.map +1 -0
- package/esm/production/store/models/report.migration.mjs +20 -0
- package/esm/production/store/models/report.migration.mjs.map +1 -0
- package/esm/production/store/models/report.model.mjs +13 -0
- package/esm/production/store/models/report.model.mjs.map +1 -0
- package/esm/production/store/models/sample.migration.mjs +25 -0
- package/esm/production/store/models/sample.migration.mjs.map +1 -0
- package/esm/production/store/models/sample.model.mjs +13 -0
- package/esm/production/store/models/sample.model.mjs.map +1 -0
- package/esm/production/store/models/session.migration.mjs +31 -0
- package/esm/production/store/models/session.migration.mjs.map +1 -0
- package/esm/production/store/models/session.model.mjs +13 -0
- package/esm/production/store/models/session.model.mjs.map +1 -0
- package/esm/production/store/models/state.migration.mjs +26 -0
- package/esm/production/store/models/state.migration.mjs.map +1 -0
- package/esm/production/store/models/state.model.mjs +13 -0
- package/esm/production/store/models/state.model.mjs.map +1 -0
- package/esm/query-shape.mjs +14 -1
- package/esm/query-shape.mjs.map +1 -1
- package/esm/server/explain-route.mjs +26 -1
- package/esm/server/explain-route.mjs.map +1 -1
- package/esm/server/index.mjs +9 -4
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/insights-routes.mjs +62 -0
- package/esm/server/insights-routes.mjs.map +1 -0
- package/esm/server/log-routes.mjs +32 -5
- package/esm/server/log-routes.mjs.map +1 -1
- package/esm/server/openapi-routes.mjs +3 -2
- package/esm/server/openapi-routes.mjs.map +1 -1
- package/esm/server/requests-routes.mjs +125 -0
- package/esm/server/requests-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +42 -0
- package/esm/server/session-routes.mjs.map +1 -0
- package/esm/server/stream-route.mjs +81 -11
- package/esm/server/stream-route.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +34 -25
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/log-source.mjs +14 -1
- package/esm/sources/log-source.mjs.map +1 -1
- package/esm/types.d.mts +202 -1
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +9 -4
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +159 -21
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +159 -21
- package/ui/dashboard/assets/app.css +3 -0
- package/ui/dashboard/assets/app.js +50 -0
- package/ui/dashboard/build-info.json +21 -0
- package/ui/dashboard/index.html +15 -0
- package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
- package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
- package/cjs/server-B11ShQYE.cjs +0 -628
- package/cjs/server-B11ShQYE.cjs.map +0 -1
- package/cjs/src-Xwm3Eel9.cjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1158
- package/ui/index.html +0 -28
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { queryShape } from "../../query-shape.mjs";
|
|
2
|
+
import { createCollector } from "../../collector.mjs";
|
|
3
|
+
import { createShapeExplainer } from "./explain.mjs";
|
|
4
|
+
import { createErrorGroups, createQueryStats, createRecentLogs, createRouteStats, truncate } from "./stats-stores.mjs";
|
|
5
|
+
import { scrubErrorText, scrubQueryError, toStoredSample } from "./redact.mjs";
|
|
6
|
+
import { sampleMatchesFilter } from "./filter.mjs";
|
|
7
|
+
|
|
8
|
+
//#region ../../packages/devtools/src/production/capture/engine.ts
|
|
9
|
+
/** Per sampled request limits (see "Bounded memory"). */
|
|
10
|
+
const MAX_LOGS_PER_REQUEST = 50;
|
|
11
|
+
const MAX_PHASES_PER_REQUEST = 100;
|
|
12
|
+
const MAX_CACHE_PER_REQUEST = 1e3;
|
|
13
|
+
const MAX_ACTIVE = 2e3;
|
|
14
|
+
const MAX_PENDING = 500;
|
|
15
|
+
const FLUSH_AT = 50;
|
|
16
|
+
const FLUSH_EVERY_MS = 5e3;
|
|
17
|
+
const WARN_EVERY_MS = 6e4;
|
|
18
|
+
const LOG_MESSAGE_MAX = 1e3;
|
|
19
|
+
function stripQuery(path) {
|
|
20
|
+
const index = path.indexOf("?");
|
|
21
|
+
return index === -1 ? path : path.slice(0, index);
|
|
22
|
+
}
|
|
23
|
+
/** The lengths the error groups keep (see `createErrorGroups`). */
|
|
24
|
+
const REQUEST_ERROR_MAX = 500;
|
|
25
|
+
const REQUEST_STACK_MAX = 4e3;
|
|
26
|
+
function errorMessage(error) {
|
|
27
|
+
return error instanceof Error ? error.message : String(error);
|
|
28
|
+
}
|
|
29
|
+
/** A request's error message as the monitor keeps it: without the values in it (see `scrubErrorText`). */
|
|
30
|
+
function requestErrorMessage(error) {
|
|
31
|
+
return scrubErrorText(errorMessage(error), REQUEST_ERROR_MAX);
|
|
32
|
+
}
|
|
33
|
+
function touchesMonitorTables(event) {
|
|
34
|
+
return event.sql !== void 0 && event.sql.includes("devtools_") || event.collection !== void 0 && event.collection.startsWith("devtools_");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The capture of one process without any registration: sampling, the ring,
|
|
38
|
+
* the statistics, the sample writer and the request source. The hooks are
|
|
39
|
+
* plain functions so a spec (or the benchmark) can drive them directly.
|
|
40
|
+
*/
|
|
41
|
+
function createCaptureEngine(deps) {
|
|
42
|
+
const { production, instance, store } = deps;
|
|
43
|
+
const random = deps.random ?? Math.random;
|
|
44
|
+
const now = deps.now ?? (() => performance.timeOrigin + performance.now());
|
|
45
|
+
const warn = deps.warn ?? (() => {});
|
|
46
|
+
const logLevels = new Set(production.logLevels);
|
|
47
|
+
const collector = createCollector({
|
|
48
|
+
...deps.options,
|
|
49
|
+
maxRequests: production.maxRequests
|
|
50
|
+
});
|
|
51
|
+
const queries = createQueryStats({
|
|
52
|
+
maxShapes: production.maxShapes,
|
|
53
|
+
instance: instance.id
|
|
54
|
+
});
|
|
55
|
+
const routes = createRouteStats({
|
|
56
|
+
maxRoutes: production.maxRoutes,
|
|
57
|
+
instance: instance.id
|
|
58
|
+
});
|
|
59
|
+
const errors = createErrorGroups({ maxGroups: production.maxErrorGroups });
|
|
60
|
+
const logs = createRecentLogs({ maxEntries: 200 });
|
|
61
|
+
const active = /* @__PURE__ */ new Map();
|
|
62
|
+
const recent = /* @__PURE__ */ new Map();
|
|
63
|
+
const pending = [];
|
|
64
|
+
const counts = {
|
|
65
|
+
requests: 0,
|
|
66
|
+
sampled: 0,
|
|
67
|
+
keptUnsampled: 0,
|
|
68
|
+
stored: 0,
|
|
69
|
+
droppedStored: 0,
|
|
70
|
+
droppedQueries: 0
|
|
71
|
+
};
|
|
72
|
+
let exampleSequence = 0;
|
|
73
|
+
let budgetMinute = -1;
|
|
74
|
+
let budgetUsed = 0;
|
|
75
|
+
let lastWarnAt = -Infinity;
|
|
76
|
+
let flushing = Promise.resolve();
|
|
77
|
+
let timer;
|
|
78
|
+
const remember = (sample) => {
|
|
79
|
+
recent.delete(sample.id);
|
|
80
|
+
recent.set(sample.id, sample);
|
|
81
|
+
while (recent.size > production.maxRequests) recent.delete(recent.keys().next().value);
|
|
82
|
+
};
|
|
83
|
+
const doFlush = async () => {
|
|
84
|
+
if (!store || pending.length === 0) return;
|
|
85
|
+
const batch = pending.splice(0, pending.length);
|
|
86
|
+
try {
|
|
87
|
+
await store.samples.insert(batch);
|
|
88
|
+
counts.stored += batch.length;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
counts.droppedStored += batch.length;
|
|
91
|
+
const at = now();
|
|
92
|
+
if (at - lastWarnAt >= WARN_EVERY_MS) {
|
|
93
|
+
lastWarnAt = at;
|
|
94
|
+
warn(`devtools could not store ${batch.length} request sample(s), they were dropped: ${errorMessage(error)}. Check the database connection and that the devtools migrations ran.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const flush = () => {
|
|
99
|
+
flushing = flushing.then(doFlush, doFlush);
|
|
100
|
+
return flushing;
|
|
101
|
+
};
|
|
102
|
+
const enqueue = (sample) => {
|
|
103
|
+
remember(sample);
|
|
104
|
+
if (!store) return;
|
|
105
|
+
const minute = Math.floor(now() / 6e4);
|
|
106
|
+
if (minute !== budgetMinute) {
|
|
107
|
+
budgetMinute = minute;
|
|
108
|
+
budgetUsed = 0;
|
|
109
|
+
}
|
|
110
|
+
if (budgetUsed >= production.maxStoredSamplesPerMinute) {
|
|
111
|
+
counts.droppedStored++;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
budgetUsed++;
|
|
115
|
+
pending.push(sample);
|
|
116
|
+
if (pending.length > MAX_PENDING) {
|
|
117
|
+
pending.shift();
|
|
118
|
+
counts.droppedStored++;
|
|
119
|
+
}
|
|
120
|
+
if (pending.length >= FLUSH_AT) flush();
|
|
121
|
+
};
|
|
122
|
+
const newState = (route) => ({
|
|
123
|
+
queries: 0,
|
|
124
|
+
logs: 0,
|
|
125
|
+
phases: 0,
|
|
126
|
+
cache: 0,
|
|
127
|
+
dropped: 0,
|
|
128
|
+
route
|
|
129
|
+
});
|
|
130
|
+
const recordRequestError = (request, result, route) => {
|
|
131
|
+
const status = result.status;
|
|
132
|
+
if (!(status !== void 0 && status >= 500 || result.error !== void 0)) return;
|
|
133
|
+
const error = result.error;
|
|
134
|
+
errors.record({
|
|
135
|
+
source: "request",
|
|
136
|
+
message: error === void 0 ? `HTTP ${status}` : requestErrorMessage(error),
|
|
137
|
+
name: error instanceof Error ? error.name : null,
|
|
138
|
+
stack: error instanceof Error && error.stack !== void 0 ? scrubErrorText(error.stack, REQUEST_STACK_MAX) : null,
|
|
139
|
+
route: route ?? null,
|
|
140
|
+
status: status ?? null,
|
|
141
|
+
requestId: request.requestId,
|
|
142
|
+
at: now()
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const finishSampled = (request, state, result) => {
|
|
146
|
+
const route = request.route ?? state.route;
|
|
147
|
+
collector.endRequest(request.requestId, {
|
|
148
|
+
...result.status === void 0 ? {} : { status: result.status },
|
|
149
|
+
durationMs: result.durationMs,
|
|
150
|
+
...result.error === void 0 ? {} : { error: requestErrorMessage(result.error) },
|
|
151
|
+
...route === void 0 ? {} : { route }
|
|
152
|
+
});
|
|
153
|
+
const settled = collector.getRequest(request.requestId);
|
|
154
|
+
if (!settled) return;
|
|
155
|
+
const failed = result.status !== void 0 && result.status >= 500 || result.error !== void 0;
|
|
156
|
+
routes.record({
|
|
157
|
+
method: request.method,
|
|
158
|
+
route: route ?? "",
|
|
159
|
+
status: result.status ?? null,
|
|
160
|
+
failed,
|
|
161
|
+
durationMs: result.durationMs,
|
|
162
|
+
at: now(),
|
|
163
|
+
requestId: request.requestId,
|
|
164
|
+
phases: settled.phases.map((phase) => ({
|
|
165
|
+
name: phase.name,
|
|
166
|
+
durationMs: phase.durationMs
|
|
167
|
+
}))
|
|
168
|
+
});
|
|
169
|
+
for (const warning of settled.warnings) queries.recordNPlusOne(warning.shape, warning.count);
|
|
170
|
+
recordRequestError(request, result, route);
|
|
171
|
+
enqueue(toStoredSample(settled, instance.id, state.dropped));
|
|
172
|
+
};
|
|
173
|
+
const finishUnsampled = (request, result) => {
|
|
174
|
+
if (deps.isDashboardPath(request.path)) return;
|
|
175
|
+
counts.keptUnsampled++;
|
|
176
|
+
const startedAt = now() - result.durationMs;
|
|
177
|
+
const path = stripQuery(request.path);
|
|
178
|
+
const summary = {
|
|
179
|
+
id: request.requestId,
|
|
180
|
+
method: request.method,
|
|
181
|
+
path,
|
|
182
|
+
startedAt,
|
|
183
|
+
durationMs: result.durationMs,
|
|
184
|
+
queryCount: 0,
|
|
185
|
+
warningCount: 0,
|
|
186
|
+
instance: instance.id,
|
|
187
|
+
partial: true
|
|
188
|
+
};
|
|
189
|
+
if (request.route !== void 0) summary.route = request.route;
|
|
190
|
+
if (result.status !== void 0) summary.status = result.status;
|
|
191
|
+
recordRequestError(request, result, request.route);
|
|
192
|
+
enqueue({
|
|
193
|
+
id: request.requestId,
|
|
194
|
+
instance: instance.id,
|
|
195
|
+
startedAt,
|
|
196
|
+
summary,
|
|
197
|
+
detail: null
|
|
198
|
+
});
|
|
199
|
+
collector.startRequest({
|
|
200
|
+
id: request.requestId,
|
|
201
|
+
method: request.method,
|
|
202
|
+
path,
|
|
203
|
+
...request.route === void 0 ? {} : { route: request.route },
|
|
204
|
+
startedAt
|
|
205
|
+
});
|
|
206
|
+
collector.endRequest(request.requestId, {
|
|
207
|
+
...result.status === void 0 ? {} : { status: result.status },
|
|
208
|
+
durationMs: result.durationMs,
|
|
209
|
+
...result.error === void 0 ? {} : { error: requestErrorMessage(result.error) },
|
|
210
|
+
...request.route === void 0 ? {} : { route: request.route }
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
/** The query without an id or a shape, from what the driver emitted. */
|
|
214
|
+
const queryInput = (event) => {
|
|
215
|
+
const input = {
|
|
216
|
+
connection: event.connection,
|
|
217
|
+
driver: event.driver,
|
|
218
|
+
startedAt: event.startedAt,
|
|
219
|
+
durationMs: event.durationMs
|
|
220
|
+
};
|
|
221
|
+
if (event.sql !== void 0) input.sql = event.sql;
|
|
222
|
+
if (event.bindings !== void 0) input.bindings = event.bindings;
|
|
223
|
+
if (event.collection !== void 0) input.collection = event.collection;
|
|
224
|
+
if (event.command !== void 0) input.command = event.command;
|
|
225
|
+
if (event.pipeline !== void 0) input.pipeline = event.pipeline;
|
|
226
|
+
if (event.rowCount !== void 0) input.rowCount = event.rowCount;
|
|
227
|
+
if (event.error !== void 0) input.error = scrubQueryError(errorMessage(event.error));
|
|
228
|
+
return input;
|
|
229
|
+
};
|
|
230
|
+
const exampleOf = (event) => ({
|
|
231
|
+
...queryInput(event),
|
|
232
|
+
id: `x${++exampleSequence}`,
|
|
233
|
+
shape: queryShape(event)
|
|
234
|
+
});
|
|
235
|
+
const recordQuery = (query, route, requestId) => {
|
|
236
|
+
queries.record({
|
|
237
|
+
shape: query.shape,
|
|
238
|
+
driver: query.driver,
|
|
239
|
+
connection: query.connection,
|
|
240
|
+
durationMs: query.durationMs,
|
|
241
|
+
failed: query.error !== void 0,
|
|
242
|
+
at: query.startedAt,
|
|
243
|
+
route,
|
|
244
|
+
requestId
|
|
245
|
+
});
|
|
246
|
+
queries.rememberExample(query);
|
|
247
|
+
};
|
|
248
|
+
return {
|
|
249
|
+
collector,
|
|
250
|
+
queries,
|
|
251
|
+
routes,
|
|
252
|
+
errors,
|
|
253
|
+
logs,
|
|
254
|
+
requests: {
|
|
255
|
+
async list(filter) {
|
|
256
|
+
let storedRows = [];
|
|
257
|
+
if (store) try {
|
|
258
|
+
storedRows = await store.samples.list(filter);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
warn(`devtools could not read request samples: ${errorMessage(error)}. Showing this process's requests only.`);
|
|
261
|
+
}
|
|
262
|
+
const merged = /* @__PURE__ */ new Map();
|
|
263
|
+
for (const row of storedRows) merged.set(row.id, row);
|
|
264
|
+
for (const sample of recent.values()) if (!merged.has(sample.id) && sampleMatchesFilter(sample.summary, filter)) merged.set(sample.id, sample.summary);
|
|
265
|
+
return [...merged.values()].sort((a, b) => b.startedAt - a.startedAt).slice(0, Math.max(1, filter.limit));
|
|
266
|
+
},
|
|
267
|
+
async get(id) {
|
|
268
|
+
let stored = null;
|
|
269
|
+
if (store) try {
|
|
270
|
+
stored = await store.samples.get(id);
|
|
271
|
+
} catch {
|
|
272
|
+
stored = null;
|
|
273
|
+
}
|
|
274
|
+
stored ??= recent.get(id) ?? null;
|
|
275
|
+
if (stored) return stored.detail ?? stored.summary;
|
|
276
|
+
const live = collector.getRequest(id);
|
|
277
|
+
if (!live) return null;
|
|
278
|
+
const dropped = active.get(id)?.dropped ?? 0;
|
|
279
|
+
const sample = toStoredSample(live, instance.id, dropped);
|
|
280
|
+
return sample.detail ?? sample.summary;
|
|
281
|
+
},
|
|
282
|
+
async clear() {
|
|
283
|
+
const memory = recent.size;
|
|
284
|
+
const waiting = pending.length;
|
|
285
|
+
recent.clear();
|
|
286
|
+
pending.length = 0;
|
|
287
|
+
collector.clear();
|
|
288
|
+
if (!store) return memory;
|
|
289
|
+
return await store.samples.clear() + waiting;
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
hooks: {
|
|
293
|
+
onRequestStart(request) {
|
|
294
|
+
if (deps.isDashboardPath(request.path)) return;
|
|
295
|
+
counts.requests++;
|
|
296
|
+
if (!(random() < production.sampleRate)) return;
|
|
297
|
+
counts.sampled++;
|
|
298
|
+
if (active.size >= MAX_ACTIVE) active.delete(active.keys().next().value);
|
|
299
|
+
active.set(request.requestId, newState(request.route));
|
|
300
|
+
collector.startRequest({
|
|
301
|
+
id: request.requestId,
|
|
302
|
+
method: request.method,
|
|
303
|
+
path: stripQuery(request.path),
|
|
304
|
+
...request.route === void 0 ? {} : { route: request.route },
|
|
305
|
+
startedAt: now()
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
onPhase(request, phase) {
|
|
309
|
+
const state = active.get(request.requestId);
|
|
310
|
+
if (!state) return;
|
|
311
|
+
if (request.route !== void 0) state.route = request.route;
|
|
312
|
+
if (state.phases >= MAX_PHASES_PER_REQUEST) return;
|
|
313
|
+
state.phases++;
|
|
314
|
+
collector.addPhase(request.requestId, {
|
|
315
|
+
name: phase.name,
|
|
316
|
+
durationMs: phase.durationMs,
|
|
317
|
+
startedAt: phase.startedAt ?? now() - phase.durationMs
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
onRequestEnd(request, result) {
|
|
321
|
+
const state = active.get(request.requestId);
|
|
322
|
+
if (state) {
|
|
323
|
+
active.delete(request.requestId);
|
|
324
|
+
finishSampled(request, state, result);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (result.durationMs >= production.slowRequestMs || result.status !== void 0 && result.status >= 500 || result.error !== void 0) finishUnsampled(request, result);
|
|
328
|
+
},
|
|
329
|
+
onQuery(requestId, event) {
|
|
330
|
+
const state = requestId === void 0 ? void 0 : active.get(requestId);
|
|
331
|
+
if (state && requestId !== void 0) {
|
|
332
|
+
if (touchesMonitorTables(event)) return;
|
|
333
|
+
let query;
|
|
334
|
+
if (state.queries < production.maxQueriesPerRequest) {
|
|
335
|
+
state.queries++;
|
|
336
|
+
query = collector.addQuery(requestId, queryInput(event));
|
|
337
|
+
} else {
|
|
338
|
+
state.dropped++;
|
|
339
|
+
counts.droppedQueries++;
|
|
340
|
+
query = exampleOf(event);
|
|
341
|
+
}
|
|
342
|
+
recordQuery(query, state.route ?? null, requestId);
|
|
343
|
+
delete query.sql;
|
|
344
|
+
delete query.bindings;
|
|
345
|
+
delete query.pipeline;
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (requestId === void 0) {
|
|
349
|
+
if (touchesMonitorTables(event)) return;
|
|
350
|
+
if (random() < production.sampleRate) {
|
|
351
|
+
const query = exampleOf(event);
|
|
352
|
+
recordQuery(query, null, null);
|
|
353
|
+
} else if (event.durationMs >= production.slowQueryMs) queries.rememberExample(exampleOf(event));
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (event.durationMs >= production.slowQueryMs && !touchesMonitorTables(event)) queries.rememberExample(exampleOf(event));
|
|
357
|
+
},
|
|
358
|
+
onLog(requestId, entry) {
|
|
359
|
+
const wanted = logLevels.has(entry.level);
|
|
360
|
+
const state = requestId === void 0 ? void 0 : active.get(requestId);
|
|
361
|
+
if (!wanted && !state) return;
|
|
362
|
+
const message = truncate(entry.message, LOG_MESSAGE_MAX);
|
|
363
|
+
const kept = {
|
|
364
|
+
level: entry.level,
|
|
365
|
+
module: entry.module,
|
|
366
|
+
action: entry.action,
|
|
367
|
+
message,
|
|
368
|
+
at: entry.at
|
|
369
|
+
};
|
|
370
|
+
if (state && requestId !== void 0) {
|
|
371
|
+
if (state.logs < MAX_LOGS_PER_REQUEST) {
|
|
372
|
+
state.logs++;
|
|
373
|
+
collector.addLog(requestId, kept);
|
|
374
|
+
}
|
|
375
|
+
} else collector.addLog(void 0, kept);
|
|
376
|
+
if (!wanted) return;
|
|
377
|
+
logs.record({
|
|
378
|
+
level: entry.level,
|
|
379
|
+
module: entry.module,
|
|
380
|
+
action: entry.action,
|
|
381
|
+
message,
|
|
382
|
+
at: entry.at,
|
|
383
|
+
requestId: state && requestId !== void 0 ? requestId : null
|
|
384
|
+
});
|
|
385
|
+
if (entry.level === "error") errors.record({
|
|
386
|
+
source: "log",
|
|
387
|
+
message: entry.message,
|
|
388
|
+
name: null,
|
|
389
|
+
stack: null,
|
|
390
|
+
route: state?.route ?? null,
|
|
391
|
+
status: null,
|
|
392
|
+
requestId: state && requestId !== void 0 ? requestId : null,
|
|
393
|
+
at: entry.at
|
|
394
|
+
});
|
|
395
|
+
},
|
|
396
|
+
onCache(requestId, operation) {
|
|
397
|
+
if (requestId === void 0) return;
|
|
398
|
+
const state = active.get(requestId);
|
|
399
|
+
if (!state || state.cache >= MAX_CACHE_PER_REQUEST) return;
|
|
400
|
+
state.cache++;
|
|
401
|
+
collector.addCacheOperation(requestId, {
|
|
402
|
+
type: operation.type,
|
|
403
|
+
driver: operation.driver,
|
|
404
|
+
at: operation.at
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
explain: createShapeExplainer({
|
|
409
|
+
queries,
|
|
410
|
+
executing: production.explain.executing,
|
|
411
|
+
instance: instance.id,
|
|
412
|
+
redact: true,
|
|
413
|
+
...deps.run === void 0 ? {} : { run: deps.run }
|
|
414
|
+
}),
|
|
415
|
+
flush,
|
|
416
|
+
counters: () => ({
|
|
417
|
+
sampleRate: production.sampleRate,
|
|
418
|
+
requests: counts.requests,
|
|
419
|
+
sampled: counts.sampled,
|
|
420
|
+
keptUnsampled: counts.keptUnsampled,
|
|
421
|
+
stored: counts.stored,
|
|
422
|
+
droppedStored: counts.droppedStored,
|
|
423
|
+
evictedShapes: queries.evicted(),
|
|
424
|
+
evictedRoutes: routes.evicted(),
|
|
425
|
+
evictedErrors: errors.evicted(),
|
|
426
|
+
droppedQueries: counts.droppedQueries
|
|
427
|
+
}),
|
|
428
|
+
startWriter() {
|
|
429
|
+
if (!store || timer) return;
|
|
430
|
+
timer = setInterval(() => void flush(), FLUSH_EVERY_MS);
|
|
431
|
+
timer.unref();
|
|
432
|
+
},
|
|
433
|
+
stopWriter() {
|
|
434
|
+
if (timer) clearInterval(timer);
|
|
435
|
+
timer = void 0;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
//#endregion
|
|
441
|
+
export { createCaptureEngine };
|
|
442
|
+
//# sourceMappingURL=engine.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.mjs","names":[],"sources":["../../../../../../../../../packages/devtools/src/production/capture/engine.ts"],"sourcesContent":["import { createCollector } from \"../../collector\";\nimport { queryShape } from \"../../query-shape\";\nimport type {\n DevtoolsCacheOperation,\n DevtoolsCollector,\n DevtoolsLogEntry,\n DevtoolsQuery,\n DevtoolsRequest,\n} from \"../../types\";\nimport type {\n DevtoolsCaptureCounters,\n DevtoolsSampleDetail,\n DevtoolsSampleSummary,\n} from \"../contracts\";\nimport type { DevtoolsStoredSample } from \"../store/types\";\nimport { createShapeExplainer } from \"./explain\";\nimport { sampleMatchesFilter } from \"./filter\";\nimport { scrubErrorText, scrubQueryError, toStoredSample } from \"./redact\";\nimport {\n createErrorGroups,\n createQueryStats,\n createRecentLogs,\n createRouteStats,\n truncate,\n} from \"./stats-stores\";\nimport type {\n DevtoolsCaptureDeps,\n DevtoolsErrorGroups,\n DevtoolsQueryStats,\n DevtoolsRecentLogs,\n DevtoolsRequestSource,\n DevtoolsRouteStatsStore,\n} from \"./types\";\n\n/** Per sampled request limits (see \"Bounded memory\"). */\nconst MAX_LOGS_PER_REQUEST = 50;\nconst MAX_PHASES_PER_REQUEST = 100;\nconst MAX_CACHE_PER_REQUEST = 1000;\nconst MAX_ACTIVE = 2000;\nconst MAX_PENDING = 500;\nconst FLUSH_AT = 50;\nconst FLUSH_EVERY_MS = 5000;\nconst WARN_EVERY_MS = 60_000;\nconst LOG_MESSAGE_MAX = 1000;\n\n/** The shape of the event cascade's `dataSourceRegistry` emits for `\"query\"`. */\nexport type DevtoolsQueryEvent = {\n connection: string;\n driver: \"postgres\" | \"mongodb\";\n sql?: string;\n bindings?: unknown[];\n collection?: string;\n command?: string;\n pipeline?: unknown;\n durationMs: number;\n startedAt: number;\n rowCount?: number;\n error?: unknown;\n};\n\n/** What core's tracing hooks hand over for a request. */\nexport type DevtoolsTracedRequest = {\n requestId: string;\n method: string;\n path: string;\n route?: string | undefined;\n};\n\ntype RequestState = {\n queries: number;\n logs: number;\n phases: number;\n cache: number;\n dropped: number;\n route: string | undefined;\n};\n\n/** The functions the tracing, query, log and cache sources call. */\nexport type DevtoolsCaptureHooks = {\n onRequestStart(request: DevtoolsTracedRequest): void;\n onPhase(\n request: DevtoolsTracedRequest,\n phase: { name: string; durationMs: number; startedAt?: number | undefined },\n ): void;\n onRequestEnd(\n request: DevtoolsTracedRequest,\n result: { status?: number | undefined; durationMs: number; error?: unknown },\n ): void;\n onQuery(requestId: string | undefined, event: DevtoolsQueryEvent): void;\n onLog(requestId: string | undefined, entry: Omit<DevtoolsLogEntry, \"context\">): void;\n onCache(requestId: string | undefined, operation: DevtoolsCacheOperation): void;\n};\n\n/** Everything the production capture is made of, apart from the registration with core, cascade, the logger and the cache. */\nexport type DevtoolsCaptureEngine = {\n collector: DevtoolsCollector;\n queries: DevtoolsQueryStats;\n routes: DevtoolsRouteStatsStore;\n errors: DevtoolsErrorGroups;\n logs: DevtoolsRecentLogs;\n requests: DevtoolsRequestSource;\n hooks: DevtoolsCaptureHooks;\n counters(): DevtoolsCaptureCounters;\n explain(shapeId: string): ReturnType<ReturnType<typeof createShapeExplainer>>;\n /** Starts the 5 s write timer (a no-op without a store). */\n startWriter(): void;\n stopWriter(): void;\n flush(): Promise<void>;\n};\n\nfunction stripQuery(path: string): string {\n const index = path.indexOf(\"?\");\n\n return index === -1 ? path : path.slice(0, index);\n}\n\n/** The lengths the error groups keep (see `createErrorGroups`). */\nconst REQUEST_ERROR_MAX = 500;\nconst REQUEST_STACK_MAX = 4000;\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** A request's error message as the monitor keeps it: without the values in it (see `scrubErrorText`). */\nfunction requestErrorMessage(error: unknown): string {\n return scrubErrorText(errorMessage(error), REQUEST_ERROR_MAX);\n}\n\nfunction touchesMonitorTables(event: DevtoolsQueryEvent): boolean {\n return (\n (event.sql !== undefined && event.sql.includes(\"devtools_\")) ||\n (event.collection !== undefined && event.collection.startsWith(\"devtools_\"))\n );\n}\n\n/**\n * The capture of one process without any registration: sampling, the ring,\n * the statistics, the sample writer and the request source. The hooks are\n * plain functions so a spec (or the benchmark) can drive them directly.\n */\nexport function createCaptureEngine(deps: DevtoolsCaptureDeps): DevtoolsCaptureEngine {\n const { production, instance, store } = deps;\n const random = deps.random ?? Math.random;\n const now = deps.now ?? (() => performance.timeOrigin + performance.now());\n const warn = deps.warn ?? (() => {});\n const logLevels = new Set<string>(production.logLevels);\n\n const collector = createCollector({ ...deps.options, maxRequests: production.maxRequests });\n const queries = createQueryStats({ maxShapes: production.maxShapes, instance: instance.id });\n const routes = createRouteStats({ maxRoutes: production.maxRoutes, instance: instance.id });\n const errors = createErrorGroups({ maxGroups: production.maxErrorGroups });\n const logs = createRecentLogs({ maxEntries: 200 });\n\n const active = new Map<string, RequestState>();\n const recent = new Map<string, DevtoolsStoredSample>();\n const pending: DevtoolsStoredSample[] = [];\n const counts = {\n requests: 0,\n sampled: 0,\n keptUnsampled: 0,\n stored: 0,\n droppedStored: 0,\n droppedQueries: 0,\n };\n\n let exampleSequence = 0;\n let budgetMinute = -1;\n let budgetUsed = 0;\n let lastWarnAt = -Infinity;\n let flushing: Promise<void> = Promise.resolve();\n let timer: ReturnType<typeof setInterval> | undefined;\n\n // -- sample writer ---------------------------------------------------------\n\n const remember = (sample: DevtoolsStoredSample) => {\n recent.delete(sample.id);\n recent.set(sample.id, sample);\n\n while (recent.size > production.maxRequests) {\n recent.delete(recent.keys().next().value as string);\n }\n };\n\n const doFlush = async () => {\n if (!store || pending.length === 0) return;\n\n const batch = pending.splice(0, pending.length);\n\n try {\n await store.samples.insert(batch);\n counts.stored += batch.length;\n } catch (error) {\n counts.droppedStored += batch.length;\n\n const at = now();\n\n if (at - lastWarnAt >= WARN_EVERY_MS) {\n lastWarnAt = at;\n warn(\n `devtools could not store ${batch.length} request sample(s), they were dropped: ${errorMessage(error)}. Check the database connection and that the devtools migrations ran.`,\n );\n }\n }\n };\n\n const flush = (): Promise<void> => {\n flushing = flushing.then(doFlush, doFlush);\n\n return flushing;\n };\n\n const enqueue = (sample: DevtoolsStoredSample) => {\n remember(sample);\n\n if (!store) return;\n\n const minute = Math.floor(now() / 60_000);\n\n if (minute !== budgetMinute) {\n budgetMinute = minute;\n budgetUsed = 0;\n }\n\n if (budgetUsed >= production.maxStoredSamplesPerMinute) {\n counts.droppedStored++;\n return;\n }\n\n budgetUsed++;\n pending.push(sample);\n\n if (pending.length > MAX_PENDING) {\n pending.shift();\n counts.droppedStored++;\n }\n\n if (pending.length >= FLUSH_AT) void flush();\n };\n\n // -- hooks -----------------------------------------------------------------\n\n const newState = (route: string | undefined): RequestState => ({\n queries: 0,\n logs: 0,\n phases: 0,\n cache: 0,\n dropped: 0,\n route,\n });\n\n const recordRequestError = (\n request: DevtoolsTracedRequest,\n result: { status?: number | undefined; error?: unknown },\n route: string | undefined,\n ) => {\n const status = result.status;\n const failed = (status !== undefined && status >= 500) || result.error !== undefined;\n\n if (!failed) return;\n\n const error = result.error;\n\n errors.record({\n source: \"request\",\n message: error === undefined ? `HTTP ${status}` : requestErrorMessage(error),\n name: error instanceof Error ? error.name : null,\n // The first line of a stack repeats the message.\n stack:\n error instanceof Error && error.stack !== undefined\n ? scrubErrorText(error.stack, REQUEST_STACK_MAX)\n : null,\n route: route ?? null,\n status: status ?? null,\n requestId: request.requestId,\n at: now(),\n });\n };\n\n const finishSampled = (\n request: DevtoolsTracedRequest,\n state: RequestState,\n result: { status?: number | undefined; durationMs: number; error?: unknown },\n ) => {\n const route = request.route ?? state.route;\n\n collector.endRequest(request.requestId, {\n ...(result.status === undefined ? {} : { status: result.status }),\n durationMs: result.durationMs,\n ...(result.error === undefined ? {} : { error: requestErrorMessage(result.error) }),\n ...(route === undefined ? {} : { route }),\n });\n\n const settled = collector.getRequest(request.requestId);\n\n if (!settled) return;\n\n const failed =\n (result.status !== undefined && result.status >= 500) || result.error !== undefined;\n\n routes.record({\n method: request.method,\n route: route ?? \"\",\n status: result.status ?? null,\n failed,\n durationMs: result.durationMs,\n at: now(),\n requestId: request.requestId,\n phases: settled.phases.map((phase) => ({ name: phase.name, durationMs: phase.durationMs })),\n });\n\n for (const warning of settled.warnings) queries.recordNPlusOne(warning.shape, warning.count);\n\n recordRequestError(request, result, route);\n enqueue(toStoredSample(settled, instance.id, state.dropped));\n };\n\n const finishUnsampled = (\n request: DevtoolsTracedRequest,\n result: { status?: number | undefined; durationMs: number; error?: unknown },\n ) => {\n if (deps.isDashboardPath(request.path)) return;\n\n counts.keptUnsampled++;\n\n const startedAt = now() - result.durationMs;\n const path = stripQuery(request.path);\n const summary: DevtoolsSampleSummary = {\n id: request.requestId,\n method: request.method,\n path,\n startedAt,\n durationMs: result.durationMs,\n queryCount: 0,\n warningCount: 0,\n instance: instance.id,\n partial: true,\n };\n\n if (request.route !== undefined) summary.route = request.route;\n if (result.status !== undefined) summary.status = result.status;\n\n recordRequestError(request, result, request.route);\n enqueue({ id: request.requestId, instance: instance.id, startedAt, summary, detail: null });\n\n // The live stream shows it too.\n collector.startRequest({\n id: request.requestId,\n method: request.method,\n path,\n ...(request.route === undefined ? {} : { route: request.route }),\n startedAt,\n });\n collector.endRequest(request.requestId, {\n ...(result.status === undefined ? {} : { status: result.status }),\n durationMs: result.durationMs,\n ...(result.error === undefined ? {} : { error: requestErrorMessage(result.error) }),\n ...(request.route === undefined ? {} : { route: request.route }),\n });\n };\n\n /** The query without an id or a shape, from what the driver emitted. */\n const queryInput = (event: DevtoolsQueryEvent): Omit<DevtoolsQuery, \"id\" | \"shape\"> => {\n const input: Omit<DevtoolsQuery, \"id\" | \"shape\"> = {\n connection: event.connection,\n driver: event.driver,\n startedAt: event.startedAt,\n durationMs: event.durationMs,\n };\n\n if (event.sql !== undefined) input.sql = event.sql;\n if (event.bindings !== undefined) input.bindings = event.bindings;\n if (event.collection !== undefined) input.collection = event.collection;\n if (event.command !== undefined) input.command = event.command;\n if (event.pipeline !== undefined) input.pipeline = event.pipeline;\n if (event.rowCount !== undefined) input.rowCount = event.rowCount;\n if (event.error !== undefined) input.error = scrubQueryError(errorMessage(event.error));\n\n return input;\n };\n\n const exampleOf = (event: DevtoolsQueryEvent): DevtoolsQuery => ({\n ...queryInput(event),\n id: `x${++exampleSequence}`,\n shape: queryShape(event),\n });\n\n const recordQuery = (query: DevtoolsQuery, route: string | null, requestId: string | null) => {\n queries.record({\n shape: query.shape,\n driver: query.driver,\n connection: query.connection,\n durationMs: query.durationMs,\n failed: query.error !== undefined,\n at: query.startedAt,\n route,\n requestId,\n });\n queries.rememberExample(query);\n };\n\n const hooks: DevtoolsCaptureHooks = {\n onRequestStart(request) {\n if (deps.isDashboardPath(request.path)) return;\n\n counts.requests++;\n\n if (!(random() < production.sampleRate)) return;\n\n counts.sampled++;\n\n if (active.size >= MAX_ACTIVE) active.delete(active.keys().next().value as string);\n\n active.set(request.requestId, newState(request.route));\n collector.startRequest({\n id: request.requestId,\n method: request.method,\n path: stripQuery(request.path),\n ...(request.route === undefined ? {} : { route: request.route }),\n startedAt: now(),\n });\n },\n\n onPhase(request, phase) {\n const state = active.get(request.requestId);\n\n if (!state) return;\n\n if (request.route !== undefined) state.route = request.route;\n if (state.phases >= MAX_PHASES_PER_REQUEST) return;\n\n state.phases++;\n collector.addPhase(request.requestId, {\n name: phase.name,\n durationMs: phase.durationMs,\n startedAt: phase.startedAt ?? now() - phase.durationMs,\n });\n },\n\n onRequestEnd(request, result) {\n const state = active.get(request.requestId);\n\n if (state) {\n active.delete(request.requestId);\n finishSampled(request, state, result);\n return;\n }\n\n if (\n result.durationMs >= production.slowRequestMs ||\n (result.status !== undefined && result.status >= 500) ||\n result.error !== undefined\n ) {\n finishUnsampled(request, result);\n }\n },\n\n onQuery(requestId, event) {\n const state = requestId === undefined ? undefined : active.get(requestId);\n\n if (state && requestId !== undefined) {\n if (touchesMonitorTables(event)) return;\n\n let query: DevtoolsQuery;\n\n if (state.queries < production.maxQueriesPerRequest) {\n state.queries++;\n query = collector.addQuery(requestId, queryInput(event));\n } else {\n state.dropped++;\n counts.droppedQueries++;\n query = exampleOf(event);\n }\n\n recordQuery(query, state.route ?? null, requestId);\n\n // The ring keeps the shape only; the statistics copied what EXPLAIN needs.\n delete query.sql;\n delete query.bindings;\n delete query.pipeline;\n return;\n }\n\n if (requestId === undefined) {\n // Work outside a request is sampled query by query.\n if (touchesMonitorTables(event)) return;\n\n if (random() < production.sampleRate) {\n const query = exampleOf(event);\n\n recordQuery(query, null, null);\n } else if (event.durationMs >= production.slowQueryMs) {\n queries.rememberExample(exampleOf(event));\n }\n\n return;\n }\n\n // An unsampled request: only a slow query leaves a trace, in its shape's `slowest`.\n if (event.durationMs >= production.slowQueryMs && !touchesMonitorTables(event)) {\n queries.rememberExample(exampleOf(event));\n }\n },\n\n onLog(requestId, entry) {\n const wanted = logLevels.has(entry.level);\n const state = requestId === undefined ? undefined : active.get(requestId);\n\n if (!wanted && !state) return;\n\n const message = truncate(entry.message, LOG_MESSAGE_MAX);\n const kept: DevtoolsLogEntry = {\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message,\n at: entry.at,\n };\n\n if (state && requestId !== undefined) {\n if (state.logs < MAX_LOGS_PER_REQUEST) {\n state.logs++;\n collector.addLog(requestId, kept);\n }\n } else {\n collector.addLog(undefined, kept);\n }\n\n if (!wanted) return;\n\n logs.record({\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message,\n at: entry.at,\n requestId: state && requestId !== undefined ? requestId : null,\n });\n\n if (entry.level === \"error\") {\n errors.record({\n source: \"log\",\n message: entry.message,\n name: null,\n stack: null,\n route: state?.route ?? null,\n status: null,\n requestId: state && requestId !== undefined ? requestId : null,\n at: entry.at,\n });\n }\n },\n\n onCache(requestId, operation) {\n if (requestId === undefined) return;\n\n const state = active.get(requestId);\n\n if (!state || state.cache >= MAX_CACHE_PER_REQUEST) return;\n\n state.cache++;\n // Counts only: keys and tags never enter the ring.\n collector.addCacheOperation(requestId, {\n type: operation.type,\n driver: operation.driver,\n at: operation.at,\n });\n },\n };\n\n // -- request source --------------------------------------------------------\n\n const requests: DevtoolsRequestSource = {\n async list(filter) {\n let storedRows: DevtoolsSampleSummary[] = [];\n\n if (store) {\n try {\n storedRows = await store.samples.list(filter);\n } catch (error) {\n warn(\n `devtools could not read request samples: ${errorMessage(error)}. Showing this process's requests only.`,\n );\n }\n }\n\n const merged = new Map<string, DevtoolsSampleSummary>();\n\n for (const row of storedRows) merged.set(row.id, row);\n\n for (const sample of recent.values()) {\n if (!merged.has(sample.id) && sampleMatchesFilter(sample.summary, filter)) {\n merged.set(sample.id, sample.summary);\n }\n }\n\n return [...merged.values()]\n .sort((a, b) => b.startedAt - a.startedAt)\n .slice(0, Math.max(1, filter.limit));\n },\n\n async get(id) {\n let stored: DevtoolsStoredSample | null = null;\n\n if (store) {\n try {\n stored = await store.samples.get(id);\n } catch {\n stored = null;\n }\n }\n\n stored ??= recent.get(id) ?? null;\n\n if (stored) return stored.detail ?? stored.summary;\n\n const live: DevtoolsRequest | undefined = collector.getRequest(id);\n\n if (!live) return null;\n\n const dropped = active.get(id)?.dropped ?? 0;\n const sample = toStoredSample(live, instance.id, dropped);\n\n return (sample.detail ?? sample.summary) as DevtoolsSampleDetail | DevtoolsSampleSummary;\n },\n\n async clear() {\n const memory = recent.size;\n const waiting = pending.length;\n\n recent.clear();\n pending.length = 0;\n collector.clear();\n\n if (!store) return memory;\n\n const removed = await store.samples.clear();\n\n return removed + waiting;\n },\n };\n\n const explain = createShapeExplainer({\n queries,\n executing: production.explain.executing,\n instance: instance.id,\n // Values never leave the process, and plans repeat them.\n redact: true,\n ...(deps.run === undefined ? {} : { run: deps.run }),\n });\n\n return {\n collector,\n queries,\n routes,\n errors,\n logs,\n requests,\n hooks,\n explain,\n flush,\n counters: () => ({\n sampleRate: production.sampleRate,\n requests: counts.requests,\n sampled: counts.sampled,\n keptUnsampled: counts.keptUnsampled,\n stored: counts.stored,\n droppedStored: counts.droppedStored,\n evictedShapes: queries.evicted(),\n evictedRoutes: routes.evicted(),\n evictedErrors: errors.evicted(),\n droppedQueries: counts.droppedQueries,\n }),\n startWriter() {\n if (!store || timer) return;\n\n timer = setInterval(() => void flush(), FLUSH_EVERY_MS);\n timer.unref();\n },\n stopWriter() {\n if (timer) clearInterval(timer);\n\n timer = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;AAmCA,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,wBAAwB;AAC9B,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAmExB,SAAS,WAAW,MAAsB;CACxC,MAAM,QAAQ,KAAK,QAAQ,GAAG;CAE9B,OAAO,UAAU,KAAK,OAAO,KAAK,MAAM,GAAG,KAAK;AAClD;;AAGA,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAE1B,SAAS,aAAa,OAAwB;CAC5C,OAA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