-
Notifications
You must be signed in to change notification settings - Fork 26
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: Rename: Datadog -> DatadogLambda #285
Conversation
props: DatadogProps; | ||
transport: Transport; | ||
constructor(scope: Construct, id: string, props: DatadogProps) { | ||
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() == "true") { |
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
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() == "true") { | |
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() === "true") { |
Expected '===' and instead saw '=='. (...read more)
In JavaScript, ==
and !=
comparisons do type coercion, which can be confusing and may introduce potential errors. Use the type-safe equality operators ===
and !==
instead.
public addGitCommitMetadata( | ||
lambdaFunctions: LambdaFunction[], | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore |
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.
public addGitCommitMetadata( | ||
lambdaFunctions: LambdaFunction[], | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
gitCommitSha?: string, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
gitRepoUrl?: string, | ||
): 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
Too many parameters (7). Maximum allowed is 4. (...read more)
Having too many parameters can make your code hard to read. The parameters must be used in appropriate order. Forgetting the order of parameters can cause mistakes.
Too many parameters is a code smell. You should refactor your code in smaller reusable bits. While it may be valid to require more than four parameters, you should use object destructuring.
} from "./index"; | ||
import { LambdaFunction } from "./interfaces"; | ||
|
||
const versionJson = require("../version.json"); |
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 Lambda Functions in TypeScript stack with Datadog" | ||
); | ||
console.log("Instrumenting Lambda 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.
props: DatadogProps; | ||
transport: Transport; | ||
constructor(scope: Construct, id: string, props: DatadogProps) { | ||
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() == "true") { |
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
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() == "true") { | |
if (process.env.DD_CONSTRUCT_DEBUG_LOGS?.toLowerCase() === "true") { |
Expected '===' and instead saw '=='. (...read more)
In JavaScript, ==
and !=
comparisons do type coercion, which can be confusing and may introduce potential errors. Use the type-safe equality operators ===
and !==
instead.
public addGitCommitMetadata( | ||
lambdaFunctions: LambdaFunction[], | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore |
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.
public addGitCommitMetadata( | ||
lambdaFunctions: LambdaFunction[], | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
gitCommitSha?: string, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
gitRepoUrl?: string, | ||
): 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
Too many parameters (7). Maximum allowed is 4. (...read more)
Having too many parameters can make your code hard to read. The parameters must be used in appropriate order. Forgetting the order of parameters can cause mistakes.
Too many parameters is a code smell. You should refactor your code in smaller reusable bits. While it may be valid to require more than four parameters, you should use object destructuring.
} from "./index"; | ||
import { LambdaFunction } from "./interfaces"; | ||
|
||
const versionJson = require("../version.json"); |
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 Lambda Functions in TypeScript stack with Datadog" | ||
); | ||
console.log("Instrumenting Lambda 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.
aa63b23
to
de6d7e4
Compare
983592b
to
46a3573
Compare
de6d7e4
to
2208e0e
Compare
// @ts-ignore | ||
gitCommitSha?: string, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore |
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.
2208e0e
to
635722f
Compare
new LambdaRestApi(this, "rest-test", { | ||
handler: lambdaFunction, | ||
deployOptions: { | ||
accessLogDestination: new LogGroupLogDestination(restLogGroup), | ||
}, | ||
}); |
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 * as lambda from "aws-cdk-lib/aws-lambda"; | ||
import { LogGroup } from "aws-cdk-lib/aws-logs"; | ||
import { addCdkConstructVersionTag, checkForMultipleApiKeys, DatadogLambda, DD_HANDLER_ENV_VAR } from "../src/index"; | ||
const { ISecret } = require("aws-cdk-lib/aws-secretsmanager"); |
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.
const app = new App(); | ||
const env = { account: "601427279990", region: "sa-east-1" }; | ||
const stack = new ExampleStack(app, "lambda-function-stack", { env: env }); | ||
console.log("Stack name: " + stack.stackName); |
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 { LogGroup } from "aws-cdk-lib/aws-logs"; | ||
import { addCdkConstructVersionTag, checkForMultipleApiKeys, DatadogLambda, DD_HANDLER_ENV_VAR } from "../src/index"; | ||
const { ISecret } = require("aws-cdk-lib/aws-secretsmanager"); | ||
const versionJson = require("../version.json"); |
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.
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.
These are just comments on existing code. Let me address them in a separate PR.
635722f
to
3646d05
Compare
3646d05
to
a61fe64
Compare
@@ -0,0 +1,52 @@ | |||
/* |
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.
Copied and modified from integration_tests/stacks/lambda-function-stack.ts
@@ -0,0 +1,365 @@ | |||
/* |
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.
This file is renamed from datadog.ts
@@ -1,537 +1,11 @@ | |||
import { App, Stack, Token } from "aws-cdk-lib"; | |||
import { Template } from "aws-cdk-lib/assertions"; | |||
import { App, Stack } from "aws-cdk-lib"; |
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.
This file was first renamed as datadog-lambda.spec.ts
. Then datadog.spec.ts
was created again with one test, to ensure the Datadog
API still works.
/merge |
🚂 MergeQueue: pull request added to the queue The median merge time in Use |
Just an FYI, this is a breaking change. Packages that depend on datadog-cdk-constructs will now fail, with errors similar to (in Python, for example)
|
What does this PR do?
Datadog
class asDatadogLambda
, including:datadog.ts
asdatadog-lambda.ts
datadog.spec.ts
asdatadog-lambda.spec.ts
Datadog
useDatadogLambda
Datadog
class which just wraps (extends) the newDatadogLambda
class, so its behavior will be the same as the oldDatadog
class. Let me know if you think I should wrap it in a different way.lambda-function-stack-legacy-datadog-api.ts
, which usesDatadog
instead ofDatadogLambda
, showing how to use the legacyDatadog
APIdatadog.spec.ts
to ensure theDatadog
API still worksMotivation
To make it cleaner to add
DatadogStepFunction
class later. Details in [RFC] Changing API for Datadog CDK ConstructTesting Guidelines
Automated testing
datadog.spec.ts
Manual testing
1. using
DatadogLambda
APISteps:
examples/typescript-stack/lib/cdk-typescript-stack.ts
, replace theCdkTypeScriptStack
class with theExampleStack
class inintegration_tests/stacks/lambda-function-stack.ts
. I can't use the existingCdkTypeScriptStack
class due to some docker permission issue.ExampleStack
class usesDatadogLambda
APIResult:
2. using
Datadog
APIStep:
ExampleStack
class useDatadog
class instead ofDatadogLambda
. Deploy again.Result:
Additional Notes
Next steps:
README.md
, recommending users to useDatadogLambda
instead ofDatadog
Types of Changes
Check all that apply