Skip to content

Commit

Permalink
fix(metrics): correct image pull throughput calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
  • Loading branch information
azr committed May 24, 2024
1 parent 45e3091 commit 6b15ee0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/cri/server/images/image_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,12 @@ func (c *CRIImageService) PullImage(ctx context.Context, name string, credential
}
}

const mbToByte = 1024 * 1024
size, _ := image.Size(ctx)
imagePullingSpeed := float64(size) / mbToByte / time.Since(startTime).Seconds()
sizeByte, _ := image.Size(ctx)
imagePullingSpeed := float64(sizeByte) / time.Since(startTime).Seconds()
imagePullThroughput.Observe(imagePullingSpeed)

log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", name, imageID,
repoTag, repoDigest, strconv.FormatInt(size, 10), time.Since(startTime))
repoTag, repoDigest, strconv.FormatInt(sizeByte, 10), time.Since(startTime))
// NOTE(random-liu): the actual state in containerd is the source of truth, even we maintain
// in-memory image store, it's only for in-memory indexing. The image could be removed
// by someone else anytime, before/during/after we create the metadata. We should always
Expand Down

0 comments on commit 6b15ee0

Please sign in to comment.