@adonis-agora/telescope 0.23.0 → 0.25.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 +58 -0
- package/dist/providers/telescope_provider.js +1 -1
- package/dist/providers/telescope_provider.js.map +1 -1
- 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 +1 -1
- package/dist/src/index.js +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_exporter.d.ts +40 -3
- package/dist/src/otel/otel_exporter.d.ts.map +1 -1
- package/dist/src/otel/otel_exporter.js +55 -7
- package/dist/src/otel/otel_exporter.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/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/tiered.d.ts +9 -4
- package/dist/src/stores/tiered.d.ts.map +1 -1
- package/dist/src/stores/tiered.js +34 -11
- package/dist/src/stores/tiered.js.map +1 -1
- 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 +20 -14
- package/skills/telescope-storage-retention/SKILL.md +6 -3
- package/skills/telescope-watchers/SKILL.md +7 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { forwardOptionalReads } from '../store.js';
|
|
1
2
|
import { passesSampling } from './sampling.js';
|
|
2
3
|
/**
|
|
3
4
|
* A {@link TelescopeStore} decorator that applies tail-sampling on the WRITE
|
|
@@ -24,6 +25,7 @@ export class SamplingTelescopeStore {
|
|
|
24
25
|
this.inner = inner;
|
|
25
26
|
this.sampling = sampling;
|
|
26
27
|
this.random = random;
|
|
28
|
+
forwardOptionalReads(this, inner);
|
|
27
29
|
}
|
|
28
30
|
async record(input) {
|
|
29
31
|
if (!passesSampling(this.sampling, input, this.random)) {
|
|
@@ -52,7 +54,10 @@ function droppedEntry(input) {
|
|
|
52
54
|
return {
|
|
53
55
|
id: '',
|
|
54
56
|
type: input.type,
|
|
55
|
-
|
|
57
|
+
// A getter, so a lazily computed key is not computed for an entry that is dropped.
|
|
58
|
+
get familyHash() {
|
|
59
|
+
return input.familyHash ?? null;
|
|
60
|
+
},
|
|
56
61
|
content: input.content,
|
|
57
62
|
tags: input.tags ?? [],
|
|
58
63
|
sequence: -1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampling_store.js","sourceRoot":"","sources":["../../../src/sampling/sampling_store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampling_store.js","sourceRoot":"","sources":["../../../src/sampling/sampling_store.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,oBAAoB,EAAuB,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,sBAAsB;IAEd,KAAK;IACL,QAAQ;IACR,MAAM;IAHzB,YACmB,KAAqB,EACrB,QAAwB,EACxB,MAAM,GAAiB,IAAI,CAAC,MAAM;qBAFlC,KAAK;wBACL,QAAQ;sBACR,MAAM;QAEvB,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAW,KAA4B;QACjD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACvD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC,KAAkB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,SAAe,EAAE,QAAiB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,6EAA6E;AAC7E,SAAS,YAAY,CAAW,KAA4B;IAC1D,OAAO;QACL,EAAE,EAAE,EAAE;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,mFAAmF;QACnF,IAAI,UAAU;YACZ,OAAO,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC;QAClC,CAAC;QACD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC;QACZ,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,QAAQ;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;QAC9B,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Run `fn` as telescope's own work: nothing it causes is recorded. */
|
|
2
|
+
export declare function runAsTelescopeWork<T>(fn: () => T): T;
|
|
3
|
+
/** Whether the caller is inside {@link runAsTelescopeWork}. */
|
|
4
|
+
export declare function isTelescopeWork(): boolean;
|
|
5
|
+
//# sourceMappingURL=self_scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self_scope.d.ts","sourceRoot":"","sources":["../../src/self_scope.ts"],"names":[],"mappings":"AAwBA,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEpD;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Marks work telescope does on its own behalf — the lucid store's INSERTs, reads and
|
|
4
|
+
* prunes — so the watchers can tell it apart from the app's.
|
|
5
|
+
*
|
|
6
|
+
* The query watcher records every `db:query` Lucid emits, and when the store shares
|
|
7
|
+
* the app's connection its own INSERT is one of them: recorded through the store, it
|
|
8
|
+
* becomes another INSERT, another `db:query`, and the loop never ends. Every
|
|
9
|
+
* ingestion point that goes through `safeRecord` drops entries raised inside this
|
|
10
|
+
* scope.
|
|
11
|
+
*
|
|
12
|
+
* Kept on a `Symbol.for()` global slot like the origin scope, so a store built by
|
|
13
|
+
* one copy of this package and a watcher loaded from another still agree.
|
|
14
|
+
*/
|
|
15
|
+
const SELF_SCOPE_KEY = Symbol.for('@agora/telescope:self-scope');
|
|
16
|
+
const globalSlot = globalThis;
|
|
17
|
+
const storage = globalSlot[SELF_SCOPE_KEY] ??
|
|
18
|
+
new AsyncLocalStorage();
|
|
19
|
+
globalSlot[SELF_SCOPE_KEY] = storage;
|
|
20
|
+
/** Run `fn` as telescope's own work: nothing it causes is recorded. */
|
|
21
|
+
export function runAsTelescopeWork(fn) {
|
|
22
|
+
return storage.run(true, fn);
|
|
23
|
+
}
|
|
24
|
+
/** Whether the caller is inside {@link runAsTelescopeWork}. */
|
|
25
|
+
export function isTelescopeWork() {
|
|
26
|
+
return storage.getStore() === true;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=self_scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self_scope.js","sourceRoot":"","sources":["../../src/self_scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEjE,MAAM,UAAU,GAAG,UAAqC,CAAC;AAEzD,MAAM,OAAO,GACV,UAAU,CAAC,cAAc,CAAyC;IACnE,IAAI,iBAAiB,EAAQ,CAAC;AAChC,UAAU,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC;AAErC,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAAI,EAAW;IAC/C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,mFAAmF;IACnF,OAAO,CAAC,YAAY,CAA6B;IAEjD,YACmB,KAAK,EAAE,cAAc;IACtC,8EAA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KAAK,EAAE,cAAc;IACtC,8EAA8E;IAC7D,YAAY,GAAE,mBAAwB,EACrD;IAEJ,gFAAgF;IAChF,IAAI,cAAc,IAAI,cAAc,CAEnC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAGnD;IAED,mDAAmD;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAEzC;IAED,wCAAwC;IACxC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAEtC;IAED,iEAAiE;IACjE,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAEzC;IAED,sCAAsC;IACtC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAEvB;IAED;;;;OAIG;IACG,WAAW,CAAC,KAAK,SAAK,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAWnE;IAED,0EAA0E;IACpE,OAAO,CAAC,KAAK,SAAK,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAYjE;CACF"}
|
package/dist/src/service.js
CHANGED
|
@@ -53,8 +53,12 @@ export class TelescopeService {
|
|
|
53
53
|
* the store's newest-first ordering.
|
|
54
54
|
*/
|
|
55
55
|
async topFamilies(limit = 10, type) {
|
|
56
|
+
if (typeof this.store.countFamilies === 'function') {
|
|
57
|
+
return this.store.countFamilies(type !== undefined ? { limit, type } : { limit });
|
|
58
|
+
}
|
|
56
59
|
const counts = new Map();
|
|
57
|
-
|
|
60
|
+
const query = { omitContent: true, ...(type !== undefined ? { type } : {}) };
|
|
61
|
+
for (const entry of await this.store.list(query)) {
|
|
58
62
|
if (!entry.familyHash)
|
|
59
63
|
continue;
|
|
60
64
|
counts.set(entry.familyHash, (counts.get(entry.familyHash) ?? 0) + 1);
|
|
@@ -63,8 +67,11 @@ export class TelescopeService {
|
|
|
63
67
|
}
|
|
64
68
|
/** Top-N most common tags across stored entries, optionally by prefix. */
|
|
65
69
|
async topTags(limit = 10, prefix) {
|
|
70
|
+
if (typeof this.store.countTags === 'function') {
|
|
71
|
+
return this.store.countTags(prefix !== undefined ? { limit, prefix } : { limit });
|
|
72
|
+
}
|
|
66
73
|
const counts = new Map();
|
|
67
|
-
for (const entry of await this.store.list()) {
|
|
74
|
+
for (const entry of await this.store.list({ omitContent: true })) {
|
|
68
75
|
for (const tag of entry.tags) {
|
|
69
76
|
if (prefix !== undefined && !tag.startsWith(prefix))
|
|
70
77
|
continue;
|
package/dist/src/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAS5B;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAKR,KAAK;IAEL,YAAY;IAN/B,mFAAmF;IAC3E,YAAY,GAAwB,IAAI,CAAC;IAEjD,YACmB,KAAqB;IACtC,8EAA8E;IAC7D,YAAY,GAAwB,EAAE;qBAFtC,KAAK;4BAEL,YAAY;IAC5B,CAAC;IAEJ,gFAAgF;IAChF,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,KAAkB;QAC1B,IAAI,CAAC,YAAY,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,mDAAmD;IACnD,IAAI,CAAC,KAAkB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK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AAC"}
|
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,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CA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;IAEvC,mDAAmD;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAE3C,sCAAsC;IACtC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;;OAGG;IACH,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3D,iCAAiC;IACjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1D;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAEnE;;;;OAIG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEhE;;;;OAIG;IACH,SAAS,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAC1D;AAKD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAMxF"}
|
package/dist/src/store.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GA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