Skip to content

Commit

Permalink
feat: Support both Lambda APIs in the example TypeScript stack
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 committed Sep 30, 2024
1 parent ad38953 commit 6eec489
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions examples/typescript-stack/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env node
import * as cdk from "aws-cdk-lib";
import { CdkTypeScriptStack } from "../lib/cdk-typescript-stack";
import { CdkTypeScriptLambdaOldApiStack } from "../lib/cdk-typescript-lambda-old-api-stack";

const app = new cdk.App();
new CdkTypeScriptStack(app, "CdkTypeScriptStack", {});
new CdkTypeScriptLambdaOldApiStack(app, "CdkTypeScriptLambdaOldApiStack", {});
app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { Datadog, DatadogProps } from "datadog-cdk-constructs-v2";
import { CdkTypeScriptStackBase } from "./cdk-typescript-stack-base";

export class CdkTypeScriptLambdaOldApiStack extends CdkTypeScriptStackBase {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

console.log("Instrumenting Lambda Functions in TypeScript stack using the old Datadog Lambda API");

const datadogProps: DatadogProps = {
dotnetLayerVersion: 15,
nodeLayerVersion: 108,
pythonLayerVersion: 89,
extensionLayerVersion: 55,
addLayers: true,
apiKey: process.env.DD_API_KEY,
enableDatadogTracing: true,
enableDatadogASM: true,
flushMetricsToLogs: true,
site: "datadoghq.com",
};

const datadog = new Datadog(this, "Datadog", datadogProps);

datadog.addLambdaFunctions(this.lambdaFunctions);
}
}
2 changes: 1 addition & 1 deletion examples/typescript-stack/lib/cdk-typescript-stack-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Function } from "aws-cdk-lib/aws-lambda";
import { HttpLambdaIntegration } from "aws-cdk-lib/aws-apigatewayv2-integrations";
import { Construct } from "constructs";

export class CdkTypeScriptStackBase extends Stack {
export abstract class CdkTypeScriptStackBase extends Stack {
protected lambdaFunctions: lambda.Function[];
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript-stack/lib/cdk-typescript-stack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { Datadog, DatadogProps } from "datadog-cdk-constructs-v2";
import { DatadogLambda, DatadogLambdaProps } from "datadog-cdk-constructs-v2";
import { CdkTypeScriptStackBase } from "./cdk-typescript-stack-base";

export class CdkTypeScriptStack extends CdkTypeScriptStackBase {
Expand All @@ -9,7 +9,7 @@ export class CdkTypeScriptStack extends CdkTypeScriptStackBase {

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

const datadogProps: DatadogProps = {
const datadogLambdaProps: DatadogLambdaProps = {
dotnetLayerVersion: 15,
nodeLayerVersion: 108,
pythonLayerVersion: 89,
Expand All @@ -22,7 +22,7 @@ export class CdkTypeScriptStack extends CdkTypeScriptStackBase {
site: "datadoghq.com",
};

const datadog = new Datadog(this, "Datadog", datadogProps);
const datadog = new DatadogLambda(this, "Datadog", datadogLambdaProps);

datadog.addLambdaFunctions(this.lambdaFunctions);
}
Expand Down

0 comments on commit 6eec489

Please sign in to comment.