Skip to content

Commit

Permalink
Test unsupported runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 committed Dec 6, 2024
1 parent c27d8d9 commit 793365b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 165 deletions.
44 changes: 0 additions & 44 deletions examples/lambda/node/hello.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,4 @@
const axios = require('axios');

const {
sendDistributionMetric,
sendDistributionMetricWithDate,
} = require("datadog-lambda-js");
const tracer = require("dd-trace");

// submit a custom span named "sleep"
const sleep = tracer.wrap("sleep", (ms) => {
return new Promise((resolve) => setTimeout(resolve, ms));
});

exports.lambda_handler = async (event) => {
await axios.get("https://www.datadoghq.com");

// add custom tags to the lambda function span,
// does NOT work when X-Ray tracing is enabled
const span = tracer.scope().active();
span.setTag("customer_id", "123456");

await sleep(100);

// submit a custom span
const sandwich = tracer.trace("hello.world", () => {
console.log("Hello, World!");
});

// submit a custom metric
sendDistributionMetric(
"coffee_house.order_value", // metric name
12.45, // metric value
"product:latte", // tag
"order:online" // another tag
);

// submit a custom metric with timestamp
sendDistributionMetricWithDate(
"coffee_house.order_value", // metric name
12.45, // metric value
new Date(Date.now()), // date, must be within last 20 mins
"product:latte", // tag
"order:online" // another tag
);

console.log("Logging from hello.js");

const response = {
Expand Down
64 changes: 3 additions & 61 deletions examples/typescript-stack/lib/cdk-typescript-stack-base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { GoFunction } from "@aws-cdk/aws-lambda-go-alpha";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as apigwv2 from "aws-cdk-lib/aws-apigatewayv2";
import { BundlingOutput, Duration, Stack, StackProps } from "aws-cdk-lib";
import { 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";

export abstract class CdkTypeScriptStackBase extends Stack {
Expand All @@ -14,7 +11,7 @@ export abstract class CdkTypeScriptStackBase extends Stack {
console.log("Creating Hello World TypeScript stack");

const helloNode = new Function(this, "hello-node", {
runtime: lambda.Runtime.NODEJS_20_X,
runtime: lambda.determineLatestNodeRuntime(this),
memorySize: 256,
timeout: Duration.seconds(10),
code: lambda.Code.fromAsset("../lambda/node", {
Expand All @@ -27,61 +24,6 @@ export abstract class CdkTypeScriptStackBase extends Stack {
handler: "hello.lambda_handler",
});

const helloPython = new Function(this, "hello-python", {
runtime: lambda.Runtime.PYTHON_3_12,
timeout: Duration.seconds(10),
memorySize: 256,
code: lambda.Code.fromAsset("../lambda/python", {
bundling: {
image: lambda.Runtime.PYTHON_3_12.bundlingImage,
command: ["bash", "-c", "pip install -r requirements.txt -t /asset-output && cp -aT . /asset-output"],
},
}),
handler: "hello.lambda_handler",
});

const helloGo = new GoFunction(this, "hello-go", {
entry: "../lambda/go/hello.go",
architecture: lambda.Architecture.ARM_64,
runtime: lambda.Runtime.PROVIDED_AL2,
timeout: Duration.seconds(10),
bundling: {
goBuildFlags: ['-ldflags "-s -w"'],
},
environment: {
LOG_LEVEL: "INFO",
TABLE_NAME: "HelloWorld",
},
});

const helloDotnet = new Function(this, "hello-dotnet", {
runtime: lambda.Runtime.DOTNET_8,
handler: "HelloWorld::HelloWorld.Handler::SayHi",
memorySize: 256,
code: lambda.Code.fromAsset("../lambda/dotnet/", {
bundling: {
image: lambda.Runtime.DOTNET_8.bundlingImage,
command: [
"/bin/sh",
"-c",
" dotnet tool install -g Amazon.Lambda.Tools" +
" && dotnet build" +
" && dotnet lambda package --output-package /asset-output/function.zip",
],
user: "root",
outputType: BundlingOutput.ARCHIVED,
},
}),
});

this.lambdaFunctions = [helloNode, helloPython, helloGo, helloDotnet];

const dotnetHttpIntegration = new HttpLambdaIntegration("GetDotnetIntegration", helloDotnet);
const dotnetHttpApi = new apigwv2.HttpApi(this, "dotnetHttpApi");
dotnetHttpApi.addRoutes({
path: "/hello",
methods: [apigwv2.HttpMethod.GET],
integration: dotnetHttpIntegration,
});
this.lambdaFunctions = [helloNode];
}
}
6 changes: 3 additions & 3 deletions examples/typescript-stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
},
"devDependencies": {
"@types/node": "^20.8.8",
"aws-cdk": "^2.134.0",
"aws-cdk": "^2.146.0",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
},
"dependencies": {
"@aws-cdk/aws-lambda-go-alpha": "^2.134.0-alpha.0",
"@aws-cdk/aws-lambda-python-alpha": "^2.134.0-alpha.0",
"aws-cdk-lib": "^2.134.0",
"aws-cdk-lib": "^2.146.0",
"constructs": "^10.3.0",
"datadog-cdk-constructs-v2": "^1.13.0"
"datadog-cdk-constructs-v2": "file:./datadog-cdk-constructs-v2-1.21.0.jsii.tgz"
}
}
106 changes: 50 additions & 56 deletions examples/typescript-stack/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# yarn lockfile v1


"@aws-cdk/asset-awscli-v1@^2.2.202":
version "2.2.202"
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.202.tgz#4627201d71f6a5c60db36385ce09cb81005f4b32"
integrity sha512-JqlF0D4+EVugnG5dAsNZMqhu3HW7ehOXm5SDMxMbXNDMdsF0pxtQKNHRl52z1U9igsHmaFpUgSGjbhAJ+0JONg==
"@aws-cdk/asset-awscli-v1@^2.2.208":
version "2.2.213"
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.213.tgz#7f112d9b4f9dd698f4655e7911bcf45510325a06"
integrity sha512-crm1yDJmORJF2Y9gDvNUX4Q3iQXVhWrL7oaZfpx3QDqrvVz5UEgWGpJdysqDuWFZTmIgtrI5Svq3UfdwCNNpsg==

"@aws-cdk/asset-kubectl-v20@^2.1.2":
version "2.1.2"
resolved "https://registry.npmjs.org/@aws-cdk/asset-kubectl-v20/-/asset-kubectl-v20-2.1.2.tgz"
integrity sha512-3M2tELJOxQv0apCIiuKQ4pAbncz9GuLwnKFqxifWfe77wuMxyTRPmxssYHs42ePqzap1LT6GDcPygGs+hHstLg==
"@aws-cdk/asset-kubectl-v20@^2.1.3":
version "2.1.3"
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-kubectl-v20/-/asset-kubectl-v20-2.1.3.tgz#80e09004be173995e91614e34d947da11dd9ff4d"
integrity sha512-cDG1w3ieM6eOT9mTefRuTypk95+oyD7P5X/wRltwmYxU7nZc3+076YEVS6vrjDKr3ADYbfn0lDKpfB1FBtO9CQ==

"@aws-cdk/asset-node-proxy-agent-v6@^2.0.1":
version "2.0.1"
resolved "https://registry.npmjs.org/@aws-cdk/asset-node-proxy-agent-v6/-/asset-node-proxy-agent-v6-2.0.1.tgz"
integrity sha512-DDt4SLdLOwWCjGtltH4VCST7hpOI5DzieuhGZsBpZ+AgJdSI2GCjklCXm0GCTwJG/SolkL5dtQXyUKgg9luBDg==
"@aws-cdk/asset-node-proxy-agent-v6@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-node-proxy-agent-v6/-/asset-node-proxy-agent-v6-2.1.0.tgz#6d3c7860354d4856a7e75375f2f0ecab313b4989"
integrity sha512-7bY3J8GCVxLupn/kNmpPc5VJz8grx+4RKfnnJiO1LG+uxkZfANZG3RMHhE+qQxxwkyQ9/MfPtTpf748UhR425A==

"@aws-cdk/aws-lambda-go-alpha@^2.134.0-alpha.0":
version "2.134.0-alpha.0"
Expand All @@ -27,6 +27,14 @@
resolved "https://registry.yarnpkg.com/@aws-cdk/aws-lambda-python-alpha/-/aws-lambda-python-alpha-2.134.0-alpha.0.tgz#8a85a8f08a05f71f6fca55d14da6cb3116c3612d"
integrity sha512-St+Ej+Efm1+EPz5k1D+4ej8zod+1/ocK7hBsSPFI2hfnEfBPQci9Pkjr8qkNnU8ODB3ZJpL08r/ghi4XMTf0PQ==

"@aws-cdk/cloud-assembly-schema@^38.0.1":
version "38.0.1"
resolved "https://registry.yarnpkg.com/@aws-cdk/cloud-assembly-schema/-/cloud-assembly-schema-38.0.1.tgz#cdf4684ae8778459e039cd44082ea644a3504ca9"
integrity sha512-KvPe+NMWAulfNVwY7jenFhzhuLhLqJ/OPy5jx7wUstbjnYnjRVLpUHPU3yCjXFE0J8cuJVdx95BJ4rOs66Pi9w==
dependencies:
jsonschema "^1.4.1"
semver "^7.6.3"

"@balena/dockerignore@^1.0.2":
version "1.0.2"
resolved "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz"
Expand Down Expand Up @@ -126,30 +134,31 @@ astral-regex@^2.0.0:
resolved "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==

aws-cdk-lib@^2.134.0:
version "2.134.0"
resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.134.0.tgz#92b53afed0d2bc4378211638d8ab056577b36840"
integrity sha512-fjJLsZ7L+HLVSOGfYxMcAbUYBb1I/UWLH9STkPiytT+hWQNN6lmZYLDHlqCqcS8gFyyCqu4i3KOOt/ZDHDVo2Q==
aws-cdk-lib@^2.146.0:
version "2.171.1"
resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.171.1.tgz#111e8e830b85582e80a60f68182fd0d3a60fb066"
integrity sha512-BmXodHmeOWu7EZMwXFA+Mp+SnlZgIwhMxfOmqpdGa5dXF4BWOrs0cm4YgrzcJkg0XK713eXPj5IWGj8YeRIU3g==
dependencies:
"@aws-cdk/asset-awscli-v1" "^2.2.202"
"@aws-cdk/asset-kubectl-v20" "^2.1.2"
"@aws-cdk/asset-node-proxy-agent-v6" "^2.0.1"
"@aws-cdk/asset-awscli-v1" "^2.2.208"
"@aws-cdk/asset-kubectl-v20" "^2.1.3"
"@aws-cdk/asset-node-proxy-agent-v6" "^2.1.0"
"@aws-cdk/cloud-assembly-schema" "^38.0.1"
"@balena/dockerignore" "^1.0.2"
case "1.6.3"
fs-extra "^11.2.0"
ignore "^5.3.1"
ignore "^5.3.2"
jsonschema "^1.4.1"
mime-types "^2.1.35"
minimatch "^3.1.2"
punycode "^2.3.1"
semver "^7.6.0"
table "^6.8.1"
semver "^7.6.3"
table "^6.8.2"
yaml "1.10.2"

aws-cdk@^2.134.0:
version "2.134.0"
resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.134.0.tgz#029b126df81ed5e4c95390bb1a112fb2c07fca15"
integrity sha512-/0rygJZpBMK4DQHciMH6ZR4bnQ80/6usHMXmJrvwbSpKFW2WpkYKwzpAxnnQeiyzfEIIUoB+oyIy7EmKS1HLtA==
aws-cdk@^2.146.0:
version "2.171.1"
resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.171.1.tgz#b3599bfcccfd64275f943d93cde7acaf17f2560d"
integrity sha512-IWENyT4F5UcLr1szLsbipUdjIHn8FD3d/RvaIvhs2+qCamkfEV5mqv/ChMvRJ8H2jebhIZ2iz74or9O5Ismp+Q==
optionalDependencies:
fsevents "2.3.2"

Expand Down Expand Up @@ -198,10 +207,9 @@ create-require@^1.1.0:
resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==

datadog-cdk-constructs-v2@^1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/datadog-cdk-constructs-v2/-/datadog-cdk-constructs-v2-1.13.0.tgz#4629f1bbf6f09facc62161462fa5ffd657595e1a"
integrity sha512-sJ2lLdnIMfQvLL8jUfVIBoZ2lLfJjNoCAy1P9J1XPxBd++MCSQfyScsjrt8PQG/0kz0LDmh9HCHp1QvG/k3vjw==
"datadog-cdk-constructs-v2@file:./datadog-cdk-constructs-v2-1.21.0.jsii.tgz":
version "1.21.0"
resolved "file:./datadog-cdk-constructs-v2-1.21.0.jsii.tgz#446fd8adf01f0d09a167ed524a8cbb277c0e1d8c"
dependencies:
loglevel "^1.9.1"

Expand Down Expand Up @@ -239,10 +247,10 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0:
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==

ignore@^5.3.1:
version "5.3.1"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==
ignore@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==

is-fullwidth-code-point@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -278,13 +286,6 @@ loglevel@^1.9.1:
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.9.1.tgz#d63976ac9bcd03c7c873116d41c2a85bafff1be7"
integrity sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"

make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz"
Expand Down Expand Up @@ -324,12 +325,10 @@ require-from-string@^2.0.2:
resolved "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz"
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==

semver@^7.6.0:
version "7.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
dependencies:
lru-cache "^6.0.0"
semver@^7.6.3:
version "7.6.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==

slice-ansi@^4.0.0:
version "4.0.0"
Expand All @@ -356,10 +355,10 @@ strip-ansi@^6.0.1:
dependencies:
ansi-regex "^5.0.1"

table@^6.8.1:
version "6.8.1"
resolved "https://registry.npmjs.org/table/-/table-6.8.1.tgz"
integrity sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==
table@^6.8.2:
version "6.9.0"
resolved "https://registry.yarnpkg.com/table/-/table-6.9.0.tgz#50040afa6264141c7566b3b81d4d82c47a8668f5"
integrity sha512-9kY+CygyYM6j02t5YFHbNz2FN5QmYGv9zAjVp4lCDjlCw7amdckXlEt/bjMhUIfj4ThGRE4gCUH5+yGnNuPo5A==
dependencies:
ajv "^8.0.1"
lodash.truncate "^4.4.2"
Expand Down Expand Up @@ -413,11 +412,6 @@ v8-compile-cache-lib@^3.0.1:
resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz"
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==

yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

[email protected]:
version "1.10.2"
resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz"
Expand Down
2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 793365b

Please sign in to comment.