apm-optima 0.0.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.
Files changed (131) hide show
  1. package/dist/adapters/http.adapter.d.ts +12 -0
  2. package/dist/adapters/http.adapter.js +2 -0
  3. package/dist/adapters/websocket.adapter.d.ts +5 -0
  4. package/dist/adapters/websocket.adapter.js +2 -0
  5. package/dist/config/config.manager.d.ts +12 -0
  6. package/dist/config/config.manager.js +111 -0
  7. package/dist/config/config.types.d.ts +19 -0
  8. package/dist/config/config.types.js +2 -0
  9. package/dist/config/index.d.ts +2 -0
  10. package/dist/config/index.js +18 -0
  11. package/dist/core/delivery/index.d.ts +2 -0
  12. package/dist/core/delivery/index.js +18 -0
  13. package/dist/core/delivery/metrics.publisher.d.ts +18 -0
  14. package/dist/core/delivery/metrics.publisher.js +36 -0
  15. package/dist/core/delivery/websocket.events.d.ts +12 -0
  16. package/dist/core/delivery/websocket.events.js +16 -0
  17. package/dist/core/domain/common.types.d.ts +44 -0
  18. package/dist/core/domain/common.types.js +20 -0
  19. package/dist/core/domain/dashboard.types.d.ts +108 -0
  20. package/dist/core/domain/dashboard.types.js +2 -0
  21. package/dist/core/domain/endpoints.types.d.ts +43 -0
  22. package/dist/core/domain/endpoints.types.js +2 -0
  23. package/dist/core/domain/index.d.ts +6 -0
  24. package/dist/core/domain/index.js +22 -0
  25. package/dist/core/domain/metrics.types.d.ts +119 -0
  26. package/dist/core/domain/metrics.types.js +2 -0
  27. package/dist/core/domain/system.types.d.ts +51 -0
  28. package/dist/core/domain/system.types.js +2 -0
  29. package/dist/core/domain/telemetry.types.d.ts +8 -0
  30. package/dist/core/domain/telemetry.types.js +2 -0
  31. package/dist/core/storage/index.d.ts +3 -0
  32. package/dist/core/storage/index.js +19 -0
  33. package/dist/core/storage/local.repository.d.ts +17 -0
  34. package/dist/core/storage/local.repository.js +52 -0
  35. package/dist/core/storage/stores/alert.store.d.ts +13 -0
  36. package/dist/core/storage/stores/alert.store.js +71 -0
  37. package/dist/core/storage/stores/analytics.store.d.ts +15 -0
  38. package/dist/core/storage/stores/analytics.store.js +59 -0
  39. package/dist/core/storage/stores/bucket.store.d.ts +40 -0
  40. package/dist/core/storage/stores/bucket.store.js +75 -0
  41. package/dist/core/storage/stores/dashboard.store.d.ts +15 -0
  42. package/dist/core/storage/stores/dashboard.store.js +78 -0
  43. package/dist/core/storage/stores/endpoint.store.d.ts +16 -0
  44. package/dist/core/storage/stores/endpoint.store.js +62 -0
  45. package/dist/core/storage/stores/health.store.d.ts +20 -0
  46. package/dist/core/storage/stores/health.store.js +133 -0
  47. package/dist/core/storage/stores/index.d.ts +8 -0
  48. package/dist/core/storage/stores/index.js +24 -0
  49. package/dist/core/storage/stores/metrics.store.d.ts +23 -0
  50. package/dist/core/storage/stores/metrics.store.js +49 -0
  51. package/dist/core/storage/stores/system.store.d.ts +8 -0
  52. package/dist/core/storage/stores/system.store.js +19 -0
  53. package/dist/core/storage/utility/histogram.d.ts +37 -0
  54. package/dist/core/storage/utility/histogram.js +91 -0
  55. package/dist/core/storage/utility/index.d.ts +2 -0
  56. package/dist/core/storage/utility/index.js +18 -0
  57. package/dist/core/storage/utility/ring-buffer.d.ts +12 -0
  58. package/dist/core/storage/utility/ring-buffer.js +47 -0
  59. package/dist/core/telemetry/collector.service.d.ts +18 -0
  60. package/dist/core/telemetry/collector.service.js +92 -0
  61. package/dist/core/telemetry/collectors/cpu.collector.d.ts +22 -0
  62. package/dist/core/telemetry/collectors/cpu.collector.js +39 -0
  63. package/dist/core/telemetry/collectors/event-loop.collector.d.ts +22 -0
  64. package/dist/core/telemetry/collectors/event-loop.collector.js +27 -0
  65. package/dist/core/telemetry/collectors/gc.collector.d.ts +61 -0
  66. package/dist/core/telemetry/collectors/gc.collector.js +86 -0
  67. package/dist/core/telemetry/collectors/handles.collector.d.ts +20 -0
  68. package/dist/core/telemetry/collectors/handles.collector.js +26 -0
  69. package/dist/core/telemetry/collectors/index.d.ts +6 -0
  70. package/dist/core/telemetry/collectors/index.js +22 -0
  71. package/dist/core/telemetry/collectors/interface.d.ts +3 -0
  72. package/dist/core/telemetry/collectors/interface.js +2 -0
  73. package/dist/core/telemetry/collectors/memory.collector.d.ts +18 -0
  74. package/dist/core/telemetry/collectors/memory.collector.js +24 -0
  75. package/dist/core/telemetry/collectors/runtime.collector.d.ts +32 -0
  76. package/dist/core/telemetry/collectors/runtime.collector.js +29 -0
  77. package/dist/core/telemetry/correlation.service.d.ts +9 -0
  78. package/dist/core/telemetry/correlation.service.js +72 -0
  79. package/dist/core/telemetry/logger.d.ts +11 -0
  80. package/dist/core/telemetry/logger.js +63 -0
  81. package/dist/core/telemetry/telemetry.service.d.ts +10 -0
  82. package/dist/core/telemetry/telemetry.service.js +36 -0
  83. package/dist/core/utility/base-math.d.ts +15 -0
  84. package/dist/core/utility/base-math.js +26 -0
  85. package/dist/core/utility/conversion.d.ts +31 -0
  86. package/dist/core/utility/conversion.js +74 -0
  87. package/dist/core/utility/index.d.ts +4 -0
  88. package/dist/core/utility/index.js +20 -0
  89. package/dist/core/utility/mocking.d.ts +21 -0
  90. package/dist/core/utility/mocking.js +40 -0
  91. package/dist/core/utility/pagination.d.ts +9 -0
  92. package/dist/core/utility/pagination.js +23 -0
  93. package/dist/core/utility/statistics.d.ts +140 -0
  94. package/dist/core/utility/statistics.js +349 -0
  95. package/dist/express/index.d.ts +6 -0
  96. package/dist/express/index.js +22 -0
  97. package/dist/express/metrics-websocket.adapter.d.ts +14 -0
  98. package/dist/express/metrics-websocket.adapter.js +70 -0
  99. package/dist/express/metrics.adapter.d.ts +12 -0
  100. package/dist/express/metrics.adapter.js +31 -0
  101. package/dist/express/metrics.bootstrap.d.ts +2 -0
  102. package/dist/express/metrics.bootstrap.js +35 -0
  103. package/dist/express/metrics.dashboard.d.ts +2 -0
  104. package/dist/express/metrics.dashboard.js +15 -0
  105. package/dist/express/metrics.middleware.d.ts +2 -0
  106. package/dist/express/metrics.middleware.js +29 -0
  107. package/dist/index.d.ts +3 -0
  108. package/dist/index.js +6 -0
  109. package/dist/nest/index.d.ts +4 -0
  110. package/dist/nest/index.js +11 -0
  111. package/dist/nest/metrics-websocket.adapter.d.ts +15 -0
  112. package/dist/nest/metrics-websocket.adapter.js +88 -0
  113. package/dist/nest/metrics.adapter.d.ts +12 -0
  114. package/dist/nest/metrics.adapter.js +33 -0
  115. package/dist/nest/metrics.bootstrap.service.d.ts +13 -0
  116. package/dist/nest/metrics.bootstrap.service.js +66 -0
  117. package/dist/nest/metrics.interceptor.d.ts +11 -0
  118. package/dist/nest/metrics.interceptor.js +57 -0
  119. package/dist/nest/metrics.module.d.ts +6 -0
  120. package/dist/nest/metrics.module.js +74 -0
  121. package/dist/simulation/config.d.ts +20 -0
  122. package/dist/simulation/config.js +54 -0
  123. package/dist/simulation/journey.d.ts +7 -0
  124. package/dist/simulation/journey.js +49 -0
  125. package/dist/simulation/scenarios.d.ts +17 -0
  126. package/dist/simulation/scenarios.js +96 -0
  127. package/dist/simulation/simulation.d.ts +24 -0
  128. package/dist/simulation/simulation.js +154 -0
  129. package/dist/simulation/utility.d.ts +23 -0
  130. package/dist/simulation/utility.js +50 -0
  131. package/package.json +71 -0
@@ -0,0 +1,12 @@
1
+ export type RequestRequiredData = Readonly<{
2
+ method: string;
3
+ endpoint: string;
4
+ clientIp?: string;
5
+ }>;
6
+ export type ResponseRequiredData = Readonly<{
7
+ statusCode: number;
8
+ }>;
9
+ export interface HttpAdapter<TRequest, TResponse> {
10
+ getRequest(request: TRequest): RequestRequiredData;
11
+ getResponse(response: TResponse): ResponseRequiredData;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export interface WebSocketAdapter {
2
+ init(): void;
3
+ broadcast(event: string, data: unknown): void;
4
+ disconnect(): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { ConfigOptions, ReadonlyConfig } from './config.types';
2
+ export declare class ConfigManager {
3
+ private static instance;
4
+ private config;
5
+ private readonly defaultConfig;
6
+ private constructor();
7
+ static getInstance(): ConfigManager;
8
+ initialize(userOptions?: ConfigOptions): ReadonlyConfig;
9
+ get(): ReadonlyConfig;
10
+ private validateAndSanitize;
11
+ }
12
+ export declare const getConfig: () => ReadonlyConfig;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConfig = exports.ConfigManager = void 0;
4
+ class ConfigManager {
5
+ static instance;
6
+ config;
7
+ defaultConfig = Object.freeze({
8
+ dashboardPath: '/optima-metrics',
9
+ simulation: {
10
+ intervalMs: 100,
11
+ requestsPerTick: 20,
12
+ },
13
+ publisher: {
14
+ intervalMs: 1000,
15
+ slowLatencyThresholdMs: 500,
16
+ eventLoopLagThresholdMs: 100,
17
+ eventLoopResolutionMs: 20,
18
+ },
19
+ tickIntervalMs: 250,
20
+ excludePaths: [
21
+ '/_next/*',
22
+ '/_next/**',
23
+ '*.map',
24
+ '*.js',
25
+ '*.css',
26
+ '/favicon.ico',
27
+ '/metrics_pack',
28
+ '/',
29
+ '/health',
30
+ '/optima-metrics/**',
31
+ '/optima-metrics/*',
32
+ ], //! OPTIMIZE THIS
33
+ consoleLog: true,
34
+ ringBufferSize: 60,
35
+ alertBufferSize: 100,
36
+ });
37
+ constructor() {
38
+ this.config = this.defaultConfig;
39
+ }
40
+ static getInstance() {
41
+ if (!ConfigManager.instance) {
42
+ ConfigManager.instance = new ConfigManager();
43
+ }
44
+ return ConfigManager.instance;
45
+ }
46
+ initialize(userOptions) {
47
+ const validated = this.validateAndSanitize(userOptions);
48
+ this.config = Object.freeze({
49
+ ...this.defaultConfig,
50
+ ...validated
51
+ });
52
+ return this.config;
53
+ }
54
+ get() {
55
+ return this.config;
56
+ }
57
+ validateAndSanitize(options) {
58
+ if (!options) {
59
+ return {};
60
+ }
61
+ const sanitized = {};
62
+ if (options.dashboardPath !== undefined) {
63
+ if (options.dashboardPath === false) {
64
+ sanitized.dashboardPath = false;
65
+ }
66
+ else {
67
+ sanitized.dashboardPath = String(options.dashboardPath);
68
+ }
69
+ }
70
+ if (options.simulation !== undefined) {
71
+ if (typeof options.simulation === 'boolean') {
72
+ sanitized.simulation = options.simulation;
73
+ }
74
+ else {
75
+ sanitized.simulation = {
76
+ intervalMs: Math.max(1, options.simulation.intervalMs),
77
+ requestsPerTick: Math.max(1, options.simulation.requestsPerTick),
78
+ };
79
+ }
80
+ }
81
+ if (options.publisher !== undefined) {
82
+ sanitized.publisher = {
83
+ intervalMs: Math.max(1, options.publisher.intervalMs),
84
+ slowLatencyThresholdMs: Math.max(1, options.publisher.slowLatencyThresholdMs),
85
+ eventLoopLagThresholdMs: Math.max(1, options.publisher.eventLoopLagThresholdMs),
86
+ eventLoopResolutionMs: options.publisher.eventLoopResolutionMs !== undefined
87
+ ? Math.max(1, options.publisher.eventLoopResolutionMs)
88
+ : undefined,
89
+ };
90
+ }
91
+ if (options.tickIntervalMs !== undefined) {
92
+ sanitized.tickIntervalMs = Math.max(1, options.tickIntervalMs);
93
+ }
94
+ if (Array.isArray(options.excludePaths)) {
95
+ sanitized.excludePaths = options.excludePaths.filter(path => typeof path === 'string');
96
+ }
97
+ if (options.consoleLog !== undefined) {
98
+ sanitized.consoleLog = Boolean(options.consoleLog);
99
+ }
100
+ if (options.ringBufferSize !== undefined) {
101
+ sanitized.ringBufferSize = Math.max(1, options.ringBufferSize);
102
+ }
103
+ if (options.alertBufferSize !== undefined) {
104
+ sanitized.alertBufferSize = Math.max(1, options.alertBufferSize);
105
+ }
106
+ return sanitized;
107
+ }
108
+ }
109
+ exports.ConfigManager = ConfigManager;
110
+ const getConfig = () => ConfigManager.getInstance().get();
111
+ exports.getConfig = getConfig;
@@ -0,0 +1,19 @@
1
+ export interface ConfigOptions {
2
+ dashboardPath?: string | false;
3
+ simulation?: false | {
4
+ intervalMs: number;
5
+ requestsPerTick: number;
6
+ };
7
+ publisher?: {
8
+ intervalMs: number;
9
+ slowLatencyThresholdMs: number;
10
+ eventLoopLagThresholdMs: number;
11
+ eventLoopResolutionMs?: number;
12
+ };
13
+ tickIntervalMs?: number;
14
+ excludePaths?: string[];
15
+ consoleLog?: boolean;
16
+ ringBufferSize?: number;
17
+ alertBufferSize?: number;
18
+ }
19
+ export type ReadonlyConfig = Readonly<Required<ConfigOptions>>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './config.types';
2
+ export * from './config.manager';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config.types"), exports);
18
+ __exportStar(require("./config.manager"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './metrics.publisher';
2
+ export * from './websocket.events';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./metrics.publisher"), exports);
18
+ __exportStar(require("./websocket.events"), exports);
@@ -0,0 +1,18 @@
1
+ import type { WebSocketAdapter } from "../../adapters/websocket.adapter";
2
+ import type { SystemStaticInfo, AnalyticsData, DashboardData, HealthData } from "../domain";
3
+ export interface MetricsDataProvider {
4
+ getSystemStaticInfo(): SystemStaticInfo;
5
+ getDashboardData(): DashboardData;
6
+ getAnalyticsData(): AnalyticsData;
7
+ getHealthData(): HealthData;
8
+ }
9
+ export declare class MetricsPublisher {
10
+ private readonly provider;
11
+ private readonly websocket;
12
+ private readonly intervalMs;
13
+ private interval?;
14
+ constructor(provider: MetricsDataProvider, websocket: WebSocketAdapter, intervalMs?: number);
15
+ start(): void;
16
+ stop(): void;
17
+ private publish;
18
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetricsPublisher = void 0;
4
+ const websocket_events_1 = require("./websocket.events");
5
+ class MetricsPublisher {
6
+ provider;
7
+ websocket;
8
+ intervalMs;
9
+ interval;
10
+ constructor(provider, websocket, intervalMs = 1000) {
11
+ this.provider = provider;
12
+ this.websocket = websocket;
13
+ this.intervalMs = intervalMs;
14
+ }
15
+ start() {
16
+ if (this.interval)
17
+ return;
18
+ this.interval = setInterval(() => {
19
+ this.publish();
20
+ }, this.intervalMs);
21
+ }
22
+ stop() {
23
+ if (!this.interval)
24
+ return;
25
+ clearInterval(this.interval);
26
+ this.interval = undefined;
27
+ }
28
+ publish() {
29
+ //? consider sending only the changed data instead of sending all data every time
30
+ this.websocket.broadcast(websocket_events_1.WebSocketEvents.RESPONSE_SYSTEM_DATA, this.provider.getSystemStaticInfo());
31
+ this.websocket.broadcast(websocket_events_1.WebSocketEvents.RESPONSE_DASHBOARD_DATA, this.provider.getDashboardData());
32
+ this.websocket.broadcast(websocket_events_1.WebSocketEvents.RESPONSE_ANALYTICS_DATA, this.provider.getAnalyticsData());
33
+ this.websocket.broadcast(websocket_events_1.WebSocketEvents.RESPONSE_HEALTH_DATA, this.provider.getHealthData());
34
+ }
35
+ }
36
+ exports.MetricsPublisher = MetricsPublisher;
@@ -0,0 +1,12 @@
1
+ export declare enum WebSocketEvents {
2
+ REQUEST_CONFIGURATION = "request-configuration",
3
+ RESPONSE_CONFIGURATION = "response-configuration",
4
+ REQUEST_SYSTEM_DATA = "request-system-data",
5
+ RESPONSE_SYSTEM_DATA = "response-system-data",
6
+ REQUEST_DASHBOARD_DATA = "request-dashboard-data",
7
+ RESPONSE_DASHBOARD_DATA = "response-dashboard-data",
8
+ REQUEST_ANALYTICS_DATA = "request-analytics-data",
9
+ RESPONSE_ANALYTICS_DATA = "response-analytics-data",
10
+ REQUEST_HEALTH_DATA = "request-health-data",
11
+ RESPONSE_HEALTH_DATA = "response-health-data"
12
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketEvents = void 0;
4
+ var WebSocketEvents;
5
+ (function (WebSocketEvents) {
6
+ WebSocketEvents["REQUEST_CONFIGURATION"] = "request-configuration";
7
+ WebSocketEvents["RESPONSE_CONFIGURATION"] = "response-configuration";
8
+ WebSocketEvents["REQUEST_SYSTEM_DATA"] = "request-system-data";
9
+ WebSocketEvents["RESPONSE_SYSTEM_DATA"] = "response-system-data";
10
+ WebSocketEvents["REQUEST_DASHBOARD_DATA"] = "request-dashboard-data";
11
+ WebSocketEvents["RESPONSE_DASHBOARD_DATA"] = "response-dashboard-data";
12
+ WebSocketEvents["REQUEST_ANALYTICS_DATA"] = "request-analytics-data";
13
+ WebSocketEvents["RESPONSE_ANALYTICS_DATA"] = "response-analytics-data";
14
+ WebSocketEvents["REQUEST_HEALTH_DATA"] = "request-health-data";
15
+ WebSocketEvents["RESPONSE_HEALTH_DATA"] = "response-health-data";
16
+ })(WebSocketEvents || (exports.WebSocketEvents = WebSocketEvents = {}));
@@ -0,0 +1,44 @@
1
+ export type ConnectionStatus = 'ONLINE' | 'OFFLINE' | 'CONNECTING' | 'DISCONNECTED';
2
+ export type HealthStatus = 'HEALTHY' | 'DEGRADED' | 'UNHEALTHY' | 'UNKNOWN';
3
+ export type SeverityLevel = 'info' | 'advisory' | 'warning' | 'critical';
4
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
5
+ export type StatusCategory = '2xx' | '3xx' | '4xx' | '5xx' | 'unknown';
6
+ /**
7
+ * Represents a network route with its associated HTTP method and path.
8
+ * @property {HttpMethod | string} method - The HTTP method for the route (e.g., GET, POST).
9
+ * @property {string} route - The path of the route (e.g., '/api/users').
10
+ */
11
+ export interface EndpointRoute {
12
+ method: HttpMethod | string;
13
+ route: string;
14
+ }
15
+ /**
16
+ * Represents an alert message with a title, timestamp, and severity level.
17
+ * @property {string} title - The title or summary of the alert.
18
+ * @property {string} timestamp - The timestamp when the alert was generated (ISO 8601 format).
19
+ * @property {SeverityLevel} severity - The severity level of the alert (info, advisory, warning, critical).
20
+ */
21
+ export interface AlertMessage {
22
+ title: string;
23
+ timestamp: string;
24
+ severity: SeverityLevel;
25
+ }
26
+ /**
27
+ * Represents pagination metadata for paginated data responses.
28
+ * @property {number} page - The current page number.
29
+ * @property {number} pageSize - The actual number of items returned on the current page.
30
+ * @property {number} perPageCount - The number of items per page.
31
+ * @property {number} totalCount - The total number of items available across all pages.
32
+ */
33
+ export interface PaginationMeta {
34
+ page: number;
35
+ pageSize: number;
36
+ perPageCount: number;
37
+ totalCount: number;
38
+ }
39
+ /**
40
+ * Categorizes an HTTP status code into a broader status category.
41
+ * @param statusCode - The HTTP status code to categorize.
42
+ * @returns A string representing the status category: '2xx', '3xx', '4xx', '5xx', or 'unknown'.
43
+ */
44
+ export declare function categorizeStatusCode(statusCode: number): StatusCategory;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.categorizeStatusCode = categorizeStatusCode;
4
+ /**
5
+ * Categorizes an HTTP status code into a broader status category.
6
+ * @param statusCode - The HTTP status code to categorize.
7
+ * @returns A string representing the status category: '2xx', '3xx', '4xx', '5xx', or 'unknown'.
8
+ */
9
+ function categorizeStatusCode(statusCode) {
10
+ if (statusCode >= 200 && statusCode < 300)
11
+ return '2xx';
12
+ else if (statusCode >= 300 && statusCode < 400)
13
+ return '3xx';
14
+ else if (statusCode >= 400 && statusCode < 500)
15
+ return '4xx';
16
+ else if (statusCode >= 500 && statusCode < 600)
17
+ return '5xx';
18
+ else
19
+ return 'unknown';
20
+ }
@@ -0,0 +1,108 @@
1
+ import type { AlertMessage, PaginationMeta } from './common.types';
2
+ import type { CpuMetrics, MemoryMetrics, EventLoopMetrics, GCMetrics, LibuvHandles, HistoricTimeSeries } from './metrics.types';
3
+ import type { V8RuntimeInfo } from './system.types';
4
+ import type { EndpointTelemetry, EndpointLatencyDistribution, EndpointVolume } from './endpoints.types';
5
+ /**
6
+ * Represents the complete dashboard data structure, including current metrics, historical data, impacted endpoints, alerts, and chart configurations.
7
+ * @property {object} current - Current instantaneous values for various metrics.
8
+ * @property {HistoricTimeSeries} history - Historical time series data for various metrics.
9
+ * @property {EndpointTelemetry[]} impactEndpoints - List of impacted endpoints with their telemetry data.
10
+ * @property {AlertMessage[]} alerts - List of alert messages.
11
+ * @property {object} charts - Explicit chart configuration maps matching chart configurations directly.
12
+ * @property {object} charts.throughputAndLatency - Chart data for throughput and latency metrics.
13
+ * @property {object} charts.runtimePerformance - Chart data for runtime performance metrics.
14
+ */
15
+ export interface DashboardData {
16
+ current: {
17
+ rps: number;
18
+ latency: number;
19
+ errorRate: number;
20
+ eventLoopLag: number;
21
+ heapUsage: number;
22
+ heapSize: number;
23
+ };
24
+ history: HistoricTimeSeries;
25
+ impactEndpoints: EndpointTelemetry[];
26
+ alerts: AlertMessage[];
27
+ charts: {
28
+ throughput: {
29
+ rps: number[];
30
+ errorClient: number[];
31
+ errorServer: number[];
32
+ totalCount: number;
33
+ };
34
+ percentiles: {
35
+ p50: number[];
36
+ p95: number[];
37
+ p99: number[];
38
+ totalCount: number;
39
+ };
40
+ runtimePerformance: {
41
+ heapUsage: number[];
42
+ heapSize: number[];
43
+ lag: number[];
44
+ totalCount: number;
45
+ };
46
+ };
47
+ }
48
+ /**
49
+ * Represents the analytics data structure, including summary statistics, latency distribution, request volume, and a paginated table of endpoint telemetry data.
50
+ * @property {object} summary - Summary statistics for the analytics data.
51
+ * @property {number} summary.totalEndpoints - Total number of endpoints analyzed.
52
+ * @property {number} summary.healthyEndpoints - Number of healthy endpoints.
53
+ * @property {number} summary.slowEndpoints - Number of slow endpoints.
54
+ * @property {number} summary.slowEndpointsThreshold - Threshold for determining slow endpoints.
55
+ * @property {number} summary.errorEndpoints - Number of endpoints with errors.
56
+ * @property {EndpointLatencyDistribution[]} latencyDistribution - Array of latency distribution data for each endpoint.
57
+ * @property {EndpointVolume[]} requestVolume - Array of request volume data for each endpoint.
58
+ * @property {object} endpointsTable - Paginated table of endpoint telemetry data.
59
+ * @property {EndpointTelemetry[]} endpointsTable.data - Array of endpoint telemetry data for the current page.
60
+ * @property {PaginationMeta} endpointsTable.pagination - Pagination metadata for the endpoints table.
61
+ */
62
+ export interface AnalyticsData {
63
+ summary: {
64
+ totalEndpoints: number;
65
+ healthyEndpoints: number;
66
+ slowEndpoints: number;
67
+ slowEndpointsThreshold: number;
68
+ errorEndpoints: number;
69
+ };
70
+ latencyDistribution: EndpointLatencyDistribution[];
71
+ requestVolume: EndpointVolume[];
72
+ endpointsTable: {
73
+ data: EndpointTelemetry[];
74
+ pagination: PaginationMeta;
75
+ };
76
+ history: EndpointTelemetry[][];
77
+ }
78
+ /**
79
+ * Represents the health data structure, including CPU metrics, memory metrics, event loop metrics, libuv handle metrics, garbage collection metrics, V8 runtime information, and historical data for event loop lag and memory breakdown.
80
+ * @property {CpuMetrics} cpu - CPU metrics data.
81
+ * @property {MemoryMetrics} memory - Memory metrics data.
82
+ * @property {EventLoopMetrics} eventLoop - Event loop metrics data.
83
+ * @property {LibuvHandles} handles - Libuv handle metrics data.
84
+ * @property {GCMetrics} garbageCollection - Garbage collection metrics data.
85
+ * @property {V8RuntimeInfo} runtime - V8 runtime information data.
86
+ * @property {object} history - Historical data for event loop lag and memory breakdown.
87
+ * @property {number[]} history.eventLoopLag - Array of historical event loop lag values.
88
+ * @property {object} history.memoryBreakdown - Historical memory breakdown data.
89
+ * @property {number[]} history.memoryBreakdown.usedHeap - Array of historical used heap memory values.
90
+ * @property {number[]} history.memoryBreakdown.totalHeap - Array of historical total heap memory values.
91
+ * @property {number[]} history.memoryBreakdown.rssMemory - Array of historical resident set size (RSS) memory values.
92
+ */
93
+ export interface HealthData {
94
+ cpu: CpuMetrics;
95
+ memory: MemoryMetrics;
96
+ eventLoop: EventLoopMetrics;
97
+ handles: LibuvHandles;
98
+ garbageCollection: GCMetrics;
99
+ runtime: V8RuntimeInfo;
100
+ history: {
101
+ eventLoopLag: number[];
102
+ memoryBreakdown: {
103
+ usedHeap: number[];
104
+ totalHeap: number[];
105
+ rssMemory: number[];
106
+ };
107
+ };
108
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import type { EndpointRoute } from './common.types';
2
+ /**
3
+ * Represents telemetry data for a specific endpoint, including request rate, latency percentiles, error rate, and optional status information.
4
+ * @property {number} rps - Requests per second for the endpoint.
5
+ * @property {number} p95 - 95th percentile latency for the endpoint.
6
+ * @property {number} [p99] - Optional 99th percentile latency for the endpoint.
7
+ * @property {number} errorRate - Error rate for the endpoint (as a percentage).
8
+ * @property {string} [status] - Optional status of the endpoint (e.g., 'HEALTHY', 'UNHEALTHY').
9
+ * @property {number} [requestCount] - Optional total number of requests made to the endpoint.
10
+ * @property {number} [averageLatency] - Optional average latency for the endpoint.
11
+ */
12
+ export interface EndpointTelemetry extends EndpointRoute {
13
+ rps: number;
14
+ p95: number;
15
+ p99?: number;
16
+ errorRate: number;
17
+ status?: string;
18
+ requestCount?: number;
19
+ averageLatency?: number;
20
+ }
21
+ /**
22
+ * Represents the latency distribution for a specific endpoint, including the 50th, 95th, and 99th percentile latencies.
23
+ * @property {string} endpoint - The endpoint path (e.g., '/api/users').
24
+ * @property {number} p50 - 50th percentile latency for the endpoint.
25
+ * @property {number} p95 - 95th percentile latency for the endpoint.
26
+ * @property {number} p99 - 99th percentile latency for the endpoint.
27
+ */
28
+ export interface EndpointLatencyDistribution {
29
+ endpoint: string;
30
+ p50: number;
31
+ p95: number;
32
+ p99: number;
33
+ }
34
+ /**
35
+ * Represents the request volume for a specific endpoint, including the total number of requests made to that endpoint.
36
+ * @property {string} endpoint - The endpoint path (e.g., '/api/users').
37
+ * @property {number} volume - The total number of requests made to the endpoint.
38
+ */
39
+ export interface EndpointVolume {
40
+ endpoint: string;
41
+ volume: number;
42
+ rps: number;
43
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export * from './common.types';
2
+ export * from './system.types';
3
+ export * from './metrics.types';
4
+ export * from './endpoints.types';
5
+ export * from './dashboard.types';
6
+ export * from './telemetry.types';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common.types"), exports);
18
+ __exportStar(require("./system.types"), exports);
19
+ __exportStar(require("./metrics.types"), exports);
20
+ __exportStar(require("./endpoints.types"), exports);
21
+ __exportStar(require("./dashboard.types"), exports);
22
+ __exportStar(require("./telemetry.types"), exports);