Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: add event loop stats
Sheen Capadngane5947fcab985
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 0f13032631..9aa60a631d 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -1,5 +1,6 @@import { CronJob } from "cron";import { Knex } from "knex";+import { monitorEventLoopDelay } from "perf_hooks";import { z } from "zod";import { registerCertificateEstRouter } from "@app/ee/routes/est/certificate-est-router";@@ -96,6 +97,7 @@ import { trustedIpDALFactory } from "@app/ee/services/trusted-ip/trusted-ip-dal"import { trustedIpServiceFactory } from "@app/ee/services/trusted-ip/trusted-ip-service";import { TKeyStoreFactory } from "@app/keystore/keystore";import { getConfig, TEnvConfig } from "@app/lib/config/env";+import { logger } from "@app/lib/logger";import { TQueueServiceFactory } from "@app/queue";import { readLimit } from "@app/server/config/rateLimiter";import { accessTokenQueueServiceFactory } from "@app/services/access-token-queue/access-token-queue";@@ -246,6 +248,9 @@ import { registerV1Routes } from "./v1";import { registerV2Routes } from "./v2";import { registerV3Routes } from "./v3";+const histogram = monitorEventLoopDelay({ resolution: 20 });+histogram.enable();+export const registerRoutes = async (server: FastifyZodProvider,{@@ -1630,6 +1635,18 @@ export const registerRoutes = async (const cfg = getConfig();const serverCfg = await getServerCfg();+ const meanLagMs = histogram.mean / 1e6;+ const maxLagMs = histogram.max / 1e6;+ const p99LagMs = histogram.percentile(99) / 1e6;++ logger.info(+ `Event loop stats - Mean: ${meanLagMs.toFixed(2)}ms, Max: ${maxLagMs.toFixed(2)}ms, p99: ${p99LagMs.toFixed(+ 2+ )}ms`+ );++ logger.info(`Raw event loop stats: ${JSON.stringify(histogram, null, 2)}`);+// try {// await db.raw("SELECT NOW()");// } catch (err) {