From ae0d1e831b339ad4b8ec5c1930409e3f6fa93a40 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 1 May 2017 15:16:55 -0400 Subject: [PATCH] Add prometheus metric for queued builds --- endpoints/building.py | 6 +++++- util/metrics/metricqueue.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/endpoints/building.py b/endpoints/building.py index 8515287a1..74a611841 100644 --- a/endpoints/building.py +++ b/endpoints/building.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta from flask import request -from app import app, dockerfile_build_queue +from app import app, dockerfile_build_queue, metric_queue from data import model from data.database import db from auth.auth_context import get_authenticated_user @@ -82,6 +82,10 @@ def start_build(repository, prepared_build, pull_robot_name=None): build_request.queue_id = queue_id build_request.save() + # Add the queueing of the build to the metrics queue. + metric_queue.repository_build_queued.Inc(labelvalues=[repository.namespace_user.username, + repository.name]) + # Add the build to the repo's log and spawn the build_queued notification. event_log_metadata = { 'build_id': build_request.uuid, diff --git a/util/metrics/metricqueue.py b/util/metrics/metricqueue.py index ce39b6329..20577829b 100644 --- a/util/metrics/metricqueue.py +++ b/util/metrics/metricqueue.py @@ -74,6 +74,10 @@ class MetricQueue(object): labelnames=['namespace', 'repo_name', 'protocol', 'status']) + self.repository_build_queued = prom.create_counter('repository_build_queued', + 'Repository Build Queued Count', + labelnames=['namespace', 'repo_name']) + self.repository_build_completed = prom.create_counter('repository_build_completed', 'Repository Build Complete Count', labelnames=['namespace', 'repo_name',