adonisjs-server-stats 1.6.2 → 1.6.11
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 +1 -0
- package/dist/core/api-client.d.ts.map +1 -1
- package/dist/core/dashboard-api.d.ts +2 -1
- package/dist/core/dashboard-api.d.ts.map +1 -1
- package/dist/core/dashboard-data-controller.d.ts +2 -0
- package/dist/core/dashboard-data-controller.d.ts.map +1 -1
- package/dist/core/debug-data-controller.d.ts +1 -0
- package/dist/core/debug-data-controller.d.ts.map +1 -1
- package/dist/core/history-buffer.d.ts.map +1 -1
- package/dist/core/index.js +404 -361
- package/dist/core/server-stats-controller.d.ts +1 -0
- package/dist/core/server-stats-controller.d.ts.map +1 -1
- package/dist/core/sparkline.d.ts.map +1 -1
- package/dist/react/core/api-client.d.ts.map +1 -1
- package/dist/react/core/dashboard-api.d.ts +2 -1
- package/dist/react/core/dashboard-api.d.ts.map +1 -1
- package/dist/react/core/dashboard-data-controller.d.ts +2 -0
- package/dist/react/core/dashboard-data-controller.d.ts.map +1 -1
- package/dist/react/core/debug-data-controller.d.ts +1 -0
- package/dist/react/core/debug-data-controller.d.ts.map +1 -1
- package/dist/react/core/history-buffer.d.ts.map +1 -1
- package/dist/react/core/server-stats-controller.d.ts +1 -0
- package/dist/react/core/server-stats-controller.d.ts.map +1 -1
- package/dist/react/core/sparkline.d.ts.map +1 -1
- package/dist/src/collectors/app_collector.d.ts.map +1 -1
- package/dist/src/collectors/db_pool_collector.d.ts.map +1 -1
- package/dist/src/collectors/redis_collector.d.ts.map +1 -1
- package/dist/src/controller/debug_controller.d.ts +3 -1
- package/dist/src/controller/debug_controller.d.ts.map +1 -1
- package/dist/src/controller/debug_controller.js +25 -20
- package/dist/src/dashboard/chart_aggregator.js +42 -41
- package/dist/src/dashboard/dashboard_controller.d.ts.map +1 -1
- package/dist/src/dashboard/dashboard_controller.js +7 -5
- package/dist/src/dashboard/dashboard_store.d.ts +61 -19
- package/dist/src/dashboard/dashboard_store.d.ts.map +1 -1
- package/dist/src/dashboard/dashboard_store.js +677 -474
- package/dist/src/dashboard/integrations/config_inspector.d.ts +4 -0
- package/dist/src/dashboard/integrations/config_inspector.d.ts.map +1 -1
- package/dist/src/dashboard/integrations/config_inspector.js +16 -2
- package/dist/src/dashboard/migrator.d.ts.map +1 -1
- package/dist/src/dashboard/migrator.js +30 -4
- package/dist/src/data/data_access.d.ts.map +1 -1
- package/dist/src/data/data_access.js +40 -7
- package/dist/src/debug/debug_store.d.ts.map +1 -1
- package/dist/src/debug/debug_store.js +17 -7
- package/dist/src/debug/email_collector.d.ts +2 -0
- package/dist/src/debug/email_collector.d.ts.map +1 -1
- package/dist/src/debug/email_collector.js +17 -13
- package/dist/src/debug/event_collector.d.ts +7 -1
- package/dist/src/debug/event_collector.d.ts.map +1 -1
- package/dist/src/debug/event_collector.js +46 -17
- package/dist/src/debug/query_collector.d.ts +12 -0
- package/dist/src/debug/query_collector.d.ts.map +1 -1
- package/dist/src/debug/query_collector.js +35 -5
- package/dist/src/debug/ring_buffer.d.ts +14 -0
- package/dist/src/debug/ring_buffer.d.ts.map +1 -1
- package/dist/src/debug/ring_buffer.js +48 -2
- package/dist/src/debug/trace_collector.d.ts +1 -0
- package/dist/src/debug/trace_collector.d.ts.map +1 -1
- package/dist/src/debug/trace_collector.js +4 -1
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +5 -1
- package/dist/src/edge/client/dashboard.js +2 -2
- package/dist/src/edge/client/debug-panel-deferred.js +1 -1
- package/dist/src/edge/client/debug-panel.js +1 -1
- package/dist/src/edge/client/stats-bar.js +1 -1
- package/dist/src/edge/client-vue/dashboard.js +5 -5
- package/dist/src/edge/client-vue/debug-panel-deferred.js +2 -2
- package/dist/src/edge/client-vue/debug-panel.js +2 -2
- package/dist/src/edge/client-vue/stats-bar.js +3 -3
- package/dist/src/engine/request_metrics.d.ts.map +1 -1
- package/dist/src/engine/request_metrics.js +33 -3
- package/dist/src/log_stream/log_stream_provider.js +1 -1
- package/dist/src/log_stream/log_stream_service.d.ts +1 -0
- package/dist/src/log_stream/log_stream_service.d.ts.map +1 -1
- package/dist/src/log_stream/log_stream_service.js +13 -3
- package/dist/src/prometheus/prometheus_collector.d.ts +14 -3
- package/dist/src/prometheus/prometheus_collector.d.ts.map +1 -1
- package/dist/src/prometheus/prometheus_collector.js +209 -198
- package/dist/src/provider/server_stats_provider.d.ts.map +1 -1
- package/dist/src/provider/server_stats_provider.js +17 -31
- package/dist/src/stubs/config.stub +3 -0
- package/dist/src/types.d.ts +12 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts +7 -5
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +27 -5
- package/package.json +6 -2
|
@@ -39,8 +39,16 @@ export class RingBuffer {
|
|
|
39
39
|
}
|
|
40
40
|
/** Returns the most recent N items (newest first). */
|
|
41
41
|
latest(n) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (this.count === 0)
|
|
43
|
+
return [];
|
|
44
|
+
const take = Math.min(n, this.count);
|
|
45
|
+
const result = new Array(take);
|
|
46
|
+
// Walk backwards from the most recently inserted item
|
|
47
|
+
for (let i = 0; i < take; i++) {
|
|
48
|
+
const idx = (this.head - 1 - i + this.capacity) % this.capacity;
|
|
49
|
+
result[i] = this.buffer[idx];
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
44
52
|
}
|
|
45
53
|
getNextId() {
|
|
46
54
|
return this.nextId++;
|
|
@@ -56,6 +64,44 @@ export class RingBuffer {
|
|
|
56
64
|
this.head = 0;
|
|
57
65
|
this.count = 0;
|
|
58
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Find a single item by predicate, searching from newest to oldest.
|
|
69
|
+
* Returns immediately on first match without copying the buffer.
|
|
70
|
+
*/
|
|
71
|
+
findFromEnd(predicate) {
|
|
72
|
+
if (this.count === 0)
|
|
73
|
+
return undefined;
|
|
74
|
+
const start = this.count < this.capacity ? 0 : this.head;
|
|
75
|
+
for (let i = this.count - 1; i >= 0; i--) {
|
|
76
|
+
const idx = (start + i) % this.capacity;
|
|
77
|
+
const item = this.buffer[idx];
|
|
78
|
+
if (predicate(item))
|
|
79
|
+
return item;
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Collect items from the end of the buffer while the predicate holds.
|
|
85
|
+
* Iterates from newest to oldest and stops at the first non-match.
|
|
86
|
+
* Returns items in insertion order (oldest first).
|
|
87
|
+
*
|
|
88
|
+
* Useful for efficiently getting "items since ID X" without copying the
|
|
89
|
+
* entire buffer, since IDs are monotonically increasing.
|
|
90
|
+
*/
|
|
91
|
+
collectFromEnd(predicate) {
|
|
92
|
+
if (this.count === 0)
|
|
93
|
+
return [];
|
|
94
|
+
const result = [];
|
|
95
|
+
const start = this.count < this.capacity ? 0 : this.head;
|
|
96
|
+
for (let i = this.count - 1; i >= 0; i--) {
|
|
97
|
+
const idx = (start + i) % this.capacity;
|
|
98
|
+
const item = this.buffer[idx];
|
|
99
|
+
if (!predicate(item))
|
|
100
|
+
break;
|
|
101
|
+
result.push(item);
|
|
102
|
+
}
|
|
103
|
+
return result.reverse();
|
|
104
|
+
}
|
|
59
105
|
/** Bulk-load items (e.g. from disk). Pushes each in order, respecting capacity. */
|
|
60
106
|
load(items) {
|
|
61
107
|
for (const item of items) {
|
|
@@ -22,6 +22,7 @@ export declare function trace<T>(label: string, fn: () => Promise<T>): Promise<T
|
|
|
22
22
|
* the request context. Users can add custom spans via {@link trace}.
|
|
23
23
|
*/
|
|
24
24
|
export declare class TraceCollector {
|
|
25
|
+
private static readonly MAX_SPANS_PER_TRACE;
|
|
25
26
|
private buffer;
|
|
26
27
|
private als;
|
|
27
28
|
private emitter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace_collector.d.ts","sourceRoot":"","sources":["../../../src/debug/trace_collector.ts"],"names":[],"mappings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,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAIjD,KAAK,IAAI,IAAI;IAIb,uEAAuE;IACvE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;IAIzD,0EAA0E;IAC1E,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;CAK1C"}
|
|
@@ -33,6 +33,7 @@ export async function trace(label, fn) {
|
|
|
33
33
|
* the request context. Users can add custom spans via {@link trace}.
|
|
34
34
|
*/
|
|
35
35
|
export class TraceCollector {
|
|
36
|
+
static MAX_SPANS_PER_TRACE = 200;
|
|
36
37
|
buffer;
|
|
37
38
|
als = new AsyncLocalStorage();
|
|
38
39
|
emitter = null;
|
|
@@ -78,6 +79,8 @@ export class TraceCollector {
|
|
|
78
79
|
const ctx = this.als.getStore();
|
|
79
80
|
if (!ctx)
|
|
80
81
|
return;
|
|
82
|
+
if (ctx.spans.length >= TraceCollector.MAX_SPANS_PER_TRACE)
|
|
83
|
+
return;
|
|
81
84
|
ctx.spans.push({
|
|
82
85
|
id: String(ctx.nextSpanId++),
|
|
83
86
|
parentId: ctx.currentSpanId,
|
|
@@ -165,7 +168,7 @@ export class TraceCollector {
|
|
|
165
168
|
return this.buffer.latest(n);
|
|
166
169
|
}
|
|
167
170
|
getTrace(id) {
|
|
168
|
-
return this.buffer.
|
|
171
|
+
return this.buffer.findFromEnd((t) => t.id === id);
|
|
169
172
|
}
|
|
170
173
|
getTotalCount() {
|
|
171
174
|
return this.buffer.size();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AA4RjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,yBAAyB,
|
|
1
|
+
{"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AA4RjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,yBAAyB,CA+CjF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bold, dim } from './utils/logger.js';
|
|
1
|
+
import { bold, dim, setVerbose } from './utils/logger.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve `toolbar`, `dashboard`, and `advanced` aliases into a
|
|
4
4
|
* {@link DevToolbarOptions} object, merging with any existing
|
|
@@ -344,6 +344,9 @@ function logDeprecationWarnings(config) {
|
|
|
344
344
|
* ```
|
|
345
345
|
*/
|
|
346
346
|
export function defineConfig(config) {
|
|
347
|
+
// Apply verbose setting early so all subsequent log.info calls respect it
|
|
348
|
+
const verbose = config.verbose ?? false;
|
|
349
|
+
setVerbose(verbose);
|
|
347
350
|
// Resolve aliases (new names take precedence over old)
|
|
348
351
|
const intervalMs = config.pollInterval ?? config.intervalMs ?? 3000;
|
|
349
352
|
let transport;
|
|
@@ -377,5 +380,6 @@ export function defineConfig(config) {
|
|
|
377
380
|
onStats: config.onStats,
|
|
378
381
|
devToolbar,
|
|
379
382
|
shouldShow,
|
|
383
|
+
verbose,
|
|
380
384
|
};
|
|
381
385
|
}
|