Skip to content

Commit

Permalink
misc: added custom metrics for integration syncs
Browse files Browse the repository at this point in the history
  • Loading branch information
sheensantoscapadngan committed Dec 19, 2024
1 parent bbc8091 commit cde813a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/src/services/secret/secret-queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-await-in-loop */
import opentelemetry from "@opentelemetry/api";
import { AxiosError } from "axios";

import {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cde813a

Please sign in to comment.