feature(app.py): adding queue_metrics to queues
publishing queue metrics for SRE [none]
This commit is contained in:
parent
8755706454
commit
3fd8c8a60d
4 changed files with 9 additions and 5 deletions
1
app.py
1
app.py
|
@ -182,6 +182,7 @@ oauth_apps = [github_trigger, gitlab_trigger]
|
||||||
image_replication_queue = WorkQueue(app.config['REPLICATION_QUEUE_NAME'], tf,
|
image_replication_queue = WorkQueue(app.config['REPLICATION_QUEUE_NAME'], tf,
|
||||||
has_namespace=False, metric_queue=metric_queue)
|
has_namespace=False, metric_queue=metric_queue)
|
||||||
dockerfile_build_queue = WorkQueue(app.config['DOCKERFILE_BUILD_QUEUE_NAME'], tf,
|
dockerfile_build_queue = WorkQueue(app.config['DOCKERFILE_BUILD_QUEUE_NAME'], tf,
|
||||||
|
metric_queue=metric_queue,
|
||||||
reporter=BuildMetricQueueReporter(metric_queue),
|
reporter=BuildMetricQueueReporter(metric_queue),
|
||||||
has_namespace=True)
|
has_namespace=True)
|
||||||
notification_queue = WorkQueue(app.config['NOTIFICATION_QUEUE_NAME'], tf, has_namespace=True,
|
notification_queue = WorkQueue(app.config['NOTIFICATION_QUEUE_NAME'], tf, has_namespace=True,
|
||||||
|
|
|
@ -5,7 +5,6 @@ from contextlib import contextmanager
|
||||||
|
|
||||||
from data.database import QueueItem, db, db_for_update, db_random_func
|
from data.database import QueueItem, db, db_for_update, db_random_func
|
||||||
from util.morecollections import AttrDict
|
from util.morecollections import AttrDict
|
||||||
from hashlib import sha256
|
|
||||||
|
|
||||||
|
|
||||||
MINIMUM_EXTENSION = timedelta(seconds=20)
|
MINIMUM_EXTENSION = timedelta(seconds=20)
|
||||||
|
@ -121,9 +120,11 @@ class WorkQueue(object):
|
||||||
(running_count, available_not_running_count, available_count) = self.get_metrics()
|
(running_count, available_not_running_count, available_count) = self.get_metrics()
|
||||||
|
|
||||||
if self._metric_queue:
|
if self._metric_queue:
|
||||||
dim = {'queue': self._queue_name}
|
|
||||||
self._metric_queue.work_queue_running.Set(running_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])
|
self._metric_queue.work_queue_available.Set(available_count, labelvalues=[self._queue_name])
|
||||||
|
self._metric_queue.work_queue_available_not_running.Set(available_not_running_count,
|
||||||
|
labelvalues=[self._queue_name])
|
||||||
|
|
||||||
|
|
||||||
if self._reporter:
|
if self._reporter:
|
||||||
self._reporter(self._currently_processing, running_count,
|
self._reporter(self._currently_processing, running_count,
|
||||||
|
|
|
@ -5,8 +5,6 @@ from storage.distributedstorage import DistributedStorage
|
||||||
from storage.swift import SwiftStorage
|
from storage.swift import SwiftStorage
|
||||||
from storage.downloadproxy import DownloadProxy
|
from storage.downloadproxy import DownloadProxy
|
||||||
|
|
||||||
from urlparse import urlparse, parse_qs
|
|
||||||
|
|
||||||
STORAGE_DRIVER_CLASSES = {
|
STORAGE_DRIVER_CLASSES = {
|
||||||
'LocalStorage': LocalStorage,
|
'LocalStorage': LocalStorage,
|
||||||
'S3Storage': S3Storage,
|
'S3Storage': S3Storage,
|
||||||
|
@ -15,6 +13,7 @@ STORAGE_DRIVER_CLASSES = {
|
||||||
'SwiftStorage': SwiftStorage,
|
'SwiftStorage': SwiftStorage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_storage_driver(location, metric_queue, chunk_cleanup_queue, storage_params):
|
def get_storage_driver(location, metric_queue, chunk_cleanup_queue, storage_params):
|
||||||
""" Returns a storage driver class for the given storage configuration
|
""" Returns a storage driver class for the given storage configuration
|
||||||
(a pair of string name and a dict of parameters). """
|
(a pair of string name and a dict of parameters). """
|
||||||
|
|
|
@ -62,6 +62,10 @@ class MetricQueue(object):
|
||||||
'Available items in a queue',
|
'Available items in a queue',
|
||||||
labelnames=['queue_name'])
|
labelnames=['queue_name'])
|
||||||
|
|
||||||
|
self.work_queue_available_not_running = prom.create_gauge('work_queue_available_not_running',
|
||||||
|
'Available items that are not yet running',
|
||||||
|
labelnames=['queue_name'])
|
||||||
|
|
||||||
self.repository_pull = prom.create_counter('repository_pull', 'Repository Pull Count',
|
self.repository_pull = prom.create_counter('repository_pull', 'Repository Pull Count',
|
||||||
labelnames=['namespace', 'repo_name', 'protocol',
|
labelnames=['namespace', 'repo_name', 'protocol',
|
||||||
'status'])
|
'status'])
|
||||||
|
@ -165,7 +169,6 @@ def _time_after_request(name, metric_queue):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
dur = time.time() - start
|
dur = time.time() - start
|
||||||
dims = {'endpoint': request.endpoint}
|
|
||||||
|
|
||||||
metric_queue.resp_time.Observe(dur, labelvalues=[request.endpoint])
|
metric_queue.resp_time.Observe(dur, labelvalues=[request.endpoint])
|
||||||
metric_queue.resp_code.Inc(labelvalues=[request.endpoint, r.status_code])
|
metric_queue.resp_code.Inc(labelvalues=[request.endpoint, r.status_code])
|
||||||
|
|
Reference in a new issue