From 080802ed2dab39f052de08c17285ee7a7f9c4411 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 21 Nov 2016 12:29:59 -0500 Subject: [PATCH] Add tracking of pulled tag/digest to logs Fixes #2148 --- endpoints/v2/manifest.py | 5 +++-- static/js/directives/ui/logs-view.js | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/endpoints/v2/manifest.py b/endpoints/v2/manifest.py index 0d220fcab..2cd80bec7 100644 --- a/endpoints/v2/manifest.py +++ b/endpoints/v2/manifest.py @@ -50,7 +50,8 @@ def fetch_manifest_by_tagname(namespace_name, repo_name, manifest_ref): repo = model.get_repository(namespace_name, repo_name) if repo is not None: - track_and_log('pull_repo', repo, analytics_name='pull_repo_100x', analytics_sample=0.01) + track_and_log('pull_repo', repo, analytics_name='pull_repo_100x', analytics_sample=0.01, + tag=manifest_ref) metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True]) return Response( @@ -73,7 +74,7 @@ def fetch_manifest_by_digest(namespace_name, repo_name, manifest_ref): repo = model.get_repository(namespace_name, repo_name) if repo is not None: - track_and_log('pull_repo', repo) + track_and_log('pull_repo', repo, manifest_digest=manifest_ref) metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True]) return Response(manifest.json, status=200, headers={'Content-Type': manifest.media_type, diff --git a/static/js/directives/ui/logs-view.js b/static/js/directives/ui/logs-view.js index a7439ca7b..72ed40eb8 100644 --- a/static/js/directives/ui/logs-view.js +++ b/static/js/directives/ui/logs-view.js @@ -86,18 +86,24 @@ angular.module('quay').directive('logsView', function () { return prefix; }, 'pull_repo': function(metadata) { + var description = 'repository'; + if (metadata.tag) { + description = 'tag {tag}'; + } else if (metadata.manifest_digest) { + description = 'digest {manifest_digest}'; + } + if (metadata.token) { - var prefix = 'Pull of repository' if (metadata.token_type == 'build-worker') { - prefix += ' by build worker'; + return 'Pull of ' + description + ' by build worker'; } else { - prefix += ' via token'; + return 'Pull of ' + description + ' via token'; } return prefix; } else if (metadata.username) { - return 'Pull repository {repo} by {username}'; + return 'Pull ' + description + ' by {username}'; } else { - return 'Public pull of repository {repo} by {_ip}'; + return 'Public pull of ' + description + ' by {_ip}'; } }, 'delete_repo': 'Delete repository: {repo}',