Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate cdk v2 #1448

Merged
merged 19 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion cdk/v2/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const path = require("path");
const fs = require("fs");
const {
WorkflowExecutionError
} = require("rudder-workflow-engine/build/errors");
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
const { logger } = require("handlebars");
const { WorkflowEngineError } = require("rudder-workflow-engine/build/errors");
const { TRANSFORMER_METRIC } = require("../../v0/util/constant");

const CDK_V2_ROOT_DIR = __dirname;

Expand Down Expand Up @@ -37,8 +43,39 @@ function getPlatformBindingsPaths() {
return bindingsPaths;
}

function getErrorInfo(err) {
// Handle various CDK error types
let errorInfo = err;
if (err instanceof WorkflowExecutionError) {
logger.error(
"Error occurred during workflow step execution: ",
err.stepName
);
errorInfo = {
message: err.message,
status: err.status,
destinationResponse: err.error.destinationResponse,
koladilip marked this conversation as resolved.
Show resolved Hide resolved
statTags: err.error.statTags,
authErrorCategory: err.error.authErrorCategory
};
// TODO: Add a special stat tag to bump the priority of the error
} else if (err instanceof WorkflowEngineError) {
logger.error("Error occurred during workflow step: ", err.stepName);
errorInfo = {
message: err.message,
status: err.status,
statTags: {
stage: TRANSFORMER_METRIC.TRANSFORMER_STAGE.TRANSFORM,
scope: TRANSFORMER_METRIC.MEASUREMENT_TYPE.CDK.SCOPE
}
};
}
return errorInfo;
}

module.exports = {
getRootPathForDestination,
getWorkflowPath,
getPlatformBindingsPaths
getPlatformBindingsPaths,
getErrorInfo
};
32 changes: 2 additions & 30 deletions versionedRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ const fs = require("fs");
const path = require("path");
const { ConfigFactory, Executor } = require("rudder-transformer-cdk");
const set = require("set-value");
const {
WorkflowExecutionError,
WorkflowEngineError
} = require("rudder-workflow-engine/build/errors");
const logger = require("./logger");
const stats = require("./util/stats");
const { SUPPORTED_VERSIONS, API_VERSION } = require("./routes/utils/constants");
Expand Down Expand Up @@ -39,6 +35,7 @@ const { compileUserLibrary } = require("./util/ivmFactory");
const { getIntegrations } = require("./routes/utils");
const { RespStatusError, RetryRequestError } = require("./util/utils");
const { getWorkflowEngine } = require("./cdk/v2/handler");
const { getErrorInfo } = require("./cdk/v2/utils");

const CDK_DEST_PATH = "cdk";
const basePath = path.resolve(__dirname, `./${CDK_DEST_PATH}`);
Expand Down Expand Up @@ -104,32 +101,7 @@ async function handleCdkV2(destName, parsedEvent) {
// TODO: Handle remaining output scenarios
return result.output;
} catch (err) {
// Handle various CDK error types
let errorInfo = err;
if (err instanceof WorkflowExecutionError) {
logger.error(
"Error occurred during workflow step execution: ",
err.stepName
);
errorInfo = {
message: err.message,
status: err.status,
destinationResponse: err.error.destinationResponse,
statTags: err.error.statTags,
authErrorCategory: err.error.authErrorCategory
};
// TODO: Add a special stat tag to bump the priority of the error
} else if (err instanceof WorkflowEngineError) {
logger.error("Error occurred during workflow step: ", err.stepName);
errorInfo = {
message: err.message,
status: err.status,
statTags: {
stage: TRANSFORMER_METRIC.TRANSFORMER_STAGE.TRANSFORM,
scope: TRANSFORMER_METRIC.MEASUREMENT_TYPE.CDK.SCOPE
}
};
}
const errorInfo = getErrorInfo(err);

// TODO: Bump the error priority even further as it's an unhandled error in the CDK
const errObj = generateErrorObject(
Expand Down