forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metricstagservice.go
39 lines (31 loc) · 1.29 KB
/
metricstagservice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package metrics
import (
"github.com/docker/distribution"
"github.com/docker/distribution/context"
)
// TagService wraps a distribution.TagService to collect statistics
type TagService struct {
Tags distribution.TagService
Reponame string
}
var _ distribution.TagService = &TagService{}
func (t *TagService) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
defer NewTimer(RegistryAPIRequests, []string{"tagservice.get", t.Reponame}).Stop()
return t.Tags.Get(ctx, tag)
}
func (t *TagService) Tag(ctx context.Context, tag string, desc distribution.Descriptor) error {
defer NewTimer(RegistryAPIRequests, []string{"tagservice.tag", t.Reponame}).Stop()
return t.Tags.Tag(ctx, tag, desc)
}
func (t *TagService) Untag(ctx context.Context, tag string) error {
defer NewTimer(RegistryAPIRequests, []string{"tagservice.untag", t.Reponame}).Stop()
return t.Tags.Untag(ctx, tag)
}
func (t *TagService) All(ctx context.Context) ([]string, error) {
defer NewTimer(RegistryAPIRequests, []string{"tagservice.all", t.Reponame}).Stop()
return t.Tags.All(ctx)
}
func (t *TagService) Lookup(ctx context.Context, digest distribution.Descriptor) ([]string, error) {
defer NewTimer(RegistryAPIRequests, []string{"tagservice.lookup", t.Reponame}).Stop()
return t.Tags.Lookup(ctx, digest)
}