public static async Task <QueueStatSummary> GetQueueStatsAsync(this IMetricsClientStats stats, string name, string subQueueName = null, DateTime?start = null, DateTime?end = null, int dataPoints = 20) { if (subQueueName == null) { subQueueName = String.Empty; } else { subQueueName = "." + subQueueName; } var countTask = stats.GetGaugeStatsAsync($"{name}.count", start, end, dataPoints); var workingTask = stats.GetGaugeStatsAsync($"{name}.working", start, end, dataPoints); var deadletterTask = stats.GetGaugeStatsAsync($"{name}.deadletter", start, end, dataPoints); var enqueuedTask = stats.GetCounterStatsAsync($"{name}{subQueueName}.enqueued", start, end, dataPoints); var queueTimeTask = stats.GetTimerStatsAsync($"{name}{subQueueName}.queuetime", start, end, dataPoints); var dequeuedTask = stats.GetCounterStatsAsync($"{name}{subQueueName}.dequeued", start, end, dataPoints); var completedTask = stats.GetCounterStatsAsync($"{name}{subQueueName}.completed", start, end, dataPoints); var abandonedTask = stats.GetCounterStatsAsync($"{name}{subQueueName}.abandoned", start, end, dataPoints); var processTimeTask = stats.GetTimerStatsAsync($"{name}{subQueueName}.processtime", start, end, dataPoints); await Task.WhenAll(countTask, workingTask, deadletterTask, enqueuedTask, queueTimeTask, dequeuedTask, completedTask, abandonedTask, processTimeTask).AnyContext(); return(new QueueStatSummary { Count = countTask.Result, Working = workingTask.Result, Deadletter = deadletterTask.Result, Enqueued = enqueuedTask.Result, QueueTime = queueTimeTask.Result, Dequeued = dequeuedTask.Result, Completed = completedTask.Result, Abandoned = abandonedTask.Result, ProcessTime = processTimeTask.Result }); }
private async Task AssertCounterAsync(IMetricsClientStats client, string name, long expected) { await Run.WithRetriesAsync(async() => { long actual = await client.GetCounterCountAsync(name, SystemClock.UtcNow.Subtract(TimeSpan.FromHours(1))); Assert.Equal(expected, actual); }, 8, logger : _logger); }
public static Task <QueueStatSummary> GetQueueStatsAsync(this IMetricsClientStats stats, string name, string subMetricName = null, DateTime?utcStart = null, DateTime?utcEnd = null, int dataPoints = 20) { if (subMetricName == null) { subMetricName = String.Empty; } else { subMetricName = "." + subMetricName; } var countTask = stats.GetGaugeStatsAsync($"{name}.count", utcStart, utcEnd, dataPoints); var workingTask = stats.GetGaugeStatsAsync($"{name}.working", utcStart, utcEnd, dataPoints); var deadletterTask = stats.GetGaugeStatsAsync($"{name}.deadletter", utcStart, utcEnd, dataPoints); var enqueuedTask = stats.GetCounterStatsAsync($"{name}{subMetricName}.enqueued", utcStart, utcEnd, dataPoints); var queueTimeTask = stats.GetTimerStatsAsync($"{name}{subMetricName}.queuetime", utcStart, utcEnd, dataPoints); var dequeuedTask = stats.GetCounterStatsAsync($"{name}{subMetricName}.dequeued", utcStart, utcEnd, dataPoints); var completedTask = stats.GetCounterStatsAsync($"{name}{subMetricName}.completed", utcStart, utcEnd, dataPoints); var abandonedTask = stats.GetCounterStatsAsync($"{name}{subMetricName}.abandoned", utcStart, utcEnd, dataPoints); var processTimeTask = stats.GetTimerStatsAsync($"{name}{subMetricName}.processtime", utcStart, utcEnd, dataPoints); return(Task.WhenAll(countTask, workingTask, deadletterTask, enqueuedTask, queueTimeTask, dequeuedTask, completedTask, abandonedTask, processTimeTask) .ContinueWith(t => new QueueStatSummary { Count = countTask.Result, Working = workingTask.Result, Deadletter = deadletterTask.Result, Enqueued = enqueuedTask.Result, QueueTime = queueTimeTask.Result, Dequeued = dequeuedTask.Result, Completed = completedTask.Result, Abandoned = abandonedTask.Result, ProcessTime = processTimeTask.Result }, TaskContinuationOptions.OnlyOnRanToCompletion)); }
public static async Task <QueueStatSummary> GetQueueStatsAsync(this IMetricsClientStats stats, string name, DateTime?start = null, DateTime?end = null, int dataPoints = 20) { var countTask = stats.GetGaugeStatsAsync($"{name}.count", start, end); var enqueuedTask = stats.GetCounterStatsAsync($"{name}.enqueued", start, end); var queueTimeTask = stats.GetTimerStatsAsync($"{name}.queuetime", start, end); var dequeuedTask = stats.GetCounterStatsAsync($"{name}.dequeued", start, end); var completedTask = stats.GetCounterStatsAsync($"{name}.completed", start, end); var abandonedTask = stats.GetCounterStatsAsync($"{name}.abandoned", start, end); var processTimeTask = stats.GetTimerStatsAsync($"{name}.processtime", start, end); await Task.WhenAll(countTask, enqueuedTask, queueTimeTask, dequeuedTask, completedTask, abandonedTask, processTimeTask); return(new QueueStatSummary { Count = countTask.Result, Enqueued = enqueuedTask.Result, QueueTime = queueTimeTask.Result, Dequeued = dequeuedTask.Result, Completed = completedTask.Result, Abandoned = abandonedTask.Result, ProcessTime = processTimeTask.Result }); }
public static async Task <double> GetLastGaugeValueAsync(this IMetricsClientStats stats, string name, DateTime?start = null, DateTime?end = null) { var result = await stats.GetGaugeStatsAsync(name, start, end, 1).AnyContext(); return(result.Last); }
public static async Task <long> GetCounterCountAsync(this IMetricsClientStats stats, string name, DateTime?start = null, DateTime?end = null) { var result = await stats.GetCounterStatsAsync(name, start, end, 1).AnyContext(); return(result.Count); }