Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop#85
Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop#85YunchuWang merged 12 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces standardized logging infrastructure to the Durable Task SDK by adding a Logger interface with multiple implementations (ConsoleLogger, NoOpLogger, AzureLoggerAdapter), along with utility functions for exponential backoff and retry logic. The changes also improve the gRPC client shutdown process to properly await cleanup operations.
Changes:
- Added
Loggerinterface withConsoleLoggerandNoOpLoggerimplementations for standardized logging - Implemented
AzureLoggerAdapterto integrate with Azure SDK's logging infrastructure - Added
ExponentialBackoffclass with utility functions (sleep,withTimeout) for retry scenarios - Updated
TaskHubGrpcClientandTaskHubGrpcWorkerto accept optional logger instances and use proper shutdown handling
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| submodules/durabletask-protobuf | Submodule commit update |
| packages/durabletask-js/src/types/logger.type.ts | New logger interface and implementations (ConsoleLogger, NoOpLogger) |
| packages/durabletask-js/src/utils/backoff.util.ts | New exponential backoff utilities with sleep and timeout functions |
| packages/durabletask-js/src/worker/task-hub-grpc-worker.ts | Integrated logger, improved shutdown handling with pending work item tracking |
| packages/durabletask-js/src/worker/orchestration-executor.ts | Replaced console calls with logger instance |
| packages/durabletask-js/src/worker/activity-executor.ts | Replaced console calls with logger instance |
| packages/durabletask-js/src/client/client.ts | Integrated logger parameter and replaced console calls |
| packages/durabletask-js/src/index.ts | Exported logger types |
| packages/durabletask-js-azuremanaged/src/azure-logger-adapter.ts | New Azure SDK logger adapter implementation |
| packages/durabletask-js-azuremanaged/src/worker-builder.ts | Added logger and shutdown timeout configuration options |
| packages/durabletask-js-azuremanaged/src/client-builder.ts | Added logger configuration option |
| packages/durabletask-js-azuremanaged/src/index.ts | Exported logger types and Azure adapter |
| packages/durabletask-js-azuremanaged/package.json | Added @azure/logger dependency |
| test files | Added comprehensive unit tests and updated existing tests to use NoOpLogger |
| example files | Updated to demonstrate logger usage |
| .gitignore | Added .DS_Store entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/durabletask-js-azuremanaged/src/azure-logger-adapter.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 27 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Implemented AzureLoggerAdapter to integrate with Azure SDK logging infrastructure. - Created createAzureLogger function for customizable logging namespaces. - Added unit tests for AzureLoggerAdapter and createAzureLogger. feat: Introduce backoff utility for retry scenarios - Implemented ExponentialBackoff class with configurable options for retries. - Added utility functions sleep and withTimeout for handling delays and timeouts. - Created unit tests for ExponentialBackoff and related utilities. feat: Add ConsoleLogger and NoOpLogger implementations - Implemented ConsoleLogger for default logging to the console. - Added NoOpLogger for silent logging, useful in testing scenarios. - Created unit tests for both ConsoleLogger and NoOpLogger to ensure compliance with Logger interface. chore: Define Logger interface for Durable Task SDK - Created Logger interface to standardize logging across the SDK. - Added documentation for Logger interface and its default implementations.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Id with undefined
- Cancel stream before removing listeners in stop() so error handler can suppress CANCELLED - Remove unnecessary stream.cancel() in 'end' handler (stream already closed) - Add .catch() handlers to all recursive internalRunWorker calls
- Replace 10ms sleep with awaiting stream close/end/error events - Add 1s timeout fallback for stream closure - Fix inconsistent JSDoc indentation in client-builder.ts
- Pass error objects as separate arguments instead of string interpolation - Consolidate duplicate error+info logging calls into single error calls - Maintains proper severity levels for error logs Addresses Copilot review feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…terfaces and constructors
2e14296 to
b47ff2f
Compare
Summary
What changed?
Loggerinterface to standardize logging across the SDKConsoleLoggerfor default logging to the consoleNoOpLoggerfor silent logging (useful in testing)AzureLoggerAdapterto integrate with Azure SDK logging infrastructureExponentialBackoffclass and utility functions (sleep,withTimeout) for retry scenariosTaskHubGrpcClient.stop()to properly await gRPC stub closeWhy is this change needed?
Issues / work items
Project checklist
CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
AzureLoggerAdapter,ConsoleLogger,NoOpLogger, andExponentialBackoffManual validation (only if runtime/behavior changed)
Notes for reviewers
AzureLoggerAdapterenables proper integration with Azure SDK's logging system for the azure-managed package