Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<!-- Testing Frameworks & Analysis Packages -->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.34.1"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
Expand Down
2 changes: 1 addition & 1 deletion samples/ExportHistoryWebApp/ExportHistoryWebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down
11 changes: 7 additions & 4 deletions src/Client/Grpc/GrpcDurableEntityClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@
RequestId = requestId.ToString(),
Name = operationName,
Input = this.dataConverter.Serialize(input),
ScheduledTime = scheduledTime?.ToTimestamp(),
ScheduledTime = scheduledTime?.ToTimestamp(),
RequestTime = DateTimeOffset.UtcNow.ToTimestamp(),
};
};

if (Activity.Current is { } activity)
{
request.ParentTraceContext ??= new P.TraceContext();
request.ParentTraceContext.TraceParent = activity.Id;
request.ParentTraceContext.TraceState = activity.TraceStateString;
}

// TODO this.logger.LogSomething
this.logger.SignalingEntity(id.ToString(), operationName);
try
{
await this.sidecarClient.SignalEntityAsync(request, cancellationToken: cancellation);
Expand Down Expand Up @@ -107,6 +107,7 @@
int emptyEntitiesRemoved = 0;
int orphanedLocksReleased = 0;

this.logger.CleaningEntityStorage();
try
{
do
Expand Down Expand Up @@ -156,6 +157,7 @@
IncludeState = includeState,
};

this.logger.GettingEntity(id.ToString());
try
{
P.GetEntityResponse response = await this.sidecarClient
Expand All @@ -180,6 +182,7 @@
DateTimeOffset? lastModifiedFrom = filter?.LastModifiedFrom;
DateTimeOffset? lastModifiedTo = filter?.LastModifiedTo;

this.logger.QueryingEntities(startsWith, lastModifiedFrom, lastModifiedTo);
return Pageable.Create(async (continuation, pageSize, cancellation) =>
{
pageSize ??= filter?.PageSize;
Expand Down
12 changes: 12 additions & 0 deletions src/Client/Grpc/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,17 @@ public static void PurgingInstances(this ILogger logger, PurgeInstancesFilter fi
string? statuses = filter?.Statuses is null ? null : string.Join("|", filter.Statuses);
PurgingInstances(logger, filter?.CreatedFrom, filter?.CreatedTo, statuses);
}

[LoggerMessage(EventId = 47, Level = LogLevel.Information, Message = "Signaling entity '{instanceId}' with operation '{operationName}'.")]
public static partial void SignalingEntity(this ILogger logger, string instanceId, string operationName);

[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.
public static partial void QueryingEntities(this ILogger logger, string? startsWith, DateTimeOffset? lastModifiedFrom, DateTimeOffset? lastModifiedTo);

[LoggerMessage(EventId = 52, Level = LogLevel.Information, Message = "Cleaning entity storage.")]
public static partial void CleaningEntityStorage(this ILogger logger);
}
}
2 changes: 1 addition & 1 deletion src/InProcessTestHost/Sidecar/Grpc/TaskHubGrpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ async Task SendWorkItemToClientAsync(P.WorkItem workItem)
{
outputStream = this.workerToClientStream ??
// CA2201: Use specific exception types
throw new InvalidOperationException("TODO: No client is connected! Need to wait until a client connects before executing!");
throw new InvalidOperationException("No client is connected. Need to wait until a client connects before executing.");
}

// The gRPC channel can only handle one message at a time, so we need to serialize access to it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Licensed under the MIT License.

using Microsoft.DurableTask.Entities;
using Microsoft.Extensions.Logging;

namespace Microsoft.DurableTask.ScheduledTasks;

// TODO: logging
// TODO: May need separate orchs, result is obj now

/// <summary>
Expand All @@ -18,7 +18,22 @@ public class ExecuteScheduleOperationOrchestrator : TaskOrchestrator<ScheduleOpe
/// <inheritdoc/>
public override async Task<object> RunAsync(TaskOrchestrationContext context, ScheduleOperationRequest input)
{
return await context.Entities.CallEntityAsync<object>(input.EntityId, input.OperationName, input.Input);
ILogger logger = context.CreateReplaySafeLogger<ExecuteScheduleOperationOrchestrator>();
string scheduleId = input.EntityId.Key;

logger.ScheduleOperationInfo(scheduleId, input.OperationName, "Executing schedule operation via orchestrator");

try
{
object result = await context.Entities.CallEntityAsync<object>(input.EntityId, input.OperationName, input.Input);
logger.ScheduleOperationInfo(scheduleId, input.OperationName, "Schedule operation completed successfully");
return result;
}
catch (Exception ex)
{
logger.ScheduleOperationError(scheduleId, input.OperationName, ex.Message, ex);
throw;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Microsoft.DurableTask.Client;
using Microsoft.DurableTask.Client.Entities;
using Microsoft.DurableTask.Entities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;

Expand All @@ -20,6 +22,9 @@ public ExecuteScheduleOperationOrchestratorTests()
this.mockContext = new Mock<TaskOrchestrationContext>(MockBehavior.Strict);
this.mockEntityClient = new Mock<TaskOrchestrationEntityFeature>(MockBehavior.Loose);
this.mockContext.Setup(c => c.Entities).Returns(this.mockEntityClient.Object);
this.mockContext
.Setup(c => c.CreateReplaySafeLogger<ExecuteScheduleOperationOrchestrator>())
.Returns(NullLogger.Instance);
this.orchestrator = new ExecuteScheduleOperationOrchestrator();
}

Expand Down
Loading