mcp-wordpress 1.2.2 → 1.3.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/README.md +210 -182
- package/dist/cache/CacheInvalidation.d.ts +3 -3
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +119 -119
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +5 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +26 -16
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +29 -29
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
- package/dist/cache/__tests__/CacheManager.test.js +113 -113
- package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
- package/dist/cache/index.d.ts +7 -7
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +4 -4
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +4 -4
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +55 -51
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +158 -158
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.js +72 -72
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.js +46 -46
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/RequestManager.d.ts +5 -3
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +39 -19
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/config/ConfigurationSchema.d.ts +2 -2
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +40 -40
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -2
- package/dist/config/ServerConfiguration.js +35 -35
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +296 -255
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +60 -51
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/docs/index.d.ts +3 -3
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/mcp-wordpress-1.3.0.tgz +0 -0
- package/dist/performance/MetricsCollector.d.ts +3 -3
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +33 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +12 -12
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +200 -154
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +5 -5
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +53 -52
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +6 -6
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/performance/index.js +3 -3
- package/dist/security/InputValidator.d.ts +1 -1
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +111 -88
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +5 -5
- package/dist/security/SecurityConfig.js +92 -92
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +1 -1
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +4 -4
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts +2 -2
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js +35 -32
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools/BaseToolManager.js +5 -5
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +32 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +1 -1
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +71 -71
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +79 -79
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/index.d.ts +10 -10
- package/dist/tools/index.js +10 -10
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.js +80 -80
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +75 -75
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +1 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +311 -287
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +94 -94
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +2 -2
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +60 -60
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +2 -2
- package/dist/tools/taxonomies.js +89 -89
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.js +68 -68
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +13 -13
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +12 -12
- package/dist/types/client.js.map +1 -1
- package/dist/types/index.d.ts +19 -19
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/mcp.d.ts +7 -7
- package/dist/types/wordpress.d.ts +21 -21
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.js +28 -28
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +13 -13
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js +5 -5
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +41 -31
- package/dist/utils/validation.js.map +1 -1
- package/docs/CACHING.md +36 -2
- package/docs/DOCKER.md +24 -18
- package/docs/PERFORMANCE_MONITORING.md +49 -1
- package/docs/SECURITY_TESTING.md +30 -1
- package/docs/api/README.md +9 -1
- package/docs/api/summary.json +1 -1
- package/docs/contract-testing.md +24 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
- package/docs/developer/MAINTENANCE.md +29 -3
- package/docs/developer/MIGRATION_GUIDE.md +13 -1
- package/docs/developer/NPM_AUTH_SETUP.md +13 -2
- package/docs/developer/REFACTORING.md +31 -1
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
- package/docs/user-guides/DOCKER_SETUP.md +264 -0
- package/docs/user-guides/DTX_SETUP.md +327 -0
- package/docs/user-guides/NPM_SETUP.md +109 -0
- package/docs/user-guides/NPX_SETUP.md +281 -0
- package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
- package/package.json +27 -8
- package/src/cache/CacheInvalidation.ts +140 -132
- package/src/cache/CacheManager.ts +40 -29
- package/src/cache/HttpCacheWrapper.ts +105 -68
- package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
- package/src/cache/__tests__/CacheManager.test.ts +156 -152
- package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
- package/src/cache/index.ts +13 -13
- package/src/client/CachedWordPressClient.ts +90 -80
- package/src/client/api.ts +205 -205
- package/src/client/auth.ts +80 -80
- package/src/client/managers/AuthenticationManager.ts +61 -61
- package/src/client/managers/BaseManager.ts +11 -11
- package/src/client/managers/RequestManager.ts +79 -47
- package/src/client/managers/index.ts +3 -3
- package/src/config/ConfigurationSchema.ts +44 -44
- package/src/config/ServerConfiguration.ts +39 -39
- package/src/docs/DocumentationGenerator.ts +402 -295
- package/src/docs/MarkdownFormatter.ts +94 -69
- package/src/docs/index.ts +4 -4
- package/src/index.ts +24 -21
- package/src/performance/MetricsCollector.ts +90 -58
- package/src/performance/PerformanceAnalytics.ts +386 -262
- package/src/performance/PerformanceMonitor.ts +152 -118
- package/src/performance/index.ts +9 -9
- package/src/security/InputValidator.ts +148 -91
- package/src/security/SecurityConfig.ts +94 -94
- package/src/server/ConnectionTester.ts +21 -15
- package/src/server/ToolRegistry.ts +64 -51
- package/src/server.ts +2 -2
- package/src/tools/BaseToolManager.ts +6 -6
- package/src/tools/auth.ts +42 -37
- package/src/tools/cache.ts +85 -81
- package/src/tools/comments.ts +93 -91
- package/src/tools/index.ts +10 -10
- package/src/tools/media.ts +89 -89
- package/src/tools/pages.ts +89 -87
- package/src/tools/performance.ts +443 -352
- package/src/tools/posts.ts +109 -107
- package/src/tools/site.ts +86 -77
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +157 -60
- package/src/types/index.ts +49 -27
- package/src/types/mcp.ts +15 -15
- package/src/types/wordpress.ts +57 -29
- package/src/utils/debug.ts +37 -37
- package/src/utils/error.ts +47 -25
- package/src/utils/toolWrapper.ts +12 -8
- package/src/utils/validation.ts +116 -65
- package/dist/client/WordPressClient.d.ts +0 -81
- package/dist/client/WordPressClient.d.ts.map +0 -1
- package/dist/client/WordPressClient.js +0 -354
- package/dist/client/WordPressClient.js.map +0 -1
- package/dist/performance/AnomalyDetector.d.ts +0 -63
- package/dist/performance/AnomalyDetector.d.ts.map +0 -1
- package/dist/performance/AnomalyDetector.js +0 -222
- package/dist/performance/AnomalyDetector.js.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
- package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
- package/dist/performance/BenchmarkAnalyzer.js +0 -301
- package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
- package/dist/performance/TrendAnalyzer.d.ts +0 -69
- package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
- package/dist/performance/TrendAnalyzer.js +0 -203
- package/dist/performance/TrendAnalyzer.js.map +0 -1
- package/dist/tools/BaseToolClass.d.ts +0 -76
- package/dist/tools/BaseToolClass.d.ts.map +0 -1
- package/dist/tools/BaseToolClass.js +0 -104
- package/dist/tools/BaseToolClass.js.map +0 -1
- package/dist/tools/base.d.ts +0 -37
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -60
- package/dist/tools/base.js.map +0 -1
- package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +0 -187
package/src/tools/performance.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Provides comprehensive performance insights and management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ToolDefinition } from
|
|
7
|
-
import { PerformanceMonitor } from
|
|
8
|
-
import { MetricsCollector } from
|
|
9
|
-
import { PerformanceAnalytics } from
|
|
10
|
-
import { toolWrapper } from
|
|
6
|
+
import type { ToolDefinition } from "../server/ToolRegistry.js";
|
|
7
|
+
import { PerformanceMonitor } from "../performance/PerformanceMonitor.js";
|
|
8
|
+
import { MetricsCollector } from "../performance/MetricsCollector.js";
|
|
9
|
+
import { PerformanceAnalytics } from "../performance/PerformanceAnalytics.js";
|
|
10
|
+
import { toolWrapper } from "../utils/toolWrapper.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Performance Tools Class
|
|
@@ -22,26 +22,26 @@ export default class PerformanceTools {
|
|
|
22
22
|
this.monitor = new PerformanceMonitor({
|
|
23
23
|
enableRealTimeMonitoring: true,
|
|
24
24
|
enableHistoricalData: true,
|
|
25
|
-
enableAlerts: true
|
|
25
|
+
enableAlerts: true,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
this.collector = new MetricsCollector(this.monitor, {
|
|
29
29
|
enableRealTime: true,
|
|
30
30
|
enableToolTracking: true,
|
|
31
|
-
enableCacheIntegration: true
|
|
31
|
+
enableCacheIntegration: true,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
this.analytics = new PerformanceAnalytics(this.collector, {
|
|
35
35
|
enablePredictiveAnalysis: true,
|
|
36
36
|
enableAnomalyDetection: true,
|
|
37
|
-
enableTrendAnalysis: true
|
|
37
|
+
enableTrendAnalysis: true,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// Register clients if provided
|
|
41
41
|
if (clients) {
|
|
42
42
|
for (const [siteId, client] of clients) {
|
|
43
43
|
this.collector.registerClient(siteId, client);
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
// Register cache manager if client has one
|
|
46
46
|
if (client.cacheManager) {
|
|
47
47
|
this.collector.registerCacheManager(siteId, client.cacheManager);
|
|
@@ -59,197 +59,212 @@ export default class PerformanceTools {
|
|
|
59
59
|
getTools(): ToolDefinition[] {
|
|
60
60
|
return [
|
|
61
61
|
{
|
|
62
|
-
name:
|
|
63
|
-
description:
|
|
62
|
+
name: "wp_performance_stats",
|
|
63
|
+
description: "Get real-time performance statistics and metrics",
|
|
64
64
|
parameters: [
|
|
65
65
|
{
|
|
66
|
-
name:
|
|
67
|
-
type:
|
|
68
|
-
description:
|
|
69
|
-
|
|
66
|
+
name: "site",
|
|
67
|
+
type: "string",
|
|
68
|
+
description:
|
|
69
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
70
|
+
required: false,
|
|
70
71
|
},
|
|
71
72
|
{
|
|
72
|
-
name:
|
|
73
|
-
type:
|
|
74
|
-
description:
|
|
75
|
-
|
|
73
|
+
name: "category",
|
|
74
|
+
type: "string",
|
|
75
|
+
description:
|
|
76
|
+
"Category of metrics to return (overview, requests, cache, system, tools, all)",
|
|
77
|
+
required: false,
|
|
76
78
|
},
|
|
77
79
|
{
|
|
78
|
-
name:
|
|
79
|
-
type:
|
|
80
|
-
description:
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
name: "format",
|
|
81
|
+
type: "string",
|
|
82
|
+
description:
|
|
83
|
+
"Detail level of the response (summary, detailed, raw)",
|
|
84
|
+
required: false,
|
|
85
|
+
},
|
|
83
86
|
],
|
|
84
|
-
handler: this.getPerformanceStats.bind(this)
|
|
87
|
+
handler: this.getPerformanceStats.bind(this),
|
|
85
88
|
},
|
|
86
89
|
{
|
|
87
|
-
name:
|
|
88
|
-
description:
|
|
90
|
+
name: "wp_performance_history",
|
|
91
|
+
description: "Get historical performance data and trends",
|
|
89
92
|
parameters: [
|
|
90
93
|
{
|
|
91
|
-
name:
|
|
92
|
-
type:
|
|
93
|
-
description:
|
|
94
|
-
|
|
94
|
+
name: "site",
|
|
95
|
+
type: "string",
|
|
96
|
+
description:
|
|
97
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
98
|
+
required: false,
|
|
95
99
|
},
|
|
96
100
|
{
|
|
97
|
-
name:
|
|
98
|
-
type:
|
|
99
|
-
description:
|
|
100
|
-
|
|
101
|
+
name: "timeframe",
|
|
102
|
+
type: "string",
|
|
103
|
+
description:
|
|
104
|
+
"Time period for historical data (1h, 6h, 12h, 24h, 7d)",
|
|
105
|
+
required: false,
|
|
101
106
|
},
|
|
102
107
|
{
|
|
103
|
-
name:
|
|
104
|
-
type:
|
|
105
|
-
description:
|
|
106
|
-
|
|
108
|
+
name: "metrics",
|
|
109
|
+
type: "array",
|
|
110
|
+
description:
|
|
111
|
+
"Specific metrics to include (responseTime, cacheHitRate, errorRate, memoryUsage, requestVolume)",
|
|
112
|
+
required: false,
|
|
107
113
|
},
|
|
108
114
|
{
|
|
109
|
-
name:
|
|
110
|
-
type:
|
|
111
|
-
description:
|
|
112
|
-
required: false
|
|
113
|
-
}
|
|
115
|
+
name: "includeTrends",
|
|
116
|
+
type: "boolean",
|
|
117
|
+
description: "Include trend analysis (default: true)",
|
|
118
|
+
required: false,
|
|
119
|
+
},
|
|
114
120
|
],
|
|
115
|
-
handler: this.getPerformanceHistory.bind(this)
|
|
121
|
+
handler: this.getPerformanceHistory.bind(this),
|
|
116
122
|
},
|
|
117
123
|
{
|
|
118
|
-
name:
|
|
119
|
-
description:
|
|
124
|
+
name: "wp_performance_benchmark",
|
|
125
|
+
description: "Compare current performance against industry benchmarks",
|
|
120
126
|
parameters: [
|
|
121
127
|
{
|
|
122
|
-
name:
|
|
123
|
-
type:
|
|
124
|
-
description:
|
|
125
|
-
|
|
128
|
+
name: "site",
|
|
129
|
+
type: "string",
|
|
130
|
+
description:
|
|
131
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
132
|
+
required: false,
|
|
126
133
|
},
|
|
127
134
|
{
|
|
128
|
-
name:
|
|
129
|
-
type:
|
|
130
|
-
description:
|
|
131
|
-
|
|
135
|
+
name: "category",
|
|
136
|
+
type: "string",
|
|
137
|
+
description:
|
|
138
|
+
"Benchmark category (response_time, cache_performance, error_rate, system_resources, all)",
|
|
139
|
+
required: false,
|
|
132
140
|
},
|
|
133
141
|
{
|
|
134
|
-
name:
|
|
135
|
-
type:
|
|
136
|
-
description:
|
|
137
|
-
required: false
|
|
138
|
-
}
|
|
142
|
+
name: "includeRecommendations",
|
|
143
|
+
type: "boolean",
|
|
144
|
+
description: "Include improvement recommendations (default: true)",
|
|
145
|
+
required: false,
|
|
146
|
+
},
|
|
139
147
|
],
|
|
140
|
-
handler: this.getBenchmarkComparison.bind(this)
|
|
148
|
+
handler: this.getBenchmarkComparison.bind(this),
|
|
141
149
|
},
|
|
142
150
|
{
|
|
143
|
-
name:
|
|
144
|
-
description:
|
|
151
|
+
name: "wp_performance_alerts",
|
|
152
|
+
description: "Get performance alerts and anomaly detection results",
|
|
145
153
|
parameters: [
|
|
146
154
|
{
|
|
147
|
-
name:
|
|
148
|
-
type:
|
|
149
|
-
description:
|
|
150
|
-
|
|
155
|
+
name: "site",
|
|
156
|
+
type: "string",
|
|
157
|
+
description:
|
|
158
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
159
|
+
required: false,
|
|
151
160
|
},
|
|
152
161
|
{
|
|
153
|
-
name:
|
|
154
|
-
type:
|
|
155
|
-
description:
|
|
156
|
-
|
|
162
|
+
name: "severity",
|
|
163
|
+
type: "string",
|
|
164
|
+
description:
|
|
165
|
+
"Filter alerts by severity level (info, warning, error, critical)",
|
|
166
|
+
required: false,
|
|
157
167
|
},
|
|
158
168
|
{
|
|
159
|
-
name:
|
|
160
|
-
type:
|
|
161
|
-
description:
|
|
162
|
-
|
|
169
|
+
name: "category",
|
|
170
|
+
type: "string",
|
|
171
|
+
description:
|
|
172
|
+
"Filter alerts by category (performance, cache, system, wordpress)",
|
|
173
|
+
required: false,
|
|
163
174
|
},
|
|
164
175
|
{
|
|
165
|
-
name:
|
|
166
|
-
type:
|
|
167
|
-
description:
|
|
168
|
-
required: false
|
|
176
|
+
name: "limit",
|
|
177
|
+
type: "number",
|
|
178
|
+
description: "Maximum number of alerts to return (default: 20)",
|
|
179
|
+
required: false,
|
|
169
180
|
},
|
|
170
181
|
{
|
|
171
|
-
name:
|
|
172
|
-
type:
|
|
173
|
-
description:
|
|
174
|
-
required: false
|
|
175
|
-
}
|
|
182
|
+
name: "includeAnomalies",
|
|
183
|
+
type: "boolean",
|
|
184
|
+
description: "Include detected anomalies (default: true)",
|
|
185
|
+
required: false,
|
|
186
|
+
},
|
|
176
187
|
],
|
|
177
|
-
handler: this.getPerformanceAlerts.bind(this)
|
|
188
|
+
handler: this.getPerformanceAlerts.bind(this),
|
|
178
189
|
},
|
|
179
190
|
{
|
|
180
|
-
name:
|
|
181
|
-
description:
|
|
191
|
+
name: "wp_performance_optimize",
|
|
192
|
+
description: "Get optimization recommendations and insights",
|
|
182
193
|
parameters: [
|
|
183
194
|
{
|
|
184
|
-
name:
|
|
185
|
-
type:
|
|
186
|
-
description:
|
|
187
|
-
|
|
195
|
+
name: "site",
|
|
196
|
+
type: "string",
|
|
197
|
+
description:
|
|
198
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
199
|
+
required: false,
|
|
188
200
|
},
|
|
189
201
|
{
|
|
190
|
-
name:
|
|
191
|
-
type:
|
|
192
|
-
description:
|
|
193
|
-
|
|
202
|
+
name: "focus",
|
|
203
|
+
type: "string",
|
|
204
|
+
description:
|
|
205
|
+
"Optimization focus area (speed, reliability, efficiency, scaling)",
|
|
206
|
+
required: false,
|
|
194
207
|
},
|
|
195
208
|
{
|
|
196
|
-
name:
|
|
197
|
-
type:
|
|
198
|
-
description:
|
|
199
|
-
|
|
209
|
+
name: "priority",
|
|
210
|
+
type: "string",
|
|
211
|
+
description:
|
|
212
|
+
"Implementation timeline (quick_wins, medium_term, long_term, all)",
|
|
213
|
+
required: false,
|
|
200
214
|
},
|
|
201
215
|
{
|
|
202
|
-
name:
|
|
203
|
-
type:
|
|
204
|
-
description:
|
|
205
|
-
required: false
|
|
216
|
+
name: "includeROI",
|
|
217
|
+
type: "boolean",
|
|
218
|
+
description: "Include ROI estimates (default: true)",
|
|
219
|
+
required: false,
|
|
206
220
|
},
|
|
207
221
|
{
|
|
208
|
-
name:
|
|
209
|
-
type:
|
|
210
|
-
description:
|
|
211
|
-
required: false
|
|
212
|
-
}
|
|
222
|
+
name: "includePredictions",
|
|
223
|
+
type: "boolean",
|
|
224
|
+
description: "Include performance predictions (default: true)",
|
|
225
|
+
required: false,
|
|
226
|
+
},
|
|
213
227
|
],
|
|
214
|
-
handler: this.getOptimizationRecommendations.bind(this)
|
|
228
|
+
handler: this.getOptimizationRecommendations.bind(this),
|
|
215
229
|
},
|
|
216
230
|
{
|
|
217
|
-
name:
|
|
218
|
-
description:
|
|
231
|
+
name: "wp_performance_export",
|
|
232
|
+
description: "Export comprehensive performance report",
|
|
219
233
|
parameters: [
|
|
220
234
|
{
|
|
221
|
-
name:
|
|
222
|
-
type:
|
|
223
|
-
description:
|
|
224
|
-
|
|
235
|
+
name: "site",
|
|
236
|
+
type: "string",
|
|
237
|
+
description:
|
|
238
|
+
"Specific site ID for multi-site setups (optional for single site)",
|
|
239
|
+
required: false,
|
|
225
240
|
},
|
|
226
241
|
{
|
|
227
|
-
name:
|
|
228
|
-
type:
|
|
229
|
-
description:
|
|
230
|
-
required: false
|
|
242
|
+
name: "format",
|
|
243
|
+
type: "string",
|
|
244
|
+
description: "Export format (json, csv, summary)",
|
|
245
|
+
required: false,
|
|
231
246
|
},
|
|
232
247
|
{
|
|
233
|
-
name:
|
|
234
|
-
type:
|
|
235
|
-
description:
|
|
236
|
-
required: false
|
|
248
|
+
name: "includeHistorical",
|
|
249
|
+
type: "boolean",
|
|
250
|
+
description: "Include historical data (default: true)",
|
|
251
|
+
required: false,
|
|
237
252
|
},
|
|
238
253
|
{
|
|
239
|
-
name:
|
|
240
|
-
type:
|
|
241
|
-
description:
|
|
242
|
-
required: false
|
|
254
|
+
name: "includeAnalytics",
|
|
255
|
+
type: "boolean",
|
|
256
|
+
description: "Include analytics and insights (default: true)",
|
|
257
|
+
required: false,
|
|
243
258
|
},
|
|
244
259
|
{
|
|
245
|
-
name:
|
|
246
|
-
type:
|
|
247
|
-
description:
|
|
248
|
-
required: false
|
|
249
|
-
}
|
|
260
|
+
name: "timeRange",
|
|
261
|
+
type: "string",
|
|
262
|
+
description: "Time range for data export (1h, 6h, 24h, 7d, 30d)",
|
|
263
|
+
required: false,
|
|
264
|
+
},
|
|
250
265
|
],
|
|
251
|
-
handler: this.exportPerformanceReport.bind(this)
|
|
252
|
-
}
|
|
266
|
+
handler: this.exportPerformanceReport.bind(this),
|
|
267
|
+
},
|
|
253
268
|
];
|
|
254
269
|
}
|
|
255
270
|
|
|
@@ -258,11 +273,11 @@ export default class PerformanceTools {
|
|
|
258
273
|
*/
|
|
259
274
|
private async getPerformanceStats(params: any): Promise<any> {
|
|
260
275
|
return toolWrapper(async () => {
|
|
261
|
-
const { site, category =
|
|
262
|
-
|
|
276
|
+
const { site, category = "overview", format = "summary" } = params;
|
|
277
|
+
|
|
263
278
|
// Get current metrics
|
|
264
279
|
const metrics = this.collector.collectCurrentMetrics();
|
|
265
|
-
|
|
280
|
+
|
|
266
281
|
// Get site-specific metrics if requested
|
|
267
282
|
let siteMetrics = null;
|
|
268
283
|
if (site) {
|
|
@@ -271,8 +286,8 @@ export default class PerformanceTools {
|
|
|
271
286
|
|
|
272
287
|
// Filter by category
|
|
273
288
|
const result: any = {};
|
|
274
|
-
|
|
275
|
-
if (category ===
|
|
289
|
+
|
|
290
|
+
if (category === "overview" || category === "all") {
|
|
276
291
|
result.overview = {
|
|
277
292
|
overallHealth: this.calculateHealthStatus(metrics),
|
|
278
293
|
performanceScore: this.calculatePerformanceScore(metrics),
|
|
@@ -280,47 +295,51 @@ export default class PerformanceTools {
|
|
|
280
295
|
averageResponseTime: `${metrics.requests.averageResponseTime.toFixed(0)}ms`,
|
|
281
296
|
cacheHitRate: `${(metrics.cache.hitRate * 100).toFixed(1)}%`,
|
|
282
297
|
errorRate: `${((metrics.requests.failed / Math.max(metrics.requests.total, 1)) * 100).toFixed(2)}%`,
|
|
283
|
-
uptime: this.formatUptime(metrics.system.uptime)
|
|
298
|
+
uptime: this.formatUptime(metrics.system.uptime),
|
|
284
299
|
};
|
|
285
300
|
}
|
|
286
301
|
|
|
287
|
-
if (category ===
|
|
302
|
+
if (category === "requests" || category === "all") {
|
|
288
303
|
result.requests = {
|
|
289
304
|
...metrics.requests,
|
|
290
305
|
requestsPerSecond: metrics.requests.requestsPerSecond.toFixed(2),
|
|
291
306
|
p50ResponseTime: `${metrics.requests.p50ResponseTime}ms`,
|
|
292
307
|
p95ResponseTime: `${metrics.requests.p95ResponseTime}ms`,
|
|
293
|
-
p99ResponseTime: `${metrics.requests.p99ResponseTime}ms
|
|
308
|
+
p99ResponseTime: `${metrics.requests.p99ResponseTime}ms`,
|
|
294
309
|
};
|
|
295
310
|
}
|
|
296
311
|
|
|
297
|
-
if (category ===
|
|
312
|
+
if (category === "cache" || category === "all") {
|
|
298
313
|
result.cache = {
|
|
299
314
|
...metrics.cache,
|
|
300
315
|
hitRate: `${(metrics.cache.hitRate * 100).toFixed(1)}%`,
|
|
301
316
|
memoryUsage: `${metrics.cache.memoryUsageMB.toFixed(1)}MB`,
|
|
302
|
-
efficiency: this.calculateCacheEfficiency(metrics.cache)
|
|
317
|
+
efficiency: this.calculateCacheEfficiency(metrics.cache),
|
|
303
318
|
};
|
|
304
319
|
}
|
|
305
320
|
|
|
306
|
-
if (category ===
|
|
321
|
+
if (category === "system" || category === "all") {
|
|
307
322
|
result.system = {
|
|
308
323
|
...metrics.system,
|
|
309
324
|
memoryUsage: `${metrics.system.memoryUsage}%`,
|
|
310
325
|
cpuUsage: `${metrics.system.cpuUsage}%`,
|
|
311
|
-
uptime: this.formatUptime(metrics.system.uptime)
|
|
326
|
+
uptime: this.formatUptime(metrics.system.uptime),
|
|
312
327
|
};
|
|
313
328
|
}
|
|
314
329
|
|
|
315
|
-
if (category ===
|
|
330
|
+
if (category === "tools" || category === "all") {
|
|
316
331
|
result.tools = {
|
|
317
332
|
mostUsedTool: metrics.tools.mostUsedTool,
|
|
318
|
-
totalToolCalls: Object.values(metrics.tools.toolUsageCount).reduce(
|
|
333
|
+
totalToolCalls: Object.values(metrics.tools.toolUsageCount).reduce(
|
|
334
|
+
(sum: number, count: any) => sum + count,
|
|
335
|
+
0,
|
|
336
|
+
),
|
|
319
337
|
topTools: Object.entries(metrics.tools.toolUsageCount)
|
|
320
|
-
.sort(([,a], [,b]) => (b as number) - (a as number))
|
|
338
|
+
.sort(([, a], [, b]) => (b as number) - (a as number))
|
|
321
339
|
.slice(0, 5)
|
|
322
340
|
.map(([tool, count]) => ({ tool, count })),
|
|
323
|
-
toolPerformance:
|
|
341
|
+
toolPerformance:
|
|
342
|
+
format === "detailed" ? metrics.tools.toolPerformance : undefined,
|
|
324
343
|
};
|
|
325
344
|
}
|
|
326
345
|
|
|
@@ -329,7 +348,7 @@ export default class PerformanceTools {
|
|
|
329
348
|
result.siteSpecific = {
|
|
330
349
|
siteId: site,
|
|
331
350
|
cache: siteMetrics.cache,
|
|
332
|
-
client: siteMetrics.client
|
|
351
|
+
client: siteMetrics.client,
|
|
333
352
|
};
|
|
334
353
|
}
|
|
335
354
|
|
|
@@ -338,13 +357,13 @@ export default class PerformanceTools {
|
|
|
338
357
|
timestamp: new Date().toISOString(),
|
|
339
358
|
category,
|
|
340
359
|
format,
|
|
341
|
-
site: site ||
|
|
342
|
-
monitoringEnabled: true
|
|
360
|
+
site: site || "all",
|
|
361
|
+
monitoringEnabled: true,
|
|
343
362
|
};
|
|
344
363
|
|
|
345
364
|
return {
|
|
346
365
|
success: true,
|
|
347
|
-
data: result
|
|
366
|
+
data: result,
|
|
348
367
|
};
|
|
349
368
|
});
|
|
350
369
|
}
|
|
@@ -354,35 +373,40 @@ export default class PerformanceTools {
|
|
|
354
373
|
*/
|
|
355
374
|
private async getPerformanceHistory(params: any): Promise<any> {
|
|
356
375
|
return toolWrapper(async () => {
|
|
357
|
-
const {
|
|
358
|
-
site,
|
|
359
|
-
timeframe =
|
|
360
|
-
metrics: requestedMetrics,
|
|
361
|
-
includeTrends = true
|
|
376
|
+
const {
|
|
377
|
+
site,
|
|
378
|
+
timeframe = "24h",
|
|
379
|
+
metrics: requestedMetrics,
|
|
380
|
+
includeTrends = true,
|
|
362
381
|
} = params;
|
|
363
382
|
|
|
364
383
|
// Convert timeframe to milliseconds
|
|
365
384
|
const timeframMs = this.parseTimeframe(timeframe);
|
|
366
385
|
const startTime = Date.now() - timeframMs;
|
|
367
|
-
|
|
386
|
+
|
|
368
387
|
// Get historical data
|
|
369
388
|
const historicalData = this.monitor.getHistoricalData(startTime);
|
|
370
|
-
|
|
389
|
+
|
|
371
390
|
// Analyze trends if requested
|
|
372
391
|
let trends = null;
|
|
373
392
|
if (includeTrends) {
|
|
374
393
|
// Add current data for trend analysis
|
|
375
394
|
this.analytics.addDataPoint(this.collector.collectCurrentMetrics());
|
|
376
395
|
trends = this.analytics.analyzeTrends();
|
|
377
|
-
|
|
396
|
+
|
|
378
397
|
// Filter trends by requested metrics
|
|
379
398
|
if (requestedMetrics && Array.isArray(requestedMetrics)) {
|
|
380
|
-
trends = trends.filter(trend =>
|
|
399
|
+
trends = trends.filter((trend) =>
|
|
400
|
+
requestedMetrics.includes(trend.metric),
|
|
401
|
+
);
|
|
381
402
|
}
|
|
382
403
|
}
|
|
383
404
|
|
|
384
405
|
// Process historical data for charting
|
|
385
|
-
const chartData = this.processHistoricalDataForChart(
|
|
406
|
+
const chartData = this.processHistoricalDataForChart(
|
|
407
|
+
historicalData,
|
|
408
|
+
requestedMetrics,
|
|
409
|
+
);
|
|
386
410
|
|
|
387
411
|
return {
|
|
388
412
|
success: true,
|
|
@@ -392,19 +416,28 @@ export default class PerformanceTools {
|
|
|
392
416
|
historicalData: chartData,
|
|
393
417
|
trends: trends || [],
|
|
394
418
|
summary: {
|
|
395
|
-
averageResponseTime: this.calculateAverage(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
419
|
+
averageResponseTime: this.calculateAverage(
|
|
420
|
+
historicalData.map((d) => d.requests.averageResponseTime),
|
|
421
|
+
),
|
|
422
|
+
averageCacheHitRate: this.calculateAverage(
|
|
423
|
+
historicalData.map((d) => d.cache.hitRate),
|
|
424
|
+
),
|
|
425
|
+
averageErrorRate: this.calculateAverage(
|
|
426
|
+
historicalData.map((d) =>
|
|
427
|
+
d.requests.total > 0 ? d.requests.failed / d.requests.total : 0,
|
|
428
|
+
),
|
|
429
|
+
),
|
|
430
|
+
totalRequests: historicalData.reduce(
|
|
431
|
+
(sum, d) => sum + d.requests.total,
|
|
432
|
+
0,
|
|
433
|
+
),
|
|
401
434
|
},
|
|
402
435
|
metadata: {
|
|
403
436
|
timestamp: new Date().toISOString(),
|
|
404
|
-
site: site ||
|
|
405
|
-
requestedMetrics: requestedMetrics || [
|
|
406
|
-
}
|
|
407
|
-
}
|
|
437
|
+
site: site || "all",
|
|
438
|
+
requestedMetrics: requestedMetrics || ["all"],
|
|
439
|
+
},
|
|
440
|
+
},
|
|
408
441
|
};
|
|
409
442
|
});
|
|
410
443
|
}
|
|
@@ -414,23 +447,25 @@ export default class PerformanceTools {
|
|
|
414
447
|
*/
|
|
415
448
|
private async getBenchmarkComparison(params: any): Promise<any> {
|
|
416
449
|
return toolWrapper(async () => {
|
|
417
|
-
const { site, category =
|
|
450
|
+
const { site, category = "all", includeRecommendations = true } = params;
|
|
418
451
|
|
|
419
452
|
// Get benchmark comparisons
|
|
420
453
|
const benchmarks = this.analytics.benchmarkPerformance();
|
|
421
|
-
|
|
454
|
+
|
|
422
455
|
// Filter by category if specified
|
|
423
456
|
let filteredBenchmarks = benchmarks;
|
|
424
|
-
if (category !==
|
|
457
|
+
if (category !== "all") {
|
|
425
458
|
const categoryMap: Record<string, string> = {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
459
|
+
response_time: "Response Time",
|
|
460
|
+
cache_performance: "Cache Hit Rate",
|
|
461
|
+
error_rate: "Error Rate",
|
|
462
|
+
system_resources: "Memory Usage",
|
|
430
463
|
};
|
|
431
464
|
const targetCategory = categoryMap[category];
|
|
432
465
|
if (targetCategory) {
|
|
433
|
-
filteredBenchmarks = benchmarks.filter(
|
|
466
|
+
filteredBenchmarks = benchmarks.filter(
|
|
467
|
+
(b) => b.category === targetCategory,
|
|
468
|
+
);
|
|
434
469
|
}
|
|
435
470
|
}
|
|
436
471
|
|
|
@@ -439,36 +474,40 @@ export default class PerformanceTools {
|
|
|
439
474
|
if (includeRecommendations) {
|
|
440
475
|
const insights = this.analytics.generateInsights();
|
|
441
476
|
recommendations = insights
|
|
442
|
-
.filter(insight => insight.category ===
|
|
443
|
-
.map(insight => ({
|
|
477
|
+
.filter((insight) => insight.category === "optimization")
|
|
478
|
+
.map((insight) => ({
|
|
444
479
|
title: insight.title,
|
|
445
480
|
description: insight.description,
|
|
446
481
|
priority: insight.priority,
|
|
447
482
|
estimatedImprovement: insight.estimatedImprovement,
|
|
448
|
-
implementationEffort: insight.implementationEffort
|
|
483
|
+
implementationEffort: insight.implementationEffort,
|
|
449
484
|
}));
|
|
450
485
|
}
|
|
451
486
|
|
|
452
487
|
return {
|
|
453
488
|
success: true,
|
|
454
489
|
data: {
|
|
455
|
-
benchmarks: filteredBenchmarks.map(benchmark => ({
|
|
490
|
+
benchmarks: filteredBenchmarks.map((benchmark) => ({
|
|
456
491
|
...benchmark,
|
|
457
492
|
status: this.formatBenchmarkStatus(benchmark.status),
|
|
458
|
-
improvement:
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
493
|
+
improvement:
|
|
494
|
+
benchmark.improvement > 0
|
|
495
|
+
? {
|
|
496
|
+
needed: benchmark.improvement,
|
|
497
|
+
description:
|
|
498
|
+
this.getBenchmarkImprovementDescription(benchmark),
|
|
499
|
+
}
|
|
500
|
+
: null,
|
|
462
501
|
})),
|
|
463
502
|
overallRanking: this.calculateOverallRanking(benchmarks),
|
|
464
503
|
recommendations: recommendations || [],
|
|
465
504
|
metadata: {
|
|
466
505
|
timestamp: new Date().toISOString(),
|
|
467
506
|
category,
|
|
468
|
-
site: site ||
|
|
469
|
-
benchmarkVersion:
|
|
470
|
-
}
|
|
471
|
-
}
|
|
507
|
+
site: site || "all",
|
|
508
|
+
benchmarkVersion: "2024-industry-standards",
|
|
509
|
+
},
|
|
510
|
+
},
|
|
472
511
|
};
|
|
473
512
|
});
|
|
474
513
|
}
|
|
@@ -478,20 +517,20 @@ export default class PerformanceTools {
|
|
|
478
517
|
*/
|
|
479
518
|
private async getPerformanceAlerts(params: any): Promise<any> {
|
|
480
519
|
return toolWrapper(async () => {
|
|
481
|
-
const {
|
|
482
|
-
site,
|
|
483
|
-
severity,
|
|
484
|
-
category,
|
|
485
|
-
limit = 20,
|
|
486
|
-
includeAnomalies = true
|
|
520
|
+
const {
|
|
521
|
+
site,
|
|
522
|
+
severity,
|
|
523
|
+
category,
|
|
524
|
+
limit = 20,
|
|
525
|
+
includeAnomalies = true,
|
|
487
526
|
} = params;
|
|
488
527
|
|
|
489
528
|
// Get alerts from monitor
|
|
490
529
|
let alerts = this.monitor.getAlerts(severity);
|
|
491
|
-
|
|
530
|
+
|
|
492
531
|
// Filter by category if specified
|
|
493
532
|
if (category) {
|
|
494
|
-
alerts = alerts.filter(alert => alert.category === category);
|
|
533
|
+
alerts = alerts.filter((alert) => alert.category === category);
|
|
495
534
|
}
|
|
496
535
|
|
|
497
536
|
// Limit results
|
|
@@ -506,44 +545,47 @@ export default class PerformanceTools {
|
|
|
506
545
|
// Calculate alert summary
|
|
507
546
|
const alertSummary = {
|
|
508
547
|
total: alerts.length,
|
|
509
|
-
critical: alerts.filter(a => a.severity ===
|
|
510
|
-
error: alerts.filter(a => a.severity ===
|
|
511
|
-
warning: alerts.filter(a => a.severity ===
|
|
512
|
-
info: alerts.filter(a => a.severity ===
|
|
548
|
+
critical: alerts.filter((a) => a.severity === "critical").length,
|
|
549
|
+
error: alerts.filter((a) => a.severity === "error").length,
|
|
550
|
+
warning: alerts.filter((a) => a.severity === "warning").length,
|
|
551
|
+
info: alerts.filter((a) => a.severity === "info").length,
|
|
513
552
|
};
|
|
514
553
|
|
|
515
554
|
const anomalySummary = {
|
|
516
555
|
total: anomalies.length,
|
|
517
|
-
critical: anomalies.filter(a => a.severity ===
|
|
518
|
-
major: anomalies.filter(a => a.severity ===
|
|
519
|
-
moderate: anomalies.filter(a => a.severity ===
|
|
520
|
-
minor: anomalies.filter(a => a.severity ===
|
|
556
|
+
critical: anomalies.filter((a) => a.severity === "critical").length,
|
|
557
|
+
major: anomalies.filter((a) => a.severity === "major").length,
|
|
558
|
+
moderate: anomalies.filter((a) => a.severity === "moderate").length,
|
|
559
|
+
minor: anomalies.filter((a) => a.severity === "minor").length,
|
|
521
560
|
};
|
|
522
561
|
|
|
523
562
|
return {
|
|
524
563
|
success: true,
|
|
525
564
|
data: {
|
|
526
|
-
alerts: alerts.map(alert => ({
|
|
565
|
+
alerts: alerts.map((alert) => ({
|
|
527
566
|
...alert,
|
|
528
567
|
timestamp: new Date(alert.timestamp).toISOString(),
|
|
529
|
-
formattedMessage: this.formatAlertMessage(alert)
|
|
568
|
+
formattedMessage: this.formatAlertMessage(alert),
|
|
530
569
|
})),
|
|
531
|
-
anomalies: anomalies.map(anomaly => ({
|
|
570
|
+
anomalies: anomalies.map((anomaly) => ({
|
|
532
571
|
...anomaly,
|
|
533
572
|
timestamp: new Date(anomaly.timestamp).toISOString(),
|
|
534
|
-
formattedDescription: this.formatAnomalyDescription(anomaly)
|
|
573
|
+
formattedDescription: this.formatAnomalyDescription(anomaly),
|
|
535
574
|
})),
|
|
536
575
|
summary: {
|
|
537
576
|
alerts: alertSummary,
|
|
538
577
|
anomalies: anomalySummary,
|
|
539
|
-
overallStatus: this.calculateAlertStatus(
|
|
578
|
+
overallStatus: this.calculateAlertStatus(
|
|
579
|
+
alertSummary,
|
|
580
|
+
anomalySummary,
|
|
581
|
+
),
|
|
540
582
|
},
|
|
541
583
|
metadata: {
|
|
542
584
|
timestamp: new Date().toISOString(),
|
|
543
|
-
filters: { severity, category, site: site ||
|
|
544
|
-
limit
|
|
545
|
-
}
|
|
546
|
-
}
|
|
585
|
+
filters: { severity, category, site: site || "all" },
|
|
586
|
+
limit,
|
|
587
|
+
},
|
|
588
|
+
},
|
|
547
589
|
};
|
|
548
590
|
});
|
|
549
591
|
}
|
|
@@ -553,38 +595,55 @@ export default class PerformanceTools {
|
|
|
553
595
|
*/
|
|
554
596
|
private async getOptimizationRecommendations(params: any): Promise<any> {
|
|
555
597
|
return toolWrapper(async () => {
|
|
556
|
-
const {
|
|
557
|
-
site,
|
|
558
|
-
focus =
|
|
559
|
-
priority =
|
|
560
|
-
includeROI = true,
|
|
561
|
-
includePredictions = true
|
|
598
|
+
const {
|
|
599
|
+
site,
|
|
600
|
+
focus = "speed",
|
|
601
|
+
priority = "all",
|
|
602
|
+
includeROI = true,
|
|
603
|
+
includePredictions = true,
|
|
562
604
|
} = params;
|
|
563
605
|
|
|
564
606
|
// Generate optimization plan
|
|
565
607
|
const optimizationPlan = this.analytics.generateOptimizationPlan();
|
|
566
|
-
|
|
608
|
+
|
|
567
609
|
// Filter by priority
|
|
568
610
|
let recommendations = [];
|
|
569
|
-
if (priority ===
|
|
570
|
-
recommendations.push(
|
|
611
|
+
if (priority === "quick_wins" || priority === "all") {
|
|
612
|
+
recommendations.push(
|
|
613
|
+
...optimizationPlan.quickWins.map((r) => ({
|
|
614
|
+
...r,
|
|
615
|
+
timeline: "quick_wins",
|
|
616
|
+
})),
|
|
617
|
+
);
|
|
571
618
|
}
|
|
572
|
-
if (priority ===
|
|
573
|
-
recommendations.push(
|
|
619
|
+
if (priority === "medium_term" || priority === "all") {
|
|
620
|
+
recommendations.push(
|
|
621
|
+
...optimizationPlan.mediumTerm.map((r) => ({
|
|
622
|
+
...r,
|
|
623
|
+
timeline: "medium_term",
|
|
624
|
+
})),
|
|
625
|
+
);
|
|
574
626
|
}
|
|
575
|
-
if (priority ===
|
|
576
|
-
recommendations.push(
|
|
627
|
+
if (priority === "long_term" || priority === "all") {
|
|
628
|
+
recommendations.push(
|
|
629
|
+
...optimizationPlan.longTerm.map((r) => ({
|
|
630
|
+
...r,
|
|
631
|
+
timeline: "long_term",
|
|
632
|
+
})),
|
|
633
|
+
);
|
|
577
634
|
}
|
|
578
635
|
|
|
579
636
|
// Filter by focus area
|
|
580
|
-
if (focus !==
|
|
637
|
+
if (focus !== "speed") {
|
|
581
638
|
const focusMap: Record<string, string[]> = {
|
|
582
|
-
reliability: [
|
|
583
|
-
efficiency: [
|
|
584
|
-
scaling: [
|
|
639
|
+
reliability: ["reliability"],
|
|
640
|
+
efficiency: ["cost", "performance"],
|
|
641
|
+
scaling: ["performance", "reliability"],
|
|
585
642
|
};
|
|
586
643
|
const targetImpacts = focusMap[focus] || [];
|
|
587
|
-
recommendations = recommendations.filter(r =>
|
|
644
|
+
recommendations = recommendations.filter((r) =>
|
|
645
|
+
targetImpacts.includes(r.impact),
|
|
646
|
+
);
|
|
588
647
|
}
|
|
589
648
|
|
|
590
649
|
// Get predictions if requested
|
|
@@ -596,10 +655,10 @@ export default class PerformanceTools {
|
|
|
596
655
|
return {
|
|
597
656
|
success: true,
|
|
598
657
|
data: {
|
|
599
|
-
recommendations: recommendations.map(rec => ({
|
|
658
|
+
recommendations: recommendations.map((rec) => ({
|
|
600
659
|
...rec,
|
|
601
660
|
formattedPriority: this.formatPriority(rec.priority),
|
|
602
|
-
formattedEffort: this.formatEffort(rec.implementationEffort)
|
|
661
|
+
formattedEffort: this.formatEffort(rec.implementationEffort),
|
|
603
662
|
})),
|
|
604
663
|
roi: includeROI ? optimizationPlan.estimatedROI : null,
|
|
605
664
|
predictions: predictions || null,
|
|
@@ -608,15 +667,15 @@ export default class PerformanceTools {
|
|
|
608
667
|
quickWins: optimizationPlan.quickWins.length,
|
|
609
668
|
mediumTerm: optimizationPlan.mediumTerm.length,
|
|
610
669
|
longTerm: optimizationPlan.longTerm.length,
|
|
611
|
-
estimatedImpact: this.calculateEstimatedImpact(recommendations)
|
|
670
|
+
estimatedImpact: this.calculateEstimatedImpact(recommendations),
|
|
612
671
|
},
|
|
613
672
|
metadata: {
|
|
614
673
|
timestamp: new Date().toISOString(),
|
|
615
674
|
focus,
|
|
616
675
|
priority,
|
|
617
|
-
site: site ||
|
|
618
|
-
}
|
|
619
|
-
}
|
|
676
|
+
site: site || "all",
|
|
677
|
+
},
|
|
678
|
+
},
|
|
620
679
|
};
|
|
621
680
|
});
|
|
622
681
|
}
|
|
@@ -626,28 +685,28 @@ export default class PerformanceTools {
|
|
|
626
685
|
*/
|
|
627
686
|
private async exportPerformanceReport(params: any): Promise<any> {
|
|
628
687
|
return toolWrapper(async () => {
|
|
629
|
-
const {
|
|
630
|
-
site,
|
|
631
|
-
format =
|
|
632
|
-
includeHistorical = true,
|
|
633
|
-
includeAnalytics = true,
|
|
634
|
-
timeRange =
|
|
688
|
+
const {
|
|
689
|
+
site,
|
|
690
|
+
format = "json",
|
|
691
|
+
includeHistorical = true,
|
|
692
|
+
includeAnalytics = true,
|
|
693
|
+
timeRange = "24h",
|
|
635
694
|
} = params;
|
|
636
695
|
|
|
637
696
|
// Generate comprehensive analytics report
|
|
638
697
|
const report = this.analytics.exportAnalyticsReport();
|
|
639
|
-
|
|
698
|
+
|
|
640
699
|
// Add additional data based on parameters
|
|
641
700
|
const exportData: any = {
|
|
642
701
|
metadata: {
|
|
643
702
|
generatedAt: new Date().toISOString(),
|
|
644
|
-
site: site ||
|
|
703
|
+
site: site || "all",
|
|
645
704
|
timeRange,
|
|
646
705
|
format,
|
|
647
|
-
version:
|
|
706
|
+
version: "1.0.0",
|
|
648
707
|
},
|
|
649
708
|
summary: report.summary,
|
|
650
|
-
currentMetrics: this.collector.collectCurrentMetrics()
|
|
709
|
+
currentMetrics: this.collector.collectCurrentMetrics(),
|
|
651
710
|
};
|
|
652
711
|
|
|
653
712
|
if (includeHistorical) {
|
|
@@ -663,14 +722,14 @@ export default class PerformanceTools {
|
|
|
663
722
|
insights: report.insights,
|
|
664
723
|
anomalies: report.anomalies,
|
|
665
724
|
predictions: report.predictions,
|
|
666
|
-
optimizationPlan: report.optimizationPlan
|
|
725
|
+
optimizationPlan: report.optimizationPlan,
|
|
667
726
|
};
|
|
668
727
|
}
|
|
669
728
|
|
|
670
729
|
// Add aggregated statistics
|
|
671
730
|
exportData.aggregatedStats = {
|
|
672
731
|
cache: this.collector.getAggregatedCacheStats(),
|
|
673
|
-
client: this.collector.getAggregatedClientStats()
|
|
732
|
+
client: this.collector.getAggregatedClientStats(),
|
|
674
733
|
};
|
|
675
734
|
|
|
676
735
|
// Add site comparison if multi-site
|
|
@@ -680,9 +739,9 @@ export default class PerformanceTools {
|
|
|
680
739
|
|
|
681
740
|
// Format output based on requested format
|
|
682
741
|
let formattedOutput: any;
|
|
683
|
-
if (format ===
|
|
742
|
+
if (format === "csv") {
|
|
684
743
|
formattedOutput = this.convertToCSV(exportData);
|
|
685
|
-
} else if (format ===
|
|
744
|
+
} else if (format === "summary") {
|
|
686
745
|
formattedOutput = this.createSummaryReport(exportData);
|
|
687
746
|
} else {
|
|
688
747
|
formattedOutput = exportData;
|
|
@@ -695,8 +754,8 @@ export default class PerformanceTools {
|
|
|
695
754
|
timestamp: new Date().toISOString(),
|
|
696
755
|
format,
|
|
697
756
|
dataSize: JSON.stringify(exportData).length,
|
|
698
|
-
site: site ||
|
|
699
|
-
}
|
|
757
|
+
site: site || "all",
|
|
758
|
+
},
|
|
700
759
|
};
|
|
701
760
|
});
|
|
702
761
|
}
|
|
@@ -705,61 +764,64 @@ export default class PerformanceTools {
|
|
|
705
764
|
|
|
706
765
|
private calculateHealthStatus(metrics: any): string {
|
|
707
766
|
let score = 100;
|
|
708
|
-
|
|
767
|
+
|
|
709
768
|
if (metrics.requests.averageResponseTime > 2000) score -= 30;
|
|
710
769
|
else if (metrics.requests.averageResponseTime > 1000) score -= 15;
|
|
711
|
-
|
|
712
|
-
const errorRate =
|
|
770
|
+
|
|
771
|
+
const errorRate =
|
|
772
|
+
metrics.requests.failed / Math.max(metrics.requests.total, 1);
|
|
713
773
|
if (errorRate > 0.05) score -= 30;
|
|
714
774
|
else if (errorRate > 0.02) score -= 15;
|
|
715
|
-
|
|
775
|
+
|
|
716
776
|
if (metrics.cache.hitRate < 0.7) score -= 25;
|
|
717
777
|
else if (metrics.cache.hitRate < 0.85) score -= 10;
|
|
718
|
-
|
|
778
|
+
|
|
719
779
|
if (metrics.system.memoryUsage > 85) score -= 15;
|
|
720
|
-
|
|
721
|
-
if (score >= 90) return
|
|
722
|
-
if (score >= 75) return
|
|
723
|
-
if (score >= 60) return
|
|
724
|
-
if (score >= 40) return
|
|
725
|
-
return
|
|
780
|
+
|
|
781
|
+
if (score >= 90) return "Excellent";
|
|
782
|
+
if (score >= 75) return "Good";
|
|
783
|
+
if (score >= 60) return "Fair";
|
|
784
|
+
if (score >= 40) return "Poor";
|
|
785
|
+
return "Critical";
|
|
726
786
|
}
|
|
727
787
|
|
|
728
788
|
private calculatePerformanceScore(metrics: any): number {
|
|
729
789
|
let score = 100;
|
|
730
|
-
|
|
790
|
+
|
|
731
791
|
// Response time scoring
|
|
732
792
|
if (metrics.requests.averageResponseTime > 3000) score -= 40;
|
|
733
793
|
else if (metrics.requests.averageResponseTime > 1500) score -= 25;
|
|
734
794
|
else if (metrics.requests.averageResponseTime > 800) score -= 10;
|
|
735
|
-
|
|
795
|
+
|
|
736
796
|
// Error rate scoring
|
|
737
|
-
const errorRate =
|
|
797
|
+
const errorRate =
|
|
798
|
+
metrics.requests.failed / Math.max(metrics.requests.total, 1);
|
|
738
799
|
if (errorRate > 0.1) score -= 30;
|
|
739
800
|
else if (errorRate > 0.05) score -= 20;
|
|
740
801
|
else if (errorRate > 0.02) score -= 10;
|
|
741
|
-
|
|
802
|
+
|
|
742
803
|
// Cache performance scoring
|
|
743
804
|
if (metrics.cache.hitRate < 0.5) score -= 20;
|
|
744
805
|
else if (metrics.cache.hitRate < 0.75) score -= 10;
|
|
745
806
|
else if (metrics.cache.hitRate < 0.9) score -= 5;
|
|
746
|
-
|
|
807
|
+
|
|
747
808
|
// System resource scoring
|
|
748
809
|
if (metrics.system.memoryUsage > 90) score -= 10;
|
|
749
810
|
else if (metrics.system.memoryUsage > 80) score -= 5;
|
|
750
|
-
|
|
811
|
+
|
|
751
812
|
return Math.max(0, Math.min(100, score));
|
|
752
813
|
}
|
|
753
814
|
|
|
754
815
|
private calculateCacheEfficiency(cacheMetrics: any): string {
|
|
755
|
-
const efficiency =
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
if (efficiency >=
|
|
761
|
-
if (efficiency >=
|
|
762
|
-
return
|
|
816
|
+
const efficiency =
|
|
817
|
+
cacheMetrics.hitRate * 100 +
|
|
818
|
+
(cacheMetrics.totalSize > 0 ? 10 : 0) -
|
|
819
|
+
(cacheMetrics.evictions > 100 ? 10 : 0);
|
|
820
|
+
|
|
821
|
+
if (efficiency >= 95) return "Excellent";
|
|
822
|
+
if (efficiency >= 85) return "Good";
|
|
823
|
+
if (efficiency >= 70) return "Fair";
|
|
824
|
+
return "Poor";
|
|
763
825
|
}
|
|
764
826
|
|
|
765
827
|
private formatUptime(uptimeMs: number): string {
|
|
@@ -767,7 +829,7 @@ export default class PerformanceTools {
|
|
|
767
829
|
const minutes = Math.floor(seconds / 60);
|
|
768
830
|
const hours = Math.floor(minutes / 60);
|
|
769
831
|
const days = Math.floor(hours / 24);
|
|
770
|
-
|
|
832
|
+
|
|
771
833
|
if (days > 0) return `${days}d ${hours % 24}h ${minutes % 60}m`;
|
|
772
834
|
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
|
773
835
|
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
@@ -776,43 +838,61 @@ export default class PerformanceTools {
|
|
|
776
838
|
|
|
777
839
|
private parseTimeframe(timeframe: string): number {
|
|
778
840
|
const map: Record<string, number> = {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
841
|
+
"1h": 60 * 60 * 1000,
|
|
842
|
+
"6h": 6 * 60 * 60 * 1000,
|
|
843
|
+
"12h": 12 * 60 * 60 * 1000,
|
|
844
|
+
"24h": 24 * 60 * 60 * 1000,
|
|
845
|
+
"7d": 7 * 24 * 60 * 60 * 1000,
|
|
846
|
+
"30d": 30 * 24 * 60 * 60 * 1000,
|
|
785
847
|
};
|
|
786
|
-
return map[timeframe] || map[
|
|
848
|
+
return map[timeframe] || map["24h"];
|
|
787
849
|
}
|
|
788
850
|
|
|
789
|
-
private processHistoricalDataForChart(
|
|
851
|
+
private processHistoricalDataForChart(
|
|
852
|
+
data: any[],
|
|
853
|
+
requestedMetrics?: string[],
|
|
854
|
+
): any {
|
|
790
855
|
if (!data.length) return {};
|
|
791
|
-
|
|
792
|
-
const allMetrics = [
|
|
856
|
+
|
|
857
|
+
const allMetrics = [
|
|
858
|
+
"responseTime",
|
|
859
|
+
"cacheHitRate",
|
|
860
|
+
"errorRate",
|
|
861
|
+
"memoryUsage",
|
|
862
|
+
"requestVolume",
|
|
863
|
+
];
|
|
793
864
|
const metricsToProcess = requestedMetrics || allMetrics;
|
|
794
|
-
|
|
865
|
+
|
|
795
866
|
const result: any = {};
|
|
796
|
-
|
|
867
|
+
|
|
797
868
|
for (const metric of metricsToProcess) {
|
|
798
869
|
result[metric] = data.map((point, index) => ({
|
|
799
870
|
timestamp: point.system.uptime,
|
|
800
871
|
value: this.extractMetricValue(point, metric),
|
|
801
|
-
index
|
|
872
|
+
index,
|
|
802
873
|
}));
|
|
803
874
|
}
|
|
804
|
-
|
|
875
|
+
|
|
805
876
|
return result;
|
|
806
877
|
}
|
|
807
878
|
|
|
808
879
|
private extractMetricValue(dataPoint: any, metric: string): number {
|
|
809
880
|
switch (metric) {
|
|
810
|
-
case
|
|
811
|
-
|
|
812
|
-
case
|
|
813
|
-
|
|
814
|
-
case
|
|
815
|
-
|
|
881
|
+
case "responseTime":
|
|
882
|
+
return dataPoint.requests.averageResponseTime;
|
|
883
|
+
case "cacheHitRate":
|
|
884
|
+
return dataPoint.cache.hitRate * 100;
|
|
885
|
+
case "errorRate":
|
|
886
|
+
return (
|
|
887
|
+
(dataPoint.requests.failed / Math.max(dataPoint.requests.total, 1)) *
|
|
888
|
+
100
|
|
889
|
+
);
|
|
890
|
+
case "memoryUsage":
|
|
891
|
+
return dataPoint.system.memoryUsage;
|
|
892
|
+
case "requestVolume":
|
|
893
|
+
return dataPoint.requests.requestsPerSecond;
|
|
894
|
+
default:
|
|
895
|
+
return 0;
|
|
816
896
|
}
|
|
817
897
|
}
|
|
818
898
|
|
|
@@ -823,37 +903,43 @@ export default class PerformanceTools {
|
|
|
823
903
|
|
|
824
904
|
private formatBenchmarkStatus(status: string): string {
|
|
825
905
|
const statusMap: Record<string, string> = {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
906
|
+
excellent: "🟢 Excellent",
|
|
907
|
+
good: "🟡 Good",
|
|
908
|
+
average: "🟠 Average",
|
|
909
|
+
below_average: "🔴 Below Average",
|
|
910
|
+
poor: "⚫ Poor",
|
|
831
911
|
};
|
|
832
912
|
return statusMap[status] || status;
|
|
833
913
|
}
|
|
834
914
|
|
|
835
915
|
private getBenchmarkImprovementDescription(benchmark: any): string {
|
|
836
916
|
const improvements: Record<string, string> = {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
917
|
+
"Response Time": `Reduce by ${benchmark.improvement.toFixed(0)}ms`,
|
|
918
|
+
"Cache Hit Rate": `Increase by ${benchmark.improvement.toFixed(1)}%`,
|
|
919
|
+
"Error Rate": `Reduce by ${benchmark.improvement.toFixed(2)}%`,
|
|
920
|
+
"Memory Usage": `Reduce by ${benchmark.improvement.toFixed(0)}%`,
|
|
841
921
|
};
|
|
842
|
-
return
|
|
922
|
+
return (
|
|
923
|
+
improvements[benchmark.category] || `Improve by ${benchmark.improvement}`
|
|
924
|
+
);
|
|
843
925
|
}
|
|
844
926
|
|
|
845
|
-
private calculateOverallRanking(benchmarks: any[]): {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
927
|
+
private calculateOverallRanking(benchmarks: any[]): {
|
|
928
|
+
percentile: number;
|
|
929
|
+
status: string;
|
|
930
|
+
} {
|
|
931
|
+
const statuses = benchmarks.map((b) => b.status);
|
|
932
|
+
const excellentCount = statuses.filter((s) => s === "excellent").length;
|
|
933
|
+
const goodCount = statuses.filter((s) => s === "good").length;
|
|
934
|
+
|
|
935
|
+
const percentile =
|
|
936
|
+
((excellentCount + goodCount * 0.8) / statuses.length) * 100;
|
|
937
|
+
|
|
938
|
+
let status = "Needs Improvement";
|
|
939
|
+
if (percentile >= 90) status = "Top Performer";
|
|
940
|
+
else if (percentile >= 75) status = "Above Average";
|
|
941
|
+
else if (percentile >= 50) status = "Average";
|
|
942
|
+
|
|
857
943
|
return { percentile: Math.round(percentile), status };
|
|
858
944
|
}
|
|
859
945
|
|
|
@@ -862,64 +948,68 @@ export default class PerformanceTools {
|
|
|
862
948
|
}
|
|
863
949
|
|
|
864
950
|
private formatAnomalyDescription(anomaly: any): string {
|
|
865
|
-
const direction =
|
|
951
|
+
const direction =
|
|
952
|
+
anomaly.actualValue > anomaly.expectedValue ? "higher" : "lower";
|
|
866
953
|
return `${anomaly.metric} is ${Math.abs(anomaly.deviation).toFixed(1)}% ${direction} than expected (${anomaly.expectedValue.toFixed(2)} vs ${anomaly.actualValue.toFixed(2)})`;
|
|
867
954
|
}
|
|
868
955
|
|
|
869
956
|
private calculateAlertStatus(alertSummary: any, anomalySummary: any): string {
|
|
870
957
|
const critical = alertSummary.critical + anomalySummary.critical;
|
|
871
958
|
const high = alertSummary.error + anomalySummary.major;
|
|
872
|
-
|
|
873
|
-
if (critical > 0) return
|
|
874
|
-
if (high > 2) return
|
|
875
|
-
if (alertSummary.warning + anomalySummary.moderate > 5)
|
|
876
|
-
|
|
959
|
+
|
|
960
|
+
if (critical > 0) return "Critical Issues Detected";
|
|
961
|
+
if (high > 2) return "High Priority Issues";
|
|
962
|
+
if (alertSummary.warning + anomalySummary.moderate > 5)
|
|
963
|
+
return "Performance Warnings";
|
|
964
|
+
return "System Healthy";
|
|
877
965
|
}
|
|
878
966
|
|
|
879
967
|
private formatPriority(priority: string): string {
|
|
880
968
|
const map: Record<string, string> = {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
969
|
+
critical: "🔴 Critical",
|
|
970
|
+
high: "🟠 High",
|
|
971
|
+
medium: "🟡 Medium",
|
|
972
|
+
low: "🟢 Low",
|
|
885
973
|
};
|
|
886
974
|
return map[priority] || priority;
|
|
887
975
|
}
|
|
888
976
|
|
|
889
977
|
private formatEffort(effort: string): string {
|
|
890
978
|
const map: Record<string, string> = {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
979
|
+
low: "⚡ Low Effort",
|
|
980
|
+
medium: "⚖️ Medium Effort",
|
|
981
|
+
high: "🏋️ High Effort",
|
|
894
982
|
};
|
|
895
983
|
return map[effort] || effort;
|
|
896
984
|
}
|
|
897
985
|
|
|
898
986
|
private calculateEstimatedImpact(recommendations: any[]): string {
|
|
899
|
-
const highImpact = recommendations.filter(r =>
|
|
987
|
+
const highImpact = recommendations.filter((r) =>
|
|
988
|
+
["critical", "high"].includes(r.priority),
|
|
989
|
+
).length;
|
|
900
990
|
const totalImpact = recommendations.length;
|
|
901
|
-
|
|
902
|
-
if (highImpact >= 3) return
|
|
903
|
-
if (totalImpact >= 5) return
|
|
904
|
-
if (totalImpact > 0) return
|
|
905
|
-
return
|
|
991
|
+
|
|
992
|
+
if (highImpact >= 3) return "Significant Performance Gains Expected";
|
|
993
|
+
if (totalImpact >= 5) return "Moderate Performance Improvements";
|
|
994
|
+
if (totalImpact > 0) return "Minor Performance Optimizations";
|
|
995
|
+
return "System Already Optimized";
|
|
906
996
|
}
|
|
907
997
|
|
|
908
998
|
private convertToCSV(data: any): string {
|
|
909
999
|
// Simplified CSV conversion for current metrics
|
|
910
1000
|
const metrics = data.currentMetrics;
|
|
911
1001
|
const csv = [
|
|
912
|
-
|
|
1002
|
+
"Metric,Value,Unit",
|
|
913
1003
|
`Total Requests,${metrics.requests.total},count`,
|
|
914
1004
|
`Average Response Time,${metrics.requests.averageResponseTime.toFixed(0)},ms`,
|
|
915
1005
|
`Success Rate,${((metrics.requests.successful / Math.max(metrics.requests.total, 1)) * 100).toFixed(1)},%`,
|
|
916
1006
|
`Cache Hit Rate,${(metrics.cache.hitRate * 100).toFixed(1)},%`,
|
|
917
1007
|
`Cache Size,${metrics.cache.totalSize},entries`,
|
|
918
1008
|
`Memory Usage,${metrics.system.memoryUsage},percent`,
|
|
919
|
-
`Uptime,${metrics.system.uptime},ms
|
|
1009
|
+
`Uptime,${metrics.system.uptime},ms`,
|
|
920
1010
|
];
|
|
921
|
-
|
|
922
|
-
return csv.join(
|
|
1011
|
+
|
|
1012
|
+
return csv.join("\n");
|
|
923
1013
|
}
|
|
924
1014
|
|
|
925
1015
|
private createSummaryReport(data: any): any {
|
|
@@ -931,10 +1021,11 @@ export default class PerformanceTools {
|
|
|
931
1021
|
averageResponseTime: `${metrics.requests.averageResponseTime.toFixed(0)}ms`,
|
|
932
1022
|
cacheEfficiency: `${(metrics.cache.hitRate * 100).toFixed(1)}%`,
|
|
933
1023
|
systemLoad: `${metrics.system.memoryUsage}%`,
|
|
934
|
-
errorRate: `${((metrics.requests.failed / Math.max(metrics.requests.total, 1)) * 100).toFixed(2)}
|
|
1024
|
+
errorRate: `${((metrics.requests.failed / Math.max(metrics.requests.total, 1)) * 100).toFixed(2)}%`,
|
|
935
1025
|
},
|
|
936
1026
|
recommendations: data.analytics?.insights?.slice(0, 3) || [],
|
|
937
|
-
nextSteps:
|
|
1027
|
+
nextSteps:
|
|
1028
|
+
"Review detailed metrics and implement high-priority optimizations",
|
|
938
1029
|
};
|
|
939
1030
|
}
|
|
940
1031
|
|