@descryy/runtime-database-observation 0.4.6 → 0.4.8
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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/postgres-log-parser.d.ts +4 -4
- package/dist/postgres-log-parser.js +4 -4
- package/dist/postgres-log-source.d.ts +55 -0
- package/dist/postgres-log-source.d.ts.map +1 -0
- package/dist/postgres-log-source.js +164 -0
- package/dist/postgres-log-source.js.map +1 -0
- package/dist/postgres-query-collector.d.ts +9 -3
- package/dist/postgres-query-collector.d.ts.map +1 -1
- package/dist/postgres-query-collector.js +9 -3
- package/dist/postgres-query-collector.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,6 @@ export type { PostgresLogQuery } from "./postgres-log-parser.ts";
|
|
|
9
9
|
export { parsePostgresLogLine } from "./postgres-log-parser.ts";
|
|
10
10
|
export type { PostgresQueryCollectorOptions } from "./postgres-query-collector.ts";
|
|
11
11
|
export { createPostgresQueryCollector } from "./postgres-query-collector.ts";
|
|
12
|
+
export type { PostgresStatementLogSource } from "./postgres-log-source.ts";
|
|
13
|
+
export { createPostgresLogSource } from "./postgres-log-source.ts";
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAC1E,O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4 +5,5 @@ export { createDatabaseQueryCollector, SQLITE_PRELOAD_MODULE_PATH } from "./quer
|
|
|
5
5
|
export { resolveObservedDatabaseQuery } from "./graph-mapping.js";
|
|
6
6
|
export { parsePostgresLogLine } from "./postgres-log-parser.js";
|
|
7
7
|
export { createPostgresQueryCollector } from "./postgres-query-collector.js";
|
|
8
|
+
export { createPostgresLogSource } from "./postgres-log-source.js";
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAA2C,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGhG,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAA2C,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGhG,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAG7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* a real name).
|
|
14
14
|
*
|
|
15
15
|
* Verified against PostgreSQL's own documented log format (`log_statement`,
|
|
16
|
-
* `log_line_prefix`), not guessed
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* `log_line_prefix`), not guessed, and now also **live-tested against a
|
|
17
|
+
* real `postgres:16` Docker container** producing real `LOG: statement:`
|
|
18
|
+
* lines (`postgres-query-collector.ts`'s `test/postgres-live.test.ts`) —
|
|
19
|
+
* not just doc-verified syntax fed in by hand.
|
|
20
20
|
*
|
|
21
21
|
* **Disclosed, deliberate scope, same "refuse rather than guess" rule
|
|
22
22
|
* `query-line-parser.ts` and `table-extraction.ts` already apply:**
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* a real name).
|
|
14
14
|
*
|
|
15
15
|
* Verified against PostgreSQL's own documented log format (`log_statement`,
|
|
16
|
-
* `log_line_prefix`), not guessed
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* `log_line_prefix`), not guessed, and now also **live-tested against a
|
|
17
|
+
* real `postgres:16` Docker container** producing real `LOG: statement:`
|
|
18
|
+
* lines (`postgres-query-collector.ts`'s `test/postgres-live.test.ts`) —
|
|
19
|
+
* not just doc-verified syntax fed in by hand.
|
|
20
20
|
*
|
|
21
21
|
* **Disclosed, deliberate scope, same "refuse rather than guess" rule
|
|
22
22
|
* `query-line-parser.ts` and `table-extraction.ts` already apply:**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live sources for Postgres's own statement log (RG-5(b)/(c)) — the piece
|
|
3
|
+
* `postgres-query-collector.ts` consumes but, until now, nothing in this
|
|
4
|
+
* repo produced. Two concrete shapes, matching what a deployment can
|
|
5
|
+
* actually hand this collector:
|
|
6
|
+
*
|
|
7
|
+
* - `{ kind: "file" }` — a log file the operator already writes to
|
|
8
|
+
* (`log_destination = 'stderr'` plus `logging_collector = on`, or any
|
|
9
|
+
* equivalent). Tailed from its current end: pre-existing content is not
|
|
10
|
+
* replayed, only what is appended after this source starts.
|
|
11
|
+
* - `{ kind: "dockerContainer" }` — a Docker container whose own stdout IS
|
|
12
|
+
* the statement log, which is the default for the official `postgres`
|
|
13
|
+
* image (`log_statement = 'all'` logs to stdout, not a file, unless
|
|
14
|
+
* `logging_collector` is turned on). Followed via `docker logs -f
|
|
15
|
+
* --since <when this source was created> <container>` — nothing from
|
|
16
|
+
* before the channel started, and nothing lost between the channel
|
|
17
|
+
* starting and the follower attaching. `--tail 0` (the first version)
|
|
18
|
+
* began at the moment of attach instead; the source is lazy, so that
|
|
19
|
+
* moment is whenever the collector first reads, and a query issued in
|
|
20
|
+
* between — often the application's first request — was silently missed
|
|
21
|
+
* (found as an intermittent failure of the desktop's Postgres end-to-end
|
|
22
|
+
* test under load). The boundary uses the docker daemon's own log
|
|
23
|
+
* timestamps against this host's clock, so it assumes a local daemon.
|
|
24
|
+
*
|
|
25
|
+
* **Never turns logging on.** `log_statement` is the operator's own
|
|
26
|
+
* setting; this module only reads whatever a deployment already produces.
|
|
27
|
+
* Its callers are what disclose "database channel: not observed" when
|
|
28
|
+
* neither shape is configured — this module has no opinion on that, it
|
|
29
|
+
* only knows how to tail a source once one is named.
|
|
30
|
+
*
|
|
31
|
+
* Both branches accept an optional `AbortSignal` so a caller can end a
|
|
32
|
+
* live tail deterministically: the docker branch kills the `docker logs
|
|
33
|
+
* -f` child (which ends its stdout, which ends the async iterable, which
|
|
34
|
+
* is what lets `PostgresQueryCollector.stop()` — which just awaits its
|
|
35
|
+
* consume loop finishing — ever resolve for a source that would otherwise
|
|
36
|
+
* run forever); the file branch checks the signal between polls.
|
|
37
|
+
*/
|
|
38
|
+
import { type ProcessOutputSource } from "@descryy/runtime-backend-observation";
|
|
39
|
+
export type PostgresStatementLogSource = {
|
|
40
|
+
readonly kind: "file";
|
|
41
|
+
readonly path: string;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "dockerContainer";
|
|
44
|
+
readonly container: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Builds the `ProcessOutputSource` `createPostgresQueryCollector` consumes,
|
|
48
|
+
* over whichever statement-log shape a caller configured. `serviceName`
|
|
49
|
+
* follows `ProcessOutputSource`'s own required-not-optional contract —
|
|
50
|
+
* `null` is a real statement ("no declared service"), never an omission.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createPostgresLogSource(logSource: PostgresStatementLogSource, processId: string, serviceName: string | null, options?: {
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
}): ProcessOutputSource;
|
|
55
|
+
//# sourceMappingURL=postgres-log-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-log-source.d.ts","sourceRoot":"","sources":["../src/postgres-log-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,EAAwC,KAAK,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAEtH,MAAM,MAAM,0BAA0B,GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AA+GrE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,0BAA0B,EACrC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC1C,mBAAmB,CAUrB"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live sources for Postgres's own statement log (RG-5(b)/(c)) — the piece
|
|
3
|
+
* `postgres-query-collector.ts` consumes but, until now, nothing in this
|
|
4
|
+
* repo produced. Two concrete shapes, matching what a deployment can
|
|
5
|
+
* actually hand this collector:
|
|
6
|
+
*
|
|
7
|
+
* - `{ kind: "file" }` — a log file the operator already writes to
|
|
8
|
+
* (`log_destination = 'stderr'` plus `logging_collector = on`, or any
|
|
9
|
+
* equivalent). Tailed from its current end: pre-existing content is not
|
|
10
|
+
* replayed, only what is appended after this source starts.
|
|
11
|
+
* - `{ kind: "dockerContainer" }` — a Docker container whose own stdout IS
|
|
12
|
+
* the statement log, which is the default for the official `postgres`
|
|
13
|
+
* image (`log_statement = 'all'` logs to stdout, not a file, unless
|
|
14
|
+
* `logging_collector` is turned on). Followed via `docker logs -f
|
|
15
|
+
* --since <when this source was created> <container>` — nothing from
|
|
16
|
+
* before the channel started, and nothing lost between the channel
|
|
17
|
+
* starting and the follower attaching. `--tail 0` (the first version)
|
|
18
|
+
* began at the moment of attach instead; the source is lazy, so that
|
|
19
|
+
* moment is whenever the collector first reads, and a query issued in
|
|
20
|
+
* between — often the application's first request — was silently missed
|
|
21
|
+
* (found as an intermittent failure of the desktop's Postgres end-to-end
|
|
22
|
+
* test under load). The boundary uses the docker daemon's own log
|
|
23
|
+
* timestamps against this host's clock, so it assumes a local daemon.
|
|
24
|
+
*
|
|
25
|
+
* **Never turns logging on.** `log_statement` is the operator's own
|
|
26
|
+
* setting; this module only reads whatever a deployment already produces.
|
|
27
|
+
* Its callers are what disclose "database channel: not observed" when
|
|
28
|
+
* neither shape is configured — this module has no opinion on that, it
|
|
29
|
+
* only knows how to tail a source once one is named.
|
|
30
|
+
*
|
|
31
|
+
* Both branches accept an optional `AbortSignal` so a caller can end a
|
|
32
|
+
* live tail deterministically: the docker branch kills the `docker logs
|
|
33
|
+
* -f` child (which ends its stdout, which ends the async iterable, which
|
|
34
|
+
* is what lets `PostgresQueryCollector.stop()` — which just awaits its
|
|
35
|
+
* consume loop finishing — ever resolve for a source that would otherwise
|
|
36
|
+
* run forever); the file branch checks the signal between polls.
|
|
37
|
+
*/
|
|
38
|
+
import { spawn } from "node:child_process";
|
|
39
|
+
import { readFile, stat } from "node:fs/promises";
|
|
40
|
+
import { LineSplitter } from "@descryy/runtime-backend-observation";
|
|
41
|
+
const FILE_POLL_INTERVAL_MS = 200;
|
|
42
|
+
function sleep(ms) {
|
|
43
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
44
|
+
}
|
|
45
|
+
async function* tailFile(path, signal) {
|
|
46
|
+
let offset;
|
|
47
|
+
try {
|
|
48
|
+
offset = (await stat(path)).size;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
offset = 0;
|
|
52
|
+
}
|
|
53
|
+
const splitter = new LineSplitter();
|
|
54
|
+
while (signal?.aborted !== true) {
|
|
55
|
+
let size;
|
|
56
|
+
try {
|
|
57
|
+
size = (await stat(path)).size;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
await sleep(FILE_POLL_INTERVAL_MS);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (size > offset) {
|
|
64
|
+
const buffer = await readFile(path);
|
|
65
|
+
const chunk = buffer.subarray(offset).toString("utf8");
|
|
66
|
+
offset = size;
|
|
67
|
+
const observedAt = new Date().toISOString();
|
|
68
|
+
for (const text of splitter.push(chunk)) {
|
|
69
|
+
yield { text, stream: "combined", observedAt };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
await sleep(FILE_POLL_INTERVAL_MS);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Merges `docker logs -f`'s own stdout and stderr into one line stream.
|
|
77
|
+
*
|
|
78
|
+
* **Both, deliberately.** The official Postgres image's default
|
|
79
|
+
* `log_destination = 'stderr'` means its statement log arrives on the
|
|
80
|
+
* *container's* stderr — which `docker logs` relays on its own stderr fd,
|
|
81
|
+
* not stdout. Reading stdout alone (the first version of this function)
|
|
82
|
+
* measurably captured nothing against a real container; this was found by
|
|
83
|
+
* running it, not reasoned from documentation.
|
|
84
|
+
*
|
|
85
|
+
* Not a `for await` over either stream directly: iterating two independent
|
|
86
|
+
* readables in that style serialises them (fully drain one before touching
|
|
87
|
+
* the other), which would reorder-and-delay whichever stream is read
|
|
88
|
+
* second. This uses `data` events on both instead, queued in arrival order
|
|
89
|
+
* — the same "no true cross-stream ordering guarantee" disclosure
|
|
90
|
+
* `process-output.ts`'s own header already states for `ManagedProcess`.
|
|
91
|
+
*/
|
|
92
|
+
async function* tailDockerContainer(container, since, signal) {
|
|
93
|
+
const child = spawn("docker", ["logs", "-f", "--since", since.toISOString(), container], {
|
|
94
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
95
|
+
...(signal === undefined ? {} : { signal }),
|
|
96
|
+
});
|
|
97
|
+
const splitter = new LineSplitter();
|
|
98
|
+
const queue = [];
|
|
99
|
+
let waiter = null;
|
|
100
|
+
let done = false;
|
|
101
|
+
function wake() {
|
|
102
|
+
if (waiter !== null) {
|
|
103
|
+
const resolve = waiter;
|
|
104
|
+
waiter = null;
|
|
105
|
+
resolve();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function onChunk(chunk) {
|
|
109
|
+
queue.push(chunk.toString("utf8"));
|
|
110
|
+
wake();
|
|
111
|
+
}
|
|
112
|
+
function onDone() {
|
|
113
|
+
done = true;
|
|
114
|
+
wake();
|
|
115
|
+
}
|
|
116
|
+
child.stdout.on("data", onChunk);
|
|
117
|
+
child.stderr.on("data", onChunk);
|
|
118
|
+
child.once("close", onDone);
|
|
119
|
+
// An aborted signal kills the child, which surfaces as an 'error' event on
|
|
120
|
+
// the ChildProcess itself (not either stream) -- swallowed here, because
|
|
121
|
+
// `onDone` (via 'close', which always follows) is this generator's real
|
|
122
|
+
// end signal, and an unhandled 'error' event would otherwise crash the
|
|
123
|
+
// process.
|
|
124
|
+
child.on("error", () => undefined);
|
|
125
|
+
try {
|
|
126
|
+
for (;;) {
|
|
127
|
+
while (queue.length > 0) {
|
|
128
|
+
const chunk = queue.shift();
|
|
129
|
+
const observedAt = new Date().toISOString();
|
|
130
|
+
for (const text of splitter.push(chunk)) {
|
|
131
|
+
yield { text, stream: "combined", observedAt };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (done)
|
|
135
|
+
return;
|
|
136
|
+
await new Promise((resolve) => {
|
|
137
|
+
waiter = resolve;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
child.stdout.off("data", onChunk);
|
|
143
|
+
child.stderr.off("data", onChunk);
|
|
144
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
145
|
+
child.kill();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Builds the `ProcessOutputSource` `createPostgresQueryCollector` consumes,
|
|
150
|
+
* over whichever statement-log shape a caller configured. `serviceName`
|
|
151
|
+
* follows `ProcessOutputSource`'s own required-not-optional contract —
|
|
152
|
+
* `null` is a real statement ("no declared service"), never an omission.
|
|
153
|
+
*/
|
|
154
|
+
export function createPostgresLogSource(logSource, processId, serviceName, options) {
|
|
155
|
+
// Taken here, eagerly, not inside the generator: the generator does not run
|
|
156
|
+
// until the collector first reads, and that delay is the window `--since`
|
|
157
|
+
// exists to close.
|
|
158
|
+
const startedAt = new Date();
|
|
159
|
+
const lines = logSource.kind === "file"
|
|
160
|
+
? tailFile(logSource.path, options?.signal)
|
|
161
|
+
: tailDockerContainer(logSource.container, startedAt, options?.signal);
|
|
162
|
+
return { processId, serviceName, lines };
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=postgres-log-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-log-source.js","sourceRoot":"","sources":["../src/postgres-log-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;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AU,uBAAuB,CACrC,SAAqC,EACrC,SAAiB,EACjB,WAA0B,EAC1B,OAA2C;IAE3C,4EAA4E;IAC5E,0EAA0E;IAC1E,mBAAmB;IACnB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,KAAK,GACT,SAAS,CAAC,IAAI,KAAK,MAAM;QACvB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;QAC3C,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -16,9 +16,15 @@
|
|
|
16
16
|
* this collector does not add. See `packages/database-observation`'s
|
|
17
17
|
* package description for the same disclosure on the `node:sqlite` path.
|
|
18
18
|
*
|
|
19
|
-
* **
|
|
20
|
-
* `postgres-
|
|
21
|
-
*
|
|
19
|
+
* **Live-tested against a real, disposable `postgres:16` Docker container**
|
|
20
|
+
* (`test/postgres-live.test.ts`): a real `INSERT`/`SELECT` issued via
|
|
21
|
+
* `psql` inside the container, its statement log tailed via
|
|
22
|
+
* `createPostgresLogSource`'s `dockerContainer` source (`docker logs -f`),
|
|
23
|
+
* and a real `DATABASE_QUERY` record read back out. Found in the process:
|
|
24
|
+
* the official image's default `log_destination = 'stderr'` means the
|
|
25
|
+
* statement log arrives on the container's stderr, which `docker logs`
|
|
26
|
+
* relays on its own stderr fd — a stdout-only tail captured nothing against
|
|
27
|
+
* the real thing. Skips with a named reason when Docker is unavailable.
|
|
22
28
|
*/
|
|
23
29
|
import type { Collector } from "@descryy/runtime-contracts";
|
|
24
30
|
import { type ProcessOutputSource } from "@descryy/runtime-backend-observation";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-query-collector.d.ts","sourceRoot":"","sources":["../src/postgres-query-collector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"postgres-query-collector.d.ts","sourceRoot":"","sources":["../src/postgres-query-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAmF,MAAM,4BAA4B,CAAC;AAC7I,OAAO,EAAyB,KAAK,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAMvG,MAAM,WAAW,6BAA6B;IAC5C,+HAA+H;IAC/H,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,mHAAmH;IACnH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AA2BD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,SAAS,CA6F9F"}
|
|
@@ -16,9 +16,15 @@
|
|
|
16
16
|
* this collector does not add. See `packages/database-observation`'s
|
|
17
17
|
* package description for the same disclosure on the `node:sqlite` path.
|
|
18
18
|
*
|
|
19
|
-
* **
|
|
20
|
-
* `postgres-
|
|
21
|
-
*
|
|
19
|
+
* **Live-tested against a real, disposable `postgres:16` Docker container**
|
|
20
|
+
* (`test/postgres-live.test.ts`): a real `INSERT`/`SELECT` issued via
|
|
21
|
+
* `psql` inside the container, its statement log tailed via
|
|
22
|
+
* `createPostgresLogSource`'s `dockerContainer` source (`docker logs -f`),
|
|
23
|
+
* and a real `DATABASE_QUERY` record read back out. Found in the process:
|
|
24
|
+
* the official image's default `log_destination = 'stderr'` means the
|
|
25
|
+
* statement log arrives on the container's stderr, which `docker logs`
|
|
26
|
+
* relays on its own stderr fd — a stdout-only tail captured nothing against
|
|
27
|
+
* the real thing. Skips with a named reason when Docker is unavailable.
|
|
22
28
|
*/
|
|
23
29
|
import { extractCorrelationIds } from "@descryy/runtime-backend-observation";
|
|
24
30
|
import { parsePostgresLogLine } from "./postgres-log-parser.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-query-collector.js","sourceRoot":"","sources":["../src/postgres-query-collector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"postgres-query-collector.js","sourceRoot":"","sources":["../src/postgres-query-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,qBAAqB,EAA4B,MAAM,sCAAsC,CAAC;AAEvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAS3D,MAAM,UAAU,GAAqB,gBAAgB,CAAC;AAEtD,SAAS,mBAAmB;IAC1B,MAAM,MAAM,GAAG,kGAAkG,CAAC;IAClH,MAAM,MAAM,GAAG,EAAE,YAAY,EAAE,aAAsB,EAAE,MAAM,EAAE,CAAC;IAChE,OAAO;QACL,cAAc,EAAE,MAAM;QACtB,kBAAkB,EAAE,MAAM;QAC1B,kBAAkB,EAAE,MAAM;QAC1B,gBAAgB,EAAE,MAAM;QACxB,gBAAgB,EAAE;YAChB,YAAY,EAAE,UAAU;YACxB,MAAM,EAAE,gMAAgM;SACzM;QACD,aAAa,EAAE,MAAM;QACrB,YAAY,EAAE,MAAM;QACpB,gBAAgB,EAAE,MAAM;QACxB,mBAAmB,EAAE;YACnB,YAAY,EAAE,WAAW;YACzB,MAAM,EAAE,kIAAkI;SAC3I;QACD,0BAA0B,EAAE,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,qEAAqE,EAAE;KAC3I,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAsC;IACjF,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAC3C,IAAI,eAA0C,CAAC;IAC/C,IAAI,kBAAkB,GAAkB,IAAI,CAAC;IAE7C,SAAS,iBAAiB,CAAC,KAAuD,EAAE,O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CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,KAAK,CAAC,IAAI;YACR,MAAM,eAAe,CAAC;QACxB,CAAC;QAED,YAAY;YACV,IAAI,kBAAkB,KAAK,IAAI;gBAAE,OAAO,YAAY,CAAC;YACrD,OAAO;gBACL,GAAG,YAAY;gBACf,gBAAgB,EAAE;oBAChB,YAAY,EAAE,aAAa;oBAC3B,MAAM,EAAE,6CAA6C,kBAAkB,gDAAgD;iBACxH;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descryy/runtime-database-observation",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Database query observation (plan §18, checklist §14): real DATABASE_QUERY capture via driver instrumentation, never parsed application logs. Driver #1 is node:sqlite.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@descryy/runtime-contracts": "0.3.3",
|
|
33
|
-
"@descryy/runtime-backend-observation": "0.3.
|
|
34
|
-
"@descryy/runtime-graph-correlator": "0.4.
|
|
33
|
+
"@descryy/runtime-backend-observation": "0.3.6",
|
|
34
|
+
"@descryy/runtime-graph-correlator": "0.4.8"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@descryy/runtime-controller": "0.3.
|
|
38
|
-
"@descryy/runtime-orchestrator": "0.4.
|
|
37
|
+
"@descryy/runtime-controller": "0.3.7",
|
|
38
|
+
"@descryy/runtime-orchestrator": "0.4.8"
|
|
39
39
|
}
|
|
40
40
|
}
|