Skip to content

Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop#85

Merged
YunchuWang merged 12 commits intomainfrom
torosent/logger-and-other-fixes
Feb 3, 2026
Merged

Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop#85
YunchuWang merged 12 commits intomainfrom
torosent/logger-and-other-fixes

Conversation

@torosent
Copy link
Member

@torosent torosent commented Feb 3, 2026

Summary

What changed?

  • Added Logger interface to standardize logging across the SDK
  • Implemented ConsoleLogger for default logging to the console
  • Implemented NoOpLogger for silent logging (useful in testing)
  • Added AzureLoggerAdapter to integrate with Azure SDK logging infrastructure
  • Added ExponentialBackoff class and utility functions (sleep, withTimeout) for retry scenarios
  • Fixed TaskHubGrpcClient.stop() to properly await gRPC stub close

Why is this change needed?

  • The SDK needed a standardized logging interface to provide consistent logging behavior
  • Azure SDK integration requires proper logging adapter for Azure-managed scenarios
  • The gRPC client stop method needed to properly await cleanup to prevent premature termination

Issues / work items

  • Related to logging and reliability improvements

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to CHANGELOG.md
  • Backport is not required
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • All required tests have been added/updated (unit tests, E2E tests)
  • Breaking change?
    • If yes:
      • Impact:
      • Migration guidance:

AI-assisted code disclosure (required)

Was an AI tool used? (select one)

  • No
  • Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
  • Yes, an AI agent generated most of this PR

If AI was used:

  • Tool(s): GitHub Copilot
  • AI-assisted areas/files: Logger implementations, backoff utilities, unit tests
  • What you changed after AI output: Reviewed and integrated into codebase

AI verification (required if AI was used):

  • I understand the code and can explain it
  • I verified referenced APIs/types exist and are correct
  • I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
  • I reviewed concurrency/async behavior
  • I checked for unintended breaking or behavior changes

Testing

Automated tests

  • Result: New unit tests added for AzureLoggerAdapter, ConsoleLogger, NoOpLogger, and ExponentialBackoff

Manual validation (only if runtime/behavior changed)

  • Environment (OS, Node.js version, components): N/A - Unit tests cover functionality
  • Steps + observed results: N/A
  • Evidence (optional): N/A

Notes for reviewers

  • This PR introduces foundational logging infrastructure for the SDK
  • The AzureLoggerAdapter enables proper integration with Azure SDK's logging system for the azure-managed package
  • The backoff utility provides consistent retry behavior across the SDK

Copilot AI review requested due to automatic review settings February 3, 2026 00:19
@torosent torosent changed the title feat: Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop Add Logger interface, AzureLoggerAdapter, and fix gRPC client stop Feb 3, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Logger interface with ConsoleLogger and NoOpLogger implementations for standardized logging
  • Implemented AzureLoggerAdapter to integrate with Azure SDK's logging infrastructure
  • Added ExponentialBackoff class with utility functions (sleep, withTimeout) for retry scenarios
  • Updated TaskHubGrpcClient and TaskHubGrpcWorker to 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.

@torosent torosent requested a review from Copilot February 3, 2026 00:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@torosent torosent requested a review from Copilot February 3, 2026 01:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@torosent torosent requested a review from Copilot February 3, 2026 02:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

torosent and others added 10 commits February 3, 2026 10:43
- 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>
- 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
torosent and others added 2 commits February 3, 2026 10:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@torosent torosent force-pushed the torosent/logger-and-other-fixes branch from 2e14296 to b47ff2f Compare February 3, 2026 18:54
@YunchuWang YunchuWang merged commit 032359a into main Feb 3, 2026
7 checks passed
@YunchuWang YunchuWang deleted the torosent/logger-and-other-fixes branch February 3, 2026 19:23
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.

3 participants