Skip to content

Commit dcaeec2

Browse files
Rename durable execution log scope key to executionArn (#2425)
* Rename durable execution log scope key to executionArn The .NET durable execution library emitted the execution ARN into the logging scope under the key durableExecutionArn, but the AWS Lambda console filters an execution's logs on the field executionArn. The mismatch caused user log lines to be dropped from the console's "Logger output" view. Rename the logged scope key (and its test assertions / docs) to executionArn. The SDK request/response field DurableExecutionArn is left unchanged, since that is the name used by the API. Fixes #2423 * Add change file for executionArn log key rename
1 parent edc241b commit dcaeec2

7 files changed

Lines changed: 23 additions & 9 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.Lambda.DurableExecution",
5+
"Type": "Patch",
6+
"ChangelogMessages": [
7+
"Rename the durable execution logging scope key from `durableExecutionArn` to `executionArn` so the AWS Lambda console correctly surfaces an execution's logs."
8+
]
9+
}
10+
]
11+
}

Libraries/src/Amazon.Lambda.DurableExecution/DurableFunction.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@ private static async Task<DurableExecutionInvocationOutput> WrapAsyncCore<TInput
118118
// Push execution-level metadata into a logging scope so structured
119119
// providers (the runtime's JSON formatter, Serilog, Powertools,
120120
// etc.) tag every log line emitted by user code with the
121-
// execution ARN and request id.
121+
// execution ARN and request id. The key is "executionArn" because
122+
// that is the field the Lambda console filters on when rendering an
123+
// execution's logs; "durableExecutionArn" caused logs to be dropped
124+
// from the console view (issue #2423).
122125
using (context.Logger.BeginScope(new Dictionary<string, object>
123126
{
124-
["durableExecutionArn"] = invocationInput.DurableExecutionArn,
127+
["executionArn"] = invocationInput.DurableExecutionArn,
125128
["awsRequestId"] = lambdaContext.AwsRequestId ?? string.Empty,
126129
}))
127130
{

Libraries/src/Amazon.Lambda.DurableExecution/Internal/LambdaCoreLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Amazon.Lambda.DurableExecution.Internal;
2727
/// <see cref="BeginScope"/> maintains an <see cref="AsyncLocal{T}"/> chain of
2828
/// scope state. Scopes whose state is a key/value collection have each entry
2929
/// appended to the outgoing template/args, so structured scope metadata
30-
/// (<c>durableExecutionArn</c>, <c>operationId</c>, etc.) shows up as
30+
/// (<c>executionArn</c>, <c>operationId</c>, etc.) shows up as
3131
/// top-level JSON fields without callers having to swap in a third-party
3232
/// logger. Inner scopes win on key collision; explicit message arguments
3333
/// always win over scope keys.

Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/ReplayAwareLoggerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ private void AssertScopeFieldsOnRecord(
120120

121121
if (requireExecutionScope)
122122
{
123-
Assert.True(root.TryGetProperty("durableExecutionArn", out _),
124-
$"durableExecutionArn missing on record: {record}");
123+
Assert.True(root.TryGetProperty("executionArn", out _),
124+
$"executionArn missing on record: {record}");
125125
Assert.True(root.TryGetProperty("awsRequestId", out _),
126126
$"awsRequestId missing on record: {record}");
127127
}

Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/TestFunctions/ReplayAwareLoggerFunction/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM public.ecr.aws/lambda/dotnet:10
33
COPY bin/publish/ ${LAMBDA_TASK_ROOT}
44

55
# Emit structured JSON logs so the integration test can parse log records and
6-
# assert the durable-execution scope keys (durableExecutionArn, operationId,
6+
# assert the durable-execution scope keys (executionArn, operationId,
77
# etc.) appear as top-level fields.
88
ENV AWS_LAMBDA_LOG_FORMAT=JSON
99

Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/TestFunctions/ReplayAwareLoggerFunction/Function.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private async Task<TestResult> Workflow(TestEvent input, IDurableContext context
3939
async (_, _) =>
4040
{
4141
// Emitted inside the step's BeginScope, so the line carries
42-
// both execution-level scope (durableExecutionArn, awsRequestId)
42+
// both execution-level scope (executionArn, awsRequestId)
4343
// AND step-level scope (operationId, operationName, attempt).
4444
context.Logger.LogInformation("LOG_REPLAY_TEST inside_step1 order={OrderId}", input.OrderId);
4545
await Task.CompletedTask;

Libraries/test/Amazon.Lambda.DurableExecution.Tests/Internal/LambdaCoreLoggerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void Log_WithNestedKvpScopes_InnerWinsAndOrderInnerToOuter()
136136

137137
using (logger.BeginScope(new Dictionary<string, object>
138138
{
139-
["durableExecutionArn"] = "arn-outer",
139+
["executionArn"] = "arn-outer",
140140
["awsRequestId"] = "req-1",
141141
}))
142142
using (logger.BeginScope(new Dictionary<string, object>
@@ -151,7 +151,7 @@ public void Log_WithNestedKvpScopes_InnerWinsAndOrderInnerToOuter()
151151
var entry = Assert.Single(_captured);
152152
// Inner scope keys appear before outer; the inner awsRequestId wins.
153153
Assert.Equal(
154-
"hello {Name} {operationId} {awsRequestId} {durableExecutionArn}",
154+
"hello {Name} {operationId} {awsRequestId} {executionArn}",
155155
entry.Template);
156156
Assert.Equal(
157157
new object[] { "world", "op-1", "req-INNER-WINS", "arn-outer" },

0 commit comments

Comments
 (0)