Example #1
0
        public void ShouldGetNumberOfJobs()
        {
            HangfireJobStatistics actual = _hangfireMonitorService.GetJobStatistics();

            Assert.Equal(_expectedStats.Failed, actual.Failed);
            Assert.Equal(_expectedStats.Enqueued, actual.Enqueued);
            Assert.Equal(_expectedStats.Scheduled, actual.Scheduled);
            Assert.Equal(_expectedStats.Processing, actual.Processing);
            Assert.Equal(_expectedStats.Succeeded, actual.Succeeded);
            Assert.Equal(_expectedRetrySet.Count, actual.Retry);
        }
 public void ExportHangfireStatistics()
 {
     try
     {
         HangfireJobStatistics hangfireJobStatistics = _hangfireMonitorService.GetJobStatistics();
         _hangfireGauge.WithLabels(_failedLabelValue).Set(hangfireJobStatistics.Failed);
         _hangfireGauge.WithLabels(_scheduledLabelValue).Set(hangfireJobStatistics.Scheduled);
         _hangfireGauge.WithLabels(_processingLabelValue).Set(hangfireJobStatistics.Processing);
         _hangfireGauge.WithLabels(_enqueuedLabelValue).Set(hangfireJobStatistics.Enqueued);
         _hangfireGauge.WithLabels(_succeededLabelValue).Set(hangfireJobStatistics.Succeeded);
         _hangfireGauge.WithLabels(_retryLabelValue).Set(hangfireJobStatistics.Retry);
     }
     catch (Exception ex)
     {
         if (_settings.FailScrapeOnException)
         {
             throw new ScrapeFailedException("Scrape failed due to exception. See InnerException for details.", ex);
         }
     }
 }