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

[Step Function] 3.2 Extract class ConfigLoader and LambdaConfigLoader #150

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

lym953
Copy link
Contributor

@lym953 lym953 commented Jan 7, 2025

Context of this PR series

Right now the Datadog Serverless CloudFormation Macro only supports instrumenting Lambda functions. This series of PRs makes it also support instrumenting Step Functions.

Instead of merging every PR into main branch, I'm going to merge them into a feature branch yiming.luo/step-function to:

  1. respect the holiday production freeze
  2. avoid releasing partial support for step functions

What does this PR do?

Moves some code for getting Lambda config from top-level functions into two classes:

  • ConfigLoader, for common code for loading Lambda config and loading Step Function config
  • LambdaConfigLoader extends ConfigLoader, for code specific to Lambda

Motivation

To avoid duplicate code for loading Lambda config and for loading Step Function config. For example, #148 has lots of duplicate code.

Testing Guidelines

  1. Pass the existing automated tests in lambda/env.spec.ts

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@lym953 lym953 requested a review from a team as a code owner January 7, 2025 23:08
* addLayers: true
* ...
*/
public getConfigFromCfnMappings(mappings: any): TConfig {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Unexpected any. Specify a different type. (...read more)

Do not use the any type, as it is too broad and can lead to unexpected behavior.

View in Datadog  Leave us feedback  Documentation

@@ -86,6 +86,168 @@ export interface Configuration {
apmFlushDeadline?: string;
}

abstract class ConfigLoader<TConfig> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding correctly, the stepfunction config loader will (in a future PR) will also extend this class is that right? Do we want it in the lambda folder or is there a shared code section that makes sense to keep the overlapping components in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding correctly, the stepfunction config loader will (in a future PR) will also extend this class is that right?

Yes.

Do we want it in the lambda folder or is there a shared code section that makes sense to keep the overlapping components in?

I'm okay with either, but since you raised it, let me move it to the src folder.

* addLayers: true
* ...
*/
public getConfigFromCfnMappings(mappings: any): TConfig {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Unexpected any. Specify a different type. (...read more)

Do not use the any type, as it is too broad and can lead to unexpected behavior.

View in Datadog  Leave us feedback  Documentation

@lym953 lym953 merged commit 78968e9 into yiming.luo/step-function Jan 8, 2025
10 checks passed
@lym953 lym953 deleted the yiming.luo/step-function-9-1 branch January 8, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants