Skip to content

Commit 4703b28

Browse files
authored
Merge pull request moby#37233 from dnephin/add-metrics-for-pull
Add image metrics for push and pull
2 parents 52ea99e + 6910019 commit 4703b28

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

daemon/images/image_pull.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"runtime"
77
"strings"
8+
"time"
89

910
dist "github.com/docker/distribution"
1011
"github.com/docker/distribution/reference"
@@ -20,6 +21,7 @@ import (
2021
// PullImage initiates a pull operation. image is the repository name to pull, and
2122
// tag may be either empty, or indicate a specific tag to pull.
2223
func (i *ImageService) PullImage(ctx context.Context, image, tag, os string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
24+
start := time.Now()
2325
// Special case: "pull -a" may send an image name with a
2426
// trailing :. This is ugly, but let's not break API
2527
// compatibility.
@@ -44,7 +46,9 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag, os string, met
4446
}
4547
}
4648

47-
return i.pullImageWithReference(ctx, ref, os, metaHeaders, authConfig, outStream)
49+
err = i.pullImageWithReference(ctx, ref, os, metaHeaders, authConfig, outStream)
50+
imageActions.WithValues("pull").UpdateSince(start)
51+
return err
4852
}
4953

5054
func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, os string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {

daemon/images/image_push.go

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package images // import "github.com/docker/docker/daemon/images"
33
import (
44
"context"
55
"io"
6+
"time"
67

78
"github.com/docker/distribution/manifest/schema2"
89
"github.com/docker/distribution/reference"
@@ -14,6 +15,7 @@ import (
1415

1516
// PushImage initiates a push operation on the repository named localName.
1617
func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
18+
start := time.Now()
1719
ref, err := reference.ParseNormalizedNamed(image)
1820
if err != nil {
1921
return err
@@ -59,5 +61,6 @@ func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHea
5961
err = distribution.Push(ctx, ref, imagePushConfig)
6062
close(progressChan)
6163
<-writesDone
64+
imageActions.WithValues("push").UpdateSince(start)
6265
return err
6366
}

0 commit comments

Comments
 (0)