forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metricsmanifestservice.go
35 lines (28 loc) · 1.36 KB
/
metricsmanifestservice.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
package metrics
import (
"github.com/docker/distribution"
"github.com/docker/distribution/context"
"github.com/docker/distribution/digest"
)
// ManifestService wraps a distribution.ManifestService to collect statistics
type ManifestService struct {
Manifests distribution.ManifestService
Reponame string
}
var _ distribution.ManifestService = &ManifestService{}
func (m *ManifestService) Exists(ctx context.Context, dgst digest.Digest) (bool, error) {
defer NewTimer(RegistryAPIRequests, []string{"manifestservice.exists", m.Reponame}).Stop()
return m.Manifests.Exists(ctx, dgst)
}
func (m *ManifestService) Get(ctx context.Context, dgst digest.Digest, options ...distribution.ManifestServiceOption) (distribution.Manifest, error) {
defer NewTimer(RegistryAPIRequests, []string{"manifestservice.get", m.Reponame}).Stop()
return m.Manifests.Get(ctx, dgst, options...)
}
func (m *ManifestService) Put(ctx context.Context, manifest distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {
defer NewTimer(RegistryAPIRequests, []string{"manifestservice.put", m.Reponame}).Stop()
return m.Manifests.Put(ctx, manifest, options...)
}
func (m *ManifestService) Delete(ctx context.Context, dgst digest.Digest) error {
defer NewTimer(RegistryAPIRequests, []string{"manifestservice.delete", m.Reponame}).Stop()
return m.Manifests.Delete(ctx, dgst)
}