@adonis-agora/telescope 0.3.3 → 0.5.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 +10 -0
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +6 -0
- package/dist/configure.js.map +1 -1
- package/dist/providers/telescope_ai_provider.d.ts +9 -1
- package/dist/providers/telescope_ai_provider.d.ts.map +1 -1
- package/dist/providers/telescope_ai_provider.js +22 -2
- package/dist/providers/telescope_ai_provider.js.map +1 -1
- package/dist/providers/telescope_alerts_provider.d.ts +1 -0
- package/dist/providers/telescope_alerts_provider.d.ts.map +1 -1
- package/dist/providers/telescope_alerts_provider.js +37 -1
- package/dist/providers/telescope_alerts_provider.js.map +1 -1
- package/dist/providers/telescope_mcp_provider.d.ts +26 -0
- package/dist/providers/telescope_mcp_provider.d.ts.map +1 -0
- package/dist/providers/telescope_mcp_provider.js +114 -0
- package/dist/providers/telescope_mcp_provider.js.map +1 -0
- package/dist/providers/telescope_provider.d.ts +8 -0
- package/dist/providers/telescope_provider.d.ts.map +1 -1
- package/dist/providers/telescope_provider.js +56 -1
- package/dist/providers/telescope_provider.js.map +1 -1
- package/dist/providers/telescope_ui_provider.d.ts +2 -0
- package/dist/providers/telescope_ui_provider.d.ts.map +1 -1
- package/dist/providers/telescope_ui_provider.js +106 -22
- package/dist/providers/telescope_ui_provider.js.map +1 -1
- package/dist/providers/telescope_watchers_provider.d.ts +13 -2
- package/dist/providers/telescope_watchers_provider.d.ts.map +1 -1
- package/dist/providers/telescope_watchers_provider.js +57 -7
- package/dist/providers/telescope_watchers_provider.js.map +1 -1
- package/dist/src/ai/define_config.d.ts +39 -7
- package/dist/src/ai/define_config.d.ts.map +1 -1
- package/dist/src/ai/define_config.js +14 -4
- package/dist/src/ai/define_config.js.map +1 -1
- package/dist/src/ai/diagnosis_coordinator.d.ts +106 -0
- package/dist/src/ai/diagnosis_coordinator.d.ts.map +1 -0
- package/dist/src/ai/diagnosis_coordinator.js +143 -0
- package/dist/src/ai/diagnosis_coordinator.js.map +1 -0
- package/dist/src/ai/factory.d.ts +8 -5
- package/dist/src/ai/factory.d.ts.map +1 -1
- package/dist/src/ai/factory.js +20 -8
- package/dist/src/ai/factory.js.map +1 -1
- package/dist/src/ai/index.d.ts +3 -1
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +3 -1
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/alerts/alert_rule.d.ts +79 -11
- package/dist/src/alerts/alert_rule.d.ts.map +1 -1
- package/dist/src/alerts/alerter.d.ts +11 -1
- package/dist/src/alerts/alerter.d.ts.map +1 -1
- package/dist/src/alerts/alerter.js +21 -1
- package/dist/src/alerts/alerter.js.map +1 -1
- package/dist/src/alerts/alerter_service.d.ts +103 -0
- package/dist/src/alerts/alerter_service.d.ts.map +1 -0
- package/dist/src/alerts/alerter_service.js +215 -0
- package/dist/src/alerts/alerter_service.js.map +1 -0
- package/dist/src/alerts/index.d.ts +4 -2
- package/dist/src/alerts/index.d.ts.map +1 -1
- package/dist/src/alerts/index.js +4 -2
- package/dist/src/alerts/index.js.map +1 -1
- package/dist/src/alerts/slack_format.d.ts.map +1 -1
- package/dist/src/alerts/slack_format.js +35 -2
- package/dist/src/alerts/slack_format.js.map +1 -1
- package/dist/src/client_errors/config.d.ts +66 -0
- package/dist/src/client_errors/config.d.ts.map +1 -0
- package/dist/src/client_errors/config.js +17 -0
- package/dist/src/client_errors/config.js.map +1 -0
- package/dist/src/client_errors/index.d.ts +5 -0
- package/dist/src/client_errors/index.d.ts.map +1 -0
- package/dist/src/client_errors/index.js +5 -0
- package/dist/src/client_errors/index.js.map +1 -0
- package/dist/src/client_errors/ingestor.d.ts +87 -0
- package/dist/src/client_errors/ingestor.d.ts.map +1 -0
- package/dist/src/client_errors/ingestor.js +135 -0
- package/dist/src/client_errors/ingestor.js.map +1 -0
- package/dist/src/client_errors/rate_limiter.d.ts +53 -0
- package/dist/src/client_errors/rate_limiter.d.ts.map +1 -0
- package/dist/src/client_errors/rate_limiter.js +83 -0
- package/dist/src/client_errors/rate_limiter.js.map +1 -0
- package/dist/src/client_errors/validation.d.ts +62 -0
- package/dist/src/client_errors/validation.d.ts.map +1 -0
- package/dist/src/client_errors/validation.js +109 -0
- package/dist/src/client_errors/validation.js.map +1 -0
- package/dist/src/define_config.d.ts +120 -0
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +41 -0
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/entry.d.ts +20 -0
- package/dist/src/entry.d.ts.map +1 -1
- package/dist/src/entry.js +20 -0
- package/dist/src/entry.js.map +1 -1
- package/dist/src/index.d.ts +17 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +16 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/define_config.d.ts +57 -0
- package/dist/src/mcp/define_config.d.ts.map +1 -0
- package/dist/src/mcp/define_config.js +35 -0
- package/dist/src/mcp/define_config.js.map +1 -0
- package/dist/src/mcp/index.d.ts +7 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +7 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/server.d.ts +89 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +279 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/metrics/pulse.d.ts +158 -0
- package/dist/src/metrics/pulse.d.ts.map +1 -0
- package/dist/src/metrics/pulse.js +414 -0
- package/dist/src/metrics/pulse.js.map +1 -0
- package/dist/src/overload_guard.d.ts +77 -0
- package/dist/src/overload_guard.d.ts.map +1 -0
- package/dist/src/overload_guard.js +134 -0
- package/dist/src/overload_guard.js.map +1 -0
- package/dist/src/pruner.d.ts +93 -0
- package/dist/src/pruner.d.ts.map +1 -0
- package/dist/src/pruner.js +120 -0
- package/dist/src/pruner.js.map +1 -0
- package/dist/src/registry.d.ts +26 -0
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +19 -0
- package/dist/src/registry.js.map +1 -1
- package/dist/src/service.d.ts +16 -1
- package/dist/src/service.d.ts.map +1 -1
- package/dist/src/service.js +19 -1
- package/dist/src/service.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +20 -0
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +89 -4
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/telescope_middleware.d.ts.map +1 -1
- package/dist/src/telescope_middleware.js +3 -1
- package/dist/src/telescope_middleware.js.map +1 -1
- package/dist/src/ui/api.d.ts +9 -1
- package/dist/src/ui/api.d.ts.map +1 -1
- package/dist/src/ui/api.js +23 -1
- package/dist/src/ui/api.js.map +1 -1
- package/dist/src/ui/auth.d.ts +112 -0
- package/dist/src/ui/auth.d.ts.map +1 -0
- package/dist/src/ui/auth.js +130 -0
- package/dist/src/ui/auth.js.map +1 -0
- package/dist/src/ui/dashboard_auth.d.ts +34 -0
- package/dist/src/ui/dashboard_auth.d.ts.map +1 -0
- package/dist/src/ui/dashboard_auth.js +57 -0
- package/dist/src/ui/dashboard_auth.js.map +1 -0
- package/dist/src/ui/define_config.d.ts +15 -0
- package/dist/src/ui/define_config.d.ts.map +1 -1
- package/dist/src/ui/define_config.js +4 -0
- package/dist/src/ui/define_config.js.map +1 -1
- package/dist/src/ui/index.d.ts +7 -1
- package/dist/src/ui/index.d.ts.map +1 -1
- package/dist/src/ui/index.js +6 -1
- package/dist/src/ui/index.js.map +1 -1
- package/dist/src/ui/login_page.d.ts +23 -0
- package/dist/src/ui/login_page.d.ts.map +1 -0
- package/dist/src/ui/login_page.js +170 -0
- package/dist/src/ui/login_page.js.map +1 -0
- package/dist/src/ui/session_cookie.d.ts +42 -0
- package/dist/src/ui/session_cookie.d.ts.map +1 -0
- package/dist/src/ui/session_cookie.js +97 -0
- package/dist/src/ui/session_cookie.js.map +1 -0
- package/dist/src/watchers/define_config.d.ts +115 -12
- package/dist/src/watchers/define_config.d.ts.map +1 -1
- package/dist/src/watchers/define_config.js +48 -11
- package/dist/src/watchers/define_config.js.map +1 -1
- package/dist/src/watchers/http_client_watcher.d.ts +91 -31
- package/dist/src/watchers/http_client_watcher.d.ts.map +1 -1
- package/dist/src/watchers/http_client_watcher.js +161 -53
- package/dist/src/watchers/http_client_watcher.js.map +1 -1
- package/dist/src/watchers/index.d.ts +9 -5
- package/dist/src/watchers/index.d.ts.map +1 -1
- package/dist/src/watchers/index.js +6 -2
- package/dist/src/watchers/index.js.map +1 -1
- package/dist/src/watchers/lucid_query_watcher.d.ts +20 -2
- package/dist/src/watchers/lucid_query_watcher.d.ts.map +1 -1
- package/dist/src/watchers/lucid_query_watcher.js +44 -10
- package/dist/src/watchers/lucid_query_watcher.js.map +1 -1
- package/dist/src/watchers/profiling_watcher.d.ts +144 -0
- package/dist/src/watchers/profiling_watcher.d.ts.map +1 -0
- package/dist/src/watchers/profiling_watcher.js +231 -0
- package/dist/src/watchers/profiling_watcher.js.map +1 -0
- package/dist/src/watchers/query_family_hash.d.ts +7 -2
- package/dist/src/watchers/query_family_hash.d.ts.map +1 -1
- package/dist/src/watchers/query_family_hash.js +8 -3
- package/dist/src/watchers/query_family_hash.js.map +1 -1
- package/dist/src/watchers/record.d.ts.map +1 -1
- package/dist/src/watchers/record.js +4 -0
- package/dist/src/watchers/record.js.map +1 -1
- package/dist/src/watchers/schedule_watcher.d.ts +143 -0
- package/dist/src/watchers/schedule_watcher.d.ts.map +1 -0
- package/dist/src/watchers/schedule_watcher.js +195 -0
- package/dist/src/watchers/schedule_watcher.js.map +1 -0
- package/dist/stubs/config/telescope.stub +0 -65
- package/dist/stubs/config/telescope_ai.stub +0 -36
- package/dist/stubs/config/telescope_alerts.stub +0 -47
- package/dist/stubs/config/telescope_mcp.stub +0 -0
- package/dist/stubs/config/telescope_ui.stub +0 -53
- package/dist/stubs/config/telescope_watchers.stub +0 -41
- package/dist/stubs/database/migrations/create_telescope_entries_table.stub +2 -2
- package/package.json +12 -2
|
@@ -4,6 +4,10 @@ import { queryFamilyHash } from './query_family_hash.js';
|
|
|
4
4
|
import { safeRecord } from './record.js';
|
|
5
5
|
/** The Lucid event name this watcher subscribes to. */
|
|
6
6
|
export const DB_QUERY_EVENT = 'db:query';
|
|
7
|
+
/** Placeholder a bound value is replaced with when `captureBindings` is off. */
|
|
8
|
+
const REDACTED = '[REDACTED]';
|
|
9
|
+
/** Default slow-query threshold (ms), mirrored from the resolved watcher config. */
|
|
10
|
+
const DEFAULT_SLOW_MS = 500;
|
|
7
11
|
/** Convert a `process.hrtime()` `[seconds, nanoseconds]` tuple to milliseconds. */
|
|
8
12
|
function hrtimeToMs(duration) {
|
|
9
13
|
if (!Array.isArray(duration) || duration.length !== 2)
|
|
@@ -38,6 +42,16 @@ function isDbQueryEvent(data) {
|
|
|
38
42
|
export class LucidQueryWatcher {
|
|
39
43
|
type = EntryType.Query;
|
|
40
44
|
unsubscribe = null;
|
|
45
|
+
slowMs;
|
|
46
|
+
captureBindings;
|
|
47
|
+
ignoreConnections;
|
|
48
|
+
normalize;
|
|
49
|
+
constructor(options = {}) {
|
|
50
|
+
this.slowMs = options.slowMs ?? DEFAULT_SLOW_MS;
|
|
51
|
+
this.captureBindings = options.captureBindings ?? false;
|
|
52
|
+
this.ignoreConnections = new Set((options.ignoreConnections ?? []).map((name) => name.toLowerCase()));
|
|
53
|
+
this.normalize = options.normalize ?? true;
|
|
54
|
+
}
|
|
41
55
|
start(emitter) {
|
|
42
56
|
if (this.unsubscribe)
|
|
43
57
|
return;
|
|
@@ -51,34 +65,54 @@ export class LucidQueryWatcher {
|
|
|
51
65
|
handle(data) {
|
|
52
66
|
if (!isDbQueryEvent(data))
|
|
53
67
|
return;
|
|
54
|
-
|
|
68
|
+
// An ignored connection is dropped before any work — a telescope query that
|
|
69
|
+
// hits the store's own DB, a replica used only for the timeline, etc.
|
|
70
|
+
if (this.ignoreConnections.has(data.connection.toLowerCase()))
|
|
71
|
+
return;
|
|
72
|
+
safeRecord(buildQueryEntry(data, {
|
|
73
|
+
slowMs: this.slowMs,
|
|
74
|
+
captureBindings: this.captureBindings,
|
|
75
|
+
normalize: this.normalize,
|
|
76
|
+
}), 'LucidQueryWatcher');
|
|
55
77
|
}
|
|
56
78
|
}
|
|
57
|
-
/** Map a Lucid `db:query` payload to a telescope {@link RecordInput}.
|
|
58
|
-
|
|
79
|
+
/** Map a Lucid `db:query` payload to a telescope {@link RecordInput}. Exported so
|
|
80
|
+
* the entry shape can be unit-tested without a running emitter. */
|
|
81
|
+
export function buildQueryEntry(event, options = {}) {
|
|
82
|
+
const slowMs = options.slowMs ?? DEFAULT_SLOW_MS;
|
|
83
|
+
const captureBindings = options.captureBindings ?? false;
|
|
84
|
+
const normalize = options.normalize ?? true;
|
|
59
85
|
const durationMs = hrtimeToMs(event.duration);
|
|
60
86
|
const method = typeof event.method === 'string' ? event.method : null;
|
|
61
87
|
const traceId = currentTraceId();
|
|
88
|
+
const rawBindings = Array.isArray(event.bindings) ? event.bindings : [];
|
|
62
89
|
const content = {
|
|
63
90
|
sql: event.sql,
|
|
64
|
-
|
|
91
|
+
// Redact bound VALUES by default (they carry PII/secrets) while preserving
|
|
92
|
+
// arity, so the query's shape stays visible without leaking data.
|
|
93
|
+
bindings: captureBindings ? rawBindings : rawBindings.map(() => REDACTED),
|
|
65
94
|
durationMs,
|
|
66
95
|
connection: event.connection,
|
|
67
96
|
method,
|
|
68
97
|
inTransaction: typeof event.inTransaction === 'boolean' ? event.inTransaction : null,
|
|
69
98
|
traceId,
|
|
70
99
|
};
|
|
100
|
+
const tags = [
|
|
101
|
+
`connection:${event.connection}`,
|
|
102
|
+
...(method ? [`method:${method}`] : []),
|
|
103
|
+
...(event.model ? [`model:${event.model}`] : []),
|
|
104
|
+
];
|
|
105
|
+
if (durationMs !== null && durationMs >= slowMs)
|
|
106
|
+
tags.push('slow');
|
|
71
107
|
return {
|
|
72
108
|
type: EntryType.Query,
|
|
73
|
-
|
|
109
|
+
// Group by SQL template (see queryFamilyHash) so "the same query" rolls up
|
|
110
|
+
// for the Pulse slow-query + N+1 cards. `normalize: false` hashes verbatim.
|
|
111
|
+
familyHash: normalize ? queryFamilyHash(event.sql) : queryFamilyHash(event.sql, false),
|
|
74
112
|
content,
|
|
75
113
|
durationMs,
|
|
76
114
|
traceId,
|
|
77
|
-
tags
|
|
78
|
-
`connection:${event.connection}`,
|
|
79
|
-
...(method ? [`method:${method}`] : []),
|
|
80
|
-
...(event.model ? [`model:${event.model}`] : []),
|
|
81
|
-
],
|
|
115
|
+
tags,
|
|
82
116
|
};
|
|
83
117
|
}
|
|
84
118
|
//# sourceMappingURL=lucid_query_watcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucid_query_watcher.js","sourceRoot":"","sources":["../../../src/watchers/lucid_query_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"lucid_query_watcher.js","sourceRoot":"","sources":["../../../src/watchers/lucid_query_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,uDAAuD;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,gFAAgF;AAChF,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B,o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CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;QACtF,OAAO;QACP,UAAU;QACV,OAAO;QACP,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type RecordInput } from '../entry.js';
|
|
2
|
+
/** The `type` of the entries this watcher records. */
|
|
3
|
+
export declare const PROFILE_ENTRY_TYPE: "profile";
|
|
4
|
+
/** The terminal outcome of a profiling span. */
|
|
5
|
+
export type ProfileStatus = 'completed' | 'failed';
|
|
6
|
+
/** A timing mark taken inside a span, offset (ms) from the span's start. */
|
|
7
|
+
export interface ProfileMark {
|
|
8
|
+
/** The mark label, e.g. `'validated'`, `'db-loaded'`. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Milliseconds elapsed from the span's start when the mark was taken. */
|
|
11
|
+
atMs: number;
|
|
12
|
+
}
|
|
13
|
+
/** The recorded body of a `profile` entry. */
|
|
14
|
+
export interface ProfileEntryContent {
|
|
15
|
+
/** The span label, e.g. `'checkout'`. */
|
|
16
|
+
label: string;
|
|
17
|
+
/** Total wall-clock duration of the span in milliseconds. */
|
|
18
|
+
durationMs: number;
|
|
19
|
+
/** The span outcome. */
|
|
20
|
+
status: ProfileStatus;
|
|
21
|
+
/** In-order timing marks taken inside the span (nested checkpoints). */
|
|
22
|
+
marks: ProfileMark[];
|
|
23
|
+
/** The failure message when `status` is `'failed'`, else `null`. */
|
|
24
|
+
failureReason: string | null;
|
|
25
|
+
/** The active trace id at record time, or `null`. */
|
|
26
|
+
traceId: string | null;
|
|
27
|
+
}
|
|
28
|
+
/** Options for {@link ProfilingWatcher}. */
|
|
29
|
+
export interface ProfilingWatcherOptions {
|
|
30
|
+
/** Spans at/above this many ms get a `slow` tag. Default 100. */
|
|
31
|
+
slowMs?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Spans whose duration is below this are discarded (too short to be worth a
|
|
34
|
+
* timeline entry). Default `0` (keep all).
|
|
35
|
+
*/
|
|
36
|
+
minDurationMs?: number;
|
|
37
|
+
/** Time source; injectable for tests. Default `Date.now`. */
|
|
38
|
+
clock?: {
|
|
39
|
+
now(): number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An in-flight profiling span. Add {@link mark}s inside the timed section, then
|
|
44
|
+
* call {@link end} (or {@link fail}) exactly once to record it. Recording is
|
|
45
|
+
* fire-and-forget and fully guarded — a telescope failure can never break the
|
|
46
|
+
* code being profiled.
|
|
47
|
+
*/
|
|
48
|
+
export interface ProfileSession {
|
|
49
|
+
/** Take a timing mark at the current instant (offset from the span's start). */
|
|
50
|
+
mark(label: string): this;
|
|
51
|
+
/** Finish the span and record it as `completed`. Idempotent. */
|
|
52
|
+
end(): void;
|
|
53
|
+
/** Finish the span and record it as `failed` with the given error. Idempotent. */
|
|
54
|
+
fail(error: unknown): void;
|
|
55
|
+
}
|
|
56
|
+
/** A completed span handed to {@link buildProfileEntry}. */
|
|
57
|
+
export interface CompletedProfile {
|
|
58
|
+
label: string;
|
|
59
|
+
durationMs: number;
|
|
60
|
+
status: ProfileStatus;
|
|
61
|
+
marks: ProfileMark[];
|
|
62
|
+
error?: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Records user-instrumented profiling spans as `profile` telescope entries — one
|
|
66
|
+
* per timed code section, capturing its label, total duration, in-span timing
|
|
67
|
+
* marks, and outcome (completed/failed), correlated to the active trace.
|
|
68
|
+
*
|
|
69
|
+
* ## How it works
|
|
70
|
+
* Unlike the emitter-driven watchers, profiling is DRIVEN BY THE USER: there is
|
|
71
|
+
* no event to tap. Wrap a code section with {@link profile} (or bracket it with
|
|
72
|
+
* {@link startProfile} + {@link ProfileSession.end}); the watcher times it and
|
|
73
|
+
* records one entry. It never monkey-patches anything and carries no cost while
|
|
74
|
+
* disabled — the standalone helpers are a no-op until the provider calls
|
|
75
|
+
* {@link start}.
|
|
76
|
+
*
|
|
77
|
+
* Each entry carries `familyHash` (the label) and `durationMs`, so repeated spans
|
|
78
|
+
* of the same label roll up and feed the slow-hotspot metrics cards. Recording is
|
|
79
|
+
* fire-and-forget and fully guarded: a telescope failure can never break the code
|
|
80
|
+
* being profiled.
|
|
81
|
+
*
|
|
82
|
+
* Idiomatic Adonis: a plain class, no DI decorators. The provider constructs it
|
|
83
|
+
* from `config/telescope_watchers.ts` and calls {@link start} to publish it as the
|
|
84
|
+
* default backing the bare {@link profile} / {@link startProfile} helpers;
|
|
85
|
+
* {@link stop} unpublishes.
|
|
86
|
+
*/
|
|
87
|
+
export declare class ProfilingWatcher {
|
|
88
|
+
readonly type: "profile";
|
|
89
|
+
private readonly slowMs;
|
|
90
|
+
private readonly minDurationMs;
|
|
91
|
+
private readonly clock;
|
|
92
|
+
constructor(options?: ProfilingWatcherOptions);
|
|
93
|
+
/** The watcher's time source (used by its sessions). */
|
|
94
|
+
now(): number;
|
|
95
|
+
/** Publish this configured instance as the default the standalone
|
|
96
|
+
* {@link profile} / {@link startProfile} helpers inherit. Does NOT patch any
|
|
97
|
+
* global. Named `start`/`stop` to match the other watchers' provider lifecycle. */
|
|
98
|
+
start(): void;
|
|
99
|
+
/** Unpublish this instance as the default (if it is). Never touches globals. */
|
|
100
|
+
stop(): void;
|
|
101
|
+
/** Begin a profiling span. Add marks on the returned session, then `end()`/`fail()`. */
|
|
102
|
+
startProfile(label: string): ProfileSession;
|
|
103
|
+
/**
|
|
104
|
+
* Time `fn` as a profiling span. The span's session is passed to `fn` so it can
|
|
105
|
+
* add timing marks. Records `completed` on return / resolve and `failed` on
|
|
106
|
+
* throw / reject, always re-throwing so the caller's control flow is untouched.
|
|
107
|
+
* Works with sync and async `fn`.
|
|
108
|
+
*/
|
|
109
|
+
profile<T>(label: string, fn: (session: ProfileSession) => T): T;
|
|
110
|
+
/** Record one already-completed span. Spans below `minDurationMs` are dropped;
|
|
111
|
+
* recording is fire-and-forget and never throws. */
|
|
112
|
+
record(profile: CompletedProfile): void;
|
|
113
|
+
}
|
|
114
|
+
/** Map a completed span to a telescope {@link RecordInput}. Exported so the entry
|
|
115
|
+
* shape can be unit-tested without a live watcher. */
|
|
116
|
+
export declare function buildProfileEntry(profile: CompletedProfile, slowMs?: number): RecordInput<ProfileEntryContent>;
|
|
117
|
+
/**
|
|
118
|
+
* Begin a profiling span through the provider-published default watcher. Returns a
|
|
119
|
+
* NO-OP session (nothing recorded) when the profiling watcher is not enabled, so
|
|
120
|
+
* this is safe to leave in code unconditionally.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* import { startProfile } from '@adonis-agora/telescope/watchers'
|
|
124
|
+
* const span = startProfile('checkout')
|
|
125
|
+
* // ... work ...
|
|
126
|
+
* span.mark('validated')
|
|
127
|
+
* // ... more work ...
|
|
128
|
+
* span.end()
|
|
129
|
+
*/
|
|
130
|
+
export declare function startProfile(label: string): ProfileSession;
|
|
131
|
+
/**
|
|
132
|
+
* Time `fn` as a profiling span through the provider-published default watcher.
|
|
133
|
+
* A no-op passthrough (just runs `fn`) when the profiling watcher is not enabled.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* import { profile } from '@adonis-agora/telescope/watchers'
|
|
137
|
+
* const order = await profile('checkout', async (span) => {
|
|
138
|
+
* const cart = await loadCart()
|
|
139
|
+
* span.mark('cart-loaded')
|
|
140
|
+
* return placeOrder(cart)
|
|
141
|
+
* })
|
|
142
|
+
*/
|
|
143
|
+
export declare function profile<T>(label: string, fn: (session: ProfileSession) => T): T;
|
|
144
|
+
//# sourceMappingURL=profiling_watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling_watcher.d.ts","sourceRoot":"","sources":["../../../src/watchers/profiling_watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1D,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,WAAoB,CAAC;AAEpD,gDAAgD;AAChD,MAAM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AsBG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,YAAqB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;gBAE9B,OAAO,GAAE,uBAA4B;IAMjD,wDAAwD;IACxD,GAAG,IAAI,MAAM;IAIb;;wFAEoF;IACpF,KAAK,IAAI,IAAI;IAIb,gFAAgF;IAChF,IAAI,IAAI,IAAI;IAIZ,wFAAwF;IACxF,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;IAI3C;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,CAAC,GAAG,CAAC;IAyBhE;yDACqD;IACrD,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;CAIxC;AAWD;uDACuD;AACvD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,gBAAgB,EACzB,MAAM,SAAkB,GACvB,WAAW,CAAC,mBAAmB,CAAC,CA4BlC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAG1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,CAAC,GAAG,CAAC,CAI/E"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { currentTraceId } from '../context_accessor.js';
|
|
2
|
+
import { EntryType } from '../entry.js';
|
|
3
|
+
import { safeRecord } from './record.js';
|
|
4
|
+
/** The `type` of the entries this watcher records. */
|
|
5
|
+
export const PROFILE_ENTRY_TYPE = EntryType.Profile;
|
|
6
|
+
/** Default slow-span threshold in milliseconds. */
|
|
7
|
+
const DEFAULT_SLOW_MS = 100;
|
|
8
|
+
/** A no-op session returned when profiling is not enabled — zero recording cost. */
|
|
9
|
+
const NOOP_SESSION = {
|
|
10
|
+
mark() {
|
|
11
|
+
return this;
|
|
12
|
+
},
|
|
13
|
+
end() { },
|
|
14
|
+
fail() { },
|
|
15
|
+
};
|
|
16
|
+
/** The live session backed by a configured watcher. */
|
|
17
|
+
class ActiveProfileSession {
|
|
18
|
+
watcher;
|
|
19
|
+
label;
|
|
20
|
+
startedAt;
|
|
21
|
+
marks = [];
|
|
22
|
+
settled = false;
|
|
23
|
+
constructor(watcher, label, startedAt) {
|
|
24
|
+
this.watcher = watcher;
|
|
25
|
+
this.label = label;
|
|
26
|
+
this.startedAt = startedAt;
|
|
27
|
+
}
|
|
28
|
+
mark(label) {
|
|
29
|
+
if (this.settled)
|
|
30
|
+
return this;
|
|
31
|
+
this.marks.push({ label, atMs: Math.max(0, this.watcher.now() - this.startedAt) });
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
end() {
|
|
35
|
+
this.settle('completed', undefined);
|
|
36
|
+
}
|
|
37
|
+
fail(error) {
|
|
38
|
+
this.settle('failed', error);
|
|
39
|
+
}
|
|
40
|
+
settle(status, error) {
|
|
41
|
+
if (this.settled)
|
|
42
|
+
return;
|
|
43
|
+
this.settled = true;
|
|
44
|
+
this.watcher.record({
|
|
45
|
+
label: this.label,
|
|
46
|
+
durationMs: Math.max(0, this.watcher.now() - this.startedAt),
|
|
47
|
+
status,
|
|
48
|
+
marks: this.marks,
|
|
49
|
+
error,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Cross-copy-stable slot holding the provider-configured default watcher, so the
|
|
55
|
+
* standalone {@link profile} / {@link startProfile} helpers inherit the app's
|
|
56
|
+
* configured `slowMs` / `minDurationMs` — and, crucially, are a NO-OP until the
|
|
57
|
+
* provider starts the watcher (profiling stays strictly opt-in). A `Symbol.for`
|
|
58
|
+
* global slot keeps two copies of this package in agreement, mirroring the
|
|
59
|
+
* http-client watcher's default-slot stance.
|
|
60
|
+
*/
|
|
61
|
+
const DEFAULT_SLOT = Symbol.for('@agora/telescope:defaultProfilingWatcher');
|
|
62
|
+
const slotHost = globalThis;
|
|
63
|
+
function setDefaultProfilingWatcher(watcher) {
|
|
64
|
+
slotHost[DEFAULT_SLOT] = watcher;
|
|
65
|
+
}
|
|
66
|
+
function getDefaultProfilingWatcher() {
|
|
67
|
+
return slotHost[DEFAULT_SLOT] ?? null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Records user-instrumented profiling spans as `profile` telescope entries — one
|
|
71
|
+
* per timed code section, capturing its label, total duration, in-span timing
|
|
72
|
+
* marks, and outcome (completed/failed), correlated to the active trace.
|
|
73
|
+
*
|
|
74
|
+
* ## How it works
|
|
75
|
+
* Unlike the emitter-driven watchers, profiling is DRIVEN BY THE USER: there is
|
|
76
|
+
* no event to tap. Wrap a code section with {@link profile} (or bracket it with
|
|
77
|
+
* {@link startProfile} + {@link ProfileSession.end}); the watcher times it and
|
|
78
|
+
* records one entry. It never monkey-patches anything and carries no cost while
|
|
79
|
+
* disabled — the standalone helpers are a no-op until the provider calls
|
|
80
|
+
* {@link start}.
|
|
81
|
+
*
|
|
82
|
+
* Each entry carries `familyHash` (the label) and `durationMs`, so repeated spans
|
|
83
|
+
* of the same label roll up and feed the slow-hotspot metrics cards. Recording is
|
|
84
|
+
* fire-and-forget and fully guarded: a telescope failure can never break the code
|
|
85
|
+
* being profiled.
|
|
86
|
+
*
|
|
87
|
+
* Idiomatic Adonis: a plain class, no DI decorators. The provider constructs it
|
|
88
|
+
* from `config/telescope_watchers.ts` and calls {@link start} to publish it as the
|
|
89
|
+
* default backing the bare {@link profile} / {@link startProfile} helpers;
|
|
90
|
+
* {@link stop} unpublishes.
|
|
91
|
+
*/
|
|
92
|
+
export class ProfilingWatcher {
|
|
93
|
+
type = EntryType.Profile;
|
|
94
|
+
slowMs;
|
|
95
|
+
minDurationMs;
|
|
96
|
+
clock;
|
|
97
|
+
constructor(options = {}) {
|
|
98
|
+
this.slowMs = options.slowMs ?? DEFAULT_SLOW_MS;
|
|
99
|
+
this.minDurationMs = Math.max(0, options.minDurationMs ?? 0);
|
|
100
|
+
this.clock = options.clock ?? { now: () => Date.now() };
|
|
101
|
+
}
|
|
102
|
+
/** The watcher's time source (used by its sessions). */
|
|
103
|
+
now() {
|
|
104
|
+
return this.clock.now();
|
|
105
|
+
}
|
|
106
|
+
/** Publish this configured instance as the default the standalone
|
|
107
|
+
* {@link profile} / {@link startProfile} helpers inherit. Does NOT patch any
|
|
108
|
+
* global. Named `start`/`stop` to match the other watchers' provider lifecycle. */
|
|
109
|
+
start() {
|
|
110
|
+
setDefaultProfilingWatcher(this);
|
|
111
|
+
}
|
|
112
|
+
/** Unpublish this instance as the default (if it is). Never touches globals. */
|
|
113
|
+
stop() {
|
|
114
|
+
if (getDefaultProfilingWatcher() === this)
|
|
115
|
+
setDefaultProfilingWatcher(null);
|
|
116
|
+
}
|
|
117
|
+
/** Begin a profiling span. Add marks on the returned session, then `end()`/`fail()`. */
|
|
118
|
+
startProfile(label) {
|
|
119
|
+
return new ActiveProfileSession(this, label, this.clock.now());
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Time `fn` as a profiling span. The span's session is passed to `fn` so it can
|
|
123
|
+
* add timing marks. Records `completed` on return / resolve and `failed` on
|
|
124
|
+
* throw / reject, always re-throwing so the caller's control flow is untouched.
|
|
125
|
+
* Works with sync and async `fn`.
|
|
126
|
+
*/
|
|
127
|
+
profile(label, fn) {
|
|
128
|
+
const session = this.startProfile(label);
|
|
129
|
+
let result;
|
|
130
|
+
try {
|
|
131
|
+
result = fn(session);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
session.fail(error);
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
if (isPromiseLike(result)) {
|
|
138
|
+
return result.then((value) => {
|
|
139
|
+
session.end();
|
|
140
|
+
return value;
|
|
141
|
+
}, (error) => {
|
|
142
|
+
session.fail(error);
|
|
143
|
+
throw error;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
session.end();
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/** Record one already-completed span. Spans below `minDurationMs` are dropped;
|
|
150
|
+
* recording is fire-and-forget and never throws. */
|
|
151
|
+
record(profile) {
|
|
152
|
+
if (profile.durationMs < this.minDurationMs)
|
|
153
|
+
return;
|
|
154
|
+
safeRecord(buildProfileEntry(profile, this.slowMs), 'ProfilingWatcher');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** Narrow a value to a thenable so async `fn`s are awaited without importing a Promise type. */
|
|
158
|
+
function isPromiseLike(value) {
|
|
159
|
+
return (typeof value === 'object' &&
|
|
160
|
+
value !== null &&
|
|
161
|
+
typeof value.then === 'function');
|
|
162
|
+
}
|
|
163
|
+
/** Map a completed span to a telescope {@link RecordInput}. Exported so the entry
|
|
164
|
+
* shape can be unit-tested without a live watcher. */
|
|
165
|
+
export function buildProfileEntry(profile, slowMs = DEFAULT_SLOW_MS) {
|
|
166
|
+
const durationMs = Math.max(0, profile.durationMs);
|
|
167
|
+
const failed = profile.status === 'failed';
|
|
168
|
+
const failureReason = failed && profile.error !== undefined ? errorMessage(profile.error) : null;
|
|
169
|
+
const traceId = currentTraceId();
|
|
170
|
+
const content = {
|
|
171
|
+
label: profile.label,
|
|
172
|
+
durationMs,
|
|
173
|
+
status: profile.status,
|
|
174
|
+
marks: profile.marks,
|
|
175
|
+
failureReason,
|
|
176
|
+
traceId,
|
|
177
|
+
};
|
|
178
|
+
const tags = ['profile', `profile:${profile.label}`];
|
|
179
|
+
if (failed)
|
|
180
|
+
tags.push('failed');
|
|
181
|
+
if (durationMs >= slowMs)
|
|
182
|
+
tags.push('slow');
|
|
183
|
+
return {
|
|
184
|
+
type: EntryType.Profile,
|
|
185
|
+
// Group by label so every run of the same span rolls up — the slow-hotspot key.
|
|
186
|
+
familyHash: `profile:${profile.label}`,
|
|
187
|
+
content,
|
|
188
|
+
durationMs,
|
|
189
|
+
traceId,
|
|
190
|
+
tags,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function errorMessage(error) {
|
|
194
|
+
return error instanceof Error ? error.message : String(error);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Begin a profiling span through the provider-published default watcher. Returns a
|
|
198
|
+
* NO-OP session (nothing recorded) when the profiling watcher is not enabled, so
|
|
199
|
+
* this is safe to leave in code unconditionally.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* import { startProfile } from '@adonis-agora/telescope/watchers'
|
|
203
|
+
* const span = startProfile('checkout')
|
|
204
|
+
* // ... work ...
|
|
205
|
+
* span.mark('validated')
|
|
206
|
+
* // ... more work ...
|
|
207
|
+
* span.end()
|
|
208
|
+
*/
|
|
209
|
+
export function startProfile(label) {
|
|
210
|
+
const watcher = getDefaultProfilingWatcher();
|
|
211
|
+
return watcher ? watcher.startProfile(label) : NOOP_SESSION;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Time `fn` as a profiling span through the provider-published default watcher.
|
|
215
|
+
* A no-op passthrough (just runs `fn`) when the profiling watcher is not enabled.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* import { profile } from '@adonis-agora/telescope/watchers'
|
|
219
|
+
* const order = await profile('checkout', async (span) => {
|
|
220
|
+
* const cart = await loadCart()
|
|
221
|
+
* span.mark('cart-loaded')
|
|
222
|
+
* return placeOrder(cart)
|
|
223
|
+
* })
|
|
224
|
+
*/
|
|
225
|
+
export function profile(label, fn) {
|
|
226
|
+
const watcher = getDefaultProfilingWatcher();
|
|
227
|
+
if (watcher)
|
|
228
|
+
return watcher.profile(label, fn);
|
|
229
|
+
return fn(NOOP_SESSION);
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=profiling_watcher.js.map
|
|
@@ -0,0 +1 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AgF;QAChF,UAAU,EAAE,WAAW,OAAO,CAAC,KAAK,EAAE;QACtC,OAAO;QACP,UAAU;QACV,OAAO;QACP,IAAI;KACL,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,OAAO,GAAG,0BAA0B,EAAE,CAAC;IAC7C,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO,CAAI,KAAa,EAAE,EAAkC;IAC1E,MAAM,OAAO,GAAG,0BAA0B,EAAE,CAAC;IAC7C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* from `nestjs-telescope`'s query family-hash so a dashboard can roll up every
|
|
4
4
|
* execution of `select * from users where id = ?` regardless of the id.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Grouping key for "the same query". With `normalize` on (the default) the SQL is
|
|
8
|
+
* templated first, so every execution of the same shape shares a hash regardless
|
|
9
|
+
* of bound values; with it off the raw SQL is hashed verbatim (whitespace/literals
|
|
10
|
+
* distinguish entries — no cross-execution grouping).
|
|
11
|
+
*/
|
|
12
|
+
export declare function queryFamilyHash(sql: string, normalize?: boolean): string;
|
|
8
13
|
//# sourceMappingURL=query_family_hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query_family_hash.d.ts","sourceRoot":"","sources":["../../../src/watchers/query_family_hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH
|
|
1
|
+
{"version":3,"file":"query_family_hash.d.ts","sourceRoot":"","sources":["../../../src/watchers/query_family_hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM,CAErE"}
|
|
@@ -24,8 +24,13 @@ function fnv1a(input) {
|
|
|
24
24
|
}
|
|
25
25
|
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Grouping key for "the same query". With `normalize` on (the default) the SQL is
|
|
29
|
+
* templated first, so every execution of the same shape shares a hash regardless
|
|
30
|
+
* of bound values; with it off the raw SQL is hashed verbatim (whitespace/literals
|
|
31
|
+
* distinguish entries — no cross-execution grouping).
|
|
32
|
+
*/
|
|
33
|
+
export function queryFamilyHash(sql, normalize = true) {
|
|
34
|
+
return fnv1a(normalize ? normalizeSql(sql) : sql);
|
|
30
35
|
}
|
|
31
36
|
//# sourceMappingURL=query_family_hash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query_family_hash.js","sourceRoot":"","sources":["../../../src/watchers/query_family_hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG;SACP,WAAW,EAAE;SACb,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,kBAAkB;SAClD,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,mBAAmB;SACtD,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,8EAA8E;AAC9E,SA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AAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,SAAS,GAAG,IAAI;IAC3D,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/watchers/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,cAAc,GAAG,IAAI,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/watchers/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,cAAc,GAAG,IAAI,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAsBnE"}
|
|
@@ -31,6 +31,10 @@ export function safeRecord(input, source) {
|
|
|
31
31
|
}
|
|
32
32
|
if (!store)
|
|
33
33
|
return;
|
|
34
|
+
// Honour the overload guard's shed flag: while paused, drop new entries so a
|
|
35
|
+
// lagging event loop is never made worse by telescope's own write path.
|
|
36
|
+
if (getTelescopeRuntime().paused)
|
|
37
|
+
return;
|
|
34
38
|
try {
|
|
35
39
|
const resolved = input.traceId === undefined ? { ...input, traceId: currentTraceId() } : input;
|
|
36
40
|
// Fire-and-forget: the store is async but the subscriber is sync. Swallow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/watchers/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,mBAAmB,EAAE,CAAC,KAAK,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,MAAc;IAC3D,IAAI,KAA4B,CAAC;IACjC,IAAI,CAAC;QACH,KAAK,GAAG,YAAY,EAAE,CAAC;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO;IACT,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/watchers/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,mBAAmB,EAAE,CAAC,KAAK,CAAC;AACrC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,MAAc;IAC3D,IAAI,KAA4B,CAAC;IACjC,IAAI,CAAC;QACH,KAAK,GAAG,YAAY,EAAE,CAAC;IACzB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACzB,OAA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