-
Notifications
You must be signed in to change notification settings - Fork 11
docs(logging): document Java 2.x MDC keys #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,14 +27,48 @@ Logs include execution context via MDC (works with any SLF4J-compatible logging | |
| { | ||
| "timestamp": "2024-01-15T10:30:00.000Z", | ||
| "level": "INFO", | ||
| "message": "Processing order: ORD-123", | ||
| "durableExecutionArn": "arn:aws:lambda:us-east-1:123456789:function:order-processor:exec-abc123", | ||
| "message": "Validating order details", | ||
| "executionArn": "arn:aws:lambda:us-east-1:123456789:function:order-processor:exec-abc123", | ||
| "requestId": "a1b2c3d4-5678-90ab-cdef-example12345", | ||
| "operationId": "1", | ||
| "operationName": "validate" | ||
| "operationName": "validate", | ||
| "attempt": "1" | ||
| } | ||
| ``` | ||
|
|
||
| Java SDK 2.x uses `executionArn`, `operationId`, and `operationName` by default. | ||
| Applications migrating log queries or dashboards from 1.x can temporarily emit | ||
| `durableExecutionArn`, `contextId`, and `contextName` instead: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codex AI review · Finding
|
||
|
|
||
| ```java | ||
| @Override | ||
| protected DurableConfig createConfiguration() { | ||
| return DurableConfig.builder() | ||
| .withLoggerConfig(new LoggerConfig(true, true)) | ||
| .build(); | ||
| } | ||
| ``` | ||
|
|
||
| The first argument controls replay suppression. The second enables the old MDC key | ||
| names. | ||
|
|
||
| ### Custom SLF4J Delegate | ||
|
|
||
| `getLogger()` uses the SDK's default SLF4J logger. Pass a specific SLF4J `Logger` to | ||
| `getLogger(Logger delegate)` when you want the durable metadata and replay behavior | ||
| applied to another logger: | ||
|
|
||
| ```java | ||
| private static final Logger applicationLogger = | ||
| LoggerFactory.getLogger(OrderProcessor.class); | ||
|
|
||
| var logger = ctx.getLogger(applicationLogger); | ||
| logger.info("Processing order: {}", order.getId()); | ||
| ``` | ||
|
|
||
| This creates a `DurableLogger` around the supplied delegate for that call. It does not | ||
| replace the default returned by later parameterless `getLogger()` calls. | ||
|
|
||
| ### Replay Behavior | ||
|
|
||
| By default, logs are suppressed during replay to avoid duplicates: | ||
|
|
@@ -59,4 +93,4 @@ protected DurableConfig createConfiguration() { | |
| .withLoggerConfig(LoggerConfig.withReplayLogging()) | ||
| .build(); | ||
| } | ||
| ``` | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex AI review · Finding
arf_v1_xidywmll6dim2soxj2rxpshvgaThe sample now uses the step lambda's
Validating order detailsmessage, but the Basic Usage example emits it withdebug()while the JSON still labels itINFO. Change the JSON level toDEBUG(or change the usage call toinfo()) so the documented output can actually result from the shown code.