mirror of
https://github.com/moby/moby.git
synced 2026-08-04 23:21:00 +00:00
daemon/images: Move ImageActions to metrics
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/docker/docker/container"
|
||||
dimages "github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -57,7 +58,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
if retErr == nil {
|
||||
dimages.ImageActions.WithValues("delete").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("delete").UpdateSince(start)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/containerd/platforms"
|
||||
"github.com/distribution/reference"
|
||||
imagetype "github.com/docker/docker/api/types/image"
|
||||
dimages "github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -125,7 +125,7 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *
|
||||
}
|
||||
}
|
||||
|
||||
dimages.ImageActions.WithValues("history").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("history").UpdateSince(start)
|
||||
return history, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import (
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
registrytypes "github.com/docker/docker/api/types/registry"
|
||||
dimages "github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/distribution"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/progress"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
@@ -34,7 +34,7 @@ func (i *ImageService) PullImage(ctx context.Context, baseRef reference.Named, p
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
if retErr == nil {
|
||||
dimages.ImageActions.WithValues("pull").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("pull").UpdateSince(start)
|
||||
}
|
||||
}()
|
||||
out := streamformatter.NewJSONProgressOutput(outStream, false)
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"github.com/docker/docker/api/types/auxprogress"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/progress"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/opencontainers/go-digest"
|
||||
@@ -44,7 +44,7 @@ func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named,
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
if retErr == nil {
|
||||
images.ImageActions.WithValues("push").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("push").UpdateSince(start)
|
||||
}
|
||||
}()
|
||||
out := streamformatter.NewJSONProgressOutput(outStream, false)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -173,7 +174,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ImageActions.WithValues("delete").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("delete").UpdateSince(start)
|
||||
|
||||
return records, nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/docker/api/types/backend"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/layer"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -82,6 +83,6 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *
|
||||
break
|
||||
}
|
||||
}
|
||||
ImageActions.WithValues("history").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("history").UpdateSince(start)
|
||||
return history, nil
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/docker/docker/distribution"
|
||||
progressutils "github.com/docker/docker/distribution/utils"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/progress"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -26,7 +27,7 @@ func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, platf
|
||||
start := time.Now()
|
||||
|
||||
err := i.pullImageWithReference(ctx, ref, platform, metaHeaders, authConfig, outStream)
|
||||
ImageActions.WithValues("pull").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("pull").UpdateSince(start)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/distribution"
|
||||
progressutils "github.com/docker/docker/distribution/utils"
|
||||
"github.com/docker/docker/internal/metrics"
|
||||
"github.com/docker/docker/pkg/progress"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -57,6 +58,6 @@ func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, platf
|
||||
err := distribution.Push(ctx, ref, imagePushConfig)
|
||||
close(progressChan)
|
||||
<-writesDone
|
||||
ImageActions.WithValues("push").UpdateSince(start)
|
||||
metrics.ImageActions.WithValues("push").UpdateSince(start)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package images // import "github.com/docker/docker/daemon/images"
|
||||
|
||||
import (
|
||||
gometrics "github.com/docker/go-metrics"
|
||||
)
|
||||
|
||||
// ImageActions measures the time it takes to process some image actions.
|
||||
// Exported for use in the containerd-backed image store and it is not intended
|
||||
// for external consumption. Do not use!
|
||||
var ImageActions gometrics.LabeledTimer
|
||||
|
||||
func init() {
|
||||
ns := gometrics.NewNamespace("engine", "daemon", nil)
|
||||
ImageActions = ns.NewLabeledTimer("image_actions", "The number of seconds it takes to process each image action", "action")
|
||||
// TODO: is it OK to register a namespace with the same name? Or does this
|
||||
// need to be exported from somewhere?
|
||||
gometrics.Register(ns)
|
||||
}
|
||||
@@ -16,6 +16,7 @@ var (
|
||||
NetworkActions = metricsNS.NewLabeledTimer("network_actions", "The number of seconds it takes to process each network action", "action")
|
||||
// HostInfoFunctions tracks the time taken to gather host information
|
||||
HostInfoFunctions = metricsNS.NewLabeledTimer("host_info_functions", "The number of seconds it takes to call functions gathering info about the host", "function")
|
||||
ImageActions = metricsNS.NewLabeledTimer("image_actions", "The number of seconds it takes to process each image action", "action")
|
||||
|
||||
// EngineInfo provides information about the engine and its environment
|
||||
EngineInfo = metricsNS.NewLabeledGauge("engine", "The information related to the engine and the OS it is running on", gometrics.Unit("info"),
|
||||
|
||||
Reference in New Issue
Block a user