public HangfirePrometheusExporter(IHangfireMonitorService hangfireMonitorService, HangfirePrometheusSettings settings)
 {
     _hangfireMonitorService = hangfireMonitorService ?? throw new ArgumentNullException(nameof(hangfireMonitorService));
     _settings          = settings;
     _collectorRegistry = settings.CollectorRegistry;
     _hangfireGauge     = Metrics.WithCustomRegistry(_collectorRegistry).CreateGauge(_metricName, _metricHelp, _stateLabelName);
 }
Exemple #2
0
        public HangfireMonitorTests()
        {
            _expectedStats    = _fixture.Create <StatisticsDto>();
            _expectedRetrySet = new HashSet <string>();
            _expectedRetrySet.AddMany(() => _fixture.Create <string>(), new Random().Next(100));

            Mock <IStorageConnection> storageConnection = new Mock <IStorageConnection>();

            storageConnection.Setup(x => x.GetAllItemsFromSet(retryKey)).Returns(_expectedRetrySet);

            Mock <IMonitoringApi> mockMonitoringApi = new Mock <IMonitoringApi>();

            mockMonitoringApi.Setup(x => x.GetStatistics()).Returns(_expectedStats);

            _mockStorage = new Mock <JobStorage>();
            _mockStorage.Setup(x => x.GetConnection()).Returns(storageConnection.Object);
            _mockStorage.Setup(x => x.GetMonitoringApi()).Returns(mockMonitoringApi.Object);

            _hangfireMonitorService = new HangfireMonitorService(_mockStorage.Object);
        }