@pristine-ts/observability 2.0.16 → 2.0.17
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/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/dist/lib/cjs/models/run-metadata.model.js +0 -18
- package/dist/lib/cjs/models/run-metadata.model.js.map +0 -1
- package/dist/lib/cjs/observability-configuration.js +0 -49
- package/dist/lib/cjs/observability-configuration.js.map +0 -1
- package/dist/lib/cjs/serializers/serialized-span.interface.js +0 -3
- package/dist/lib/cjs/serializers/serialized-span.interface.js.map +0 -1
- package/dist/lib/cjs/serializers/serialized-trace.interface.js +0 -3
- package/dist/lib/cjs/serializers/serialized-trace.interface.js.map +0 -1
- package/dist/lib/cjs/store/log-tailer.js +0 -110
- package/dist/lib/cjs/store/log-tailer.js.map +0 -1
- package/dist/lib/cjs/store/observability-paths.js +0 -78
- package/dist/lib/cjs/store/observability-paths.js.map +0 -1
- package/dist/lib/cjs/store/observability-run-manager.js +0 -346
- package/dist/lib/cjs/store/observability-run-manager.js.map +0 -1
- package/dist/lib/cjs/store/observability-store-reader.js +0 -174
- package/dist/lib/cjs/store/observability-store-reader.js.map +0 -1
- package/dist/lib/cjs/store/serializers/serialized-span.interface.js +0 -3
- package/dist/lib/cjs/store/serializers/serialized-span.interface.js.map +0 -1
- package/dist/lib/cjs/store/serializers/serialized-trace.interface.js +0 -3
- package/dist/lib/cjs/store/serializers/serialized-trace.interface.js.map +0 -1
- package/dist/lib/cjs/store/serializers/span-deserializer.js +0 -26
- package/dist/lib/cjs/store/serializers/span-deserializer.js.map +0 -1
- package/dist/lib/cjs/store/serializers/trace-deserializer.js +0 -24
- package/dist/lib/cjs/store/serializers/trace-deserializer.js.map +0 -1
- package/dist/lib/cjs/store/trace-deserializer.js +0 -41
- package/dist/lib/cjs/store/trace-deserializer.js.map +0 -1
- package/dist/lib/esm/models/run-metadata.model.js +0 -14
- package/dist/lib/esm/models/run-metadata.model.js.map +0 -1
- package/dist/lib/esm/observability-configuration.js +0 -46
- package/dist/lib/esm/observability-configuration.js.map +0 -1
- package/dist/lib/esm/serializers/serialized-span.interface.js +0 -2
- package/dist/lib/esm/serializers/serialized-span.interface.js.map +0 -1
- package/dist/lib/esm/serializers/serialized-trace.interface.js +0 -2
- package/dist/lib/esm/serializers/serialized-trace.interface.js.map +0 -1
- package/dist/lib/esm/store/log-tailer.js +0 -73
- package/dist/lib/esm/store/log-tailer.js.map +0 -1
- package/dist/lib/esm/store/observability-paths.js +0 -41
- package/dist/lib/esm/store/observability-paths.js.map +0 -1
- package/dist/lib/esm/store/observability-run-manager.js +0 -310
- package/dist/lib/esm/store/observability-run-manager.js.map +0 -1
- package/dist/lib/esm/store/observability-store-reader.js +0 -138
- package/dist/lib/esm/store/observability-store-reader.js.map +0 -1
- package/dist/lib/esm/store/serializers/serialized-span.interface.js +0 -2
- package/dist/lib/esm/store/serializers/serialized-span.interface.js.map +0 -1
- package/dist/lib/esm/store/serializers/serialized-trace.interface.js +0 -2
- package/dist/lib/esm/store/serializers/serialized-trace.interface.js.map +0 -1
- package/dist/lib/esm/store/serializers/span-deserializer.js +0 -22
- package/dist/lib/esm/store/serializers/span-deserializer.js.map +0 -1
- package/dist/lib/esm/store/serializers/trace-deserializer.js +0 -20
- package/dist/lib/esm/store/serializers/trace-deserializer.js.map +0 -1
- package/dist/lib/esm/store/trace-deserializer.js +0 -37
- package/dist/lib/esm/store/trace-deserializer.js.map +0 -1
- package/dist/types/models/run-metadata.model.d.ts +0 -28
- package/dist/types/observability-configuration.d.ts +0 -32
- package/dist/types/serializers/serialized-span.interface.d.ts +0 -14
- package/dist/types/serializers/serialized-trace.interface.d.ts +0 -14
- package/dist/types/store/log-tailer.d.ts +0 -27
- package/dist/types/store/observability-paths.d.ts +0 -30
- package/dist/types/store/observability-run-manager.d.ts +0 -96
- package/dist/types/store/observability-store-reader.d.ts +0 -55
- package/dist/types/store/serializers/serialized-span.interface.d.ts +0 -14
- package/dist/types/store/serializers/serialized-trace.interface.d.ts +0 -14
- package/dist/types/store/serializers/span-deserializer.d.ts +0 -11
- package/dist/types/store/serializers/trace-deserializer.d.ts +0 -9
- package/dist/types/store/trace-deserializer.d.ts +0 -41
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The plain-object shape of a stored span — as produced by `TraceRenderer.serialize`
|
|
3
|
-
* and rehydrated by `SpanDeserializer`.
|
|
4
|
-
*/
|
|
5
|
-
export interface SerializedSpan {
|
|
6
|
-
id?: string;
|
|
7
|
-
keyname: string;
|
|
8
|
-
startDate: number;
|
|
9
|
-
endDate?: number;
|
|
10
|
-
context?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
children?: SerializedSpan[];
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SerializedSpan } from "./serialized-span.interface";
|
|
2
|
-
/**
|
|
3
|
-
* The plain-object shape of a stored trace — as written to disk by
|
|
4
|
-
* `ObservabilityTracer` and rehydrated by `TraceDeserializer`.
|
|
5
|
-
*/
|
|
6
|
-
export interface SerializedTrace {
|
|
7
|
-
id: string;
|
|
8
|
-
startDate: number;
|
|
9
|
-
endDate?: number;
|
|
10
|
-
context?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
rootSpan?: SerializedSpan;
|
|
14
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Follows a growing `.jsonl` file and emits each newly-appended complete line. The
|
|
3
|
-
* `logs --follow` command and the REPL use this for a `tail -f`-style live view.
|
|
4
|
-
*
|
|
5
|
-
* Watches the file's parent directory (watching a not-yet-created file directly is
|
|
6
|
-
* unreliable across platforms) and reads the byte delta on each change. Partial trailing
|
|
7
|
-
* lines are buffered until their terminating newline arrives.
|
|
8
|
-
*
|
|
9
|
-
* Not a DI service — a plain utility. Instantiate, `follow()`, and `stop()` when done.
|
|
10
|
-
*/
|
|
11
|
-
export declare class LogTailer {
|
|
12
|
-
private readonly filePath;
|
|
13
|
-
private watcher?;
|
|
14
|
-
private offset;
|
|
15
|
-
private buffer;
|
|
16
|
-
constructor(filePath: string);
|
|
17
|
-
/**
|
|
18
|
-
* Starts following. Existing content is skipped — only lines appended after this call
|
|
19
|
-
* are emitted. Call `stop()` to release the watch.
|
|
20
|
-
*/
|
|
21
|
-
follow(onLine: (line: string) => void): void;
|
|
22
|
-
/**
|
|
23
|
-
* Stops following and releases the filesystem watch.
|
|
24
|
-
*/
|
|
25
|
-
stop(): void;
|
|
26
|
-
private drain;
|
|
27
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves every path inside the observability store from the configured store directory.
|
|
3
|
-
* Pure and stateless past construction — instantiate once with the configured directory
|
|
4
|
-
* and reuse.
|
|
5
|
-
*
|
|
6
|
-
* Layout:
|
|
7
|
-
* ```
|
|
8
|
-
* <root>/
|
|
9
|
-
* <instanceId>/logs.jsonl
|
|
10
|
-
* <instanceId>/requests.jsonl
|
|
11
|
-
* <instanceId>/traces/<traceId>.json
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* Each `<instanceId>` is one pristine process lifetime (= the kernel instantiation id).
|
|
15
|
-
* No metadata sidecars, no `latest.json` pointer — directory `mtime` answers "which is
|
|
16
|
-
* most recent."
|
|
17
|
-
*/
|
|
18
|
-
export declare class ObservabilityPaths {
|
|
19
|
-
/**
|
|
20
|
-
* The absolute store root. The configured directory is resolved against `process.cwd()`
|
|
21
|
-
* when it is not already absolute.
|
|
22
|
-
*/
|
|
23
|
-
readonly root: string;
|
|
24
|
-
constructor(configuredDirectory: string);
|
|
25
|
-
instanceDirectory(instanceId: string): string;
|
|
26
|
-
logsFile(instanceId: string): string;
|
|
27
|
-
requestsFile(instanceId: string): string;
|
|
28
|
-
tracesDirectory(instanceId: string): string;
|
|
29
|
-
traceFile(instanceId: string, traceId: string): string;
|
|
30
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { ObservabilityConfiguration } from "../observability-configuration";
|
|
2
|
-
/**
|
|
3
|
-
* Owns the lifecycle of an observability run. A "run" is one `pristine start` lifetime;
|
|
4
|
-
* the run directory is keyed by the kernel instantiation id.
|
|
5
|
-
*
|
|
6
|
-
* The observability writers (`ObservabilityLogger`, `ObservabilityTracer`) stay dormant
|
|
7
|
-
* until `beginRun()` is called — so one-shot CLI commands (`build`, `logs`, `trace`) and
|
|
8
|
-
* the REPL never pollute the store. `StartCommand` is the only caller of `beginRun()`.
|
|
9
|
-
*
|
|
10
|
-
* A singleton so the logger, the tracer, and `StartCommand` all share the same run state.
|
|
11
|
-
*/
|
|
12
|
-
export declare class ObservabilityRunManager {
|
|
13
|
-
private readonly configuration;
|
|
14
|
-
private readonly runId;
|
|
15
|
-
/**
|
|
16
|
-
* Once the reclaimed run exceeds the budget we trim back to this fraction of it, so the
|
|
17
|
-
* (relatively expensive) reclaim isn't re-triggered on the very next write.
|
|
18
|
-
*/
|
|
19
|
-
private static readonly LOW_WATER_FRACTION;
|
|
20
|
-
private readonly paths;
|
|
21
|
-
private activeRunDirectory?;
|
|
22
|
-
/**
|
|
23
|
-
* Approximate running total of bytes written to the active run. Incremented cheaply by
|
|
24
|
-
* the writers via `recordBytesWritten`; resynced to the real on-disk total after each
|
|
25
|
-
* reclaim. Used to decide when to enforce the per-run size budget without stat-ing the
|
|
26
|
-
* whole run directory on every write.
|
|
27
|
-
*/
|
|
28
|
-
private runBytes;
|
|
29
|
-
constructor(configuration: ObservabilityConfiguration, runId: string);
|
|
30
|
-
/**
|
|
31
|
-
* Begins a run: creates the run directory, writes `run.json`, repoints `latest.json`,
|
|
32
|
-
* and prunes old runs. No-op when observability is disabled. Safe to call once per
|
|
33
|
-
* process.
|
|
34
|
-
*/
|
|
35
|
-
beginRun(command: string): void;
|
|
36
|
-
/**
|
|
37
|
-
* Reports bytes just written to the run by a writer. Cheap — an add and a compare. When
|
|
38
|
-
* the running total crosses the configured `maxRunSizeBytes`, triggers a reclaim that
|
|
39
|
-
* drops the run's oldest data. No-op when no run is active or the cap is disabled.
|
|
40
|
-
*/
|
|
41
|
-
recordBytesWritten(bytes: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* Ends the active run by stamping `endedAt` into `run.json`. No-op when no run is active.
|
|
44
|
-
*/
|
|
45
|
-
endRun(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Whether a run is currently active. The writers consult this on every write.
|
|
48
|
-
*/
|
|
49
|
-
isRunActive(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* The absolute logs file for the active run, or undefined when no run is active.
|
|
52
|
-
*/
|
|
53
|
-
logsFile(): string | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* The absolute requests-index file for the active run, or undefined when no run is active.
|
|
56
|
-
*/
|
|
57
|
-
requestsFile(): string | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* The absolute path of the trace file for a given trace id in the active run, or
|
|
60
|
-
* undefined when no run is active.
|
|
61
|
-
*/
|
|
62
|
-
traceFile(traceId: string): string | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Lazily begins a run when `autoBegin` is configured and none is active yet — so a
|
|
65
|
-
* server started outside the `pristine` CLI captures its logs/traces on the first
|
|
66
|
-
* write, with nothing calling `beginRun()` explicitly.
|
|
67
|
-
*/
|
|
68
|
-
private ensureAutoBegun;
|
|
69
|
-
/**
|
|
70
|
-
* Drops the run's oldest data until it is back under the budget's low-water mark:
|
|
71
|
-
* oldest trace files first, then the head of `logs.jsonl` (keeping the newest tail).
|
|
72
|
-
* The `requests.jsonl` index is rewritten to drop entries for deleted traces.
|
|
73
|
-
*
|
|
74
|
-
* Best-effort and fully guarded — budget enforcement must never break or lose a write.
|
|
75
|
-
*/
|
|
76
|
-
private reclaim;
|
|
77
|
-
/**
|
|
78
|
-
* Rewrites a file in place keeping only its last `keepBytes` bytes, aligned forward to
|
|
79
|
-
* the next newline so no partial line survives.
|
|
80
|
-
*/
|
|
81
|
-
private trimFileHead;
|
|
82
|
-
/**
|
|
83
|
-
* Rewrites `requests.jsonl` keeping only entries whose trace file still exists — so the
|
|
84
|
-
* request index stays consistent after trace files are reclaimed.
|
|
85
|
-
*/
|
|
86
|
-
private pruneRequestsIndex;
|
|
87
|
-
/**
|
|
88
|
-
* Sum of the sizes of every file directly inside `directory`.
|
|
89
|
-
*/
|
|
90
|
-
private directoryTotalSize;
|
|
91
|
-
/**
|
|
92
|
-
* Removes run directories beyond the retained limit, ordered by their
|
|
93
|
-
* `run.json:startedAt`. Best-effort — a failure to prune never blocks a run.
|
|
94
|
-
*/
|
|
95
|
-
private pruneOldRuns;
|
|
96
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ObservabilityConfiguration } from "../observability-configuration";
|
|
2
|
-
import { RunMetadata } from "../models/run-metadata.model";
|
|
3
|
-
import { RequestSummary } from "../models/request-summary.model";
|
|
4
|
-
import { SerializedTrace } from "./trace-deserializer";
|
|
5
|
-
/**
|
|
6
|
-
* Read-only access to the observability store. Used by the `logs`, `trace` and `requests`
|
|
7
|
-
* CLI commands. Pure filesystem reads — no kernel, no running app required; it reads what
|
|
8
|
-
* a separate `pristine start` process wrote.
|
|
9
|
-
*/
|
|
10
|
-
export declare class ObservabilityStoreReader {
|
|
11
|
-
private readonly paths;
|
|
12
|
-
constructor(configuration: ObservabilityConfiguration);
|
|
13
|
-
/**
|
|
14
|
-
* The run id the `latest.json` pointer references, or undefined when the store is empty.
|
|
15
|
-
*/
|
|
16
|
-
latestRunId(): string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves an explicit run id, or falls back to the latest run.
|
|
19
|
-
*/
|
|
20
|
-
resolveRunId(explicit?: string): string | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Every run's metadata, most-recent first.
|
|
23
|
-
*/
|
|
24
|
-
listRuns(): RunMetadata[];
|
|
25
|
-
/**
|
|
26
|
-
* Reads a run's `run.json`, or undefined when absent/corrupt.
|
|
27
|
-
*/
|
|
28
|
-
readRunMetadata(runId: string): RunMetadata | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* The request summaries for a run, most-recent first, optionally capped to `limit`.
|
|
31
|
-
*/
|
|
32
|
-
readRequests(runId: string, limit?: number): RequestSummary[];
|
|
33
|
-
/**
|
|
34
|
-
* The raw log entries for a run, in write order. Each is a parsed `logs.jsonl` line.
|
|
35
|
-
*/
|
|
36
|
-
readLogs(runId: string): Record<string, any>[];
|
|
37
|
-
/**
|
|
38
|
-
* The absolute `logs.jsonl` path for a run — handed to `LogTailer` for `--follow`.
|
|
39
|
-
*/
|
|
40
|
-
logsFilePath(runId: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Finds and reads a trace by id. Searches the preferred run first (when given), then
|
|
43
|
-
* every other run most-recent first. Returns the parsed trace and the run it was found
|
|
44
|
-
* in, or undefined when no run contains it.
|
|
45
|
-
*/
|
|
46
|
-
findTrace(traceId: string, preferredRunId?: string): {
|
|
47
|
-
trace: SerializedTrace;
|
|
48
|
-
runId: string;
|
|
49
|
-
} | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* The most recently seen trace ids across the latest run — used by the REPL completer.
|
|
52
|
-
*/
|
|
53
|
-
recentTraceIds(limit: number): string[];
|
|
54
|
-
private readJsonl;
|
|
55
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The plain-object shape of a stored span — as produced by `TraceRenderer.serialize`
|
|
3
|
-
* and rehydrated by `SpanDeserializer`.
|
|
4
|
-
*/
|
|
5
|
-
export interface SerializedSpan {
|
|
6
|
-
id?: string;
|
|
7
|
-
keyname: string;
|
|
8
|
-
startDate: number;
|
|
9
|
-
endDate?: number;
|
|
10
|
-
context?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
children?: SerializedSpan[];
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SerializedSpan } from "./serialized-span.interface";
|
|
2
|
-
/**
|
|
3
|
-
* The plain-object shape of a stored trace — as written to disk by
|
|
4
|
-
* `ObservabilityTracer` and rehydrated by `TraceDeserializer`.
|
|
5
|
-
*/
|
|
6
|
-
export interface SerializedTrace {
|
|
7
|
-
id: string;
|
|
8
|
-
startDate: number;
|
|
9
|
-
endDate?: number;
|
|
10
|
-
context?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
rootSpan?: SerializedSpan;
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Span, Trace } from "@pristine-ts/common";
|
|
2
|
-
import { SerializedSpan } from "./serialized-span.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Rebuilds a `Span` (with its full child tree) from the stored plain object. Used by
|
|
5
|
-
* `TraceDeserializer` for the trace's root span and recursively for every descendant —
|
|
6
|
-
* so `traceRenderer.renderTree`/`renderFlat`, which call instance methods like
|
|
7
|
-
* `getDuration()`, work unchanged on stored traces.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SpanDeserializer {
|
|
10
|
-
static deserialize(serialized: SerializedSpan, trace: Trace): Span;
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Trace } from "@pristine-ts/common";
|
|
2
|
-
import { SerializedTrace } from "./serialized-trace.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Rehydrates a stored trace JSON (the shape written by `ObservabilityTracer`) back into
|
|
5
|
-
* a `Trace` instance, with its full span tree rebuilt via `SpanDeserializer`.
|
|
6
|
-
*/
|
|
7
|
-
export declare class TraceDeserializer {
|
|
8
|
-
static deserialize(serialized: SerializedTrace): Trace;
|
|
9
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Trace } from "@pristine-ts/common";
|
|
2
|
-
/**
|
|
3
|
-
* The plain-object shape of a stored span (as produced by `TraceRenderer.serialize`).
|
|
4
|
-
*/
|
|
5
|
-
interface SerializedSpan {
|
|
6
|
-
id?: string;
|
|
7
|
-
keyname: string;
|
|
8
|
-
startDate: number;
|
|
9
|
-
endDate?: number;
|
|
10
|
-
context?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
children?: SerializedSpan[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The plain-object shape of a stored trace.
|
|
17
|
-
*/
|
|
18
|
-
export interface SerializedTrace {
|
|
19
|
-
id: string;
|
|
20
|
-
startDate: number;
|
|
21
|
-
endDate?: number;
|
|
22
|
-
context?: {
|
|
23
|
-
[key: string]: string;
|
|
24
|
-
};
|
|
25
|
-
rootSpan?: SerializedSpan;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Rehydrates a stored trace JSON (the shape written by `ObservabilityTracer`) back into
|
|
29
|
-
* `Trace`/`Span` instances, so `traceRenderer.renderTree`/`renderFlat` — which call
|
|
30
|
-
* instance methods like `getDuration()` — work unchanged on stored traces.
|
|
31
|
-
*
|
|
32
|
-
* Stateless; instantiate once and reuse, or use the static `deserialize`.
|
|
33
|
-
*/
|
|
34
|
-
export declare class TraceDeserializer {
|
|
35
|
-
/**
|
|
36
|
-
* Rebuilds a `Trace` (with its full span tree) from the stored plain object.
|
|
37
|
-
*/
|
|
38
|
-
static deserialize(serialized: SerializedTrace): Trace;
|
|
39
|
-
private static deserializeSpan;
|
|
40
|
-
}
|
|
41
|
-
export {};
|