Skip to content

feat(sdk): emit operationName in default logger output#692

Merged
ParidelPooya merged 2 commits into
mainfrom
feat/sdk-logger-operation-name
Jul 6, 2026
Merged

feat(sdk): emit operationName in default logger output#692
ParidelPooya merged 2 commits into
mainfrom
feat/sdk-logger-operation-name

Conversation

@ParidelPooya

Copy link
Copy Markdown
Contributor

The default logger emitted requestId, executionArn, tenantId, operationId, and attempt, but never operationName. This diverged from the documented log format and from the Python and Java SDKs, which both emit operationName.

Thread the operation/step/child-context name through the async-local context tracker (runWithContext) and surface it via getDurableLogData so the default logger includes operationName when available. It is derived from the operation name (like the Java SDK) and is omitted for the root context and when no name is present, keeping the change backward-compatible.

  • context-tracker: add operationName to ContextInfo and runWithContext
  • step, wait-for-condition, and run-in-child-context handlers pass the name
  • DurableLogData: add optional operationName field
  • durable-context: populate operationName in getDurableLogData (omit at root)
  • default-logger: emit operationName when present
  • add unit/integration tests; update runWithContext argument assertions

yaythomas
yaythomas previously approved these changes Jul 6, 2026

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • All production call sites of runWithContext are covered. There are 5 in src/ (not counting tests): step-handler.ts:326, wait-for-condition-handler.ts:255, and two in run-in-child-context-handler.ts (the ReplayChildren replay path at :260 and executeChildContext at :384) all now pass the operation name. The fifth, with-durable-execution.ts:123, is the root context ("root", no name) and is correctly left untouched. No operation path that runs customer code in a tracked context was missed.
  • operationName is the human-readable name, operationId stays hashed (hashId(contextId)). Good — they carry different information and the test (operationName: "fetch-user" alongside a hashed operationId) confirms it.
  • Root is doubly-guarded. getDurableLogData in packages/aws-durable-execution-sdk-js/src/context/durable-context/durable-context.ts requires contextId !== "root" before emitting, and the root call site passes no name anyway.
  • Field ordering matches the order-sensitive tests. formatDurableLogData in packages/aws-durable-execution-sdk-js/src/utils/logger/default-logger.ts inserts operationName between operationId and attempt, matching both the DurableLogData interface order and the exact JSON.stringify assertions in default-logger.test.ts.
  • Typechecks cleanly. DefaultDurableLogEntry extends DurableLogData, so adding the optional field to packages/aws-durable-execution-sdk-js/src/types/logger.ts is enough for result.operationName = … to type.

The default logger emitted requestId, executionArn, tenantId, operationId,
and attempt, but never operationName. This diverged from the documented log
format and from the Python and Java SDKs, which both emit operationName.

Thread the operation/step/child-context name through the async-local context
tracker (runWithContext) and surface it via getDurableLogData so the default
logger includes operationName when available. It is derived from the operation
name (like the Java SDK) and is omitted for the root context and when no name
is present, keeping the change backward-compatible.

- context-tracker: add operationName to ContextInfo and runWithContext
- step, wait-for-condition, and run-in-child-context handlers pass the name
- DurableLogData: add optional operationName field
- durable-context: populate operationName in getDurableLogData (omit at root)
- default-logger: emit operationName when present
- add unit/integration tests; update runWithContext argument assertions

Refs: TT V2276912870
The logger-log-levels example acts as an integration test that asserts the
exact structured log output. Now that the default logger emits operationName
for named steps and child contexts, update the expectations to include it
wherever operationId is present.

Refs: TT V2276912870
@ParidelPooya
ParidelPooya marked this pull request as ready for review July 6, 2026 19:01
@ParidelPooya
ParidelPooya merged commit 6c6133b into main Jul 6, 2026
16 checks passed
@ParidelPooya
ParidelPooya deleted the feat/sdk-logger-operation-name branch July 6, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants