Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

chore: add comments to clarify per-pod last-tick value handling in project cleanup and environment metrics

Victor Hugo dos Santos7d25a09e1082
diff --git a/backend/src/services/project-env/project-env-queue.ts b/backend/src/services/project-env/project-env-queue.ts
index e0db20dd27..6c6f43e656 100644
--- a/backend/src/services/project-env/project-env-queue.ts
+++ b/backend/src/services/project-env/project-env-queue.ts
@@ -58,6 +58,8 @@ export const projectEnvQueueFactory = ({
}
const meter = opentelemetry.metrics.getMeter("InfisicalCore");
+ // Per-pod, last-tick value: only the pod that won the cron redlock updates this; other pods report 0.
+ // Alarms must aggregate with max() across pods, else a "stuck at cap" backlog gets diluted to ~0.
let lastDiscoveryCount = 0;
const discoveryGauge = meter.createObservableGauge("infisical.project_env_cleanup.discovered", {
description:
diff --git a/backend/src/services/project/project-cleanup-queue.ts b/backend/src/services/project/project-cleanup-queue.ts
index 4dc11f5622..5a1dd97e3e 100644
--- a/backend/src/services/project/project-cleanup-queue.ts
+++ b/backend/src/services/project/project-cleanup-queue.ts
@@ -75,6 +75,8 @@ export const projectCleanupQueueFactory = ({
// ── observability ─────────────────────────────────────────────────────────────
const meter = opentelemetry.metrics.getMeter("InfisicalCore");
+ // Per-pod, last-tick value: only the pod that won the cron redlock updates this; other pods report 0.
+ // Alarms must aggregate with max() across pods, else a "stuck at cap" backlog gets diluted to ~0.
let lastDiscoveryCount = 0;
const discoveryGauge = meter.createObservableGauge("infisical.project_cleanup.discovered", {
description: