Skip to content

Commit

Permalink
chore: capturing user_transform_test_errors stat (#3543)
Browse files Browse the repository at this point in the history
* chore: capturing user_transform_test_errors stat

* fix: error code

* fix: lint error

* chore: changed error stat to total request stat
  • Loading branch information
kanishkkatara authored Jul 24, 2024
1 parent 3ddf9e2 commit ef1c4f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/services/userTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/util/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit ef1c4f9

Please sign in to comment.