Add pool details to postgres stats

This commit is contained in:
Ajay
2023-04-07 15:55:29 -04:00
parent 69a54f64b4
commit 940cacfb0a

View File

@@ -21,6 +21,11 @@ interface PostgresStats {
avgReadTime: number;
avgWriteTime: number;
avgFailedTime: number;
pool: {
total: number;
idle: number;
waiting: number;
}
}
export interface DatabaseConfig {
@@ -266,7 +271,12 @@ export class Postgres implements IDatabase {
activeRequests: this.activePostgresRequests,
avgReadTime: this.readResponseTime.length > 0 ? this.readResponseTime.reduce((a, b) => a + b, 0) / this.readResponseTime.length : 0,
avgWriteTime: this.writeResponseTime.length > 0 ? this.writeResponseTime.reduce((a, b) => a + b, 0) / this.writeResponseTime.length : 0,
avgFailedTime: this.failedResponseTime.length > 0 ? this.failedResponseTime.reduce((a, b) => a + b, 0) / this.failedResponseTime.length : 0
avgFailedTime: this.failedResponseTime.length > 0 ? this.failedResponseTime.reduce((a, b) => a + b, 0) / this.failedResponseTime.length : 0,
pool: {
total: this.pool.totalCount,
idle: this.pool.idleCount,
waiting: this.pool.waitingCount
}
};
}