-
Notifications
You must be signed in to change notification settings - Fork 28
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: update example doc to use DatadogLambda #289
Conversation
feb86a7
to
feb6e4f
Compare
43990ce
to
1fe6976
Compare
export class CdkStepFunctionsTypeScriptStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
console.log("Creating Hello World TypeScript stack"); | ||
|
||
const helloLambdaFunction = new lambda.Function(this, "hello-python", { | ||
runtime: lambda.Runtime.PYTHON_3_12, | ||
timeout: Duration.seconds(10), | ||
memorySize: 256, | ||
code: lambda.Code.fromAsset("../lambda/python", { | ||
bundling: { | ||
image: lambda.Runtime.PYTHON_3_12.bundlingImage, | ||
command: ["bash", "-c", "pip install -r requirements.txt -t /asset-output && cp -aT . /asset-output"], | ||
}, | ||
}), | ||
handler: "hello.lambda_handler", | ||
}); | ||
|
||
const stateMachine = new sfn.StateMachine(this, "MyStateMachine", { | ||
definitionBody: sfn.DefinitionBody.fromChainable( | ||
new tasks.LambdaInvoke(this, "MyLambdaTask", { | ||
lambdaFunction: helloLambdaFunction, | ||
}).next(new sfn.Succeed(this, "GreetedWorld")), | ||
), | ||
}); | ||
|
||
console.log("Instrumenting Step Functions in TypeScript stack with Datadog"); | ||
|
||
const datadogSfn = new DatadogStepFunctions(this, "Datadog", {}); | ||
datadogSfn.addStateMachines([stateMachine]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
This class is unnecessary (...read more)
This rule advises against the unnecessary use of classes that contain only static members, or nothing. In JavaScript, classes are primarily used for object-oriented programming, where each instance of a class has its own state and behavior. Static members, on the other hand, belong to the class itself and not to any instance of the class.
When a class contains only static members, it does not make use of JavaScript's object-oriented capabilities, and it can be more difficult to understand, test, and maintain than necessary. In order to avoid this issue, consider using regular functions and variables instead of static class members. This makes your code easier to understand and maintain, and it allows you to make better use of JavaScript's features.
src/interfaces.ts
Outdated
@@ -97,3 +97,5 @@ export interface Node { | |||
} | |||
|
|||
export type LambdaFunction = lambda.Function | lambda.SingletonFunction; | |||
|
|||
export interface DatadogStepFunctionsProps {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { CdkStepFunctionsTypeScriptStack } from "../lib/cdk-step-functions-typescript-stack"; | ||
|
||
const app = new cdk.App(); | ||
new CdkStepFunctionsTypeScriptStack(app, "CdkStepFunctionsTypeScriptStack", {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
), | ||
}); | ||
|
||
console.log("Instrumenting Step Functions in TypeScript stack with Datadog"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
console.log("Creating Hello World TypeScript stack"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/datadog-step-functions.ts
Outdated
this.props = props; | ||
} | ||
|
||
public addStateMachines(_stateMachines: sfn.StateMachine[], _construct?: Construct): void {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Code Quality Violation
public addStateMachines(_stateMachines: sfn.StateMachine[], _construct?: Construct): void {} | |
public addStateMachines(_stateMachines: sfn.StateMachine[], _construct?: Construct): void {/* empty */} |
Empty statement. (...read more)
Empty or non-functional blocks in the code can be misleading and lead to maintenance difficulties. They can also lead to a false sense of security or functionality. While they may not directly introduce security issues, their presence can suggest that some logic or error handling is implemented when it is not.
329adc6
to
75d532f
Compare
What does this PR do?
Make example code in
README.md
to use:
DatadogLambda
instead ofDatadog
DatadogLambdaProps
instead ofDatadogProps
Motivation
The renaming is to make it cleaner to add
DatadogStepFunction
class later. Details in [RFC] Changing API for Datadog CDK ConstructTesting Guidelines
Additional Notes
Types of Changes
Check all that apply