Skip to content

Commit 645a2ef

Browse files
authored
[server] added metric for db pool queueing (#18477) (#18481)
1 parent e971a66 commit 645a2ef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

components/server/src/init.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { Server } from "./server";
5757
import { log, LogrusLogLevel } from "@gitpod/gitpod-protocol/lib/util/logging";
5858
import { TracingManager } from "@gitpod/gitpod-protocol/lib/util/tracing";
5959
import { TypeORM } from "@gitpod/gitpod-db/lib";
60-
import { dbConnectionsFree, dbConnectionsTotal } from "./prometheus-metrics";
60+
import { dbConnectionsEnqueued, dbConnectionsFree, dbConnectionsTotal } from "./prometheus-metrics";
6161
if (process.env.NODE_ENV === "development") {
6262
require("longjohn");
6363
}
@@ -85,6 +85,10 @@ export async function start(container: Container) {
8585
const activeConnections = pool._allConnections.length;
8686
const freeConnections = pool._freeConnections.length;
8787

88+
pool.on("enqueue", function () {
89+
dbConnectionsEnqueued.inc();
90+
});
91+
8892
dbConnectionsTotal.set(activeConnections);
8993
dbConnectionsFree.set(freeConnections);
9094
} catch (error) {

components/server/src/prometheus-metrics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export const dbConnectionsFree = new prometheusClient.Gauge({
4747
help: "Number of free connections in TypeORM pool",
4848
});
4949

50+
export const dbConnectionsEnqueued = new prometheusClient.Counter({
51+
name: "gitpod_typeorm_enqueued_connections",
52+
help: "Number of times requests put on the queue, because the pool was maxed out.",
53+
});
54+
5055
const loginCompletedTotal = new prometheusClient.Counter({
5156
name: "gitpod_login_completed_total",
5257
help: "Total number of logins completed into gitpod, by status",

0 commit comments

Comments
 (0)