Esempio n. 1
0
        protected virtual Task OnCompletedAsync(IQueueEntry <T> entry)
        {
            var metadata = entry as QueueEntry <T>;

            if (metadata != null && metadata.DequeuedTimeUtc > DateTime.MinValue)
            {
                metadata.ProcessingTime = SystemClock.UtcNow.Subtract(metadata.DequeuedTimeUtc);
            }

            var args = new CompletedEventArgs <T> {
                Queue = this, Entry = entry
            };

            return(Completed?.InvokeAsync(this, args) ?? Task.CompletedTask);
        }
Esempio n. 2
0
        protected virtual Task OnCompletedAsync(IQueueEntry <T> entry)
        {
            if (entry is QueueEntry <T> metadata && metadata.DequeuedTimeUtc > DateTime.MinValue)
            {
                metadata.ProcessingTime = SystemClock.UtcNow.Subtract(metadata.DequeuedTimeUtc);
            }

            var completed = Completed;

            if (completed == null)
            {
                return(Task.CompletedTask);
            }

            var args = new CompletedEventArgs <T> {
                Queue = this, Entry = entry
            };

            return(completed.InvokeAsync(this, args));
        }
Esempio n. 3
0
        protected override async Task OnCompleted(object sender, CompletedEventArgs <T> completedEventArgs)
        {
            await base.OnCompleted(sender, completedEventArgs).AnyContext();

            await ReportQueueCountAsync().AnyContext();

            string customMetricName = GetCustomMetricName(completedEventArgs.Metadata);

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.CounterAsync(GetFullMetricName(customMetricName, "completed")).AnyContext();
            }
            await _metricsClient.CounterAsync(GetFullMetricName("completed")).AnyContext();

            var time = (long)(completedEventArgs.Metadata?.ProcessingTime.TotalMilliseconds ?? 0D);

            if (!String.IsNullOrEmpty(customMetricName))
            {
                await _metricsClient.TimerAsync(GetFullMetricName(customMetricName, "processtime"), time).AnyContext();
            }
            await _metricsClient.TimerAsync(GetFullMetricName("processtime"), time).AnyContext();
        }
Esempio n. 4
0
 protected virtual Task OnCompleted(object sender, CompletedEventArgs <T> completedEventArgs)
 {
     return(TaskHelper.Completed());
 }