Fix Set calls to gauges

Fixes #2150

The proper function is `Set` (not `set`), which was causing these gauges to not report to Prometheus
This commit is contained in:
Joseph Schorr 2016-11-21 15:27:09 -05:00
parent ee99929f56
commit e29cb34336
2 changed files with 7 additions and 6 deletions

View file

@ -116,8 +116,8 @@ class WorkQueue(object):
dimensions=dim)
self._metric_queue.put_deprecated('Available', available_count, dimensions=dim)
self._metric_queue.work_queue_running.set(running_count, labelvalues=[self._queue_name])
self._metric_queue.work_queue_available.set(available_count, labelvalues=[self._queue_name])
self._metric_queue.work_queue_running.Set(running_count, labelvalues=[self._queue_name])
self._metric_queue.work_queue_available.Set(available_count, labelvalues=[self._queue_name])
if self._reporter:
self._reporter(self._currently_processing, running_count,

View file

@ -26,18 +26,19 @@ class GlobalPrometheusStatsWorker(Worker):
with GlobalLock('GLOBAL_PROM_STATS'):
self._report_stats()
except LockNotAcquiredException:
logger.debug('Could not acquire global lock for global prometheus stats')
return
def _report_stats(self):
logger.debug('Reporting global stats')
with UseThenDisconnect(app.config):
# Repository count.
metric_queue.repository_count.set(model.repository.get_repository_count())
metric_queue.repository_count.Set(model.repository.get_repository_count())
# User counts.
metric_queue.user_count.set(model.user.get_active_user_count())
metric_queue.org_count.set(model.organization.get_active_org_count())
metric_queue.robot_count.set(model.user.get_robot_count())
metric_queue.user_count.Set(model.user.get_active_user_count())
metric_queue.org_count.Set(model.organization.get_active_org_count())
metric_queue.robot_count.Set(model.user.get_robot_count())
def main():