-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
Fixing storage traffic issue for SC
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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 GitHub Actions / build
Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 62 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
|
||
metrics.ControlQueueLengths = JsonConvert.SerializeObject(heartbeat.ControlQueueLengths); | ||
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
Check warning on line 63 in src/WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.cs GitHub Actions / build
|
||
|