protected override Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs) { _timer.ScheduleNext(SystemClock.UtcNow.Add(_reportInterval)); var metadata = dequeuedEventArgs.Entry as IQueueEntryMetadata; string subMetricName = GetSubMetricName(dequeuedEventArgs.Entry.Value); if (!String.IsNullOrEmpty(subMetricName)) { _metricsClient.Counter(GetFullMetricName(subMetricName, "dequeued")); } _metricsClient.Counter(GetFullMetricName("dequeued")); if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue) { return(Task.CompletedTask); } var start = metadata.EnqueuedTimeUtc; var end = metadata.DequeuedTimeUtc; int time = (int)(end - start).TotalMilliseconds; if (!String.IsNullOrEmpty(subMetricName)) { _metricsClient.Timer(GetFullMetricName(subMetricName, "queuetime"), time); } _metricsClient.Timer(GetFullMetricName("queuetime"), time); return(Task.CompletedTask); }
protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs) { await base.OnDequeued(sender, dequeuedEventArgs).AnyContext(); _timer.ScheduleNext(); var metadata = dequeuedEventArgs.Entry as IQueueEntryMetadata; string customMetricName = GetCustomMetricName(dequeuedEventArgs.Entry.Value); if (!String.IsNullOrEmpty(customMetricName)) { await _metricsClient.CounterAsync(GetFullMetricName(customMetricName, "dequeued")).AnyContext(); } await _metricsClient.CounterAsync(GetFullMetricName("dequeued")).AnyContext(); if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue) { return; } var start = metadata.EnqueuedTimeUtc; var end = metadata.DequeuedTimeUtc; var time = (int)(end - start).TotalMilliseconds; if (!String.IsNullOrEmpty(customMetricName)) { await _metricsClient.TimerAsync(GetFullMetricName(customMetricName, "queuetime"), time).AnyContext(); } await _metricsClient.TimerAsync(GetFullMetricName("queuetime"), time).AnyContext(); }
protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry) { var args = new DequeuedEventArgs <T> { Queue = this, Entry = entry }; return(Dequeued?.InvokeAsync(this, args) ?? Task.CompletedTask); }
protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs) { string uniqueIdentifier = GetUniqueIdentifier(dequeuedEventArgs.Entry.Value); if (String.IsNullOrEmpty(uniqueIdentifier)) { return; } await _cacheClient.RemoveAsync(uniqueIdentifier); }
protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry) { var dequeued = Dequeued; if (dequeued == null) { return(Task.CompletedTask); } var args = new DequeuedEventArgs <T> { Queue = this, Entry = entry }; return(dequeued.InvokeAsync(this, args)); }
protected virtual Task OnDequeuedAsync(IQueueEntry <T> entry) { LastDequeueActivity = SystemClock.UtcNow; var dequeued = Dequeued; if (dequeued == null) { return(Task.CompletedTask); } var args = new DequeuedEventArgs <T> { Queue = this, Entry = entry }; return(dequeued.InvokeAsync(this, args)); }
protected override async Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs) { await base.OnDequeued(sender, dequeuedEventArgs).AnyContext(); await ReportQueueCountAsync().AnyContext(); string customMetricName = GetCustomMetricName(dequeuedEventArgs.Data); if (!String.IsNullOrEmpty(customMetricName)) { dequeuedEventArgs.Metadata.Data[CustomMetricNameKey] = customMetricName; } if (!String.IsNullOrEmpty(customMetricName)) { await _metricsClient.CounterAsync(GetFullMetricName(customMetricName, "dequeued")).AnyContext(); } await _metricsClient.CounterAsync(GetFullMetricName("dequeued")).AnyContext(); var metadata = dequeuedEventArgs.Metadata; if (metadata == null || metadata.EnqueuedTimeUtc == DateTime.MinValue || metadata.DequeuedTimeUtc == DateTime.MinValue) { return; } var start = metadata.EnqueuedTimeUtc; var end = metadata.DequeuedTimeUtc; var time = (long)(end - start).TotalMilliseconds; if (!String.IsNullOrEmpty(customMetricName)) { await _metricsClient.TimerAsync(GetFullMetricName(customMetricName, "queuetime"), time).AnyContext(); } await _metricsClient.TimerAsync(GetFullMetricName("queuetime"), time).AnyContext(); }
protected virtual Task OnDequeued(object sender, DequeuedEventArgs <T> dequeuedEventArgs) { return(TaskHelper.Completed()); }