Skip to content
Draft
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
2 changes: 2 additions & 0 deletions datadog_lambda/durable.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def extract_durable_function_tags(event):
return {}

execution_name, execution_id = parsed
is_first_invocation = event.get("CheckpointToken") is None
return {
"durable_function_execution_name": execution_name,
"durable_function_execution_id": execution_id,
"durable_function_first_invocation": str(is_first_invocation).lower(),
}
17 changes: 16 additions & 1 deletion tests/test_durable.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_works_with_numeric_version_qualifier(self):


class TestExtractDurableFunctionTags(unittest.TestCase):
def test_extracts_tags_from_event_with_durable_execution_arn(self):
def test_extracts_tags_from_event_with_checkpoint_token(self):
event = {
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-func:1/durable-execution/my-execution/550e8400-e29b-41d4-a716-446655440004",
"CheckpointToken": "some-token",
Expand All @@ -57,6 +57,21 @@ def test_extracts_tags_from_event_with_durable_execution_arn(self):
{
"durable_function_execution_name": "my-execution",
"durable_function_execution_id": "550e8400-e29b-41d4-a716-446655440004",
"durable_function_first_invocation": "false",
},
)

def test_extracts_tags_from_event_without_checkpoint_token(self):
event = {
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-func:1/durable-execution/my-execution/550e8400-e29b-41d4-a716-446655440004",
}
result = extract_durable_function_tags(event)
self.assertEqual(
result,
{
"durable_function_execution_name": "my-execution",
"durable_function_execution_id": "550e8400-e29b-41d4-a716-446655440004",
"durable_function_first_invocation": "true",
},
)

Expand Down
Loading