Skip to content

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

refactor: remove unused audit log delivery counter and update telemetry metrics

Victor Hugo dos Santoscb94c7b3653f
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
index 410c7b7177..fa2ed1dd1e 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
@@ -13,11 +13,7 @@ import { getConfig } from "@app/lib/config/env";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { classifyError } from "@app/lib/errors/classify";
import { logger } from "@app/lib/logger";
-import {
- auditLogStreamAlertFiredCounter,
- auditLogStreamDeliveryCounter,
- auditLogStreamDeliveryDurationHistogram
-} from "@app/lib/telemetry/metrics";
+import { auditLogStreamAlertFiredCounter, auditLogStreamDeliveryDurationHistogram } from "@app/lib/telemetry/metrics";
import { OrgServiceActor } from "@app/lib/types";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TNotificationServiceFactory } from "@app/services/notification/notification-service";
@@ -423,12 +419,10 @@ export const auditLogStreamServiceFactory = ({
try {
await factory.streamLog({ credentials, auditLog });
const durationS = (Date.now() - deliveryStart) / 1000;
- auditLogStreamDeliveryCounter.add(1, { ...metricBaseAttrs, outcome: "success" });
auditLogStreamDeliveryDurationHistogram.record(durationS, { ...metricBaseAttrs, outcome: "success" });
} catch (error) {
const durationS = (Date.now() - deliveryStart) / 1000;
const errorType = classifyError(error);
- auditLogStreamDeliveryCounter.add(1, { ...metricBaseAttrs, outcome: "failure", "error.type": errorType });
auditLogStreamDeliveryDurationHistogram.record(durationS, {
...metricBaseAttrs,
outcome: "failure",
diff --git a/backend/src/lib/telemetry/metrics.ts b/backend/src/lib/telemetry/metrics.ts
index a8c649d927..9857b66c90 100644
--- a/backend/src/lib/telemetry/metrics.ts
+++ b/backend/src/lib/telemetry/metrics.ts
@@ -249,18 +249,10 @@ export const auditLogDroppedCounter = infisicalCoreMeter.createCounter("infisica
});
// Audit log stream metrics. Wired in audit-log-stream-service.ts streamLog().
-export const auditLogStreamDeliveryCounter = infisicalCoreMeter.createCounter(
- "infisical.audit_log_stream.delivery.count",
- {
- description: "Per-provider audit log stream delivery attempts (success or failure).",
- unit: "{delivery}"
- }
-);
-
export const auditLogStreamDeliveryDurationHistogram = infisicalCoreMeter.createHistogram(
"infisical.audit_log_stream.delivery.duration",
{
- description: "Per-provider audit log stream delivery latency.",
+ description: "Per-provider audit log stream delivery latency and attempt count (use _count for delivery volume).",
unit: "s"
}
);
@@ -287,13 +279,9 @@ export enum KmsKeyType {
HSM = "hsm"
}
-export const kmsCryptoCounter = infisicalCoreMeter.createCounter("infisical.kms.crypto.count", {
- description: "KMS encrypt/decrypt operations by key type and outcome.",
- unit: "{operation}"
-});
-
export const kmsCryptoDurationHistogram = infisicalCoreMeter.createHistogram("infisical.kms.crypto.duration", {
- description: "KMS encrypt/decrypt operation latency. External KMS (AWS/GCP) includes network round trip.",
+ description:
+ "External KMS (AWS/GCP/HSM) encrypt/decrypt latency including network round trip (use _count for operation volume).",
unit: "s"
});
@@ -305,6 +293,7 @@ export const recordKmsCryptoMetric = (params: {
errorType?: string;
}) => {
if (!isTelemetryEnabled()) return;
+ if (params.keyType === KmsKeyType.INTERNAL) return;
const attributes = {
...buildBaseAttributes(),
"kms.operation": params.operation,
@@ -312,7 +301,6 @@ export const recordKmsCryptoMetric = (params: {
outcome: params.outcome,
...(params.errorType ? { "error.type": params.errorType } : {})
};
- kmsCryptoCounter.add(1, attributes);
kmsCryptoDurationHistogram.record(params.durationSeconds, attributes);
};
@@ -412,13 +400,8 @@ export enum ScimOperation {
DeleteGroup = "delete_group"
}
-export const scimOperationCounter = infisicalCoreMeter.createCounter("infisical.scim.operation.count", {
- description: "SCIM provisioning operations (user/group create, update, replace, delete) by outcome.",
- unit: "{operation}"
-});
-
export const scimOperationDurationHistogram = infisicalCoreMeter.createHistogram("infisical.scim.operation.duration", {
- description: "SCIM provisioning operation latency by operation type and outcome.",
+ description: "SCIM provisioning operation latency by operation type and outcome (use _count for operation volume).",
unit: "s"
});
@@ -436,7 +419,6 @@ export const recordScimOperationMetric = (params: {
};
if (params.orgId) attributes["infisical.organization.id"] = params.orgId;
if (params.error !== undefined) attributes["error.type"] = classifyError(params.error);
- scimOperationCounter.add(1, attributes);
scimOperationDurationHistogram.record((performance.now() - params.startTime) / 1000, attributes);
};
diff --git a/backend/src/server/plugins/error-handler.ts b/backend/src/server/plugins/error-handler.ts
index 443962f68b..0e2f6d6d73 100644
--- a/backend/src/server/plugins/error-handler.ts
+++ b/backend/src/server/plugins/error-handler.ts
@@ -137,7 +137,7 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
const coreAttrs: Record<string, string | number> = {
"http.request.method": method,
- "http.route": route,
+ "http.route": route ?? "unknown",
"error.type": classifyError(error)
};
if (orgId) coreAttrs["infisical.organization.id"] = orgId;
diff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdx
index 857c3a27ce..a37bf7dc8e 100644
--- a/docs/self-hosting/configuration/envars.mdx
+++ b/docs/self-hosting/configuration/envars.mdx
@@ -871,7 +871,7 @@ If the export type is set to `otlp`, you will have to configure a value for `OTE
</ParamField>
<ParamField query="OTEL_DROP_LEGACY_METERS" type="string" default="false" optional>
- When set to `true`, the SDK discards all data points from the high-cardinality `Infisical` and `API` meters before aggregation. The instruments still exist in code (no errors), but nothing is stored or exported. Only bounded-cardinality `InfisicalCore` metrics are emitted. Useful for large or multi-tenant deployments where per-actor label cardinality is too expensive. See [Monitoring & Telemetry](/self-hosting/guides/monitoring-telemetry#two-meter-tiers) for details.
+ When set to `true`, the SDK discards all data points from the high-cardinality `Infisical` and `API` meters before aggregation. The instruments still exist in code (no errors), but nothing is stored or exported. Only bounded-cardinality `InfisicalCore` metrics are emitted. Useful for large or multi-tenant deployments where per-actor label cardinality is too expensive. See [Monitoring & Telemetry](/self-hosting/guides/monitoring-telemetry#available-metrics) for details.
</ParamField>
## Identity Auth Method