Skip to content
Open
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
4 changes: 1 addition & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'otel-plugin/**'
- 'examples/**'
- 'pom.xml'
push:
Expand All @@ -21,7 +20,6 @@ on:
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'otel-plugin/**'
- 'examples/**'
- 'pom.xml'

Expand Down Expand Up @@ -96,7 +94,7 @@ jobs:
mvn clean test -B \
-Dtest.cloud.enabled=true \
-Dtest.aws.account='${{ secrets.TEST_ACCOUNT_ID }}' \
-Dtest="CloudBasedIntegrationTest,CloudBasedOtelIntegrationTest" \
-Dtest=CloudBasedIntegrationTest \
-Dtest.function.name.prefix='Java${{ matrix.java }}-' \
-Djunit.jupiter.execution.parallel.enabled=true \
-Djunit.jupiter.execution.parallel.mode.default=concurrent \
Expand Down
8 changes: 0 additions & 8 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ mvn test -Dtest=CloudBasedIntegrationTest \
| [SimpleMapExample](src/main/java/software/amazon/lambda/durable/examples/map/SimpleMapExample.java) | Concurrent map over a collection with durable steps |
| [CustomShouldCompleteMapExample](src/main/java/software/amazon/lambda/durable/examples/map/CustomShouldCompleteMapExample.java) | Custom map completion with `shouldComplete` decisions |
| [WaitForConditionExample](src/main/java/software/amazon/lambda/durable/examples/wait/WaitForConditionExample.java) | Poll a condition until met with `waitForCondition()` |
| [OtelExample](src/main/java/software/amazon/lambda/durable/examples/general/OtelExample.java) | OpenTelemetry instrumentation with logging span export |
| [OtelXRayStepExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayStepExample.java) | Export step spans to X-Ray through the ADOT Lambda Layer |
| [OtelXRayExecutionStepExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayExecutionStepExample.java) | Export spans to X-Ray with `new ExecutionOtelPlugin()` using workflow-rooted trace structure |
| [OtelXRayExecutionWaitExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayExecutionWaitExample.java) | Trace a step-wait-step workflow with ExecutionOtelPlugin across Lambda invocations |
| [OtelXRayWaitExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayWaitExample.java) | Trace a step-wait-step workflow across Lambda invocations |
| [OtelXRayMapExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayMapExample.java) | Trace concurrent map operations and item steps in X-Ray |
| [OtelXRayParallelExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayParallelExample.java) | Trace parallel branches and branch steps in X-Ray |
| [OtelXRayNestedContextExample](src/main/java/software/amazon/lambda/durable/examples/otel/OtelXRayNestedContextExample.java) | Trace nested child contexts and inner steps in X-Ray |

## Cleanup

Expand Down
65 changes: 7 additions & 58 deletions examples/generate-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import argparse
import re
import xml.etree.ElementTree as ET
from dataclasses import dataclass
from pathlib import Path

Expand All @@ -14,17 +13,6 @@
EXAMPLE_PACKAGE_ROOT = SOURCE_ROOT / "software/amazon/lambda/durable/examples"
DEFAULT_OUTPUT = EXAMPLES_DIR / "template.yaml"
TEMPLATE_ANNOTATION = "ExampleTemplate"
POM_NAMESPACE = {"m": "http://maven.apache.org/POM/4.0.0"}


def read_otel_plugin_jar_path() -> str:
root = ET.parse(EXAMPLES_DIR / "pom.xml").getroot()
version = root.findtext("m:version", namespaces=POM_NAMESPACE)
if version is None:
version = root.findtext("m:parent/m:version", namespaces=POM_NAMESPACE)
if version is None:
raise ValueError("Unable to read examples version from pom.xml")
return f"/var/task/lib/aws-durable-execution-sdk-java-plugin-otel-{version}.jar"


@dataclass(frozen=True)
Expand All @@ -33,8 +21,6 @@ class ExampleFunction:
package_name: str
suffix: str
condition: str | None
tracing: bool
java_agent: bool

@property
def logical_id(self) -> str:
Expand All @@ -51,7 +37,6 @@ def handler(self) -> str:
@property
def description(self) -> str:
words = re.sub(r"(?<!^)(?=[A-Z])", " ", self.class_name)
words = words.replace("Otel", "OTel").replace("X Ray", "X-Ray")
return f"{words} Function ARN"


Expand All @@ -71,26 +56,21 @@ def is_top_level_durable_handler(source: str, class_name: str) -> bool:
return bool(match and "extends DurableHandler" in match.group("header"))


def read_template_annotation(source: str, class_name: str) -> tuple[str | None, bool, bool]:
def read_template_condition(source: str, class_name: str) -> str | None:
class_match = re.search(rf"public\s+(?:final\s+)?class\s+{class_name}\b", source)
if not class_match:
return None, False, False
return None

prefix = source[: class_match.start()]
matches = list(
re.finditer(rf"@(?:[A-Za-z_][\w.]*\.)?{TEMPLATE_ANNOTATION}\s*(?:\((?P<body>.*?)\))?", prefix, re.DOTALL)
)
if not matches:
return None, False, False
return None

body = matches[-1].group("body") or ""
condition_match = re.search(r'condition\s*=\s*"([^"]+)"', body)
tracing_match = re.search(r"tracing\s*=\s*(true|false)", body)
java_agent_match = re.search(r"javaAgent\s*=\s*(true|false)", body)
condition = condition_match.group(1) if condition_match else None
tracing = tracing_match.group(1) == "true" if tracing_match else False
java_agent = java_agent_match.group(1) == "true" if java_agent_match else False
return condition, tracing, java_agent
return condition_match.group(1) if condition_match else None


def discover_examples() -> list[ExampleFunction]:
Expand All @@ -101,22 +81,20 @@ def discover_examples() -> list[ExampleFunction]:
if not is_top_level_durable_handler(source, class_name):
continue

condition, tracing, java_agent = read_template_annotation(source, class_name)
condition = read_template_condition(source, class_name)
package_name = read_package(source, path)
examples.append(
ExampleFunction(
class_name=class_name,
package_name=package_name,
suffix=kebab_case(class_name),
condition=condition,
tracing=tracing,
java_agent=java_agent,
)
)
return examples


def emit_function(lines: list[str], example: ExampleFunction, java_agent_extension_path: str) -> None:
def emit_function(lines: list[str], example: ExampleFunction) -> None:
lines.extend(
[
f" {example.logical_id}:",
Expand All @@ -134,26 +112,6 @@ def emit_function(lines: list[str], example: ExampleFunction, java_agent_extensi
" Role: !Ref RoleArn",
]
)
if example.tracing:
lines.extend(
[
" Tracing: Active",
" Layers:",
" - !Ref AdotLayerArn",
]
)
if example.java_agent:
lines.extend(
[
" LoggingConfig:",
" LogFormat: JSON",
" Environment:",
" Variables:",
" AWS_LAMBDA_EXEC_WRAPPER: /opt/otel-instrument",
f' JAVA_TOOL_OPTIONS: "-Dotel.javaagent.extensions={java_agent_extension_path}"',
f" OTEL_JAVAAGENT_EXTENSIONS: {java_agent_extension_path}",
]
)
lines.append("")


Expand All @@ -177,7 +135,6 @@ def emit_log_group(lines: list[str], example: ExampleFunction) -> None:


def render_template(examples: list[ExampleFunction]) -> str:
java_agent_extension_path = read_otel_plugin_jar_path()
lines = [
"# This file is generated by examples/generate-template.py. Do not edit it by hand.",
'AWSTemplateFormatVersion: "2010-09-09"',
Expand All @@ -203,14 +160,6 @@ def render_template(examples: list[ExampleFunction]) -> str:
" RoleArn:",
" Type: String",
" Description: IAM Role ARN for Lambda function execution",
" AdotLayerArn:",
" Type: String",
" Default: arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroJava:16",
" Description: >-",
" ARN of the ADOT (AWS Distro for OpenTelemetry) Lambda layer used by the tracing examples.",
" The layer is regional: its account ID and version vary by region, so override this per",
" deployment region. The default targets us-west-2 (the region used by e2e tests); CI",
" resolves the latest ARN for its region.",
"",
"Conditions:",
" IsJava21OrLater:",
Expand All @@ -237,7 +186,7 @@ def render_template(examples: list[ExampleFunction]) -> str:

for example in examples:
emit_log_group(lines, example)
emit_function(lines, example, java_agent_extension_path)
emit_function(lines, example)

lines.append("Outputs:")
for index, example in enumerate(examples):
Expand Down
48 changes: 0 additions & 48 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@
<version>${project.version}</version>
</dependency>

<!-- OTel Plugin -->
<dependency>
<groupId>software.amazon.lambda.durable</groupId>
<artifactId>aws-durable-execution-sdk-java-plugin-otel</artifactId>
<version>${project.version}</version>
</dependency>

<!-- OpenTelemetry SDK (required for OTel example) -->
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.65.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-logging</artifactId>
<version>1.65.0</version>
</dependency>

<!-- AWS Lambda Java Core -->
<dependency>
<groupId>com.amazonaws</groupId>
Expand Down Expand Up @@ -91,11 +72,6 @@
<artifactId>sts</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>xray</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down Expand Up @@ -142,30 +118,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.11.0</version>
<executions>
<execution>
<id>copy-otel-javaagent-extension</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>aws-durable-execution-sdk-java-plugin-otel</artifactId>
<version>${project.version}</version>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@
@Target(ElementType.TYPE)
public @interface ExampleTemplate {
String condition() default "";

boolean tracing() default false;

boolean javaAgent() default false;
}

This file was deleted.

Loading
Loading