From 3fd8c8a60d89227dd0305ff7079c7f85dd3b7357 Mon Sep 17 00:00:00 2001 From: Charlton Austin Date: Tue, 24 Jan 2017 16:31:33 -0500 Subject: [PATCH] feature(app.py): adding queue_metrics to queues publishing queue metrics for SRE [none] --- app.py | 1 + data/queue.py | 5 +++-- storage/__init__.py | 3 +-- util/metrics/metricqueue.py | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 06ba2e261..e168f94ba 100644 --- a/app.py +++ b/app.py @@ -182,6 +182,7 @@ oauth_apps = [github_trigger, gitlab_trigger] image_replication_queue = WorkQueue(app.config['REPLICATION_QUEUE_NAME'], tf, has_namespace=False, metric_queue=metric_queue) dockerfile_build_queue = WorkQueue(app.config['DOCKERFILE_BUILD_QUEUE_NAME'], tf, + metric_queue=metric_queue, reporter=BuildMetricQueueReporter(metric_queue), has_namespace=True) notification_queue = WorkQueue(app.config['NOTIFICATION_QUEUE_NAME'], tf, has_namespace=True, diff --git a/data/queue.py b/data/queue.py index 4e84c6738..ed515cdba 100644 --- a/data/queue.py +++ b/data/queue.py @@ -5,7 +5,6 @@ from contextlib import contextmanager from data.database import QueueItem, db, db_for_update, db_random_func from util.morecollections import AttrDict -from hashlib import sha256 MINIMUM_EXTENSION = timedelta(seconds=20) @@ -121,9 +120,11 @@ class WorkQueue(object): (running_count, available_not_running_count, available_count) = self.get_metrics() 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_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: self._reporter(self._currently_processing, running_count, diff --git a/storage/__init__.py b/storage/__init__.py index 09497df99..bbce87afd 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -5,8 +5,6 @@ from storage.distributedstorage import DistributedStorage from storage.swift import SwiftStorage from storage.downloadproxy import DownloadProxy -from urlparse import urlparse, parse_qs - STORAGE_DRIVER_CLASSES = { 'LocalStorage': LocalStorage, 'S3Storage': S3Storage, @@ -15,6 +13,7 @@ STORAGE_DRIVER_CLASSES = { 'SwiftStorage': SwiftStorage, } + def get_storage_driver(location, metric_queue, chunk_cleanup_queue, storage_params): """ Returns a storage driver class for the given storage configuration (a pair of string name and a dict of parameters). """ diff --git a/util/metrics/metricqueue.py b/util/metrics/metricqueue.py index 8ed541a0d..ce39b6329 100644 --- a/util/metrics/metricqueue.py +++ b/util/metrics/metricqueue.py @@ -62,6 +62,10 @@ class MetricQueue(object): 'Available items in a queue', 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', labelnames=['namespace', 'repo_name', 'protocol', 'status']) @@ -165,7 +169,6 @@ def _time_after_request(name, metric_queue): return r dur = time.time() - start - dims = {'endpoint': request.endpoint} metric_queue.resp_time.Observe(dur, labelvalues=[request.endpoint]) metric_queue.resp_code.Inc(labelvalues=[request.endpoint, r.status_code])