@syndew/oluso-plugin-telemetry 0.0.0-stage → 1.30.1

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.
@@ -0,0 +1,385 @@
1
+ import { AdminPlugin, NavItem, PaginatedResponse } from '@syndew/oluso-ui-core';
2
+ import { Routes } from '@angular/router';
3
+ import { Observable } from 'rxjs';
4
+ import * as _angular_core from '@angular/core';
5
+ import { OnInit, OnDestroy } from '@angular/core';
6
+
7
+ /**
8
+ * Telemetry Admin Plugin
9
+ *
10
+ * Provides system monitoring and observability functionality:
11
+ * - Dashboard with overview metrics
12
+ * - Application logs viewer with filtering and live tail
13
+ * - Distributed traces explorer
14
+ */
15
+ declare const TELEMETRY_PLUGIN: AdminPlugin;
16
+ /**
17
+ * Helper function to get Telemetry navigation items
18
+ */
19
+ declare function getTelemetryNavItems(): NavItem[];
20
+
21
+ declare const TELEMETRY_ROUTES: Routes;
22
+
23
+ /**
24
+ * Telemetry overview metrics
25
+ */
26
+ interface TelemetryMetrics {
27
+ tokensIssued: number;
28
+ tokensFailed: number;
29
+ activeUsers: number;
30
+ activeSessions: number;
31
+ authSuccessRate: number;
32
+ avgRequestDuration: number;
33
+ }
34
+ /**
35
+ * A single data point in a metric time series
36
+ */
37
+ interface MetricDataPoint {
38
+ timestamp: string;
39
+ value: number;
40
+ tags?: Record<string, string>;
41
+ }
42
+ /**
43
+ * Time series data for a specific metric
44
+ */
45
+ interface MetricSeries {
46
+ name: string;
47
+ unit: string;
48
+ data: MetricDataPoint[];
49
+ }
50
+ /**
51
+ * Log level types
52
+ */
53
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
54
+ /**
55
+ * Application log entry
56
+ */
57
+ interface LogEntry {
58
+ id: string;
59
+ timestamp: string;
60
+ level: LogLevel;
61
+ message: string;
62
+ category: string;
63
+ properties?: Record<string, unknown>;
64
+ exception?: string;
65
+ exceptionType?: string;
66
+ stackTrace?: string;
67
+ traceId?: string;
68
+ spanId?: string;
69
+ requestPath?: string;
70
+ requestMethod?: string;
71
+ userId?: string;
72
+ clientId?: string;
73
+ machineName?: string;
74
+ }
75
+ /**
76
+ * Audit log entry for security/compliance tracking
77
+ */
78
+ interface AuditLogEntry {
79
+ id: string;
80
+ timestamp: string;
81
+ category: string;
82
+ action: string;
83
+ eventType: string;
84
+ subjectId?: string;
85
+ subjectType?: string;
86
+ subjectName?: string;
87
+ subjectEmail?: string;
88
+ success: boolean;
89
+ ipAddress?: string;
90
+ userAgent?: string;
91
+ resourceType?: string;
92
+ resourceId?: string;
93
+ resourceName?: string;
94
+ details?: Record<string, unknown>;
95
+ tenantId?: string;
96
+ clientId?: string;
97
+ activityId?: string;
98
+ errorMessage?: string;
99
+ }
100
+ /**
101
+ * Trace status types
102
+ */
103
+ type TraceStatus = 'ok' | 'error' | 'unset';
104
+ /**
105
+ * An event within a trace span
106
+ */
107
+ interface TraceEvent {
108
+ name: string;
109
+ timestamp: string;
110
+ attributes?: Record<string, unknown>;
111
+ }
112
+ /**
113
+ * A span within a distributed trace
114
+ */
115
+ interface TraceSpan {
116
+ traceId: string;
117
+ spanId: string;
118
+ parentSpanId?: string;
119
+ operationName: string;
120
+ serviceName: string;
121
+ startTime: string;
122
+ duration: number;
123
+ status: TraceStatus;
124
+ tags: Record<string, string>;
125
+ events: TraceEvent[];
126
+ }
127
+ /**
128
+ * A complete distributed trace
129
+ */
130
+ interface Trace {
131
+ traceId: string;
132
+ rootSpan: TraceSpan;
133
+ spans: TraceSpan[];
134
+ duration: number;
135
+ startTime: string;
136
+ serviceName: string;
137
+ status: TraceStatus;
138
+ }
139
+ /**
140
+ * Query parameters for telemetry data
141
+ */
142
+ interface TelemetryQuery {
143
+ startTime?: string;
144
+ endTime?: string;
145
+ level?: string;
146
+ category?: string;
147
+ searchTerm?: string;
148
+ traceId?: string;
149
+ page?: number;
150
+ pageSize?: number;
151
+ }
152
+ /**
153
+ * Paginated response wrapper — alias kept for backward compatibility.
154
+ */
155
+ type PagedResult<T> = PaginatedResponse<T>;
156
+ /**
157
+ * Time range options for dashboard
158
+ */
159
+ type TimeRange = '1h' | '24h' | '7d' | '30d';
160
+ /**
161
+ * Get interval based on time range
162
+ */
163
+ declare function getIntervalForRange(range: TimeRange): string;
164
+ /**
165
+ * Format duration in ms to human readable string
166
+ */
167
+ declare function formatDuration(ms: number): string;
168
+ /**
169
+ * Log level display configuration (designed for dark terminal-style background)
170
+ */
171
+ declare const LOG_LEVEL_CONFIG: Record<LogLevel, {
172
+ textColor: string;
173
+ bgColor: string;
174
+ label: string;
175
+ }>;
176
+ /**
177
+ * Trace status display configuration
178
+ */
179
+ declare const TRACE_STATUS_CONFIG: Record<TraceStatus, {
180
+ textColor: string;
181
+ bgColor: string;
182
+ }>;
183
+
184
+ declare class TelemetryService {
185
+ private readonly api;
186
+ /**
187
+ * Get overview metrics for the telemetry dashboard
188
+ */
189
+ getOverviewMetrics(timeRange?: TimeRange): Observable<TelemetryMetrics>;
190
+ /**
191
+ * Get time series data for a specific metric
192
+ */
193
+ getMetricSeries(metricName: string, timeRange?: TimeRange): Observable<MetricSeries>;
194
+ /**
195
+ * Get application logs with filtering and pagination
196
+ */
197
+ getLogs(query: TelemetryQuery): Observable<PagedResult<LogEntry>>;
198
+ /**
199
+ * Get available log categories for filtering
200
+ */
201
+ getLogCategories(): Observable<string[]>;
202
+ /**
203
+ * Get distributed traces with filtering and pagination
204
+ */
205
+ getTraces(query: TelemetryQuery): Observable<PagedResult<Trace>>;
206
+ /**
207
+ * Get details of a specific trace by ID
208
+ */
209
+ getTrace(traceId: string): Observable<Trace>;
210
+ /**
211
+ * Trace backend configuration status. Used by the Traces page to render
212
+ * a "tracing not configured" notice in environments without Tempo.
213
+ */
214
+ getTraceBackendStatus(): Observable<{
215
+ isConfigured: boolean;
216
+ backend: string;
217
+ }>;
218
+ /**
219
+ * Log backend configuration status. Returns the source the Logs page is
220
+ * actually reading from ("database", "loki", "none") so the UI can
221
+ * surface a small badge and degrade gracefully when nothing is wired.
222
+ */
223
+ getLogBackendStatus(): Observable<{
224
+ isConfigured: boolean;
225
+ backend: string;
226
+ }>;
227
+ /**
228
+ * Clean query object by removing undefined values
229
+ */
230
+ private cleanQuery;
231
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TelemetryService, never>;
232
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TelemetryService>;
233
+ }
234
+
235
+ declare class TelemetryDashboardComponent implements OnInit, OnDestroy {
236
+ private readonly telemetryService;
237
+ private readonly destroy$;
238
+ metrics: _angular_core.WritableSignal<TelemetryMetrics | null>;
239
+ tokenSeries: _angular_core.WritableSignal<MetricSeries | null>;
240
+ authSeries: _angular_core.WritableSignal<MetricSeries | null>;
241
+ loading: _angular_core.WritableSignal<boolean>;
242
+ error: _angular_core.WritableSignal<string | null>;
243
+ timeRange: _angular_core.WritableSignal<TimeRange>;
244
+ autoRefresh: _angular_core.WritableSignal<boolean>;
245
+ systemHealth: _angular_core.Signal<"-" | "Healthy" | "Degraded">;
246
+ ngOnInit(): void;
247
+ ngOnDestroy(): void;
248
+ setTimeRange(range: TimeRange): void;
249
+ toggleAutoRefresh(): void;
250
+ loadData(): void;
251
+ getBarHeight(value: number, data: {
252
+ value: number;
253
+ }[]): number;
254
+ formatChartLabel(timestamp: string): string;
255
+ getFirstLabel(data: {
256
+ timestamp: string;
257
+ }[]): string;
258
+ getLastLabel(data: {
259
+ timestamp: string;
260
+ }[]): string;
261
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TelemetryDashboardComponent, never>;
262
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TelemetryDashboardComponent, "lib-telemetry-dashboard", never, {}, {}, never, never, true, never>;
263
+ }
264
+
265
+ declare class TelemetryLogsComponent implements OnInit, OnDestroy {
266
+ private readonly telemetryService;
267
+ private readonly router;
268
+ private readonly route;
269
+ private readonly destroy$;
270
+ logs: _angular_core.WritableSignal<LogEntry[]>;
271
+ categories: _angular_core.WritableSignal<string[]>;
272
+ loading: _angular_core.WritableSignal<boolean>;
273
+ error: _angular_core.WritableSignal<string | null>;
274
+ totalCount: _angular_core.WritableSignal<number>;
275
+ liveTail: _angular_core.WritableSignal<boolean>;
276
+ expandedLogs: _angular_core.WritableSignal<Set<string>>;
277
+ readonly THEME_KEY = "telemetry-logs-theme";
278
+ darkMode: _angular_core.WritableSignal<boolean>;
279
+ searchTerm: string;
280
+ level: string;
281
+ category: string;
282
+ currentPage: _angular_core.WritableSignal<number>;
283
+ readonly pageSize = 50;
284
+ totalPages: _angular_core.Signal<number>;
285
+ Math: Math;
286
+ backend: _angular_core.WritableSignal<string | null>;
287
+ ngOnInit(): void;
288
+ loadBackendStatus(): void;
289
+ ngOnDestroy(): void;
290
+ loadCategories(): void;
291
+ loadLogs(silent?: boolean): void;
292
+ handleSearch(): void;
293
+ toggleLiveTail(): void;
294
+ toggleExpand(logId: string): void;
295
+ hasDetails(log: LogEntry): boolean;
296
+ hasProperties(props: Record<string, unknown>): boolean;
297
+ goToPage(page: number): void;
298
+ navigateToTrace(traceId: string): void;
299
+ formatDate(dateString: string): string;
300
+ formatJson(obj: unknown): string;
301
+ /**
302
+ * Normalize log level from backend format to frontend format
303
+ * Backend returns: "Trace", "Debug", "Information", "Warning", "Error", "Critical"
304
+ * Frontend expects: "trace", "debug", "info", "warn", "error", "fatal"
305
+ */
306
+ private normalizeLevel;
307
+ getLevelClasses(level: string): string;
308
+ getLevelLabel(level: string): string;
309
+ getLevelStyles(level: string): Record<string, string>;
310
+ loadThemePreference(): boolean;
311
+ toggleTheme(): void;
312
+ getLogViewerClasses(): string;
313
+ getLogRowClasses(): string;
314
+ getTimestampClasses(): string;
315
+ getCategoryClasses(): string;
316
+ getMessageClasses(): string;
317
+ getExpandIconClasses(): string;
318
+ getDetailsContainerClasses(): string;
319
+ getPropertiesPreClasses(): string;
320
+ getExceptionPreClasses(): string;
321
+ getStackTracePreClasses(): string;
322
+ getLabelClasses(): string;
323
+ getContextValueClasses(type: 'request' | 'user' | 'client' | 'machine'): string;
324
+ getTraceLinkClasses(): string;
325
+ getSpanIdClasses(): string;
326
+ getExceptionLabelClasses(): string;
327
+ getExceptionTypeClasses(): string;
328
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TelemetryLogsComponent, never>;
329
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TelemetryLogsComponent, "lib-telemetry-logs", never, {}, {}, never, never, true, never>;
330
+ }
331
+
332
+ declare class TelemetryTracesComponent implements OnInit {
333
+ private readonly telemetryService;
334
+ private readonly router;
335
+ private readonly route;
336
+ traces: _angular_core.WritableSignal<Trace[]>;
337
+ selectedTrace: _angular_core.WritableSignal<Trace | null>;
338
+ loading: _angular_core.WritableSignal<boolean>;
339
+ error: _angular_core.WritableSignal<string | null>;
340
+ totalCount: _angular_core.WritableSignal<number>;
341
+ expandedSpans: _angular_core.WritableSignal<Set<string>>;
342
+ /**
343
+ * Trace backend configured-state.
344
+ * - `null`: status check still in flight (initial load)
345
+ * - `true`: Tempo (or other) backend is wired; render search/list
346
+ * - `false`: no backend; render the "not configured" notice instead
347
+ */
348
+ backendConfigured: _angular_core.WritableSignal<boolean | null>;
349
+ searchTerm: string;
350
+ currentPage: _angular_core.WritableSignal<number>;
351
+ readonly pageSize = 20;
352
+ totalPages: _angular_core.Signal<number>;
353
+ traceId: _angular_core.WritableSignal<string | null>;
354
+ Math: Math;
355
+ formatDuration: typeof formatDuration;
356
+ ngOnInit(): void;
357
+ private bindRoute;
358
+ loadTraces(): void;
359
+ loadTrace(id: string): void;
360
+ handleSearch(): void;
361
+ selectTrace(id: string): void;
362
+ handleBack(): void;
363
+ goToPage(page: number): void;
364
+ toggleSpanExpand(spanId: string): void;
365
+ getStatusColor(status: TraceStatus): string;
366
+ formatDate(dateString: string): string;
367
+ getSpanOffset(span: {
368
+ startTime: string;
369
+ }, trace: Trace): number;
370
+ getSpanWidth(span: {
371
+ duration: number;
372
+ }, trace: Trace): number;
373
+ /**
374
+ * Build a flattened tree of spans for rendering
375
+ */
376
+ getSpanTree(trace: Trace): Array<TraceSpan & {
377
+ depth: number;
378
+ hasChildren: boolean;
379
+ }>;
380
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TelemetryTracesComponent, never>;
381
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TelemetryTracesComponent, "lib-telemetry-traces", never, {}, {}, never, never, true, never>;
382
+ }
383
+
384
+ export { LOG_LEVEL_CONFIG, TELEMETRY_PLUGIN, TELEMETRY_ROUTES, TRACE_STATUS_CONFIG, TelemetryDashboardComponent, TelemetryLogsComponent, TelemetryService, TelemetryTracesComponent, formatDuration, getIntervalForRange, getTelemetryNavItems };
385
+ export type { AuditLogEntry, LogEntry, LogLevel, MetricDataPoint, MetricSeries, PagedResult, TelemetryMetrics, TelemetryQuery, TimeRange, Trace, TraceEvent, TraceSpan, TraceStatus };