Skip to content

Commit

Permalink
Merge pull request #2992 from Azure/alrod/dfv3-release-rc.2
Browse files Browse the repository at this point in the history
Fixing storage traffic issue for SC
  • Loading branch information
alrod authored Dec 7, 2024
2 parents aa69f43 + 95ef2ba commit 5bb1869
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ internal static IWebJobsBuilder AddDurableScaleForTrigger(this IWebJobsBuilder b
provider = new DurableTaskTriggersScaleProvider(serviceProvider.GetService<IOptions<DurableTaskOptions>>(), serviceProvider.GetService<INameResolver>(), serviceProvider.GetService<ILoggerFactory>(), serviceProvider.GetService<IEnumerable<IDurabilityProviderFactory>>(), triggerMetadata);
return provider;
});
builder.Services.AddSingleton<IScaleMonitorProvider>(serviceProvider => serviceProvider.GetServices<DurableTaskTriggersScaleProvider>().Single(x => x == provider));

// Commenting out incremental scale model for hotfix release 3.0.0-rc.4, SC uses TBS by default
// builder.Services.AddSingleton<IScaleMonitorProvider>(serviceProvider => serviceProvider.GetServices<DurableTaskTriggersScaleProvider>().Single(x => x == provider));
builder.Services.AddSingleton<ITargetScalerProvider>(serviceProvider => serviceProvider.GetServices<DurableTaskTriggersScaleProvider>().Single(x => x == provider));
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ internal class DurableTaskMetricsProvider
private readonly string hubName;
private readonly ILogger logger;
private readonly StorageAccountClientProvider storageAccountClientProvider;
private PerformanceHeartbeat heartbeat;
private DateTime heartbeatTimeStamp;

private DisconnectedPerformanceMonitor performanceMonitor;

Expand All @@ -30,25 +32,32 @@ public DurableTaskMetricsProvider(
this.logger = logger;
this.performanceMonitor = performanceMonitor;
this.storageAccountClientProvider = storageAccountClientProvider;
this.heartbeat = null;
this.heartbeatTimeStamp = DateTime.MinValue;
}

public virtual async Task<DurableTaskTriggerMetrics> GetMetricsAsync()
{
DurableTaskTriggerMetrics metrics = new DurableTaskTriggerMetrics();

// Durable stores its own metrics, so we just collect them here
PerformanceHeartbeat heartbeat = null;
try
{
DisconnectedPerformanceMonitor performanceMonitor = this.GetPerformanceMonitor();
heartbeat = await performanceMonitor.PulseAsync();

// We only want to call PulseAsync every 5 seconds
if (this.heartbeat == null || DateTime.UtcNow > this.heartbeatTimeStamp.AddSeconds(5))
{
this.heartbeat = await performanceMonitor.PulseAsync();
this.heartbeatTimeStamp = DateTime.UtcNow;
}
}
catch (Exception e) when (e.InnerException is RequestFailedException)
{
this.logger.LogWarning("{details}. HubName: {hubName}.", e.ToString(), this.hubName);
}

if (heartbeat != null)
if (this.heartbeat != null)
{
metrics.PartitionCount = heartbeat.PartitionCount;

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

metrics.ControlQueueLengths = JsonConvert.SerializeObject(heartbeat.ControlQueueLengths);

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs

View workflow job for this annotation

GitHub Actions / build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MinorVersion>0</MinorVersion>
<PatchVersion>0</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<VersionSuffix>rc.4</VersionSuffix>
<VersionSuffix>rc.5</VersionSuffix>
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
<Company>Microsoft Corporation</Company>
Expand Down

0 comments on commit 5bb1869

Please sign in to comment.