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
14 changes: 11 additions & 3 deletions packages/aws-durable-execution-sdk-python-examples/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

try:
import boto3

from aws_durable_execution_sdk_python.lambda_service import LambdaClient
except ImportError:
sys.exit(1)
Expand Down Expand Up @@ -326,6 +327,9 @@ def deploy_function(example_name: str, function_name: str | None = None):
f"arn:aws:iam::{config['account_id']}:role/DurableFunctionsIntegrationTestRole"
)

env_vars = {"AWS_ENDPOINT_URL_LAMBDA": config["lambda_endpoint"]}
env_vars.update(example_config.get("environment", {}))

function_config = {
"FunctionName": function_name,
"Runtime": "python3.13",
Expand All @@ -334,13 +338,17 @@ def deploy_function(example_name: str, function_name: str | None = None):
"Description": example_config["description"],
"Timeout": 60,
"MemorySize": 128,
"Environment": {
"Variables": {"AWS_ENDPOINT_URL_LAMBDA": config["lambda_endpoint"]}
},
"Environment": {"Variables": env_vars},
"DurableConfig": example_config["durableConfig"],
"LoggingConfig": example_config.get("loggingConfig", {}),
}

if "layers" in example_config:
function_config["Layers"] = example_config["layers"]

if "tracing" in example_config:
function_config["TracingConfig"] = {"Mode": example_config["tracing"]}

if config["kms_key_arn"]:
function_config["KMSKeyArn"] = config["kms_key_arn"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,13 @@
"RetentionPeriodInDays": 7,
"ExecutionTimeout": 300
},
"tracing": "Active",
"layers": [
"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroPython:32"
],
"environment": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
},
"path": "./src/plugin/execution_with_otel.py"
},
{
Expand All @@ -649,6 +656,14 @@
"ApplicationLogLevel": "INFO",
"LogFormat": "JSON"
},
"tracing": "Active",
"layers": [
"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroPython:32"
],
"environment": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument",
"OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED": "true"
},
"path": "./src/otel/otel_logger_example.py"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import json
from pathlib import Path

import json


def load_catalog():
"""Load examples catalog."""
Expand Down Expand Up @@ -95,6 +93,21 @@ def generate_sam_template():
example["durableConfig"]
)

if "layers" in example:
template["Resources"][function_name]["Properties"]["Layers"] = example[
"layers"
]

if "tracing" in example:
template["Resources"][function_name]["Properties"]["Tracing"] = example[
"tracing"
]

if "environment" in example:
template["Resources"][function_name]["Properties"]["Environment"] = {
"Variables": example["environment"]
}

template_path = Path(__file__).parent.parent / "template.yaml"
with open(template_path, "w") as f:
json.dump(template, f, sort_keys=False, indent=2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
from aws_durable_execution_sdk_python.execution import durable_execution


tracer_provider = TracerProvider()
trace.set_tracer_provider(tracer_provider)

# enrich_logger defaults to True, so the execution logger is wrapped with OTel
# trace context injection (otel.trace_id, otel.span_id, otel.trace_sampled).
tracer_provider = trace.get_tracer_provider()
otel = DurableExecutionOtelPlugin(tracer_provider)


Expand Down
19 changes: 19 additions & 0 deletions packages/aws-durable-execution-sdk-python-examples/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,15 @@
"DurableConfig": {
"RetentionPeriodInDays": 7,
"ExecutionTimeout": 300
},
"Layers": [
"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroPython:32"
],
"Tracing": "Active",
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
}
}
},
Expand All @@ -1047,6 +1056,16 @@
"DurableConfig": {
"RetentionPeriodInDays": 7,
"ExecutionTimeout": 300
},
"Layers": [
"arn:aws:lambda:us-west-2:615299751070:layer:AWSOpenTelemetryDistroPython:32"
],
"Tracing": "Active",
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument",
"OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED": "true"
}
}
}
}
Expand Down