@adonis-agora/telescope 0.22.0 → 0.24.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 +50 -0
- package/dist/src/ai/index.d.ts +1 -1
- package/dist/src/ai/index.js +1 -1
- package/dist/src/alerts/index.d.ts +1 -1
- package/dist/src/alerts/index.js +1 -1
- package/dist/src/index.d.ts +9 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts +1 -1
- package/dist/src/mcp/index.js +1 -1
- package/dist/src/metrics/metrics_service.d.ts +5 -0
- package/dist/src/metrics/metrics_service.d.ts.map +1 -1
- package/dist/src/metrics/metrics_service.js +32 -4
- package/dist/src/metrics/metrics_service.js.map +1 -1
- package/dist/src/metrics/pulse.d.ts +8 -0
- package/dist/src/metrics/pulse.d.ts.map +1 -1
- package/dist/src/metrics/pulse.js +125 -37
- package/dist/src/metrics/pulse.js.map +1 -1
- package/dist/src/metrics/stats.d.ts +2 -0
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js +8 -3
- package/dist/src/metrics/stats.js.map +1 -1
- package/dist/src/otel/otel_exporting_store.d.ts +1 -1
- package/dist/src/otel/otel_exporting_store.d.ts.map +1 -1
- package/dist/src/otel/otel_exporting_store.js +2 -0
- package/dist/src/otel/otel_exporting_store.js.map +1 -1
- package/dist/src/profiling/index.d.ts +1 -1
- package/dist/src/profiling/index.js +1 -1
- package/dist/src/redaction/redact.d.ts.map +1 -1
- package/dist/src/redaction/redact.js +28 -4
- package/dist/src/redaction/redact.js.map +1 -1
- package/dist/src/redaction/redacting_store.d.ts +1 -1
- package/dist/src/redaction/redacting_store.d.ts.map +1 -1
- package/dist/src/redaction/redacting_store.js +2 -0
- package/dist/src/redaction/redacting_store.js.map +1 -1
- package/dist/src/sampling/sampling_store.d.ts +1 -1
- package/dist/src/sampling/sampling_store.d.ts.map +1 -1
- package/dist/src/sampling/sampling_store.js +6 -1
- package/dist/src/sampling/sampling_store.js.map +1 -1
- package/dist/src/self_scope.d.ts +5 -0
- package/dist/src/self_scope.d.ts.map +1 -0
- package/dist/src/self_scope.js +28 -0
- package/dist/src/self_scope.js.map +1 -0
- package/dist/src/service.d.ts.map +1 -1
- package/dist/src/service.js +9 -2
- package/dist/src/service.js.map +1 -1
- package/dist/src/store.d.ts +46 -0
- package/dist/src/store.d.ts.map +1 -1
- package/dist/src/store.js +16 -1
- package/dist/src/store.js.map +1 -1
- package/dist/src/stores/factory.d.ts +79 -0
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +71 -0
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +73 -28
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +487 -183
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/stores/memory.d.ts +3 -1
- package/dist/src/stores/memory.d.ts.map +1 -1
- package/dist/src/stores/memory.js +29 -0
- package/dist/src/stores/memory.js.map +1 -1
- package/dist/src/stores/parquet.d.ts +184 -0
- package/dist/src/stores/parquet.d.ts.map +1 -0
- package/dist/src/stores/parquet.js +461 -0
- package/dist/src/stores/parquet.js.map +1 -0
- package/dist/src/stores/parquet_duckdb.d.ts +52 -0
- package/dist/src/stores/parquet_duckdb.d.ts.map +1 -0
- package/dist/src/stores/parquet_duckdb.js +266 -0
- package/dist/src/stores/parquet_duckdb.js.map +1 -0
- package/dist/src/stores/parquet_format.d.ts +108 -0
- package/dist/src/stores/parquet_format.d.ts.map +1 -0
- package/dist/src/stores/parquet_format.js +175 -0
- package/dist/src/stores/parquet_format.js.map +1 -0
- package/dist/src/stores/parquet_hyparquet.d.ts +34 -0
- package/dist/src/stores/parquet_hyparquet.d.ts.map +1 -0
- package/dist/src/stores/parquet_hyparquet.js +212 -0
- package/dist/src/stores/parquet_hyparquet.js.map +1 -0
- package/dist/src/stores/parquet_location.d.ts +88 -0
- package/dist/src/stores/parquet_location.d.ts.map +1 -0
- package/dist/src/stores/parquet_location.js +194 -0
- package/dist/src/stores/parquet_location.js.map +1 -0
- package/dist/src/stores/tiered.d.ts +96 -0
- package/dist/src/stores/tiered.d.ts.map +1 -0
- package/dist/src/stores/tiered.js +277 -0
- package/dist/src/stores/tiered.js.map +1 -0
- package/dist/src/stream/streaming_store.d.ts +1 -1
- package/dist/src/stream/streaming_store.d.ts.map +1 -1
- package/dist/src/stream/streaming_store.js +2 -0
- package/dist/src/stream/streaming_store.js.map +1 -1
- package/dist/src/telescope_middleware.d.ts.map +1 -1
- package/dist/src/telescope_middleware.js +20 -11
- package/dist/src/telescope_middleware.js.map +1 -1
- package/dist/src/ui/index.d.ts +1 -1
- package/dist/src/ui/index.js +1 -1
- package/dist/src/watchers/cache_watcher.js +1 -1
- package/dist/src/watchers/cache_watcher.js.map +1 -1
- package/dist/src/watchers/events_watcher.js +1 -1
- package/dist/src/watchers/events_watcher.js.map +1 -1
- package/dist/src/watchers/http_client_watcher.js +1 -1
- package/dist/src/watchers/http_client_watcher.js.map +1 -1
- package/dist/src/watchers/index.d.ts +1 -1
- package/dist/src/watchers/index.js +1 -1
- package/dist/src/watchers/logs_watcher.js +1 -1
- package/dist/src/watchers/logs_watcher.js.map +1 -1
- package/dist/src/watchers/lucid_query_watcher.d.ts.map +1 -1
- package/dist/src/watchers/lucid_query_watcher.js +8 -2
- package/dist/src/watchers/lucid_query_watcher.js.map +1 -1
- package/dist/src/watchers/mail_watcher.js +1 -1
- package/dist/src/watchers/mail_watcher.js.map +1 -1
- package/dist/src/watchers/profiling_watcher.js +1 -1
- package/dist/src/watchers/profiling_watcher.js.map +1 -1
- package/dist/src/watchers/queue_watcher.js +1 -1
- package/dist/src/watchers/queue_watcher.js.map +1 -1
- package/dist/src/watchers/record.d.ts +5 -1
- package/dist/src/watchers/record.d.ts.map +1 -1
- package/dist/src/watchers/record.js +10 -1
- package/dist/src/watchers/record.js.map +1 -1
- package/dist/src/watchers/redis_watcher.js +1 -1
- package/dist/src/watchers/redis_watcher.js.map +1 -1
- package/dist/src/watchers/schedule_watcher.js +1 -1
- package/dist/src/watchers/schedule_watcher.js.map +1 -1
- package/dist/stubs/database/migrations/create_telescope_entries_table.stub +2 -2
- package/package.json +35 -9
- package/skills/telescope-setup/SKILL.md +1 -1
- package/skills/telescope-storage-retention/SKILL.md +13 -7
- package/skills/telescope-watchers/SKILL.md +7 -5
package/dist/src/store.d.ts
CHANGED
|
@@ -44,6 +44,14 @@ export interface EntryQuery {
|
|
|
44
44
|
* `@adonis-agora/filter`'s `FilterInput.size` (see {@link EntryQuery.page}).
|
|
45
45
|
*/
|
|
46
46
|
size?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The caller reads everything but `content`, so a store MAY return `content: null`
|
|
49
|
+
* instead of loading and parsing it. A hint, not a filter: a store that ignores it
|
|
50
|
+
* still answers correctly, and callers must not depend on content being absent.
|
|
51
|
+
* Aggregations over a whole window set it and fetch the content of the few entries
|
|
52
|
+
* they display afterwards.
|
|
53
|
+
*/
|
|
54
|
+
omitContent?: boolean;
|
|
47
55
|
}
|
|
48
56
|
/** One row of {@link TelescopeStore.listTraceIds} — a trace and when it was last seen. */
|
|
49
57
|
export interface TraceIdRow {
|
|
@@ -69,6 +77,25 @@ export interface BucketCountQuery {
|
|
|
69
77
|
/** Only entries of this type. */
|
|
70
78
|
type?: string;
|
|
71
79
|
}
|
|
80
|
+
/** A grouping key and how many stored entries carry it. */
|
|
81
|
+
export interface KeyCountRow {
|
|
82
|
+
key: string;
|
|
83
|
+
count: number;
|
|
84
|
+
}
|
|
85
|
+
/** What {@link TelescopeStore.countFamilies} counts. */
|
|
86
|
+
export interface FamilyCountQuery {
|
|
87
|
+
/** How many families to return, busiest first. */
|
|
88
|
+
limit: number;
|
|
89
|
+
/** Only entries of this type. */
|
|
90
|
+
type?: string;
|
|
91
|
+
}
|
|
92
|
+
/** What {@link TelescopeStore.countTags} counts. */
|
|
93
|
+
export interface TagCountQuery {
|
|
94
|
+
/** How many tags to return, most common first. */
|
|
95
|
+
limit: number;
|
|
96
|
+
/** Only tags starting with this prefix. */
|
|
97
|
+
prefix?: string;
|
|
98
|
+
}
|
|
72
99
|
/** The window + page for {@link TelescopeStore.listTraceIds}. */
|
|
73
100
|
export interface TraceIdQuery {
|
|
74
101
|
/**
|
|
@@ -141,5 +168,24 @@ export interface TelescopeStore {
|
|
|
141
168
|
* scan-and-bucket, which is what this always used to do.
|
|
142
169
|
*/
|
|
143
170
|
countByBucket?(query: BucketCountQuery): Promise<BucketCountRow[]>;
|
|
171
|
+
/**
|
|
172
|
+
* OPTIONAL fast path for `TelescopeService.topFamilies`: the busiest `familyHash`
|
|
173
|
+
* values across every stored entry, most entries first, ties going to the family
|
|
174
|
+
* seen most recently. Without it the service lists the whole table and counts in JS.
|
|
175
|
+
*/
|
|
176
|
+
countFamilies?(query: FamilyCountQuery): Promise<KeyCountRow[]>;
|
|
177
|
+
/**
|
|
178
|
+
* OPTIONAL fast path for `TelescopeService.topTags`: the most common tags across
|
|
179
|
+
* every stored entry, ties going to the tag seen most recently. Without it the
|
|
180
|
+
* service lists the whole table and counts in JS.
|
|
181
|
+
*/
|
|
182
|
+
countTags?(query: TagCountQuery): Promise<KeyCountRow[]>;
|
|
144
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Give a decorating store the optional read methods its inner store has, and only
|
|
186
|
+
* those: callers detect a capability by the method being there, so a decorator that
|
|
187
|
+
* always declared them would claim fast paths the store underneath cannot serve, and
|
|
188
|
+
* one that never did would hide them.
|
|
189
|
+
*/
|
|
190
|
+
export declare function forwardOptionalReads(target: TelescopeStore, inner: TelescopeStore): void;
|
|
145
191
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/src/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,O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|
1
|
-
|
|
1
|
+
/** The optional read methods a store may implement on top of the required contract. */
|
|
2
|
+
const OPTIONAL_READS = ['listTraceIds', 'countByBucket', 'countFamilies', 'countTags'];
|
|
3
|
+
/**
|
|
4
|
+
* Give a decorating store the optional read methods its inner store has, and only
|
|
5
|
+
* those: callers detect a capability by the method being there, so a decorator that
|
|
6
|
+
* always declared them would claim fast paths the store underneath cannot serve, and
|
|
7
|
+
* one that never did would hide them.
|
|
8
|
+
*/
|
|
9
|
+
export function forwardOptionalReads(target, inner) {
|
|
10
|
+
const writable = target;
|
|
11
|
+
for (const name of OPTIONAL_READS) {
|
|
12
|
+
const method = inner[name];
|
|
13
|
+
if (typeof method === 'function')
|
|
14
|
+
writable[name] = method.bind(inner);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
2
17
|
//# sourceMappingURL=store.js.map
|
package/dist/src/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AA0MA,uFAAuF;AACvF,MAAM,cAAc,GAAG,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,CAAU,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAsB,EAAE,KAAqB;IAChF,MAAM,QAAQ,GAAG,MAA4C,CAAC;IAC9D,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,OAAO,MAAM,KAAK,UAAU;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -2,6 +2,9 @@ import type { ApplicationService } from '@adonisjs/core/types';
|
|
|
2
2
|
import type { TelescopeStore } from '../store.js';
|
|
3
3
|
import type { LucidStoreOptions } from './lucid.js';
|
|
4
4
|
import type { InMemoryStoreOptions } from './memory.js';
|
|
5
|
+
import type { ParquetColdStore } from './parquet.js';
|
|
6
|
+
import type { DuckDbEngineOptions } from './parquet_duckdb.js';
|
|
7
|
+
import type { ColdObjectStore, S3LocationOptions } from './parquet_location.js';
|
|
5
8
|
/**
|
|
6
9
|
* Runtime context a {@link StoreProvider} receives when the telescope provider builds the
|
|
7
10
|
* configured store at boot.
|
|
@@ -33,6 +36,58 @@ export interface LucidStoreConfig extends LucidStoreOptions {
|
|
|
33
36
|
*/
|
|
34
37
|
connection?: string;
|
|
35
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Where the Parquet cold tier keeps its files: a local directory, an S3 bucket through
|
|
41
|
+
* the host's own `S3Client`, or any {@link ColdObjectStore}.
|
|
42
|
+
*/
|
|
43
|
+
export type ParquetLocationConfig = {
|
|
44
|
+
dir: string;
|
|
45
|
+
} | {
|
|
46
|
+
s3: S3LocationOptions;
|
|
47
|
+
} | ColdObjectStore;
|
|
48
|
+
/**
|
|
49
|
+
* Which engine reads the cold tier:
|
|
50
|
+
*
|
|
51
|
+
* - `'hyparquet'` (default) — pure JavaScript, nothing native, nothing downloaded.
|
|
52
|
+
* - `'duckdb'` / `{ duckdb: { ... } }` — `@duckdb/node-api` (an optional peer), faster on
|
|
53
|
+
* wide scans. Boot fails if it is selected but not installed; there is no silent
|
|
54
|
+
* fallback. It never loads DuckDB's `httpfs`/`aws` extensions.
|
|
55
|
+
*/
|
|
56
|
+
export type ParquetEngineConfig = 'hyparquet' | 'duckdb' | {
|
|
57
|
+
duckdb: DuckDbEngineOptions;
|
|
58
|
+
};
|
|
59
|
+
/** Options for the `parquet` cold-tier driver (used as `storage.tiered({ cold })`). */
|
|
60
|
+
export interface ParquetStoreConfig {
|
|
61
|
+
location: ParquetLocationConfig;
|
|
62
|
+
/** Default `'hyparquet'`. */
|
|
63
|
+
engine?: ParquetEngineConfig;
|
|
64
|
+
/** Written into file names and rows. Default `<hostname>-<pid>`. */
|
|
65
|
+
instanceId?: string;
|
|
66
|
+
/** Rows per row group. Default 10,000. */
|
|
67
|
+
rowGroupSize?: number;
|
|
68
|
+
/** Rows per file. Default 200,000. */
|
|
69
|
+
maxRowsPerFile?: number;
|
|
70
|
+
}
|
|
71
|
+
/** A configured cold tier: a thunk the tiered driver calls at boot. */
|
|
72
|
+
export type ColdStoreProvider = (ctx: StoreContext) => Promise<ParquetColdStore>;
|
|
73
|
+
/** Options for the `tiered` store driver. */
|
|
74
|
+
export interface TieredStoreConfig {
|
|
75
|
+
/** The hot tier: any driver from this factory (usually `storage.lucid()`) or a store. */
|
|
76
|
+
hot: StoreProvider | TelescopeStore;
|
|
77
|
+
/** The cold tier, `storage.parquet({ ... })`. */
|
|
78
|
+
cold: ColdStoreProvider;
|
|
79
|
+
/**
|
|
80
|
+
* How long entries stay hot before `prune` moves them to cold, e.g. `'5m'`. Must be
|
|
81
|
+
* shorter than `prune.after`, which becomes the cold tier's retention.
|
|
82
|
+
*/
|
|
83
|
+
hotFor: string | number;
|
|
84
|
+
/** Hot entries read per page while moving. Default 5,000. */
|
|
85
|
+
moveBatchSize?: number;
|
|
86
|
+
/** Entries buffered before a move writes them out as files. Default 50,000. */
|
|
87
|
+
moveFlushSize?: number;
|
|
88
|
+
/** Merge each closed hour's files during prune. Default `true`. */
|
|
89
|
+
compact?: boolean;
|
|
90
|
+
}
|
|
36
91
|
/**
|
|
37
92
|
* The store factory namespace used in `config/telescope.ts`:
|
|
38
93
|
*
|
|
@@ -57,5 +112,29 @@ export declare const storage: {
|
|
|
57
112
|
memory(config?: MemoryStoreConfig): StoreProvider;
|
|
58
113
|
/** A persistent, SQL-backed store on `@adonisjs/lucid` (sqlite / Postgres / MySQL). */
|
|
59
114
|
lucid(config?: LucidStoreConfig): StoreProvider;
|
|
115
|
+
/**
|
|
116
|
+
* The Parquet cold tier for {@link storage.tiered}: hourly-partitioned files in a
|
|
117
|
+
* directory or an S3 bucket. `hyparquet`, `hyparquet-writer` and
|
|
118
|
+
* `hyparquet-compressors` are optional peers, imported only when this is built;
|
|
119
|
+
* `@duckdb/node-api` too, and only for `engine: 'duckdb'`.
|
|
120
|
+
*/
|
|
121
|
+
parquet(config: ParquetStoreConfig): ColdStoreProvider;
|
|
122
|
+
/**
|
|
123
|
+
* Hot + cold: entries are recorded into `hot` and moved to `cold` (Parquet) by the
|
|
124
|
+
* pruner once older than `hotFor`; reads span both. Needs a `prune` block — its
|
|
125
|
+
* `after` is the cold tier's retention.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* stores: {
|
|
129
|
+
* tiered: storage.tiered({
|
|
130
|
+
* hot: storage.lucid(),
|
|
131
|
+
* cold: storage.parquet({ location: { dir: 'storage/telescope' } }),
|
|
132
|
+
* hotFor: '5m',
|
|
133
|
+
* }),
|
|
134
|
+
* },
|
|
135
|
+
* prune: { after: '7d', intervalMs: 60_000 },
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
tiered(config: TieredStoreConfig): StoreProvider;
|
|
60
139
|
};
|
|
61
140
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK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CAAC,gBAAgB,CAAC,CAAC;AAEjF,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,GAAG,EAAE,aAAa,GAAG,cAAc,CAAC;IACpC,iDAAiD;IACjD,IAAI,EAAE,iBAAiB,CAAC;IACxB;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO;IAClB,+EAA+E;IAC/E,MAAM,UAAS,iBAAiB,GAAQ,aAAa;IAQrD,uFAAuF;IACvF,KAAK,UAAS,gBAAgB,GAAQ,aAAa;IAsBnD;;;;;OAKG;IACH,OAAO,SAAS,kBAAkB,GAAG,iBAAiB;IAgCtD;;;;;;;;;;;;;;;OAeG;IACH,MAAM,SAAS,iBAAiB,GAAG,aAAa;CAkBjD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { durationToMs } from '../alerts/parse_duration.js';
|
|
1
2
|
/**
|
|
2
3
|
* The store factory namespace used in `config/telescope.ts`:
|
|
3
4
|
*
|
|
@@ -44,5 +45,75 @@ export const storage = {
|
|
|
44
45
|
return new LucidTelescopeStore(client, storeOptions);
|
|
45
46
|
};
|
|
46
47
|
},
|
|
48
|
+
/**
|
|
49
|
+
* The Parquet cold tier for {@link storage.tiered}: hourly-partitioned files in a
|
|
50
|
+
* directory or an S3 bucket. `hyparquet`, `hyparquet-writer` and
|
|
51
|
+
* `hyparquet-compressors` are optional peers, imported only when this is built;
|
|
52
|
+
* `@duckdb/node-api` too, and only for `engine: 'duckdb'`.
|
|
53
|
+
*/
|
|
54
|
+
parquet(config) {
|
|
55
|
+
return async () => {
|
|
56
|
+
const [{ ParquetColdStore, loadParquetLibs }, locations] = await Promise.all([
|
|
57
|
+
import('./parquet.js'),
|
|
58
|
+
import('./parquet_location.js'),
|
|
59
|
+
]);
|
|
60
|
+
const libs = await loadParquetLibs();
|
|
61
|
+
const location = 'dir' in config.location && typeof config.location.dir === 'string'
|
|
62
|
+
? new locations.DirectoryLocation(config.location.dir)
|
|
63
|
+
: 's3' in config.location
|
|
64
|
+
? new locations.S3Location(config.location.s3)
|
|
65
|
+
: config.location;
|
|
66
|
+
const engine = config.engine ?? 'hyparquet';
|
|
67
|
+
return ParquetColdStore.create({
|
|
68
|
+
location,
|
|
69
|
+
libs,
|
|
70
|
+
...(config.instanceId !== undefined ? { instanceId: config.instanceId } : {}),
|
|
71
|
+
...(config.rowGroupSize !== undefined ? { rowGroupSize: config.rowGroupSize } : {}),
|
|
72
|
+
...(config.maxRowsPerFile !== undefined ? { maxRowsPerFile: config.maxRowsPerFile } : {}),
|
|
73
|
+
engine: async (context) => {
|
|
74
|
+
if (engine === 'hyparquet') {
|
|
75
|
+
const { HyparquetEngine } = await import('./parquet_hyparquet.js');
|
|
76
|
+
return new HyparquetEngine(context);
|
|
77
|
+
}
|
|
78
|
+
const { DuckDbEngine } = await import('./parquet_duckdb.js');
|
|
79
|
+
return DuckDbEngine.create(context, engine === 'duckdb' ? {} : engine.duckdb);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Hot + cold: entries are recorded into `hot` and moved to `cold` (Parquet) by the
|
|
86
|
+
* pruner once older than `hotFor`; reads span both. Needs a `prune` block — its
|
|
87
|
+
* `after` is the cold tier's retention.
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* stores: {
|
|
91
|
+
* tiered: storage.tiered({
|
|
92
|
+
* hot: storage.lucid(),
|
|
93
|
+
* cold: storage.parquet({ location: { dir: 'storage/telescope' } }),
|
|
94
|
+
* hotFor: '5m',
|
|
95
|
+
* }),
|
|
96
|
+
* },
|
|
97
|
+
* prune: { after: '7d', intervalMs: 60_000 },
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
tiered(config) {
|
|
101
|
+
return async (ctx) => {
|
|
102
|
+
const hotForMs = durationToMs(config.hotFor);
|
|
103
|
+
const [{ TieredTelescopeStore }, hot, cold] = await Promise.all([
|
|
104
|
+
import('./tiered.js'),
|
|
105
|
+
typeof config.hot === 'function' ? config.hot(ctx) : Promise.resolve(config.hot),
|
|
106
|
+
config.cold(ctx),
|
|
107
|
+
]);
|
|
108
|
+
return new TieredTelescopeStore({
|
|
109
|
+
hot,
|
|
110
|
+
cold,
|
|
111
|
+
hotForMs,
|
|
112
|
+
...(config.moveBatchSize !== undefined ? { moveBatchSize: config.moveBatchSize } : {}),
|
|
113
|
+
...(config.moveFlushSize !== undefined ? { moveFlushSize: config.moveFlushSize } : {}),
|
|
114
|
+
...(config.compact !== undefined ? { compact: config.compact } : {}),
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
},
|
|
47
118
|
};
|
|
48
119
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA8F3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,+EAA+E;IAC/E,MAAM,CAAC,MAAM,GAAsB,EAAE;QACnC,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC;YACrD,OAAO,IAAI,sBAA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
1
|
import { type Entry, type RecordInput } from '../entry.js';
|
|
2
|
-
import type { BucketCountQuery, BucketCountRow, EntryQuery, TelescopeStore, TraceIdQuery, TraceIdRow } from '../store.js';
|
|
2
|
+
import type { BucketCountQuery, BucketCountRow, EntryQuery, FamilyCountQuery, KeyCountRow, TagCountQuery, TelescopeStore, TraceIdQuery, TraceIdRow } from '../store.js';
|
|
3
3
|
/**
|
|
4
4
|
* The table {@link LucidTelescopeStore} reads and writes. Override via
|
|
5
5
|
* {@link LucidStoreOptions.tableName} when `telescope_entries` collides with an
|
|
@@ -33,12 +33,13 @@ export interface TelescopeColumns {
|
|
|
33
33
|
* indexes `list` / `prune` / `topFamilies` lean on, as one statement per array
|
|
34
34
|
* element so each can be issued through Lucid's `rawQuery`.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* Identifiers are double-quoted (sqlite / Postgres) unless `dialect` is a Lucid
|
|
37
|
+
* MySQL dialect name (`mysql` / `mysql2`), which gets backticks and plain
|
|
38
|
+
* `CREATE INDEX`; the column types are portable. A real deployment should still prefer the bundled migration stub
|
|
38
39
|
* so the schema is versioned, but this lets a store stand itself up in tests and
|
|
39
40
|
* scripts without a migration runner.
|
|
40
41
|
*/
|
|
41
|
-
export declare function createTableStatements(tableName?: string): string[];
|
|
42
|
+
export declare function createTableStatements(tableName?: string, dialect?: string): string[];
|
|
42
43
|
/**
|
|
43
44
|
* The marker table backing the fingerprint gate. One row PER owned entries table
|
|
44
45
|
* (keyed by that table's name, so two telescope tables in one database never
|
|
@@ -60,6 +61,16 @@ export interface LucidDatabaseLike {
|
|
|
60
61
|
table(table: string): LucidInsertBuilderLike;
|
|
61
62
|
/** Run a raw SQL statement (DDL, `MAX(sequence)` seed). */
|
|
62
63
|
rawQuery(sql: string, bindings?: unknown[]): Promise<unknown>;
|
|
64
|
+
/** The dialect, when this is a single connection client. Picks the DDL's identifier quoting. */
|
|
65
|
+
dialect?: {
|
|
66
|
+
name: string;
|
|
67
|
+
};
|
|
68
|
+
/** The default connection, when this is the `Database` facade. */
|
|
69
|
+
connection?(): {
|
|
70
|
+
dialect?: {
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
63
74
|
}
|
|
64
75
|
/** The structural query-builder surface the store leans on (Knex-shaped). */
|
|
65
76
|
export interface LucidQueryBuilderLike {
|
|
@@ -70,6 +81,8 @@ export interface LucidQueryBuilderLike {
|
|
|
70
81
|
whereNotNull(column: string): this;
|
|
71
82
|
orderBy(column: string, direction: 'asc' | 'desc'): this;
|
|
72
83
|
groupBy(...columns: string[]): this;
|
|
84
|
+
/** Group by an expression. Optional: without it, `countByBucket` buckets rows in JS. */
|
|
85
|
+
groupByRaw?(sql: string, bindings?: unknown[]): this;
|
|
73
86
|
limit(value: number): this;
|
|
74
87
|
offset(value: number): this;
|
|
75
88
|
/** Aggregate MAX with an alias, e.g. `max('created_at as last_at')`. Chainable so it
|
|
@@ -81,7 +94,8 @@ export interface LucidQueryBuilderLike {
|
|
|
81
94
|
first(): Promise<Record<string, unknown> | null>;
|
|
82
95
|
}
|
|
83
96
|
export interface LucidInsertBuilderLike {
|
|
84
|
-
|
|
97
|
+
/** Insert one row, or several in one statement. */
|
|
98
|
+
insert(row: Record<string, unknown> | Record<string, unknown>[]): Promise<unknown>;
|
|
85
99
|
}
|
|
86
100
|
/** Options for {@link LucidTelescopeStore} (and the `storage.lucid` factory). */
|
|
87
101
|
export interface LucidStoreOptions {
|
|
@@ -110,6 +124,15 @@ export interface LucidStoreOptions {
|
|
|
110
124
|
* `sequence` is seeded from `MAX(sequence)` on first use so it keeps climbing
|
|
111
125
|
* across process restarts.
|
|
112
126
|
*
|
|
127
|
+
* Writes are buffered: every entry recorded during one tick of the event loop goes
|
|
128
|
+
* out in one multi-row INSERT (split to stay under each dialect's bind limit), one
|
|
129
|
+
* statement at a time, so the store never holds more than one pooled connection
|
|
130
|
+
* for writing and a burst of watcher events costs a handful of round trips instead
|
|
131
|
+
* of one each. `record()` still resolves once its entry is persisted.
|
|
132
|
+
*
|
|
133
|
+
* Every query the store runs is marked as telescope's own work (see
|
|
134
|
+
* `self_scope.ts`), so the query watcher never records them.
|
|
135
|
+
*
|
|
113
136
|
* Usually you don't construct this directly: `config/telescope.ts` selects it via
|
|
114
137
|
* `storage.lucid({ ... })` and the provider builds it for you, lazily importing
|
|
115
138
|
* `@adonisjs/lucid` only when the `lucid` driver is the active one.
|
|
@@ -122,16 +145,17 @@ export declare class LucidTelescopeStore implements TelescopeStore {
|
|
|
122
145
|
/** Lazily-resolved init (table creation + sequence seed), run at most once. */
|
|
123
146
|
private ready;
|
|
124
147
|
private sequence;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* serialized.
|
|
131
|
-
*/
|
|
132
|
-
private writeTail;
|
|
148
|
+
private pending;
|
|
149
|
+
/** The running drain, while one is scheduled or writing. */
|
|
150
|
+
private draining;
|
|
151
|
+
private dropped;
|
|
152
|
+
private warnedDrop;
|
|
133
153
|
constructor(db: LucidDatabaseLike, options?: LucidStoreOptions);
|
|
134
154
|
record<TContent>(input: RecordInput<TContent>): Promise<Entry<TContent>>;
|
|
155
|
+
/** Entries dropped because the write buffer was full. */
|
|
156
|
+
get droppedCount(): number;
|
|
157
|
+
/** Resolves once every entry recorded so far has been written (or has failed). */
|
|
158
|
+
flush(): Promise<void>;
|
|
135
159
|
get(id: string): Promise<Entry | null>;
|
|
136
160
|
list(query?: EntryQuery): Promise<Entry[]>;
|
|
137
161
|
/**
|
|
@@ -145,29 +169,50 @@ export declare class LucidTelescopeStore implements TelescopeStore {
|
|
|
145
169
|
*/
|
|
146
170
|
listTraceIds(query: TraceIdQuery): Promise<TraceIdRow[]>;
|
|
147
171
|
/**
|
|
148
|
-
* Per-bucket, per-type counts for the throughput chart
|
|
172
|
+
* Per-bucket, per-type counts for the throughput chart, grouped in SQL so one row
|
|
173
|
+
* per `(bucket, type)` leaves the database instead of one per entry.
|
|
149
174
|
*
|
|
150
|
-
* The
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* and
|
|
154
|
-
*
|
|
155
|
-
* bytes on the wire and no per-row JSON parse.
|
|
156
|
-
*
|
|
157
|
-
* The bucketing itself stays in JS, deliberately. Doing it in SQL needs a raw
|
|
158
|
-
* select expression (`(created_at - ?) / ?`), and Lucid exposes `groupByRaw` but no
|
|
159
|
-
* `selectRaw` — the alternative is `rawQuery`, whose result shape differs per driver
|
|
160
|
-
* (`{ rows }` on Postgres, an array on SQLite). Trading a portability bug for the
|
|
161
|
-
* second-order win is a bad deal; the row count is what would justify it, and after
|
|
162
|
-
* the redis-watcher filter that count drops by roughly an order of magnitude. If
|
|
163
|
-
* this is still hot with a clean table, THAT is when it earns the raw query.
|
|
175
|
+
* The bucket is `(created_at - start) - ((created_at - start) % bucketMs)`: integer
|
|
176
|
+
* arithmetic every dialect evaluates the same way, where `/` would be integer
|
|
177
|
+
* division on some and decimal on MySQL. Each group reports its newest
|
|
178
|
+
* `created_at`, and the bucket index is computed from that in JS. A builder
|
|
179
|
+
* without `groupByRaw` gets the per-row projection, bucketed here.
|
|
164
180
|
*/
|
|
165
181
|
countByBucket(query: BucketCountQuery): Promise<BucketCountRow[]>;
|
|
182
|
+
/**
|
|
183
|
+
* The busiest families, counted by `GROUP BY family_hash` — see
|
|
184
|
+
* {@link TelescopeStore.countFamilies}.
|
|
185
|
+
*/
|
|
186
|
+
countFamilies(query: FamilyCountQuery): Promise<KeyCountRow[]>;
|
|
187
|
+
/**
|
|
188
|
+
* The most common tags — see {@link TelescopeStore.countTags}. Tags are JSON text,
|
|
189
|
+
* so they are counted here, reading only the `tags` column a page at a time in
|
|
190
|
+
* primary-key order.
|
|
191
|
+
*/
|
|
192
|
+
countTags(query: TagCountQuery): Promise<KeyCountRow[]>;
|
|
166
193
|
count(): Promise<number>;
|
|
194
|
+
/**
|
|
195
|
+
* Deletes oldest-first, {@link PRUNE_BATCH_ROWS} rows per statement, each batch
|
|
196
|
+
* addressed by its newest row's position rather than by id: a backlog of any size
|
|
197
|
+
* is pruned in bounded statements that never approach a bind limit.
|
|
198
|
+
*/
|
|
167
199
|
prune(olderThan: Date, keepLast?: number): Promise<number>;
|
|
168
200
|
clear(): Promise<void>;
|
|
169
201
|
/** Cap enforcement helper for callers running a scheduled trim. */
|
|
170
202
|
get capacity(): number | null;
|
|
203
|
+
/** The first row of an ordered query, as a position. */
|
|
204
|
+
private position;
|
|
205
|
+
/** Start a drain on the next tick unless one is already running. */
|
|
206
|
+
private scheduleDrain;
|
|
207
|
+
/** Write the buffer out, batch by batch, until it is empty. */
|
|
208
|
+
private drain;
|
|
209
|
+
/** The oldest pending writes that fit one INSERT. */
|
|
210
|
+
private takeBatch;
|
|
211
|
+
/**
|
|
212
|
+
* One multi-row INSERT. When it fails, its rows are retried one at a time, so a
|
|
213
|
+
* row the database rejects fails only its own `record()`.
|
|
214
|
+
*/
|
|
215
|
+
private writeBatch;
|
|
171
216
|
/** Run table creation (optional) + sequence seeding exactly once. */
|
|
172
217
|
private init;
|
|
173
218
|
private doInit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucid.d.ts","sourceRoot":"","sources":["../../../src/stores/lucid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,KAAK,EAAiB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"lucid.d.ts","sourceRoot":"","sources":["../../../src/stores/lucid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,KAAK,EAAiB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAG5F,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAEtD;;;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