Refactor prometheus integration

Move prometheus to SaaS and make it a plugin
Move static callers to use metrics_queue plugin
Change local-docker to support different quay clone dirnames
Change prom_aggregator to use logrus
This commit is contained in:
Jake Moshenko 2016-02-01 15:07:46 -05:00 committed by Joseph Schorr
parent 3d9acf2fff
commit 668a8edc50
10 changed files with 216 additions and 161 deletions

View file

@ -2,13 +2,10 @@ from datetime import datetime, timedelta
from data.database import QueueItem, db, db_for_update, db_random_func
from util.morecollections import AttrDict
from util.prometheus import Gauge
MINIMUM_EXTENSION = timedelta(seconds=20)
build_capacity_shortage = Gauge('build_capacity_shortage', 'Build capacity shortage.')
percent_building = Gauge('build_percent_building', 'Percent building.')
class NoopWith:
def __enter__(self):
@ -17,6 +14,7 @@ class NoopWith:
def __exit__(self, type, value, traceback):
pass
class MetricQueueReporter(object):
def __init__(self, metric_queue):
self._metric_queue = metric_queue
@ -24,11 +22,12 @@ class MetricQueueReporter(object):
def __call__(self, currently_processing, running_count, total_count):
need_capacity_count = total_count - running_count
self._metric_queue.put('BuildCapacityShortage', need_capacity_count, unit='Count')
build_capacity_shortage.Set(need_capacity_count)
self._metric_queue.build_capacity_shortage.Set(need_capacity_count)
building_percent = 100 if currently_processing else 0
self._metric_queue.put('PercentBuilding', building_percent, unit='Percent')
percent_building.Set(building_percent)
self._metric_queue.percent_building.Set(building_percent)
class WorkQueue(object):
def __init__(self, queue_name, transaction_factory,