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: Rename: Datadog -> DatadogLambda #285

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions examples/typescript-stack/lib/cdk-typescript-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BundlingOutput, Duration, Stack, StackProps } from "aws-cdk-lib";
import { Function } from "aws-cdk-lib/aws-lambda";
import { HttpLambdaIntegration } from "aws-cdk-lib/aws-apigatewayv2-integrations";
import { Construct } from "constructs";
import { Datadog } from "datadog-cdk-constructs-v2";
import { DatadogLambda } from "datadog-cdk-constructs-v2";

export class CdkTypeScriptStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
Expand Down Expand Up @@ -84,7 +84,7 @@ export class CdkTypeScriptStack extends Stack {

console.log("Instrumenting Lambda Functions in TypeScript stack with Datadog");

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation


const DatadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
dotnetLayerVersion: 15,
nodeLayerVersion: 108,
pythonLayerVersion: 89,
Expand All @@ -97,6 +97,6 @@ export class CdkTypeScriptStack extends Stack {
site: "datadoghq.com",
});

DatadogCDK.addLambdaFunctions([helloNode, helloPython, helloGo, helloDotnet]);
datadogLambda.addLambdaFunctions([helloNode, helloPython, helloGo, helloDotnet]);
}
}
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-function-arm-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";
import { Architecture } from "aws-cdk-lib/aws-lambda";

export class ExampleStack extends Stack {
Expand All @@ -32,7 +32,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
nodeLayerVersion: 62,
extensionLayerVersion: 10,
enableDatadogTracing: true,
Expand All @@ -41,8 +41,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([lambdaFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([lambdaFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copy link
Contributor Author

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

* Unless explicitly stated otherwise all files in this repository are licensed
* under the Apache License Version 2.0.
*
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2021 Datadog, Inc.
*/

import * as lambda from "aws-cdk-lib/aws-lambda";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
// use the legacy Datadog class instead of the new DatadogLambda
import { Datadog } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
super(scope, id, props);

const lambdaFunction = new lambda.Function(this, "HelloHandler", {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline("test"),
handler: "lambdaFunction.handler",
});

const restLogGroup = new LogGroup(this, "restLogGroup");
new LambdaRestApi(this, "rest-test", {
handler: lambdaFunction,
deployOptions: {
accessLogDestination: new LogGroupLogDestination(restLogGroup),
},
});
Comment on lines +27 to +32

Choose a reason for hiding this comment

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

Code Quality Violation

Do not use 'new' for side effects. (...read more)

A lonely instance is almost always useless. Do not create objects without assigning them to a variable that you will use later.

View in Datadog  Leave us feedback  Documentation


const datadog = new Datadog(this, "Datadog", {
nodeLayerVersion: 62,
extensionLayerVersion: 10,
enableDatadogTracing: true,
flushMetricsToLogs: true,
sourceCodeIntegration: false,
apiKey: "1234",
site: "datadoghq.com",
});
datadog.addLambdaFunctions([lambdaFunction]);
datadog.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

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);

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation

app.synth();
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-function-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -30,7 +30,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
nodeLayerVersion: 62,
extensionLayerVersion: 10,
enableDatadogTracing: true,
Expand All @@ -39,8 +39,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([lambdaFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([lambdaFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-java-function-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -30,7 +30,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
javaLayerVersion: 5,
extensionLayerVersion: 25,
enableDatadogTracing: true,
Expand All @@ -39,8 +39,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([lambdaJavaFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([lambdaJavaFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-nodejs-function-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -31,7 +31,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
nodeLayerVersion: 62,
extensionLayerVersion: 10,
enableDatadogTracing: true,
Expand All @@ -40,8 +40,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([lambdaNodejsFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([lambdaNodejsFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-provided-arm-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as s3 from "aws-cdk-lib/aws-s3";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand Down Expand Up @@ -31,14 +31,14 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
extensionLayerVersion: 49,
apiKey: "1234",
site: "datadoghq.com",
sourceCodeIntegration: false,
});
datadogCDK.addLambdaFunctions([providedLambda]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([providedLambda]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-provided-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as s3 from "aws-cdk-lib/aws-s3";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -30,14 +30,14 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
extensionLayerVersion: 49,
apiKey: "1234",
site: "datadoghq.com",
sourceCodeIntegration: false,
});
datadogCDK.addLambdaFunctions([providedLambda]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([providedLambda]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-python-function-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PythonFunction } from "@aws-cdk/aws-lambda-python-alpha";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -32,7 +32,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
pythonLayerVersion: 46,
extensionLayerVersion: 10,
enableDatadogTracing: true,
Expand All @@ -41,8 +41,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([lambdaPythonFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([lambdaPythonFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/stacks/lambda-singleton-function-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
import { Stack, StackProps, App } from "aws-cdk-lib";
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway";
import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Datadog } from "../../src/index";
import { DatadogLambda } from "../../src/index";

export class ExampleStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
Expand All @@ -31,7 +31,7 @@ export class ExampleStack extends Stack {
},
});

const datadogCDK = new Datadog(this, "Datadog", {
const datadogLambda = new DatadogLambda(this, "Datadog", {
nodeLayerVersion: 62,
extensionLayerVersion: 10,
enableDatadogTracing: true,
Expand All @@ -40,8 +40,8 @@ export class ExampleStack extends Stack {
apiKey: "1234",
site: "datadoghq.com",
});
datadogCDK.addLambdaFunctions([singletonLambdaFunction]);
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]);
datadogLambda.addLambdaFunctions([singletonLambdaFunction]);
datadogLambda.addForwarderToNonLambdaLogGroups([restLogGroup]);
}
}

Expand Down
Loading
Loading