diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index 9ad92e8ca3..2afad88c56 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -196,6 +196,7 @@ export class UserTransformService { public static async testTransformRoutine(events, trRevCode, libraryVersionIDs, credentials) { const response: FixMe = {}; + let errorCode: number | undefined; try { if (!trRevCode || !trRevCode.code || !trRevCode.codeVersion) { throw new Error('Invalid Request. Missing parameters in transformation code block'); @@ -231,6 +232,13 @@ export class UserTransformService { response.body = { error: extractStackTraceUptoLastSubstringMatch(error.stack, SUPPORTED_FUNC_NAMES), }; + errorCode = error.statusCode; + } finally { + const metaTags = getTransformationMetadata(events[0]?.metadata); + stats.counter('user_transform_test_count_total', events.length, { + status: errorCode || response.status, + ...metaTags, + }); } return response; } diff --git a/src/util/prometheus.js b/src/util/prometheus.js index 49f1fdcd8b..cddeb80f31 100644 --- a/src/util/prometheus.js +++ b/src/util/prometheus.js @@ -841,6 +841,12 @@ class Prometheus { 'k8_namespace', ], }, + { + name: 'user_transform_test_count_total', + help: 'user_transform_test_count_total', + type: 'counter', + labelNames: ['workspaceId', 'transformationId', 'status'], + }, { name: 'user_transform_requests', help: 'user_transform_requests',