public void IncDefault_Int64() { for (var i = 0; i < _opIterations; i++) { _gaugeInt64.Inc(); } }
public void IncDefault() { for (var i = 0; i < _opIterations; i++) { _gauge.Inc(); } }
/// <summary> /// Tracks the number of in-progress operations taking place. /// /// Calling this increments the gauge. Disposing of the returned instance decrements it again. /// </summary> /// <remarks> /// It is safe to track the sum of multiple concurrent in-progress operations with the same gauge. /// </remarks> public static IDisposable TrackInProgress(this IGauge gauge) { if (gauge == null) { throw new ArgumentNullException(nameof(gauge)); } gauge.Inc(); return(new InProgressTracker(gauge)); }
public void QueueBackgroundWorkItem( Func <CancellationToken, Task> workItem) { if (workItem == null) { throw new ArgumentNullException(nameof(workItem)); } _workItems.Enqueue(workItem); _queuedItemsGauge.Inc(); _signal.Release(); }
public async Task Invoke(HttpContext context) { _inFlightGauge.Inc(); try { await _next(context); } finally { _inFlightGauge.Dec(); } }
public Task <ProcessedMessageStatus> QueueBackgroundWorkItem(T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var taskCompletionStatus = new TaskCompletionSource <ProcessedMessageStatus>(); _workItems.Enqueue(new QueueItem <T>(item, taskCompletionStatus)); _elementsInQueue?.Inc(); _totalMessages?.Inc(); _signal.Release(); ItemCount++; return(taskCompletionStatus.Task); }
private async Task PeriodicLicenseChecksAsync() { var consecutiveFailures = 0; var isFirstCheck = true; do { logger.LogTrace("Performing license check"); try { await licenseValidator.ValidateLicenseAsync(licenseKey, moduleInstanceName, hostName, hubName, DateTime.UtcNow, serviceStopping.Token); logger.LogTrace("License is valid"); consecutiveLicenseCheckFailures.Set(0); remainingConsecutiveLicenseCheckFailures.Set(maxConsecutiveCheckFailures); } catch (OperationCanceledException) { logger.LogTrace("Canceled in-progress license check"); } catch (Exception ex) { consecutiveFailures++; logger.LogCritical(ex, isFirstCheck ? $"Startup license validation failed" : $"Post-startup license validation failed {consecutiveFailures} consecutive time(s) of max {maxConsecutiveCheckFailures}"); consecutiveLicenseCheckFailures.Inc(); remainingConsecutiveLicenseCheckFailures.Dec(); if (isFirstCheck || consecutiveFailures > maxConsecutiveCheckFailures) { throw; } } isFirstCheck = false; await Task.Delay(licenseCheckInterval, serviceStopping.Token); } while (!serviceStopping.IsCancellationRequested); }
public static void Inc(this IGauge gauge, double increment, DateTimeOffset timestamp) { gauge.Inc(increment, timestamp.ToUnixTime()); }
public static void Inc(this IGauge <long> gauge, long increment, DateTimeOffset timestamp) { gauge.Inc(increment, timestamp.ToUnixTimeMilliseconds()); }