Merge pull request #8337 from keloyang/imagePullThroughput

Register imagePullThroughput and count with MiB
This commit is contained in:
Derek McGowan 2023-05-02 10:30:19 -07:00 committed by GitHub
commit a7ceac8b63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 13 deletions

View File

@ -212,8 +212,9 @@ func (c *CRIImageService) PullImage(ctx context.Context, r *runtime.PullImageReq
} }
} }
const mbToByte = 1024 * 1024
size, _ := image.Size(ctx) size, _ := image.Size(ctx)
imagePullingSpeed := float64(size) / time.Since(startTime).Seconds() imagePullingSpeed := float64(size) / mbToByte / time.Since(startTime).Seconds()
imagePullThroughput.Observe(imagePullingSpeed) imagePullThroughput.Observe(imagePullingSpeed)
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID, log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,

View File

@ -24,23 +24,30 @@ import (
var ( var (
imagePulls metrics.LabeledCounter imagePulls metrics.LabeledCounter
inProgressImagePulls metrics.Gauge inProgressImagePulls metrics.Gauge
// pull duration / (image size / 1MBi) // image size in MB / image pull duration in seconds
imagePullThroughput prom.Histogram imagePullThroughput prom.Histogram
) )
func init() { func init() {
const (
namespace = "containerd"
subsystem = "cri_sandboxed"
)
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle. // these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
ns := metrics.NewNamespace("containerd", "cri_sandboxed", nil) ns := metrics.NewNamespace(namespace, subsystem, nil)
imagePulls = ns.NewLabeledCounter("image_pulls", "succeeded and failed counters", "status") imagePulls = ns.NewLabeledCounter("image_pulls", "succeeded and failed counters", "status")
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total) inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
imagePullThroughput = prom.NewHistogram( imagePullThroughput = prom.NewHistogram(
prom.HistogramOpts{ prom.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "image_pulling_throughput", Name: "image_pulling_throughput",
Help: "image pull throughput", Help: "image pull throughput",
Buckets: prom.DefBuckets, Buckets: prom.DefBuckets,
}, },
) )
ns.Add(imagePullThroughput)
metrics.Register(ns) metrics.Register(ns)
} }

View File

@ -209,8 +209,9 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
} }
} }
const mbToByte = 1024 * 1024
size, _ := image.Size(ctx) size, _ := image.Size(ctx)
imagePullingSpeed := float64(size) / time.Since(startTime).Seconds() imagePullingSpeed := float64(size) / mbToByte / time.Since(startTime).Seconds()
imagePullThroughput.Observe(imagePullingSpeed) imagePullThroughput.Observe(imagePullingSpeed)
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID, log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,

View File

@ -42,13 +42,18 @@ var (
imagePulls metrics.LabeledCounter imagePulls metrics.LabeledCounter
inProgressImagePulls metrics.Gauge inProgressImagePulls metrics.Gauge
// pull duration / (image size / 1MBi) // image size in MB / image pull duration in seconds
imagePullThroughput prom.Histogram imagePullThroughput prom.Histogram
) )
func init() { func init() {
const (
namespace = "containerd"
subsystem = "cri"
)
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle. // these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
ns := metrics.NewNamespace("containerd", "cri", nil) ns := metrics.NewNamespace(namespace, subsystem, nil)
sandboxListTimer = ns.NewTimer("sandbox_list", "time to list sandboxes") sandboxListTimer = ns.NewTimer("sandbox_list", "time to list sandboxes")
sandboxCreateNetworkTimer = ns.NewTimer("sandbox_create_network", "time to create the network for a sandbox") sandboxCreateNetworkTimer = ns.NewTimer("sandbox_create_network", "time to create the network for a sandbox")
@ -72,12 +77,15 @@ func init() {
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total) inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
imagePullThroughput = prom.NewHistogram( imagePullThroughput = prom.NewHistogram(
prom.HistogramOpts{ prom.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "image_pulling_throughput", Name: "image_pulling_throughput",
Help: "image pull throughput", Help: "image pull throughput",
Buckets: prom.DefBuckets, Buckets: prom.DefBuckets,
}, },
) )
ns.Add(imagePullThroughput)
metrics.Register(ns) metrics.Register(ns)
} }