Add tracking of pulled tag/digest to logs

Fixes #2148
This commit is contained in:
Joseph Schorr 2016-11-21 12:29:59 -05:00
parent ee99929f56
commit 080802ed2d
2 changed files with 14 additions and 7 deletions

View file

@ -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,

View file

@ -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 <b>build worker</b>';
return 'Pull of ' + description + ' by <b>build worker</b>';
} 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}',