feat(monitoring): add throughput metrics and expose them in ops UI
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/dcrouter',
|
||||
version: '5.1.0',
|
||||
version: '5.2.0',
|
||||
description: 'A multifaceted routing service handling mail and SMS delivery functions.'
|
||||
}
|
||||
|
||||
@@ -147,8 +147,10 @@ export class MetricsManager {
|
||||
requestsPerSecond: proxyMetrics ? proxyMetrics.requests.perSecond() : 0,
|
||||
throughput: proxyMetrics ? {
|
||||
bytesIn: proxyMetrics.totals.bytesIn(),
|
||||
bytesOut: proxyMetrics.totals.bytesOut()
|
||||
} : { bytesIn: 0, bytesOut: 0 },
|
||||
bytesOut: proxyMetrics.totals.bytesOut(),
|
||||
bytesInPerSecond: proxyMetrics.throughput.instant().in,
|
||||
bytesOutPerSecond: proxyMetrics.throughput.instant().out,
|
||||
} : { bytesIn: 0, bytesOut: 0, bytesInPerSecond: 0, bytesOutPerSecond: 0 },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ export class StatsHandler {
|
||||
cpuUsage: stats.cpuUsage,
|
||||
activeConnections: stats.activeConnections,
|
||||
totalConnections: stats.totalConnections,
|
||||
requestsPerSecond: stats.requestsPerSecond,
|
||||
throughput: stats.throughput,
|
||||
},
|
||||
history: dataArg.includeHistory ? stats.history : undefined,
|
||||
};
|
||||
@@ -191,6 +193,8 @@ export class StatsHandler {
|
||||
cpuUsage: stats.cpuUsage,
|
||||
activeConnections: stats.activeConnections,
|
||||
totalConnections: stats.totalConnections,
|
||||
requestsPerSecond: stats.requestsPerSecond,
|
||||
throughput: stats.throughput,
|
||||
};
|
||||
})
|
||||
);
|
||||
@@ -301,6 +305,7 @@ export class StatsHandler {
|
||||
requestsPerSecond: number;
|
||||
activeConnections: number;
|
||||
totalConnections: number;
|
||||
throughput: interfaces.data.IServerStats['throughput'];
|
||||
history: Array<{
|
||||
timestamp: number;
|
||||
value: number;
|
||||
@@ -316,15 +321,16 @@ export class StatsHandler {
|
||||
requestsPerSecond: serverStats.requestsPerSecond,
|
||||
activeConnections: serverStats.activeConnections,
|
||||
totalConnections: serverStats.totalConnections,
|
||||
throughput: serverStats.throughput,
|
||||
history: [], // TODO: Implement history tracking
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Fallback to basic stats if MetricsManager not available
|
||||
const uptime = process.uptime();
|
||||
const memUsage = process.memoryUsage();
|
||||
const cpuUsage = plugins.os.loadavg()[0] * 100 / plugins.os.cpus().length;
|
||||
|
||||
|
||||
return {
|
||||
uptime,
|
||||
cpuUsage: {
|
||||
@@ -340,6 +346,7 @@ export class StatsHandler {
|
||||
requestsPerSecond: 0,
|
||||
activeConnections: 0,
|
||||
totalConnections: 0,
|
||||
throughput: { bytesIn: 0, bytesOut: 0, bytesInPerSecond: 0, bytesOutPerSecond: 0 },
|
||||
history: [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user