Add prometheus metric for queued builds
This commit is contained in:
parent
d90933d856
commit
ae0d1e831b
2 changed files with 9 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
Reference in a new issue