Skip to content

Commit 3810b2f

Browse files
Addressing Phillip's feedback
1 parent d823c5b commit 3810b2f

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

docs/lambda-features/durable-functions.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The Durable Execution SDK provides a `context.logger` instance that automaticall
3939

4040
For the best experience, set the Logger on the durable context. This gives you structured JSON logging with automatic log deduplication during replays:
4141

42-
```python hl_lines="5 11 14 22" title="Integrating Logger with Durable Functions"
42+
```python hl_lines="5 8 12 15" title="Integrating Logger with Durable Functions"
4343
--8<-- "examples/lambda_features/durable_functions/src/using_logger.py"
4444
```
4545

@@ -68,7 +68,7 @@ Tracer works with Durable Functions. Each execution creates trace segments.
6868
???+ note "Trace continuity"
6969
Due to the replay mechanism, traces may be interleaved. Each execution (including replays) creates separate trace segments. Use the `execution_arn` to correlate traces.
7070

71-
```python hl_lines="5 9" title="Using Tracer with Durable Functions"
71+
```python hl_lines="5-6 9-10" title="Using Tracer with Durable Functions"
7272
--8<-- "examples/lambda_features/durable_functions/src/using_tracer.py"
7373
```
7474

@@ -84,10 +84,13 @@ Metrics work with Durable Functions, but be aware that **metrics may be emitted
8484

8585
The `@idempotent` decorator integrates with Durable Functions and is **replay-aware**. It's useful for protecting the Lambda handler entry point, especially for Event Source Mapping (ESM) invocations like SQS, Kinesis, or DynamoDB Streams.
8686

87-
```python hl_lines="9 15" title="Using Idempotency with Durable Functions"
87+
```python hl_lines="8 15" title="Using Idempotency with Durable Functions"
8888
--8<-- "examples/lambda_features/durable_functions/src/using_idempotency.py"
8989
```
9090

91+
???+ warning "Decorator ordering matters"
92+
The `@idempotent` decorator must be placed **above** `@durable_execution`. This ensures the idempotency check runs first, preventing duplicate executions before the durable workflow begins. Reversing the order would cause the durable execution to start before the idempotency check, defeating its purpose.
93+
9194
**When to use Powertools Idempotency:**
9295

9396
- Protecting the Lambda handler entry point from duplicate invocations

examples/lambda_features/durable_functions/src/using_logger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
logger = Logger(service="order-processing")
66

77

8+
@logger.inject_lambda_context
89
@durable_execution
910
def handler(event: dict, context: DurableContext) -> str:
1011
# Set Logger on the context for automatic deduplication

examples/lambda_features/durable_functions/src/using_tracer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
logger = Logger()
77

88

9+
@logger.inject_lambda_context
910
@tracer.capture_lambda_handler
1011
@durable_execution
1112
def handler(event: dict, context: DurableContext) -> str:

0 commit comments

Comments
 (0)