adonisjs-server-stats 1.6.1 → 1.6.5

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 (56) hide show
  1. package/dist/src/collectors/app_collector.d.ts.map +1 -1
  2. package/dist/src/collectors/app_collector.js +2 -1
  3. package/dist/src/collectors/auto_detect.d.ts.map +1 -1
  4. package/dist/src/collectors/auto_detect.js +7 -3
  5. package/dist/src/collectors/db_pool_collector.d.ts.map +1 -1
  6. package/dist/src/collectors/db_pool_collector.js +2 -1
  7. package/dist/src/collectors/http_collector.d.ts +4 -3
  8. package/dist/src/collectors/http_collector.d.ts.map +1 -1
  9. package/dist/src/collectors/http_collector.js +3 -5
  10. package/dist/src/collectors/redis_collector.d.ts.map +1 -1
  11. package/dist/src/collectors/redis_collector.js +2 -1
  12. package/dist/src/controller/debug_controller.d.ts +5 -0
  13. package/dist/src/controller/debug_controller.d.ts.map +1 -1
  14. package/dist/src/controller/debug_controller.js +24 -1
  15. package/dist/src/dashboard/chart_aggregator.d.ts.map +1 -1
  16. package/dist/src/dashboard/chart_aggregator.js +3 -2
  17. package/dist/src/dashboard/dashboard_store.d.ts.map +1 -1
  18. package/dist/src/dashboard/dashboard_store.js +47 -11
  19. package/dist/src/dashboard/migrator.d.ts +5 -0
  20. package/dist/src/dashboard/migrator.d.ts.map +1 -1
  21. package/dist/src/dashboard/migrator.js +44 -9
  22. package/dist/src/data/data_access.d.ts +4 -2
  23. package/dist/src/data/data_access.d.ts.map +1 -1
  24. package/dist/src/data/data_access.js +22 -4
  25. package/dist/src/define_config.d.ts.map +1 -1
  26. package/dist/src/define_config.js +7 -6
  27. package/dist/src/edge/client-vue/dashboard.js +1 -1
  28. package/dist/src/edge/client-vue/debug-panel-deferred.js +1 -1
  29. package/dist/src/edge/client-vue/debug-panel.js +1 -1
  30. package/dist/src/middleware/request_tracking_middleware.d.ts.map +1 -1
  31. package/dist/src/middleware/request_tracking_middleware.js +7 -0
  32. package/dist/src/prometheus/prometheus_collector.d.ts +14 -3
  33. package/dist/src/prometheus/prometheus_collector.d.ts.map +1 -1
  34. package/dist/src/prometheus/prometheus_collector.js +209 -198
  35. package/dist/src/provider/server_stats_provider.d.ts +9 -0
  36. package/dist/src/provider/server_stats_provider.d.ts.map +1 -1
  37. package/dist/src/provider/server_stats_provider.js +196 -59
  38. package/dist/src/utils/app_import.d.ts +23 -0
  39. package/dist/src/utils/app_import.d.ts.map +1 -0
  40. package/dist/src/utils/app_import.js +44 -0
  41. package/dist/vue/{CacheSection-CkrIB4-j.js → CacheSection-C788Yfai.js} +1 -1
  42. package/dist/vue/{ConfigSection-gulpOiq1.js → ConfigSection-CRzYxqW2.js} +1 -1
  43. package/dist/vue/{CustomPaneTab-J57ED_bh.js → CustomPaneTab-BJxT5Dp7.js} +33 -33
  44. package/dist/vue/{EmailsSection-BlKvQDx8.js → EmailsSection-C8JFMtW7.js} +1 -1
  45. package/dist/vue/{EventsSection-BdzQvIVJ.js → EventsSection-C4wXUgxG.js} +1 -1
  46. package/dist/vue/{JobsSection-DOzuMrG3.js → JobsSection-CsKWTjgN.js} +1 -1
  47. package/dist/vue/{LogsSection-CNN4y92u.js → LogsSection-BFVjSZ24.js} +12 -12
  48. package/dist/vue/{LogsTab-CJerb22r.js → LogsTab-DpEQ7euu.js} +17 -17
  49. package/dist/vue/{OverviewSection-SITNR_dA.js → OverviewSection-CbMdAido.js} +1 -1
  50. package/dist/vue/{QueriesSection-BAebAHkD.js → QueriesSection-BPiv7u3r.js} +1 -1
  51. package/dist/vue/{RequestsSection-CIR0IX39.js → RequestsSection-LtImH4rD.js} +1 -1
  52. package/dist/vue/{RoutesSection-j1U2oa0g.js → RoutesSection-CrxOxmzx.js} +1 -1
  53. package/dist/vue/{TimelineSection-Dw980UPg.js → TimelineSection-DLxMW2J_.js} +1 -1
  54. package/dist/vue/{index-COgsk_nv.js → index-qCQpBftQ.js} +2 -2
  55. package/dist/vue/index.js +1 -1
  56. package/package.json +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"request_tracking_middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/request_tracking_middleware.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAcvD;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAYD,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,IAAI,QAEvE;AAOD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,QAEjE;AAQD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,QAEnD;AASD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAErD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAQD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC,GAAG,IAAI,QAEpF;AAED,MAAM,CAAC,OAAO,OAAO,yBAAyB;IACtC,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;CA4E5C"}
1
+ {"version":3,"file":"request_tracking_middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/request_tracking_middleware.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAcvD;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAYD,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,IAAI,QAEvE;AAOD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,QAEjE;AAQD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,QAEnD;AASD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAErD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAQD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC,GAAG,IAAI,QAEpF;AAED,MAAM,CAAC,OAAO,OAAO,yBAAyB;IACtC,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;CAoF5C"}
@@ -67,7 +67,14 @@ export default class RequestTrackingMiddleware {
67
67
  await next();
68
68
  return;
69
69
  }
70
+ // Gracefully handle the startup window before collectors initialize.
71
+ // The provider defers initialization via setImmediate, so early
72
+ // requests may arrive before httpCollector() has been called.
70
73
  const metrics = getRequestMetrics();
74
+ if (!metrics) {
75
+ await next();
76
+ return;
77
+ }
71
78
  const start = performance.now();
72
79
  metrics.incrementActiveConnections();
73
80
  // Share a lazy shouldShow evaluator with Edge for @serverStats() tag.
@@ -1,7 +1,18 @@
1
1
  import type { ServerStats } from '../types.js';
2
- import type { ConfigProvider } from '@adonisjs/core/types';
3
- import type { Collector } from '@julr/adonisjs-prometheus/collectors/collector';
4
- export declare function serverStatsCollector(): ConfigProvider<Collector>;
2
+ /**
3
+ * Returns a Prometheus collector config provider for server-stats metrics.
4
+ *
5
+ * The return type is a plain `{ resolver }` object instead of the concrete
6
+ * `ConfigProvider<Collector>` type. This avoids type incompatibilities when
7
+ * the package is symlinked via `file:` dependency — TypeScript would otherwise
8
+ * see two different copies of `@adonisjs/core` types and reject the assignment.
9
+ *
10
+ * At runtime the shape is identical to `configProvider.create(...)`.
11
+ */
12
+ export declare function serverStatsCollector(): {
13
+ type: 'provider';
14
+ resolver: (app: any) => Promise<any>;
15
+ };
5
16
  export declare const ServerStatsCollector: {
6
17
  instance: {
7
18
  update(stats: Partial<ServerStats>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"prometheus_collector.d.ts","sourceRoot":"","sources":["../../../src/prometheus/prometheus_collector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAA;AAI/E,wBAAgB,oBAAoB,IAAI,cAAc,CAAC,SAAS,CAAC,CA+MhE;AAED,eAAO,MAAM,oBAAoB,EAAE;IACjC,QAAQ,EAAE;QAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;CAG/D,CAAA"}
1
+ {"version":3,"file":"prometheus_collector.d.ts","sourceRoot":"","sources":["../../../src/prometheus/prometheus_collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,CAgNjG;AAED,eAAO,MAAM,oBAAoB,EAAE;IACjC,QAAQ,EAAE;QAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;CAG/D,CAAA"}
@@ -1,203 +1,214 @@
1
- import { configProvider } from '@adonisjs/core';
1
+ /**
2
+ * Returns a Prometheus collector config provider for server-stats metrics.
3
+ *
4
+ * The return type is a plain `{ resolver }` object instead of the concrete
5
+ * `ConfigProvider<Collector>` type. This avoids type incompatibilities when
6
+ * the package is symlinked via `file:` dependency — TypeScript would otherwise
7
+ * see two different copies of `@adonisjs/core` types and reject the assignment.
8
+ *
9
+ * At runtime the shape is identical to `configProvider.create(...)`.
10
+ */
2
11
  export function serverStatsCollector() {
3
- return configProvider.create(async (app) => {
4
- const config = app.config.get('prometheus', {});
5
- // Lazy import the Collector base class
6
- const { Collector } = await import('@julr/adonisjs-prometheus/collectors/collector');
7
- class ServerStatsCollectorImpl extends Collector {
8
- static instance = null;
9
- // Process
10
- cpuPercent;
11
- eventLoopLag;
12
- // DB Pool
13
- dbPoolUsed;
14
- dbPoolFree;
15
- dbPoolPending;
16
- dbPoolMax;
17
- // Redis
18
- redisUp;
19
- redisMemoryUsedMb;
20
- redisConnectedClients;
21
- redisKeysCount;
22
- redisHitRatePercent;
23
- // Queue
24
- queueActiveJobs;
25
- queueWaitingJobs;
26
- queueDelayedJobs;
27
- queueFailedJobs;
28
- queueWorkerCount;
29
- // System
30
- systemLoadAvg;
31
- systemMemoryUsedMb;
32
- systemMemoryTotalMb;
33
- // App
34
- appOnlineUsers;
35
- appPendingWebhooks;
36
- appPendingEmails;
37
- register() {
38
- ServerStatsCollectorImpl.instance = this;
39
- ServerStatsCollector.instance = this;
40
- this.#registerProcessGauges();
41
- this.#registerDbPoolGauges();
42
- this.#registerRedisGauges();
43
- this.#registerQueueGauges();
44
- this.#registerSystemGauges();
45
- this.#registerAppGauges();
12
+ return {
13
+ type: 'provider',
14
+ resolver: async (app) => {
15
+ const { Collector } = await import('@julr/adonisjs-prometheus/collectors/collector');
16
+ const config = app.config.get('prometheus', {});
17
+ class ServerStatsCollectorImpl extends Collector {
18
+ static instance = null;
19
+ // Process
20
+ cpuPercent;
21
+ eventLoopLag;
22
+ // DB Pool
23
+ dbPoolUsed;
24
+ dbPoolFree;
25
+ dbPoolPending;
26
+ dbPoolMax;
27
+ // Redis
28
+ redisUp;
29
+ redisMemoryUsedMb;
30
+ redisConnectedClients;
31
+ redisKeysCount;
32
+ redisHitRatePercent;
33
+ // Queue
34
+ queueActiveJobs;
35
+ queueWaitingJobs;
36
+ queueDelayedJobs;
37
+ queueFailedJobs;
38
+ queueWorkerCount;
39
+ // System
40
+ systemLoadAvg;
41
+ systemMemoryUsedMb;
42
+ systemMemoryTotalMb;
43
+ // App
44
+ appOnlineUsers;
45
+ appPendingWebhooks;
46
+ appPendingEmails;
47
+ register() {
48
+ ServerStatsCollectorImpl.instance = this;
49
+ ServerStatsCollector.instance = this;
50
+ this.#registerProcessGauges();
51
+ this.#registerDbPoolGauges();
52
+ this.#registerRedisGauges();
53
+ this.#registerQueueGauges();
54
+ this.#registerSystemGauges();
55
+ this.#registerAppGauges();
56
+ }
57
+ #registerProcessGauges() {
58
+ this.cpuPercent = this.createGauge({
59
+ name: this.buildMetricName('nodejs_cpu_usage_percent'),
60
+ help: 'Node.js CPU usage percentage',
61
+ });
62
+ this.eventLoopLag = this.createGauge({
63
+ name: this.buildMetricName('nodejs_event_loop_lag_ms'),
64
+ help: 'Node.js event loop lag in milliseconds',
65
+ });
66
+ }
67
+ #registerDbPoolGauges() {
68
+ this.dbPoolUsed = this.createGauge({
69
+ name: this.buildMetricName('db_pool_used'),
70
+ help: 'Number of used database pool connections',
71
+ });
72
+ this.dbPoolFree = this.createGauge({
73
+ name: this.buildMetricName('db_pool_free'),
74
+ help: 'Number of free database pool connections',
75
+ });
76
+ this.dbPoolPending = this.createGauge({
77
+ name: this.buildMetricName('db_pool_pending'),
78
+ help: 'Number of pending database pool acquire requests',
79
+ });
80
+ this.dbPoolMax = this.createGauge({
81
+ name: this.buildMetricName('db_pool_max'),
82
+ help: 'Maximum database pool size',
83
+ });
84
+ }
85
+ #registerRedisGauges() {
86
+ this.redisUp = this.createGauge({
87
+ name: this.buildMetricName('redis_up'),
88
+ help: 'Whether Redis is reachable (0 or 1)',
89
+ });
90
+ this.redisMemoryUsedMb = this.createGauge({
91
+ name: this.buildMetricName('redis_memory_used_mb'),
92
+ help: 'Redis memory usage in megabytes',
93
+ });
94
+ this.redisConnectedClients = this.createGauge({
95
+ name: this.buildMetricName('redis_connected_clients'),
96
+ help: 'Number of connected Redis clients',
97
+ });
98
+ this.redisKeysCount = this.createGauge({
99
+ name: this.buildMetricName('redis_keys_count'),
100
+ help: 'Total number of Redis keys',
101
+ });
102
+ this.redisHitRatePercent = this.createGauge({
103
+ name: this.buildMetricName('redis_hit_rate_percent'),
104
+ help: 'Redis cache hit rate percentage',
105
+ });
106
+ }
107
+ #registerQueueGauges() {
108
+ this.queueActiveJobs = this.createGauge({
109
+ name: this.buildMetricName('queue_active_jobs'),
110
+ help: 'Number of active queue jobs',
111
+ });
112
+ this.queueWaitingJobs = this.createGauge({
113
+ name: this.buildMetricName('queue_waiting_jobs'),
114
+ help: 'Number of waiting queue jobs',
115
+ });
116
+ this.queueDelayedJobs = this.createGauge({
117
+ name: this.buildMetricName('queue_delayed_jobs'),
118
+ help: 'Number of delayed queue jobs',
119
+ });
120
+ this.queueFailedJobs = this.createGauge({
121
+ name: this.buildMetricName('queue_failed_jobs'),
122
+ help: 'Number of failed queue jobs',
123
+ });
124
+ this.queueWorkerCount = this.createGauge({
125
+ name: this.buildMetricName('queue_worker_count'),
126
+ help: 'Number of active queue workers',
127
+ });
128
+ }
129
+ #registerSystemGauges() {
130
+ this.systemLoadAvg = this.createGauge({
131
+ name: this.buildMetricName('system_load_avg'),
132
+ help: 'System load average',
133
+ labelNames: ['period'],
134
+ });
135
+ this.systemMemoryUsedMb = this.createGauge({
136
+ name: this.buildMetricName('system_memory_used_mb'),
137
+ help: 'System memory used in megabytes',
138
+ });
139
+ this.systemMemoryTotalMb = this.createGauge({
140
+ name: this.buildMetricName('system_memory_total_mb'),
141
+ help: 'System total memory in megabytes',
142
+ });
143
+ }
144
+ #registerAppGauges() {
145
+ this.appOnlineUsers = this.createGauge({
146
+ name: this.buildMetricName('app_online_users'),
147
+ help: 'Number of online users (active sessions)',
148
+ });
149
+ this.appPendingWebhooks = this.createGauge({
150
+ name: this.buildMetricName('app_pending_webhooks'),
151
+ help: 'Number of pending webhook events',
152
+ });
153
+ this.appPendingEmails = this.createGauge({
154
+ name: this.buildMetricName('app_pending_emails'),
155
+ help: 'Number of pending scheduled emails',
156
+ });
157
+ }
158
+ update(stats) {
159
+ if (stats.cpuPercent !== undefined)
160
+ this.cpuPercent.set(stats.cpuPercent);
161
+ if (stats.eventLoopLag !== undefined)
162
+ this.eventLoopLag.set(stats.eventLoopLag);
163
+ if (stats.dbPoolUsed !== undefined)
164
+ this.dbPoolUsed.set(stats.dbPoolUsed);
165
+ if (stats.dbPoolFree !== undefined)
166
+ this.dbPoolFree.set(stats.dbPoolFree);
167
+ if (stats.dbPoolPending !== undefined)
168
+ this.dbPoolPending.set(stats.dbPoolPending);
169
+ if (stats.dbPoolMax !== undefined)
170
+ this.dbPoolMax.set(stats.dbPoolMax);
171
+ if (stats.redisOk !== undefined)
172
+ this.redisUp.set(stats.redisOk ? 1 : 0);
173
+ if (stats.redisMemoryUsedMb !== undefined)
174
+ this.redisMemoryUsedMb.set(stats.redisMemoryUsedMb);
175
+ if (stats.redisConnectedClients !== undefined)
176
+ this.redisConnectedClients.set(stats.redisConnectedClients);
177
+ if (stats.redisKeysCount !== undefined)
178
+ this.redisKeysCount.set(stats.redisKeysCount);
179
+ if (stats.redisHitRate !== undefined)
180
+ this.redisHitRatePercent.set(stats.redisHitRate);
181
+ if (stats.queueActive !== undefined)
182
+ this.queueActiveJobs.set(stats.queueActive);
183
+ if (stats.queueWaiting !== undefined)
184
+ this.queueWaitingJobs.set(stats.queueWaiting);
185
+ if (stats.queueDelayed !== undefined)
186
+ this.queueDelayedJobs.set(stats.queueDelayed);
187
+ if (stats.queueFailed !== undefined)
188
+ this.queueFailedJobs.set(stats.queueFailed);
189
+ if (stats.queueWorkerCount !== undefined)
190
+ this.queueWorkerCount.set(stats.queueWorkerCount);
191
+ if (stats.systemLoadAvg1m !== undefined)
192
+ this.systemLoadAvg.set({ period: '1m' }, stats.systemLoadAvg1m);
193
+ if (stats.systemLoadAvg5m !== undefined)
194
+ this.systemLoadAvg.set({ period: '5m' }, stats.systemLoadAvg5m);
195
+ if (stats.systemLoadAvg15m !== undefined)
196
+ this.systemLoadAvg.set({ period: '15m' }, stats.systemLoadAvg15m);
197
+ if (stats.systemMemoryTotalMb !== undefined && stats.systemMemoryFreeMb !== undefined)
198
+ this.systemMemoryUsedMb.set(stats.systemMemoryTotalMb - stats.systemMemoryFreeMb);
199
+ if (stats.systemMemoryTotalMb !== undefined)
200
+ this.systemMemoryTotalMb.set(stats.systemMemoryTotalMb);
201
+ if (stats.onlineUsers !== undefined)
202
+ this.appOnlineUsers.set(stats.onlineUsers);
203
+ if (stats.pendingWebhooks !== undefined)
204
+ this.appPendingWebhooks.set(stats.pendingWebhooks);
205
+ if (stats.pendingEmails !== undefined)
206
+ this.appPendingEmails.set(stats.pendingEmails);
207
+ }
46
208
  }
47
- #registerProcessGauges() {
48
- this.cpuPercent = this.createGauge({
49
- name: this.buildMetricName('nodejs_cpu_usage_percent'),
50
- help: 'Node.js CPU usage percentage',
51
- });
52
- this.eventLoopLag = this.createGauge({
53
- name: this.buildMetricName('nodejs_event_loop_lag_ms'),
54
- help: 'Node.js event loop lag in milliseconds',
55
- });
56
- }
57
- #registerDbPoolGauges() {
58
- this.dbPoolUsed = this.createGauge({
59
- name: this.buildMetricName('db_pool_used'),
60
- help: 'Number of used database pool connections',
61
- });
62
- this.dbPoolFree = this.createGauge({
63
- name: this.buildMetricName('db_pool_free'),
64
- help: 'Number of free database pool connections',
65
- });
66
- this.dbPoolPending = this.createGauge({
67
- name: this.buildMetricName('db_pool_pending'),
68
- help: 'Number of pending database pool acquire requests',
69
- });
70
- this.dbPoolMax = this.createGauge({
71
- name: this.buildMetricName('db_pool_max'),
72
- help: 'Maximum database pool size',
73
- });
74
- }
75
- #registerRedisGauges() {
76
- this.redisUp = this.createGauge({
77
- name: this.buildMetricName('redis_up'),
78
- help: 'Whether Redis is reachable (0 or 1)',
79
- });
80
- this.redisMemoryUsedMb = this.createGauge({
81
- name: this.buildMetricName('redis_memory_used_mb'),
82
- help: 'Redis memory usage in megabytes',
83
- });
84
- this.redisConnectedClients = this.createGauge({
85
- name: this.buildMetricName('redis_connected_clients'),
86
- help: 'Number of connected Redis clients',
87
- });
88
- this.redisKeysCount = this.createGauge({
89
- name: this.buildMetricName('redis_keys_count'),
90
- help: 'Total number of Redis keys',
91
- });
92
- this.redisHitRatePercent = this.createGauge({
93
- name: this.buildMetricName('redis_hit_rate_percent'),
94
- help: 'Redis cache hit rate percentage',
95
- });
96
- }
97
- #registerQueueGauges() {
98
- this.queueActiveJobs = this.createGauge({
99
- name: this.buildMetricName('queue_active_jobs'),
100
- help: 'Number of active queue jobs',
101
- });
102
- this.queueWaitingJobs = this.createGauge({
103
- name: this.buildMetricName('queue_waiting_jobs'),
104
- help: 'Number of waiting queue jobs',
105
- });
106
- this.queueDelayedJobs = this.createGauge({
107
- name: this.buildMetricName('queue_delayed_jobs'),
108
- help: 'Number of delayed queue jobs',
109
- });
110
- this.queueFailedJobs = this.createGauge({
111
- name: this.buildMetricName('queue_failed_jobs'),
112
- help: 'Number of failed queue jobs',
113
- });
114
- this.queueWorkerCount = this.createGauge({
115
- name: this.buildMetricName('queue_worker_count'),
116
- help: 'Number of active queue workers',
117
- });
118
- }
119
- #registerSystemGauges() {
120
- this.systemLoadAvg = this.createGauge({
121
- name: this.buildMetricName('system_load_avg'),
122
- help: 'System load average',
123
- labelNames: ['period'],
124
- });
125
- this.systemMemoryUsedMb = this.createGauge({
126
- name: this.buildMetricName('system_memory_used_mb'),
127
- help: 'System memory used in megabytes',
128
- });
129
- this.systemMemoryTotalMb = this.createGauge({
130
- name: this.buildMetricName('system_memory_total_mb'),
131
- help: 'System total memory in megabytes',
132
- });
133
- }
134
- #registerAppGauges() {
135
- this.appOnlineUsers = this.createGauge({
136
- name: this.buildMetricName('app_online_users'),
137
- help: 'Number of online users (active sessions)',
138
- });
139
- this.appPendingWebhooks = this.createGauge({
140
- name: this.buildMetricName('app_pending_webhooks'),
141
- help: 'Number of pending webhook events',
142
- });
143
- this.appPendingEmails = this.createGauge({
144
- name: this.buildMetricName('app_pending_emails'),
145
- help: 'Number of pending scheduled emails',
146
- });
147
- }
148
- update(stats) {
149
- if (stats.cpuPercent !== undefined)
150
- this.cpuPercent.set(stats.cpuPercent);
151
- if (stats.eventLoopLag !== undefined)
152
- this.eventLoopLag.set(stats.eventLoopLag);
153
- if (stats.dbPoolUsed !== undefined)
154
- this.dbPoolUsed.set(stats.dbPoolUsed);
155
- if (stats.dbPoolFree !== undefined)
156
- this.dbPoolFree.set(stats.dbPoolFree);
157
- if (stats.dbPoolPending !== undefined)
158
- this.dbPoolPending.set(stats.dbPoolPending);
159
- if (stats.dbPoolMax !== undefined)
160
- this.dbPoolMax.set(stats.dbPoolMax);
161
- if (stats.redisOk !== undefined)
162
- this.redisUp.set(stats.redisOk ? 1 : 0);
163
- if (stats.redisMemoryUsedMb !== undefined)
164
- this.redisMemoryUsedMb.set(stats.redisMemoryUsedMb);
165
- if (stats.redisConnectedClients !== undefined)
166
- this.redisConnectedClients.set(stats.redisConnectedClients);
167
- if (stats.redisKeysCount !== undefined)
168
- this.redisKeysCount.set(stats.redisKeysCount);
169
- if (stats.redisHitRate !== undefined)
170
- this.redisHitRatePercent.set(stats.redisHitRate);
171
- if (stats.queueActive !== undefined)
172
- this.queueActiveJobs.set(stats.queueActive);
173
- if (stats.queueWaiting !== undefined)
174
- this.queueWaitingJobs.set(stats.queueWaiting);
175
- if (stats.queueDelayed !== undefined)
176
- this.queueDelayedJobs.set(stats.queueDelayed);
177
- if (stats.queueFailed !== undefined)
178
- this.queueFailedJobs.set(stats.queueFailed);
179
- if (stats.queueWorkerCount !== undefined)
180
- this.queueWorkerCount.set(stats.queueWorkerCount);
181
- if (stats.systemLoadAvg1m !== undefined)
182
- this.systemLoadAvg.set({ period: '1m' }, stats.systemLoadAvg1m);
183
- if (stats.systemLoadAvg5m !== undefined)
184
- this.systemLoadAvg.set({ period: '5m' }, stats.systemLoadAvg5m);
185
- if (stats.systemLoadAvg15m !== undefined)
186
- this.systemLoadAvg.set({ period: '15m' }, stats.systemLoadAvg15m);
187
- if (stats.systemMemoryTotalMb !== undefined && stats.systemMemoryFreeMb !== undefined)
188
- this.systemMemoryUsedMb.set(stats.systemMemoryTotalMb - stats.systemMemoryFreeMb);
189
- if (stats.systemMemoryTotalMb !== undefined)
190
- this.systemMemoryTotalMb.set(stats.systemMemoryTotalMb);
191
- if (stats.onlineUsers !== undefined)
192
- this.appOnlineUsers.set(stats.onlineUsers);
193
- if (stats.pendingWebhooks !== undefined)
194
- this.appPendingWebhooks.set(stats.pendingWebhooks);
195
- if (stats.pendingEmails !== undefined)
196
- this.appPendingEmails.set(stats.pendingEmails);
197
- }
198
- }
199
- return new ServerStatsCollectorImpl(config);
200
- });
209
+ return new ServerStatsCollectorImpl(config);
210
+ },
211
+ };
201
212
  }
202
213
  export const ServerStatsCollector = {
203
214
  instance: null,
@@ -14,6 +14,7 @@ export default class ServerStatsProvider {
14
14
  private statsController;
15
15
  private debugController;
16
16
  private apiController;
17
+ private dashboardDepsAvailable;
17
18
  private pinoHookActive;
18
19
  private edgePluginActive;
19
20
  private prometheusActive;
@@ -23,6 +24,7 @@ export default class ServerStatsProvider {
23
24
  private resolvedCollectors;
24
25
  constructor(app: ApplicationService);
25
26
  boot(): Promise<void>;
27
+ private initializeBoot;
26
28
  /**
27
29
  * Read start/kernel.ts and detect auth-related middleware in server.use()
28
30
  * or router.use() blocks. Returns import paths of problematic middleware.
@@ -40,6 +42,13 @@ export default class ServerStatsProvider {
40
42
  */
41
43
  private hookPinoLogger;
42
44
  ready(): Promise<void>;
45
+ private initializeServerStats;
46
+ /**
47
+ * Set up the stats collection interval, transmit broadcasting,
48
+ * and Prometheus integration. Extracted from initializeServerStats
49
+ * so the ready log fires promptly.
50
+ */
51
+ private setupStatsInterval;
43
52
  private setupDevToolbar;
44
53
  /**
45
54
  * Initialize the full-page dashboard: SQLite store, controller,
@@ -1 +1 @@
1
- {"version":3,"file":"server_stats_provider.d.ts","sourceRoot":"","sources":["../../../src/provider/server_stats_provider.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAQ9D,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAwB1B,SAAS,CAAC,GAAG,EAAE,kBAAkB;IAvB7C,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,mBAAmB,CAAmC;IAC9D,OAAO,CAAC,kBAAkB,CAAgC;IAC1D,OAAO,CAAC,uBAAuB,CAA8C;IAC7E,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,aAAa,CAA6B;IAGlD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,gBAAgB,CAAe;IACvC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,kBAAkB,CAAwB;gBAE5B,GAAG,EAAE,kBAAkB;IAEvC,IAAI;IAwGV;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAmDlC;;;;;;;OAOG;YACW,cAAc;IAqCtB,KAAK;YAkIG,eAAe;IAmG7B;;;;;;OAMG;YACW,cAAc;IA0I5B,2DAA2D;IAC3D,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2ER,QAAQ;CAwCf"}
1
+ {"version":3,"file":"server_stats_provider.d.ts","sourceRoot":"","sources":["../../../src/provider/server_stats_provider.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAQ9D,MAAM,CAAC,OAAO,OAAO,mBAAmB;IA2B1B,SAAS,CAAC,GAAG,EAAE,kBAAkB;IA1B7C,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,mBAAmB,CAAmC;IAC9D,OAAO,CAAC,kBAAkB,CAAgC;IAC1D,OAAO,CAAC,uBAAuB,CAA8C;IAC7E,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,aAAa,CAA6B;IAGlD,OAAO,CAAC,sBAAsB,CAAgB;IAG9C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,gBAAgB,CAAe;IACvC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,kBAAkB,CAAwB;gBAE5B,GAAG,EAAE,kBAAkB;IAEvC,IAAI;YAcI,cAAc;IA8I5B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAmDlC;;;;;;;OAOG;YACW,cAAc;IAqCtB,KAAK;YAuBG,qBAAqB;IA6FnC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YA2DZ,eAAe;IA8G7B;;;;;;OAMG;YACW,cAAc;IA0L5B,2DAA2D;IAC3D,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2ER,QAAQ;CAwCf"}