Skip to content

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

misc: added custom metrics for integration syncs

Sheen Capadngancde813aafb55
diff --git a/backend/src/services/secret/secret-queue.ts b/backend/src/services/secret/secret-queue.ts
index 57d32ab116..d4e857832d 100644
--- a/backend/src/services/secret/secret-queue.ts
+++ b/backend/src/services/secret/secret-queue.ts
@@ -1,4 +1,5 @@
/* eslint-disable no-await-in-loop */
+import opentelemetry from "@opentelemetry/api";
import { AxiosError } from "axios";
import {
@@ -158,6 +159,12 @@ export const secretQueueFactory = ({
projectUserMembershipRoleDAL,
projectKeyDAL
}: TSecretQueueFactoryDep) => {
+ const integrationMeter = opentelemetry.metrics.getMeter("Integrations");
+ const errorHistogram = integrationMeter.createHistogram("integration_secret_sync_errors", {
+ description: "Integration secret sync errors",
+ unit: "1"
+ });
+
const removeSecretReminder = async (dto: TRemoveSecretReminderDTO) => {
const appCfg = getConfig();
await queueService.stopRepeatableJob(
@@ -933,6 +940,18 @@ export const secretQueueFactory = ({
`Secret integration sync error [projectId=${job.data.projectId}] [environment=${environment}] [secretPath=${job.data.secretPath}]`
);
+ const appCfg = getConfig();
+ if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
+ errorHistogram.record(1, {
+ version: 1,
+ integration: integration.integration,
+ type: err instanceof AxiosError ? "AxiosError" : err?.constructor?.name || "UnknownError",
+ status: err instanceof AxiosError ? err.response?.status : undefined,
+ name: err instanceof Error ? err.name : undefined,
+ projectId: integration.projectId
+ });
+ }
+
const message =
// eslint-disable-next-line no-nested-ternary
(err instanceof AxiosError