@a-company/sentinel 0.2.0 → 3.6.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/dist/adapters/express.d.ts +3 -1
- package/dist/adapters/fastify.d.ts +3 -1
- package/dist/adapters/hono.d.ts +3 -1
- package/dist/chunk-NTX74ZPM.js +2624 -0
- package/dist/chunk-VQ3SIN7S.js +422 -0
- package/dist/cli.js +6 -6
- package/dist/{commands-KIMGFR2I.js → commands-E7ACLOE7.js} +2367 -258
- package/dist/{dist-2F7NO4H4.js → dist-AG5JNIZU.js} +27 -2
- package/dist/{dist-BPWLYV4U.js → dist-TYG2XME3.js} +27 -2
- package/dist/index.d.ts +57 -5
- package/dist/index.js +288 -186
- package/dist/mcp.js +1538 -124
- package/dist/sdk-CzFDYYST.d.ts +180 -0
- package/dist/server/index.d.ts +20 -3
- package/dist/server/index.js +805 -9
- package/dist/storage-BKyt7aPJ.d.ts +319 -0
- package/dist/transport-DqamniUy.d.ts +185 -0
- package/dist/transport.d.ts +2 -0
- package/dist/transport.js +10 -0
- package/dist/{sdk-B27_vK1g.d.ts → types-BmVoO1iF.d.ts} +196 -259
- package/package.json +15 -1
- package/ui/dist/assets/index-BuK-X6af.js +62 -0
- package/ui/dist/assets/index-BuK-X6af.js.map +1 -0
- package/ui/dist/assets/{index-DPxatSdT.css → index-DCtwmE2_.css} +1 -1
- package/ui/dist/index.html +2 -2
- package/dist/chunk-KPMG4XED.js +0 -1249
- package/ui/dist/assets/index-BNgsn_C8.js +0 -62
- package/ui/dist/assets/index-BNgsn_C8.js.map +0 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { l as CreateIncidentInput, a as SymbolicIncidentRecord, w as IncidentQueryOptions, v as IncidentNote, m as CreatePatternInput, e as FailurePattern, Z as PatternQueryOptions, k as CreateGroupInput, I as IncidentGroup, ab as ResolutionQueryOptions, ac as ResolutionRecord, b as SentinelStats, c as SymbolHealth, f as PatternExport, B as BackupExport, a5 as PracticeEventInput, a6 as PracticeEventQuery, a4 as PracticeEvent, y as LogEntryInput, G as LogQueryOptions, L as LogEntry, ag as ServiceRegistration, af as ServiceInfo, A as AppState, Q as MetricInput, R as MetricQueryOptions, O as MetricEntry, N as MetricAggregation, an as TraceSpanInput, ao as TraceView } from './types-BmVoO1iF.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Schema Registry — Application-Agnostic Event Schema Types
|
|
5
|
+
*
|
|
6
|
+
* Applications register their own event schemas, and Sentinel ingests,
|
|
7
|
+
* stores, queries, and visualizes any structured event data.
|
|
8
|
+
*/
|
|
9
|
+
interface EventSchemaDeclaration {
|
|
10
|
+
/** Unique schema identifier, e.g. "pretend-engine", "paradigm-logger" */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Schema version (semver) */
|
|
13
|
+
version: string;
|
|
14
|
+
/** Human-readable name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Optional description */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Temporal grouping primitive */
|
|
19
|
+
scope: ScopeDeclaration;
|
|
20
|
+
/** Event type definitions */
|
|
21
|
+
eventTypes: EventTypeDeclaration[];
|
|
22
|
+
/** Causality tracking configuration */
|
|
23
|
+
causality?: CausalityDeclaration;
|
|
24
|
+
/** Visualization hints for the UI */
|
|
25
|
+
visualization?: VisualizationHints;
|
|
26
|
+
/** Classification tags */
|
|
27
|
+
tags?: string[];
|
|
28
|
+
}
|
|
29
|
+
interface ScopeDeclaration {
|
|
30
|
+
/** Field name for temporal grouping, e.g. "frame", "requestId", "tick" */
|
|
31
|
+
field: string;
|
|
32
|
+
/** Field type */
|
|
33
|
+
type: 'number' | 'string';
|
|
34
|
+
/** Human-readable label, e.g. "Frame", "Request" */
|
|
35
|
+
label: string;
|
|
36
|
+
/** Whether scopes are sequential (ordered) or independent */
|
|
37
|
+
ordering: 'sequential' | 'independent';
|
|
38
|
+
/** Optional session field for grouping scopes */
|
|
39
|
+
sessionField?: string;
|
|
40
|
+
}
|
|
41
|
+
interface EventTypeDeclaration {
|
|
42
|
+
/** Event type identifier, e.g. "rule:fire", "state:set" */
|
|
43
|
+
type: string;
|
|
44
|
+
/** Category for grouping, e.g. "rules", "state" */
|
|
45
|
+
category: string;
|
|
46
|
+
/** Human-readable label */
|
|
47
|
+
label?: string;
|
|
48
|
+
/** Description of what this event type represents */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** Field declarations for event data */
|
|
51
|
+
fields?: EventFieldDeclaration[];
|
|
52
|
+
/** Expected frequency */
|
|
53
|
+
frequency?: 'high' | 'medium' | 'low';
|
|
54
|
+
/** Default severity level */
|
|
55
|
+
severity?: 'debug' | 'info' | 'warn' | 'error';
|
|
56
|
+
}
|
|
57
|
+
interface EventFieldDeclaration {
|
|
58
|
+
/** Field name */
|
|
59
|
+
name: string;
|
|
60
|
+
/** Field type */
|
|
61
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
62
|
+
/** Description */
|
|
63
|
+
description?: string;
|
|
64
|
+
/** Whether to create a database index on this field */
|
|
65
|
+
indexed?: boolean;
|
|
66
|
+
/** Whether to show this field in default table view */
|
|
67
|
+
display?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface CausalityDeclaration {
|
|
70
|
+
/** Field name for parent event reference */
|
|
71
|
+
parentField?: string;
|
|
72
|
+
/** Field for cascade depth, e.g. "pass" for cascade passes */
|
|
73
|
+
depthField?: string;
|
|
74
|
+
/** Event types that start a scope, e.g. ["tick:frame"] */
|
|
75
|
+
scopeStart?: string[];
|
|
76
|
+
/** Event types that end a scope, e.g. ["cascade:complete"] */
|
|
77
|
+
scopeEnd?: string[];
|
|
78
|
+
}
|
|
79
|
+
interface VisualizationHints {
|
|
80
|
+
/** Default view mode */
|
|
81
|
+
defaultView?: 'timeline' | 'table' | 'tree' | 'flame';
|
|
82
|
+
/** Category → color mapping */
|
|
83
|
+
categoryColors?: Record<string, string>;
|
|
84
|
+
/** Fields to show in summary/header */
|
|
85
|
+
summaryFields?: string[];
|
|
86
|
+
/** High-frequency event types hidden by default */
|
|
87
|
+
defaultExcluded?: string[];
|
|
88
|
+
}
|
|
89
|
+
interface GenericEvent {
|
|
90
|
+
/** Unique event ID */
|
|
91
|
+
id: string;
|
|
92
|
+
/** Schema this event belongs to */
|
|
93
|
+
schemaId: string;
|
|
94
|
+
/** Event type, e.g. "rule:fire" */
|
|
95
|
+
eventType: string;
|
|
96
|
+
/** Category, e.g. "rules" */
|
|
97
|
+
category: string;
|
|
98
|
+
/** ISO timestamp */
|
|
99
|
+
timestamp: string;
|
|
100
|
+
/** Scope value (frame number, request ID, etc.) */
|
|
101
|
+
scopeValue?: string;
|
|
102
|
+
/** Numeric ordinal for sequential scopes */
|
|
103
|
+
scopeOrdinal?: number;
|
|
104
|
+
/** Session identifier */
|
|
105
|
+
sessionId?: string;
|
|
106
|
+
/** Service/app that emitted the event */
|
|
107
|
+
service: string;
|
|
108
|
+
/** Event-specific data */
|
|
109
|
+
data?: Record<string, unknown>;
|
|
110
|
+
/** Severity level */
|
|
111
|
+
severity?: 'debug' | 'info' | 'warn' | 'error';
|
|
112
|
+
/** Parent event ID for causality tracking */
|
|
113
|
+
parentEventId?: string;
|
|
114
|
+
/** Depth in causality tree */
|
|
115
|
+
depth?: number;
|
|
116
|
+
}
|
|
117
|
+
interface GenericEventInput {
|
|
118
|
+
/** Optional pre-assigned ID (auto-generated if omitted) */
|
|
119
|
+
id?: string;
|
|
120
|
+
/** Event type, e.g. "rule:fire" */
|
|
121
|
+
type: string;
|
|
122
|
+
/** ISO timestamp (auto-generated if omitted) */
|
|
123
|
+
timestamp?: string;
|
|
124
|
+
/** Scope value */
|
|
125
|
+
scopeValue?: string | number;
|
|
126
|
+
/** Session identifier */
|
|
127
|
+
sessionId?: string;
|
|
128
|
+
/** Event-specific data */
|
|
129
|
+
data?: Record<string, unknown>;
|
|
130
|
+
/** Severity override (resolved from schema defaults if omitted) */
|
|
131
|
+
severity?: 'debug' | 'info' | 'warn' | 'error';
|
|
132
|
+
/** Parent event ID */
|
|
133
|
+
parentEventId?: string;
|
|
134
|
+
/** Depth in causality tree */
|
|
135
|
+
depth?: number;
|
|
136
|
+
}
|
|
137
|
+
interface GenericEventQuery {
|
|
138
|
+
schemaId?: string;
|
|
139
|
+
eventType?: string;
|
|
140
|
+
category?: string;
|
|
141
|
+
service?: string;
|
|
142
|
+
sessionId?: string;
|
|
143
|
+
scopeValue?: string;
|
|
144
|
+
scopeFrom?: string;
|
|
145
|
+
scopeTo?: string;
|
|
146
|
+
severity?: string;
|
|
147
|
+
since?: string;
|
|
148
|
+
until?: string;
|
|
149
|
+
search?: string;
|
|
150
|
+
limit?: number;
|
|
151
|
+
offset?: number;
|
|
152
|
+
}
|
|
153
|
+
interface ScopeSummary {
|
|
154
|
+
scopeValue: string;
|
|
155
|
+
scopeOrdinal?: number;
|
|
156
|
+
eventCount: number;
|
|
157
|
+
categories: Record<string, number>;
|
|
158
|
+
firstTimestamp: string;
|
|
159
|
+
lastTimestamp: string;
|
|
160
|
+
}
|
|
161
|
+
interface StoredSchema {
|
|
162
|
+
id: string;
|
|
163
|
+
version: string;
|
|
164
|
+
name: string;
|
|
165
|
+
description?: string;
|
|
166
|
+
scope: ScopeDeclaration;
|
|
167
|
+
eventTypes: EventTypeDeclaration[];
|
|
168
|
+
causality?: CausalityDeclaration;
|
|
169
|
+
visualization?: VisualizationHints;
|
|
170
|
+
tags: string[];
|
|
171
|
+
registeredAt: string;
|
|
172
|
+
updatedAt: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Paradigm Sentinel - SQLite Storage Layer
|
|
177
|
+
*
|
|
178
|
+
* Persistent storage for incidents, patterns, groups, and resolutions.
|
|
179
|
+
* Uses sql.js for pure JavaScript SQLite (no native compilation needed).
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
declare class SentinelStorage {
|
|
183
|
+
private db;
|
|
184
|
+
private dbPath;
|
|
185
|
+
private incidentCounter;
|
|
186
|
+
private initialized;
|
|
187
|
+
constructor(dbPath?: string);
|
|
188
|
+
private getDefaultDbPath;
|
|
189
|
+
private createSchema;
|
|
190
|
+
private save;
|
|
191
|
+
recordIncident(input: CreateIncidentInput): string;
|
|
192
|
+
private initializeSync;
|
|
193
|
+
/**
|
|
194
|
+
* Run schema migrations from older versions
|
|
195
|
+
*/
|
|
196
|
+
private migrateSchema;
|
|
197
|
+
/**
|
|
198
|
+
* Ensure the storage is ready for use. Must be called once before using storage methods.
|
|
199
|
+
*/
|
|
200
|
+
ensureReady(): Promise<void>;
|
|
201
|
+
getIncident(id: string): SymbolicIncidentRecord | null;
|
|
202
|
+
getRecentIncidents(options?: IncidentQueryOptions): SymbolicIncidentRecord[];
|
|
203
|
+
updateIncident(id: string, updates: Partial<SymbolicIncidentRecord>): void;
|
|
204
|
+
addIncidentNote(incidentId: string, note: Omit<IncidentNote, 'id'>): void;
|
|
205
|
+
linkIncidents(incidentId: string, relatedId: string): void;
|
|
206
|
+
getIncidentCount(options?: IncidentQueryOptions): number;
|
|
207
|
+
addPattern(input: CreatePatternInput): string;
|
|
208
|
+
getPattern(id: string): FailurePattern | null;
|
|
209
|
+
getAllPatterns(options?: PatternQueryOptions): FailurePattern[];
|
|
210
|
+
updatePattern(id: string, updates: Partial<FailurePattern>): void;
|
|
211
|
+
deletePattern(id: string): void;
|
|
212
|
+
updatePatternConfidence(patternId: string, event: 'matched' | 'resolved' | 'recurred'): void;
|
|
213
|
+
createGroup(input: CreateGroupInput): string;
|
|
214
|
+
getGroup(id: string): IncidentGroup | null;
|
|
215
|
+
getGroups(options?: {
|
|
216
|
+
limit?: number;
|
|
217
|
+
}): IncidentGroup[];
|
|
218
|
+
addToGroup(groupId: string, incidentId: string): void;
|
|
219
|
+
recordResolution(resolution: {
|
|
220
|
+
incidentId: string;
|
|
221
|
+
patternId?: string;
|
|
222
|
+
commitHash?: string;
|
|
223
|
+
prUrl?: string;
|
|
224
|
+
notes?: string;
|
|
225
|
+
}): void;
|
|
226
|
+
markRecurred(incidentId: string): void;
|
|
227
|
+
getResolutionHistory(options?: ResolutionQueryOptions): ResolutionRecord[];
|
|
228
|
+
getStats(period: {
|
|
229
|
+
start: string;
|
|
230
|
+
end: string;
|
|
231
|
+
}): SentinelStats;
|
|
232
|
+
getSymbolHealth(symbol: string): SymbolHealth;
|
|
233
|
+
exportPatterns(options?: {
|
|
234
|
+
includePrivate?: boolean;
|
|
235
|
+
}): PatternExport;
|
|
236
|
+
importPatterns(data: PatternExport, options?: {
|
|
237
|
+
overwrite?: boolean;
|
|
238
|
+
}): {
|
|
239
|
+
imported: number;
|
|
240
|
+
skipped: number;
|
|
241
|
+
};
|
|
242
|
+
exportBackup(): BackupExport;
|
|
243
|
+
importBackup(data: BackupExport): void;
|
|
244
|
+
private rowToIncident;
|
|
245
|
+
private rowToPattern;
|
|
246
|
+
private rowToGroup;
|
|
247
|
+
recordPracticeEvent(input: PracticeEventInput): string;
|
|
248
|
+
getPracticeEvents(options?: PracticeEventQuery): PracticeEvent[];
|
|
249
|
+
getPracticeEventCount(options?: PracticeEventQuery): number;
|
|
250
|
+
getComplianceRate(options?: PracticeEventQuery): {
|
|
251
|
+
total: number;
|
|
252
|
+
followed: number;
|
|
253
|
+
skipped: number;
|
|
254
|
+
partial: number;
|
|
255
|
+
rate: number;
|
|
256
|
+
};
|
|
257
|
+
private rowToPracticeEvent;
|
|
258
|
+
private inferSymbolType;
|
|
259
|
+
insertLog(input: LogEntryInput): string;
|
|
260
|
+
insertLogBatch(entries: LogEntryInput[]): {
|
|
261
|
+
accepted: number;
|
|
262
|
+
errors: string[];
|
|
263
|
+
};
|
|
264
|
+
queryLogs(options?: LogQueryOptions): LogEntry[];
|
|
265
|
+
getLogCount(options?: LogQueryOptions): number;
|
|
266
|
+
pruneLogs(maxCount: number): number;
|
|
267
|
+
private rowToLogEntry;
|
|
268
|
+
registerService(reg: ServiceRegistration): void;
|
|
269
|
+
updateServiceLastSeen(name: string): void;
|
|
270
|
+
getServices(): ServiceInfo[];
|
|
271
|
+
upsertAppState(state: AppState): void;
|
|
272
|
+
getAppState(service: string, sessionId?: string): AppState[];
|
|
273
|
+
getAllAppStates(): AppState[];
|
|
274
|
+
private rowToAppState;
|
|
275
|
+
insertMetric(input: MetricInput): string;
|
|
276
|
+
insertMetricBatch(entries: MetricInput[]): {
|
|
277
|
+
accepted: number;
|
|
278
|
+
errors: string[];
|
|
279
|
+
};
|
|
280
|
+
queryMetrics(options?: MetricQueryOptions): MetricEntry[];
|
|
281
|
+
getMetricCount(options?: MetricQueryOptions): number;
|
|
282
|
+
aggregateMetric(name: string, options?: {
|
|
283
|
+
service?: string;
|
|
284
|
+
since?: string;
|
|
285
|
+
until?: string;
|
|
286
|
+
}): MetricAggregation;
|
|
287
|
+
pruneMetrics(maxCount: number): number;
|
|
288
|
+
private rowToMetricEntry;
|
|
289
|
+
insertSpan(input: TraceSpanInput): string;
|
|
290
|
+
getTrace(traceId: string): TraceView | null;
|
|
291
|
+
queryTraces(options?: {
|
|
292
|
+
service?: string;
|
|
293
|
+
symbol?: string;
|
|
294
|
+
since?: string;
|
|
295
|
+
limit?: number;
|
|
296
|
+
}): TraceView[];
|
|
297
|
+
private rowToTraceSpan;
|
|
298
|
+
registerSchema(schema: EventSchemaDeclaration): StoredSchema;
|
|
299
|
+
getSchema(id: string): StoredSchema | null;
|
|
300
|
+
listSchemas(): StoredSchema[];
|
|
301
|
+
private rowToSchema;
|
|
302
|
+
insertEventBatch(schemaId: string, service: string, inputs: GenericEventInput[]): {
|
|
303
|
+
accepted: number;
|
|
304
|
+
errors: string[];
|
|
305
|
+
};
|
|
306
|
+
queryEvents(options?: GenericEventQuery): GenericEvent[];
|
|
307
|
+
queryEventsByScope(schemaId: string, scopeValue: string): GenericEvent[];
|
|
308
|
+
getEventScopes(schemaId: string, options?: {
|
|
309
|
+
limit?: number;
|
|
310
|
+
offset?: number;
|
|
311
|
+
sessionId?: string;
|
|
312
|
+
}): ScopeSummary[];
|
|
313
|
+
getEventCount(options?: GenericEventQuery): number;
|
|
314
|
+
pruneEvents(maxCount: number): number;
|
|
315
|
+
private rowToGenericEvent;
|
|
316
|
+
close(): void;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export { type CausalityDeclaration as C, type EventSchemaDeclaration as E, type GenericEvent as G, SentinelStorage as S, type VisualizationHints as V, type EventFieldDeclaration as a, type EventTypeDeclaration as b, type GenericEventInput as c, type GenericEventQuery as d, type ScopeDeclaration as e, type ScopeSummary as f, type StoredSchema as g };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z as LogLevel, Q as MetricInput } from './types-BmVoO1iF.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel Client SDK
|
|
5
|
+
*
|
|
6
|
+
* Lightweight client for sending structured logs to the Sentinel server.
|
|
7
|
+
* Features batching, ring buffer, auto-retry, and graceful degradation.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { createSentinelClient } from '@a-company/sentinel';
|
|
11
|
+
* const client = createSentinelClient({ service: 'my-app' });
|
|
12
|
+
* client.info('#checkout', 'Order placed', { orderId: '123' });
|
|
13
|
+
* await client.close();
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface SentinelClientOptions {
|
|
17
|
+
/** Sentinel server URL (default: http://localhost:3838) */
|
|
18
|
+
url?: string;
|
|
19
|
+
/** Service name (required) */
|
|
20
|
+
service: string;
|
|
21
|
+
/** Service version */
|
|
22
|
+
version?: string;
|
|
23
|
+
/** Environment (development, staging, production) */
|
|
24
|
+
environment?: string;
|
|
25
|
+
/** Auth token for protected servers */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** Batch size before auto-flush (default: 50) */
|
|
28
|
+
batchSize?: number;
|
|
29
|
+
/** Flush interval in ms (default: 5000) */
|
|
30
|
+
flushIntervalMs?: number;
|
|
31
|
+
/** Max entries in ring buffer before dropping oldest (default: 1000) */
|
|
32
|
+
maxBufferSize?: number;
|
|
33
|
+
/** Max retry attempts on network failure (default: 3) */
|
|
34
|
+
maxRetries?: number;
|
|
35
|
+
/** Retry backoff base in ms (default: 1000) */
|
|
36
|
+
retryBackoffMs?: number;
|
|
37
|
+
/** Callback when entries are dropped from buffer overflow */
|
|
38
|
+
onDrop?: (count: number) => void;
|
|
39
|
+
/** Callback on flush error */
|
|
40
|
+
onError?: (error: Error) => void;
|
|
41
|
+
}
|
|
42
|
+
interface SpanContext {
|
|
43
|
+
traceId: string;
|
|
44
|
+
spanId: string;
|
|
45
|
+
end: (status?: 'ok' | 'error') => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
declare class SentinelClient {
|
|
48
|
+
private readonly url;
|
|
49
|
+
private readonly service;
|
|
50
|
+
private readonly version;
|
|
51
|
+
private readonly environment;
|
|
52
|
+
private readonly token;
|
|
53
|
+
private readonly batchSize;
|
|
54
|
+
private readonly maxBufferSize;
|
|
55
|
+
private readonly maxRetries;
|
|
56
|
+
private readonly retryBackoffMs;
|
|
57
|
+
private readonly onDrop;
|
|
58
|
+
private readonly onError;
|
|
59
|
+
private readonly sessionId;
|
|
60
|
+
private logBuffer;
|
|
61
|
+
private metricsBuffer;
|
|
62
|
+
private flushTimer;
|
|
63
|
+
private closed;
|
|
64
|
+
private beforeUnloadHandler;
|
|
65
|
+
constructor(options: SentinelClientOptions);
|
|
66
|
+
/** Log a debug-level message */
|
|
67
|
+
debug(symbol: string, message: string, data?: Record<string, unknown>): void;
|
|
68
|
+
/** Log an info-level message */
|
|
69
|
+
info(symbol: string, message: string, data?: Record<string, unknown>): void;
|
|
70
|
+
/** Log a warn-level message */
|
|
71
|
+
warn(symbol: string, message: string, data?: Record<string, unknown>): void;
|
|
72
|
+
/** Log an error-level message */
|
|
73
|
+
error(symbol: string, message: string, data?: Record<string, unknown>): void;
|
|
74
|
+
/** Log a message at the specified level */
|
|
75
|
+
log(level: LogLevel, symbol: string, message: string, data?: Record<string, unknown>): void;
|
|
76
|
+
/** Record a counter metric (increments) */
|
|
77
|
+
counter(name: string, value?: number, tags?: Record<string, string>): void;
|
|
78
|
+
/** Record a gauge metric (current value) */
|
|
79
|
+
gauge(name: string, value: number, tags?: Record<string, string>): void;
|
|
80
|
+
/** Record a histogram metric (distribution) */
|
|
81
|
+
histogram(name: string, value: number, tags?: Record<string, string>): void;
|
|
82
|
+
/** Record a metric of any type */
|
|
83
|
+
metric(input: Omit<MetricInput, 'service'>): void;
|
|
84
|
+
/** Push an application state snapshot to the server */
|
|
85
|
+
pushState(state: Record<string, unknown>, activeFlows?: string[], activeGates?: string[]): Promise<void>;
|
|
86
|
+
/** Start a trace span. Call end() on the returned SpanContext when the operation completes. */
|
|
87
|
+
startSpan(symbol: string, operation: string, parentSpanId?: string): SpanContext;
|
|
88
|
+
/** Flush all buffered logs and metrics to the server */
|
|
89
|
+
flush(): Promise<void>;
|
|
90
|
+
/** Flush remaining entries and shut down the client */
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
/** Get the session ID assigned to this client instance */
|
|
93
|
+
getSessionId(): string;
|
|
94
|
+
/**
|
|
95
|
+
* Synchronous best-effort flush using sendBeacon (browser) or sync XHR fallback.
|
|
96
|
+
* Used in beforeunload where async is unreliable.
|
|
97
|
+
*/
|
|
98
|
+
private flushSync;
|
|
99
|
+
/** Register this service with the Sentinel server (fire-and-forget) */
|
|
100
|
+
private registerService;
|
|
101
|
+
/** Push a log entry into the ring buffer, enforcing maxBufferSize */
|
|
102
|
+
private pushToLogBuffer;
|
|
103
|
+
/** Push a metric entry into the ring buffer, enforcing maxBufferSize */
|
|
104
|
+
private pushToMetricsBuffer;
|
|
105
|
+
/** Drain and return all entries from the log buffer */
|
|
106
|
+
private drainLogBuffer;
|
|
107
|
+
/** Drain and return all entries from the metrics buffer */
|
|
108
|
+
private drainMetricsBuffer;
|
|
109
|
+
/** Send log entries to the server with retry */
|
|
110
|
+
private sendLogs;
|
|
111
|
+
/** Send metric entries to the server with retry */
|
|
112
|
+
private sendMetrics;
|
|
113
|
+
/**
|
|
114
|
+
* POST JSON to the Sentinel server with exponential backoff retry.
|
|
115
|
+
* Retries on network errors and 5xx responses. Does NOT retry on 4xx.
|
|
116
|
+
*/
|
|
117
|
+
private post;
|
|
118
|
+
/** Get the fetch function, falling back to globalThis.fetch */
|
|
119
|
+
private getFetch;
|
|
120
|
+
/** Wait with exponential backoff */
|
|
121
|
+
private backoff;
|
|
122
|
+
/** Handle an error, calling the onError callback if provided */
|
|
123
|
+
private handleError;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a new SentinelClient instance.
|
|
127
|
+
*
|
|
128
|
+
* Usage:
|
|
129
|
+
* const client = createSentinelClient({ service: 'my-app', environment: 'production' });
|
|
130
|
+
* client.info('#checkout', 'Order placed', { orderId: '123' });
|
|
131
|
+
*/
|
|
132
|
+
declare function createSentinelClient(options: SentinelClientOptions): SentinelClient;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* SentinelTransport — Bridge between Paradigm Logger and Sentinel Client
|
|
136
|
+
*
|
|
137
|
+
* Uses structural typing to match LogTransport interface without
|
|
138
|
+
* importing from @a-company/paradigm-logger (avoids hard dependency).
|
|
139
|
+
*
|
|
140
|
+
* Usage:
|
|
141
|
+
* import { enableSentinel } from '@a-company/sentinel/transport';
|
|
142
|
+
* import { log } from '@a-company/paradigm-logger';
|
|
143
|
+
* enableSentinel(log, { service: 'my-app' });
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/** Structurally matches LogTransport.send() entry shape */
|
|
147
|
+
interface LogEntry {
|
|
148
|
+
level: string;
|
|
149
|
+
symbol: string;
|
|
150
|
+
symbolType: string;
|
|
151
|
+
message: string;
|
|
152
|
+
data?: Record<string, unknown>;
|
|
153
|
+
correlationId?: string;
|
|
154
|
+
timestamp: string;
|
|
155
|
+
}
|
|
156
|
+
/** Structurally matches ParadigmLogger.addTransport() */
|
|
157
|
+
interface LoggerWithTransports {
|
|
158
|
+
addTransport(transport: {
|
|
159
|
+
send(entry: LogEntry): void;
|
|
160
|
+
}): void;
|
|
161
|
+
removeTransport(transport: {
|
|
162
|
+
send(entry: LogEntry): void;
|
|
163
|
+
}): void;
|
|
164
|
+
}
|
|
165
|
+
declare class SentinelTransport {
|
|
166
|
+
readonly client: SentinelClient;
|
|
167
|
+
constructor(client: SentinelClient);
|
|
168
|
+
send(entry: LogEntry): void;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Create a SentinelTransport from an existing client or options.
|
|
172
|
+
*
|
|
173
|
+
* const transport = createSentinelTransport(client);
|
|
174
|
+
* log.addTransport(transport);
|
|
175
|
+
*/
|
|
176
|
+
declare function createSentinelTransport(clientOrOptions: SentinelClient | SentinelClientOptions): SentinelTransport;
|
|
177
|
+
/**
|
|
178
|
+
* One-line setup: creates a SentinelTransport and attaches it to a logger.
|
|
179
|
+
*
|
|
180
|
+
* import { log } from '@a-company/paradigm-logger';
|
|
181
|
+
* const transport = enableSentinel(log, { service: 'my-app' });
|
|
182
|
+
*/
|
|
183
|
+
declare function enableSentinel(logger: LoggerWithTransports, clientOrOptions: SentinelClient | SentinelClientOptions): SentinelTransport;
|
|
184
|
+
|
|
185
|
+
export { SentinelClient as S, type SentinelClientOptions as a, SentinelTransport as b, type SpanContext as c, createSentinelClient as d, createSentinelTransport as e, enableSentinel as f };
|