Skip to content

Commit

Permalink
Fixing storage traffic issue for SC
Browse files Browse the repository at this point in the history
  • Loading branch information
alrod committed Dec 6, 2024
1 parent aa69f43 commit d9e7bc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 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

0 comments on commit d9e7bc2

Please sign in to comment.