Skip to content

Add missing entity/schedule logging#648

Open
YunchuWang wants to merge 7 commits intomainfrom
wangbill/add-entity-and-orchestrator-logging
Open

Add missing entity/schedule logging#648
YunchuWang wants to merge 7 commits intomainfrom
wangbill/add-entity-and-orchestrator-logging

Conversation

@YunchuWang
Copy link
Member

Summary

What changed?

  • Added logging to GrpcDurableEntityClient for all entity client operations (SignalEntityAsync, GetEntityAsync, GetAllEntitiesAsync, CleanEntityStorageAsync), replacing the existing // TODO this.logger.LogSomething comment.
  • Added 4 new LoggerMessage source-generated methods in src/Client/Grpc/Logs.cs (EventIds 47, 48, 50, 52) for entity operations.
  • Added replay-safe logging to ExecuteScheduleOperationOrchestrator using context.CreateReplaySafeLogger<T>(), with operation start, completion, and error messages. Removed // TODO: logging comment.
  • Updated ExecuteScheduleOperationOrchestratorTests to mock CreateReplaySafeLogger with NullLogger.Instance.

Why is this change needed?

  • The entity client (GrpcDurableEntityClient) had a logger field injected but never used — there was an explicit // TODO to add logging. Without logging, entity operations were invisible in diagnostics, making it harder to troubleshoot issues.
  • The ExecuteScheduleOperationOrchestrator had a // TODO: logging comment with zero observability into schedule entity operations executed through it.

Issues / work items

  • Resolves the // TODO this.logger.LogSomething in GrpcDurableEntityClient.cs
  • Resolves the // TODO: logging in ExecuteScheduleOperationOrchestrator.cs

Project checklist

  • Release notes are not required for the next release
    • Otherwise: Notes added to release_notes.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: N/A — no breaking changes, only additive logging.
      • 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 (Claude Opus 4.6)
  • AI-assisted areas/files:
    • src/Client/Grpc/Logs.cs — new LoggerMessage definitions
    • src/Client/Grpc/GrpcDurableEntityClient.cs — logging call wiring
    • src/ScheduledTasks/Orchestrations/ExecuteScheduleOperationOrchestrator.cs — replay-safe logging
    • test/ScheduledTasks.Tests/Orchestrations/ExecuteScheduleOperationOrchestratorTests.cs — mock setup update
  • What you changed after AI output: Reviewed all changes for correctness, verified EventId assignments don't conflict, verified replay-safe logger pattern matches existing orchestrators.

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: Passed
    • Client.Grpc.Tests: 38/38 passed
    • ScheduledTasks.Tests: 105/105 passed

Manual validation (only if runtime/behavior changed)

  • N/A — logging-only change, no runtime behavior change.

Notes for reviewers

  • Entity client logging follows the same LoggerMessage source generator pattern used in GrpcDurableTaskClient (orchestration client). EventIds 47, 48, 50, 52 were chosen from the available gap after existing client EventIds 40–46.
  • Orchestrator logging reuses existing ScheduleOperationInfo (EventId 113) and ScheduleOperationError (EventId 115) methods from Logs.Entity.cs, consistent with how the Schedule entity itself logs operations.

- Remove duplicate BenchmarkDotNet 0.14.0 entry in Directory.Packages.props (fixes NU1506)
- Upgrade ExportHistoryWebApp from net6.0 to net8.0 (fixes NETSDK1138)
- Remove 'TODO' prefix from exception message in TaskHubGrpcServer
…chestrator

- Add LoggerMessage methods for entity client operations (SignalingEntity,
  GettingEntity, QueryingEntities, CleaningEntityStorage) in Logs.cs
- Wire logging calls into GrpcDurableEntityClient replacing TODO comment
- Add replay-safe logging to ExecuteScheduleOperationOrchestrator with
  operation start/complete/error messages
- Update orchestrator tests to mock CreateReplaySafeLogger
Copilot AI review requested due to automatic review settings February 27, 2026 18:05
@YunchuWang YunchuWang changed the title Wangbill/add entity and orchestrator logging Add missing entity/schedule logging Feb 27, 2026
Copy link
Contributor

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

Adds source-generated and replay-safe logging to improve observability for entity client operations and schedule-operation orchestrations, and includes a couple of small hygiene updates (exception text + package/version cleanup).

Changes:

  • Added LoggerMessage-based logs for GrpcDurableEntityClient entity operations (signal/get/query/clean).
  • Added replay-safe orchestrator logging in ExecuteScheduleOperationOrchestrator and updated its unit tests to mock CreateReplaySafeLogger.
  • Minor maintenance updates: cleaned an exception message, removed a duplicate package version entry, and updated a sample to net8.0.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/ScheduledTasks.Tests/Orchestrations/ExecuteScheduleOperationOrchestratorTests.cs Mocks CreateReplaySafeLogger<T>() to support new replay-safe logging in orchestrator tests.
src/ScheduledTasks/Orchestrations/ExecuteScheduleOperationOrchestrator.cs Adds replay-safe start/success/error logs around the schedule entity call.
src/InProcessTestHost/Sidecar/Grpc/TaskHubGrpcServer.cs Replaces a TODO:-prefixed exception message with a user-facing message.
src/Client/Grpc/Logs.cs Introduces new client-side LoggerMessage methods for entity operations.
src/Client/Grpc/GrpcDurableEntityClient.cs Wires the new entity-operation logs into the gRPC entity client methods.
samples/ExportHistoryWebApp/ExportHistoryWebApp.csproj Updates sample target framework from net6.0 to net8.0.
Directory.Packages.props Removes duplicate BenchmarkDotNet version entry.

…estrator.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 27, 2026 18:13
Copy link
Contributor

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 4 out of 4 changed files in this pull request and generated 1 comment.

…ionOrchestratorTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 27, 2026 18:21
Copy link
Contributor

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 4 out of 4 changed files in this pull request and generated 1 comment.

[LoggerMessage(EventId = 48, Level = LogLevel.Information, Message = "Getting entity '{instanceId}'.")]
public static partial void GettingEntity(this ILogger logger, string instanceId);

[LoggerMessage(EventId = 50, Level = LogLevel.Information, Message = "Querying entities with filter: {{ StartsWith = {startsWith}, LastModifiedFrom = {lastModifiedFrom}, LastModifiedTo = {lastModifiedTo} }}")]
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

EventIds 49 and 51 are skipped here but are already in use by other components (InProcessTestHost/Sidecar/Logs.cs). While this is acceptable since they're in different namespaces, consider whether EventId 49 should be used for GetAllEntitiesAsync (currently using EventId 50) to maintain sequential numbering where possible. EventIds 47, 48, 50, 52 work correctly but the gap at 49 and 51 could be confusing for future maintainers.

Suggested change
[LoggerMessage(EventId = 50, Level = LogLevel.Information, Message = "Querying entities with filter: {{ StartsWith = {startsWith}, LastModifiedFrom = {lastModifiedFrom}, LastModifiedTo = {lastModifiedTo} }}")]
[LoggerMessage(EventId = 49, Level = LogLevel.Information, Message = "Querying entities with filter: {{ StartsWith = {startsWith}, LastModifiedFrom = {lastModifiedFrom}, LastModifiedTo = {lastModifiedTo} }}")]

Copilot uses AI. Check for mistakes.
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