mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 04:27:29 +00:00
misc: added custom metrics for integration syncs
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
|
import opentelemetry from "@opentelemetry/api";
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -158,6 +159,12 @@ export const secretQueueFactory = ({
|
|||||||
projectUserMembershipRoleDAL,
|
projectUserMembershipRoleDAL,
|
||||||
projectKeyDAL
|
projectKeyDAL
|
||||||
}: TSecretQueueFactoryDep) => {
|
}: 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 removeSecretReminder = async (dto: TRemoveSecretReminderDTO) => {
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
await queueService.stopRepeatableJob(
|
await queueService.stopRepeatableJob(
|
||||||
@@ -933,6 +940,18 @@ export const secretQueueFactory = ({
|
|||||||
`Secret integration sync error [projectId=${job.data.projectId}] [environment=${environment}] [secretPath=${job.data.secretPath}]`
|
`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 =
|
const message =
|
||||||
// eslint-disable-next-line no-nested-ternary
|
// eslint-disable-next-line no-nested-ternary
|
||||||
(err instanceof AxiosError
|
(err instanceof AxiosError
|
||||||
|
|||||||
Reference in New Issue
Block a user