Add replay-safe logging#295
Open
bachuv wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds a replay-safe orchestration logging capability to the Durable Task Java client by providing a Logger wrapper that suppresses log emissions during orchestration replay, reducing duplicated log output.
Changes:
- Introduces
ReplaySafeLoggerand aTaskOrchestrationContext#createReplaySafeLogger(Logger)convenience API. - Documents replay-safe logging usage patterns (including Azure Functions guidance) in the README and adds a changelog entry.
- Adds unit and integration tests validating suppression during replay and single emission during live segments.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| samples-azure-functions/src/main/java/com/functions/AzureFunctions.java | Updates the Azure Functions sample orchestrator to use createReplaySafeLogger for replay-safe logs. |
| README.md | Adds documentation and examples for replay-safe orchestration logging. |
| client/src/main/java/com/microsoft/durabletask/TaskOrchestrationContext.java | Adds the createReplaySafeLogger(Logger) default method API. |
| client/src/main/java/com/microsoft/durabletask/ReplaySafeLogger.java | Implements the replay-suppressing Logger wrapper. |
| client/src/test/java/com/microsoft/durabletask/ReplaySafeLoggerTest.java | Adds focused unit tests for suppression behavior and delegation semantics. |
| client/src/test/java/com/microsoft/durabletask/TaskOrchestrationExecutorTest.java | Adds an executor-level test validating replay suppression vs live emission. |
| client/src/test/java/com/microsoft/durabletask/IntegrationTests.java | Adds an end-to-end integration test covering parent/child orchestrations and activity logging behavior. |
| CHANGELOG.md | Records the new createReplaySafeLogger API addition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+683
to
+698
| Logger delegate = Logger.getAnonymousLogger(); | ||
| delegate.setUseParentHandlers(false); | ||
| delegate.addHandler(new Handler() { | ||
| @Override | ||
| public void publish(LogRecord record) { | ||
| messages.add(record.getMessage()); | ||
| } | ||
|
|
||
| @Override | ||
| public void flush() { | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| } | ||
| }); |
| Logger logger = ctx.createReplaySafeLogger( | ||
| Logger.getLogger(MyOrchestration.class.getName())); | ||
|
|
||
| logger.info("Starting orchestration " + ctx.getInstanceId()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new replay-safe logging feature for orchestrations, ensuring that log output is suppressed during replay segments to prevent duplicate log entries. It includes the implementation of a
ReplaySafeLogger, integration into the orchestration context, comprehensive documentation, and a new integration test to validate the behavior.Replay-safe logging feature:
ReplaySafeLoggerclass, which wraps a standardLoggerand suppresses log output when the orchestration is replaying. This prevents duplicate logs during state reconstruction. (client/src/main/java/com/microsoft/durabletask/ReplaySafeLogger.java)createReplaySafeLoggerdefault method to theTaskOrchestrationContextinterface, allowing orchestrator code to easily obtain a replay-safe logger. (client/src/main/java/com/microsoft/durabletask/TaskOrchestrationContext.java)README.md)createReplaySafeLoggerAPI. (CHANGELOG.md)Testing:
client/src/test/java/com/microsoft/durabletask/IntegrationTests.java)These changes improve the reliability and usability of orchestration logging by preventing duplicate log entries during replay, while providing clear documentation and tests for the new functionality.
Pull request checklist
CHANGELOG.mdAdditional information
Additional PR information