Skip to content
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
5 changes: 4 additions & 1 deletion .gitlab/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ outputFiles:
datasources:
flavors:
url: .gitlab/datasources/flavors.yaml

environments:
url: .gitlab/datasources/environments.yaml

regions:
url: .gitlab/datasources/regions.yaml

test_suites:
url: .gitlab/datasources/test-suites.yaml
4 changes: 4 additions & 0 deletions .gitlab/datasources/test-suites.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_suites:
- name: base
- name: otlp
- name: snapstart
4 changes: 3 additions & 1 deletion .gitlab/templates/pipeline.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ integration-suite:
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
parallel:
matrix:
- TEST_SUITE: [base, otlp]
- TEST_SUITE: {{ range (ds "test_suites").test_suites }}
- {{ .name }}
{{- end}}
rules:
- when: on_success
needs:
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import {Base} from '../lib/stacks/base';
import {Otlp} from '../lib/stacks/otlp';
import {Snapstart} from '../lib/stacks/snapstart';
import {getIdentifier} from '../tests/utils/config';

const app = new cdk.App();
Expand All @@ -21,6 +22,9 @@ const stacks = [
new Otlp(app, `integ-${identifier}-otlp`, {
env,
}),
new Snapstart(app, `integ-${identifier}-snapstart`, {
env,
}),
]

// Tag all stacks so we can easily clean them up
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/lambda/snapstart-dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
obj/
23 changes: 23 additions & 0 deletions integration-tests/lambda/snapstart-dotnet/Function.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Amazon.Lambda.Core;
using System.Collections.Generic;
using System.Threading.Tasks;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace Function
{
public class SnapstartHandler
{
public async Task<Dictionary<string, object>> FunctionHandler(Dictionary<string, object> input, ILambdaContext context)
{
// Wait 10 seconds to guarantee concurrent execution overlap
await Task.Delay(10000);

return new Dictionary<string, object>
{
{ "statusCode", 200 },
{ "body", "Snapstart .NET function executed" }
};
}
}
}
14 changes: 14 additions & 0 deletions integration-tests/lambda/snapstart-dotnet/Function.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions integration-tests/lambda/snapstart-java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
50 changes: 50 additions & 0 deletions integration-tests/lambda/snapstart-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>example</groupId>
<artifactId>snapstart-java-lambda</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Snapstart Java Lambda</name>
<description>Snapstart Java Lambda function for Datadog Extension integration testing</description>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>function</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package example;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import java.util.Map;
import java.util.HashMap;

public class SnapstartHandler implements RequestHandler<Map<String, Object>, Map<String, Object>> {
@Override
public Map<String, Object> handleRequest(Map<String, Object> event, Context context) {

// Wait 10 seconds to guarantee concurrent execution overlap
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

Map<String, Object> response = new HashMap<>();
response.put("statusCode", 200);
response.put("body", "Snapstart Java function executed");
return response;
}
}
14 changes: 14 additions & 0 deletions integration-tests/lambda/snapstart-python/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import logging
import time

logger = logging.getLogger()
logger.setLevel(logging.INFO)

def handler(event, context):
# Wait 10 seconds to guarantee concurrent execution overlap
time.sleep(10)

return {
'statusCode': 200,
'body': 'Snapstart Python function executed'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# No additional dependencies required for this simple handler
106 changes: 106 additions & 0 deletions integration-tests/lib/stacks/snapstart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { Construct } from 'constructs';
import {
createLogGroup,
defaultDatadogEnvVariables,
defaultDatadogSecretPolicy,
getExtensionLayer,
getPython313Layer,
getJava21Layer,
getDotnet8Layer
} from '../util';

export class Snapstart extends cdk.Stack {
constructor(scope: Construct, id: string, props: cdk.StackProps) {
super(scope, id, props);

const extensionLayer = getExtensionLayer(this);
const python313Layer = getPython313Layer(this);
const java21Layer = getJava21Layer(this);
const dotnet8Layer = getDotnet8Layer(this);

const javaFunctionName = `${id}-java-lambda`;
const javaFunction = new lambda.Function(this, javaFunctionName, {
runtime: lambda.Runtime.JAVA_21,
architecture: lambda.Architecture.ARM_64,
handler: 'example.SnapstartHandler::handleRequest',
code: lambda.Code.fromAsset('./lambda/snapstart-java/target/function.jar'),
functionName: javaFunctionName,
timeout: cdk.Duration.seconds(30),
memorySize: 512,
snapStart: lambda.SnapStartConf.ON_PUBLISHED_VERSIONS,
environment: {
...defaultDatadogEnvVariables,
DD_SERVICE: javaFunctionName,
AWS_LAMBDA_EXEC_WRAPPER: '/opt/datadog_wrapper',
DD_TRACE_ENABLED: 'true',
},
logGroup: createLogGroup(this, javaFunctionName)
});
javaFunction.addToRolePolicy(defaultDatadogSecretPolicy);
javaFunction.addLayers(extensionLayer);
javaFunction.addLayers(java21Layer);
const javaVersion = javaFunction.currentVersion;
const javaAlias = new lambda.Alias(this, `${javaFunctionName}-snapstart-alias`, {
aliasName: 'snapstart',
version: javaVersion,
});

const pythonFunctionName = `${id}-python-lambda`;
const pythonFunction = new lambda.Function(this, pythonFunctionName, {
runtime: lambda.Runtime.PYTHON_3_13,
architecture: lambda.Architecture.ARM_64,
handler: 'datadog_lambda.handler.handler',
code: lambda.Code.fromAsset('./lambda/snapstart-python'),
functionName: pythonFunctionName,
timeout: cdk.Duration.seconds(30),
memorySize: 512,
snapStart: lambda.SnapStartConf.ON_PUBLISHED_VERSIONS,
environment: {
...defaultDatadogEnvVariables,
DD_SERVICE: pythonFunctionName,
DD_TRACE_ENABLED: 'true',
DD_LAMBDA_HANDLER: 'lambda_function.handler',
DD_TRACE_AGENT_URL: 'http://127.0.0.1:8126',
DD_COLD_START_TRACING: 'true',
DD_MIN_COLD_START_DURATION: '0',
},
logGroup: createLogGroup(this, pythonFunctionName)
});
pythonFunction.addToRolePolicy(defaultDatadogSecretPolicy);
pythonFunction.addLayers(extensionLayer);
pythonFunction.addLayers(python313Layer);
const pythonVersion = pythonFunction.currentVersion;
const pythonAlias = new lambda.Alias(this, `${pythonFunctionName}-snapstart-alias`, {
aliasName: 'snapstart',
version: pythonVersion,
});

const dotnetFunctionName = `${id}-dotnet-lambda`;
const dotnetFunction = new lambda.Function(this, dotnetFunctionName, {
runtime: lambda.Runtime.DOTNET_8,
architecture: lambda.Architecture.ARM_64,
handler: 'Function::Function.SnapstartHandler::FunctionHandler',
code: lambda.Code.fromAsset('./lambda/snapstart-dotnet/bin/function.zip'),
functionName: dotnetFunctionName,
timeout: cdk.Duration.seconds(30),
memorySize: 512,
snapStart: lambda.SnapStartConf.ON_PUBLISHED_VERSIONS,
environment: {
...defaultDatadogEnvVariables,
DD_SERVICE: dotnetFunctionName,
AWS_LAMBDA_EXEC_WRAPPER: '/opt/datadog_wrapper',
},
logGroup: createLogGroup(this, dotnetFunctionName)
});
dotnetFunction.addToRolePolicy(defaultDatadogSecretPolicy);
dotnetFunction.addLayers(extensionLayer);
dotnetFunction.addLayers(dotnet8Layer);
const dotnetVersion = dotnetFunction.currentVersion;
const dotnetAlias = new lambda.Alias(this, `${dotnetFunctionName}-snapstart-alias`, {
aliasName: 'snapstart',
version: dotnetVersion,
});
}
}
Loading
Loading