-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|
@@ -84,7 +84,7 @@ export class CdkTypeScriptStack extends Stack { | |
|
||
console.log("Instrumenting Lambda Functions in TypeScript stack with Datadog"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
const DatadogCDK = new Datadog(this, "Datadog", { | ||
const datadogLambda = new DatadogLambda(this, "Datadog", { | ||
dotnetLayerVersion: 15, | ||
nodeLayerVersion: 108, | ||
pythonLayerVersion: 89, | ||
|
@@ -97,6 +97,6 @@ export class CdkTypeScriptStack extends Stack { | |
site: "datadoghq.com", | ||
}); | ||
|
||
DatadogCDK.addLambdaFunctions([helloNode, helloPython, helloGo, helloDotnet]); | ||
datadogLambda.addLambdaFunctions([helloNode, helloPython, helloGo, helloDotnet]); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied and modified from |
||
* 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
app.synth(); |
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
Unexpected console statement. (...read more)
Debugging with
console
is not considered a bad practice, but it's easy to forget aboutconsole
statements and leave them in production code. There is no need to pollute production builds with debugging statements.